jbkunst / highcharter

R wrapper for highcharts
http://jkunst.com/highcharter/
Other
719 stars 148 forks source link

updating a highcharts plot through user-selected datapoints #41

Closed selimrbd closed 8 years ago

selimrbd commented 8 years ago

I would like to get back data point indexes (through a window box drawn by the user) into R, do some processing, and update accordingly the highcharter graph. (without redrawing it).

example: I selected "Employed", "Housewife" and "Retired" by drawing a window:

screen shot 2016-02-11 at 00 20 51

I now want to group these 3 levels into 1, and assign the new level the mean value of the old levels.

  1. Do you think it's even doable in the original highcharts javascript library ?
  2. If yes, is this doable in the current implementation of highcharter ?
  3. If no, do you see any limitations that could prevent doing it altogether through highcharter (or is it just that it isn't implemented yet ?)

Would be glad to contribute to add this feature, if you think it's feasible

jbkunst commented 8 years ago

HI @SelimRaboudi,

I think you can program this chart handling the right highcharts events with javascript and updating the chart data. But I think this need more highcharts/javascript knowledge. I finded this example http://jsfiddle.net/highcharts/nsuA6/ and modified into this http://jsfiddle.net/tznwoc09/. It can be a start point to work. An alternative solution will be using shiny but maybe you need a standalone chart.

But going further. I think this funcionality is really interesting, for example when you are binning a variable and see rate from other varible in each group and you visualize and get the new categories/grups back to R. It can be treated like a shinygadet http://shiny.rstudio.com/articles/gadgets.html. It sounds interesting.

Anyway I think this can be achieve with highcharter but it will be need a lot of this things https://github.com/jbkunst/shiny-apps/blob/master/highcharter/server.R#L152.

So answer your points.

  1. Yes, its doable.
  2. Yes, because highcharter is a wrapper so if you can code or see and example using just js you can translate the code to R.
  3. I dont see any limitation. In my case the limitation is my highchart expertise using events XD.

I think this is not a feature, It need to be coded. Maybe after the new release of highcharter I will have time to work in this idea (chart and gadget). If you can start It would be happy if you show me and update ;)!

Tell me what you think.

Regards,

selimrbd commented 8 years ago

Hi Joshua,

Thanks for your reply

Yes, the output I'm after is indeed a Shiny Gadget (as a RStudio Addin), where a user could create groups through window dragging, and get the corresponding code immediately. It would be extremely useful to intuitively create groups while preserving reproducibility.

At first I thought you could only pass strings to JS objects through htmlwidgets which I thought would be a limitation for the data exchange required between R and JS (points positions). But then I found out about JS() I think I'll start working towards that. I'll first improve my knowledge in highcharts/htmlwidgets, and then see how this could be done.

Will keep you updated on this issue if I do any progress :)

Regards,

jbkunst commented 8 years ago

Ok @SelimRaboudi :wink:

Luck with that! I'll close the issue. If I have some news I'll talk to you here.

Regards,