1

I would like to disable a legend(breached95) based on the click of another legend(var95) in nvd3 chart.

enter image description here

Below script fires the legend click event which gives the click legend values but unable to disable another legend based on this event. How to achieve the behavior?

 callback: function(chart) {
                       chart.legend.dispatch.legendClick = function(val, i){
                            if(val.originalKey==="VaR95Total"){
                                //hide 'breached95' legend
                            }
                        };
                    },
RGR
  • 1,521
  • 2
  • 22
  • 36
  • Do you mean the legend item or the entire series? If you want to disable another series, just modify the series data to have disabled: true – jeznag Jul 30 '17 at 22:50
  • Disable. entire series. But currently there is no way to do it dynamically in the 'legendClick' event. – RGR Jul 31 '17 at 07:47
  • Why don't you just mutate the data and set disabled to true on the series? You haven't provided a JSFiddle/Plunkr so difficult to provide further feedback. e.g. var newData = data.map((dataset) => { if (dataset.key === 'series-to-disable') { dataset.disabled = true; } return dataset; }); – jeznag Jul 31 '17 at 22:45

0 Answers0