hrbrmstr / metricsgraphics

:chart_with_upwards_trend: htmlwidget interface to the MetricsGraphics.js D3 chart library
http://hrbrmstr.github.io/metricsgraphics/
Other
132 stars 35 forks source link

Linked charts #41

Open ghost opened 8 years ago

ghost commented 8 years ago

I like the linked charts and want to link them on a 3rd variable, but have not found a way to do so.

Assume you have the mtcars dataset, x-axis = mpg and you have 2 scatterplots, with y-axis disp and hp respectively. Then the rollover value that I would like to see is the car model, not just x =mpg and y = disp or y = hp.

Is there a possibility to make this link in metricsgraphics?

phillc73 commented 8 years ago

I believe it it possible.

Here's a tutorial about adding a custom rollover: http://rpackages.ianhowson.com/cran/metricsgraphics/man/mjs_add_mouseover.html

This issue is relevant if developing a Shiny app: https://github.com/hrbrmstr/metricsgraphics/issues/35

In short, using mjs_add_mouseover is the way to add additional data to the rollovers.

mjs_add_mouseover("function(d, i) {
               $('{{ID}} svg .mg-active-datapoint')
                   .text( 'Disp: ' + d.point.disp + ' | HP: ' + d.point.hp + ' | Model: ' + d.point.model);
ghost commented 8 years ago

I have tried the custom rollover option.

It gives any column that you want to see when you hover over a point, but it only does that - it gives information. It does not establish a link on the variable that you included in the custom function.

phillc73 commented 8 years ago

Sorry, I misunderstood your request.

ghost commented 8 years ago

You gave the right answer to my question, my question was not clear, I have made some edits.