-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to put javascript function in json rendered by e_inspect()? #560
Comments
As always nice catch/riddle @rdatasculptor. Just added new feature in #561 so just install the github version of echarts4r and add the jswrapper = TRUE flag library(echarts4r)
plot <- USArrests |>
e_charts(Assault) |>
e_scatter(Murder) |>
e_tooltip(
formatter = htmlwidgets::JS("function(params){return('Assault: ' + params.value[0] +'<br />Murder: ' + params.value[1])} ")
) |>
e_inspect(json = TRUE, pretty =TRUE) |>
echarts_from_json(jswrapper = TRUE)
plot Let me know how it goes ! |
great work @munoztd0 !!! it works like a charm :) You solved this one really fast. Very cool. Another (entirely different) issue is that the json doesn't contain the renderer parameter if you set it as "svg". Do you think that can be added to the json as well somehow? Maybe I will file another issue for that. |
Can you please open a new issue for this |
@munoztd0 Take a look at what @helgasoft did: helgasoft/echarty#3 (comment) Edit. Don't think it is much different from your approach 🧐, but cool anyway! |
Consider this chart:
The chart contains tooltips:
So what if I change the chart first in a json by using
e_inspect()
and change it back again to an echart by usingecharts_from_json()
?like this:
this is the result:
Obviously the tooltip javascript function is not recogized anymore.
Any ideas about how to deal with this? Is there a way (in R) to store the javascript function of the tooltip in the json in such a way that it can retrieved properly after changing it back to an echart?
The text was updated successfully, but these errors were encountered: