Reputation: 168
I have a nvd3 multichart. two line chart and I want to disable legend click. I am using d3 version 3.5.5 and nvd3 version 1.7.1
live code sample jsfiddler
I tried the following according to github answer
chart.legend.disptach.on('legendClick', function() {
return; //do nothing
});
but it doesn't work for my current version of nvd3. Do you have any clue how this might work?
Thanks in advance
Upvotes: 3
Views: 1019
Reputation: 1494
You can disable the legend click event by using the below code line:
chart.legend.updateState(false);
On hover over the legend, you would still get the hand-cursor but that can be fixed by CSS.
.nvd3 .nv-legend .nv-series {
cursor: default !important;
}
Upvotes: 0
Reputation: 102218
I never used nvd3.js and I'm not familiar with the library, but if it's good enough to you this is a solution using D3:
d3.selectAll(".nv-series").style("cursor", "default").on("click", null);
Here is your fiddle: https://jsfiddle.net/91Lpzu8u/
Upvotes: 1