How to disable some streams by default in a nvd3 Simple Line Chart?

前端 未结 4 858
-上瘾入骨i
-上瘾入骨i 2020-12-30 01:47

I have several lines and I know that clicking on the \"dot\" in the legend will hide/show it.

However, I need to start with some of the lines being disabled and not

4条回答
  •  我在风中等你
    2020-12-30 02:22

    You can change which streams are enabled/disabled by using the chart.state() object. For example:

    // Assuming your chart is called 'chart'
    var state = chart.state();
    
    for(var i=0; i < state.disabled.length; i++) {
      state.disabled[i] = ...LOGIC RETURNING TRUE OR FALSE...;
    }
    
    chart.dispatch.changeState(state);
    chart.update();
    

提交回复
热议问题