novus / nvd3

A reusable charting library written in d3.js
http://nvd3.org/
Other
7.22k stars 2.14k forks source link

Create custom legend and keep interaction between legend and graph #2188

Open maria364 opened 6 years ago

maria364 commented 6 years ago

I have created a linePlusBarChart with nvd3 and I would like to create a custom legend for this graph. The custom legend created includes images and I would like to click on an image and have the same interaction between the legend and the graph, as it is now. How is this possible? Till now I have tried to call this function chart.dispatch.on('legendClick', function (extent, brush) { chart.update(); }); but I receive this error below:

Cannot read property 'on' of undefined

ajwilco commented 6 years ago

Does this work? chart.legend.dispatch.on('legendClick', function (extent, brush) { chart.update(); });