Trigger legend click event in nvd3 using jquery?

d3.js, events, javascript, nvd3.js

Solution

you can try this:

chart.legend.dispatch.legendClick = function(d, i){
//redraw
};

It will append your own method to the legend; it works for pie chart not sure if works for the line chart;

Problem

I'm using nvd3 for a multi-bar chart, and I'd like to make the chart redraw when the user clicks the other html on my page. I tried using jQuery to select the "Stream0" legend circle on the nvd3 homepage (http://nvd3.org/) and click it using this snippet in the console: ``` $($('g.nv-series')[0]).click() ``` For reasons that I hope will be immediately obvious to people more knowledgeable about javascript, nothing happens. Is it something to do with event delegation? http://nvd3.org/

Original source

Related problems