Push events of each dc.js graph

I am using dc.js to display some charts in my dashboard. I'm looking to handle every chart click event (e.g. chart chart click event, chart chart click event and mouse up event for range charts, etc.) and store the history of the clicked charts in the database. This way the user will be able to see what the user clicks made for any chart after logging in.

I have checked dc.js for click events but I am not getting it right.

Can anyone help me? Any help would be appreciated.

+3


source to share


1 answer


It may be easier and more useful to watch the "filtered" event:

chart.on('filtered.monitor', function(chart, filter) {
    // report the filter applied
});

      

I say it easier because you don't have to worry about viewing different events for different charts. More useful because "filtered" shows you the result of a click without further processing, so you can show what you were actually looking at, not just what was clicked.

.monitor

in the above example is the event namespace. You can use whatever string you want in there, but use some namespace to avoid stepping on other observers for the same event.



If you really want click events, you can override chart.onClick

by assigning and calling the old handler (yuck), or you can use eg.

chart.selectAll('rect.bar').on('click.monitor', ...)

      

But now you have to look at the source to figure out what to choose in each chart. And the namespace is important here because you don't want to interfere with the handling of internal events.

+13


source







All Articles