How can I reset the styles given to series in Highcharts?

前端 未结 4 1173
执笔经年
执笔经年 2021-01-18 07:31

I am using Highcharts to render some graphs to my website. Sometimes, I need to remove all series from the chart and add some new series to the chart, because I requested so

4条回答
  •  日久生厌
    2021-01-18 07:57

    You can use my custom solution which reset colors in each click event.

    http://jsfiddle.net/sbochan/gJvde/1/

     function setColors(chart){
        var series = chart.series,
                 colors = chart.options.colors,
                 len = series.length-1;
    
                    if(flag) {
                        $.each(series,function(i,serie){
                            if(i==len) {
                                flag != flag;
                                serie.update({
                                    color: colors[i]
                                },true,true);
                            }
                            else {
                                serie.update({
                                    color: colors[i]
                                },false);
                            }
                        });
                    }
    }
    

提交回复
热议问题