mrjoh3 / c3

c3 HTMLWidget Ploting
39 stars 51 forks source link

Something like c3_click event for capturing click on c3 pie charts #4

Closed Nimeshbumb closed 7 years ago

Nimeshbumb commented 7 years ago

Hi,

I'm unable to find any function which can capture event_data just like plotly does for scatter plots (though it doesn't provide it for pie charts, maybe if you can then people would be using more of c3. You never know!).

So, basically I want to show which part/region of the pie I selected to show metadata about it into a datatable or something like that sort.

I would be really glad if you could provide me with some documentation because I checked most of the part online and couldn't find a better solution than asking the author directly.

Thanks and Regards, Nimesh Sajjan Bumb

mrjoh3 commented 7 years ago

Hi.

Sorry for the slow reply and thanks for your interest in the package. It is an interesting idea, I think it might be possible but will depend on the C3 is library. Hopefully I will get a chance to look at this over the next couple of weeks.

On 16 Feb 2017 7:52 PM, "Nimeshbumb" notifications@github.com wrote:

Hi,

I'm unable to find any function which can capture event_data just like plotly does for scatter plots (though it doesn't provide it for pie charts, maybe if you can then people would be using more of c3. You never know!).

So, basically I want to show which part/region of the pie I selected to show metadata about it into a datatable or something like that sort.

I would be really glad if you could provide me with some documentation because I checked most of the part online and couldn't find a better solution than asking the author directly.

Thanks and Regards, Nimesh Sajjan Bumb

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/mrjoh3/c3/issues/4, or mute the thread https://github.com/notifications/unsubscribe-auth/AB1TAX_hLQd51jaq8rYGczp2RIUcwujRks5rdA5OgaJpZM4MCvG8 .

mrjoh3 commented 7 years ago

I have just had a look at this and it is already implemented but at a very simple level. Have a look at the C3.js documentation for an explanation of what the js library is doing. An example in R would be:

data = data.frame(a = abs(rnorm(20) * 10),
            b = abs(rnorm(20) * 10),
            date = seq(as.Date("2014-01-01"), by = "month", length.out = 20))   

c3(data, onclick = htmlwidgets::JS('function(d, element){console.log(d)}'))

Then check the console log while clicking on a point and you will see you are accessing the data behind the point. I will work on adding some examples to the documentation.

mrjoh3 commented 6 years ago

commit e2bea1c20b56ac7affad10a42fe52d3fe8615dd6 added an example to the readme page and to the c3() functions documentation