score:16

Accepted answer

I found the solution in a pull request on GitHub (https://github.com/highslide-software/highcharts.com/pull/203).

You just need to reset Highcharts color counter after deleting the series. There is also a counter for the symbols.

UPDATE: From version 4.0.3 and above the name of the counters has changed:

var chart = $('#container').highcharts();
while(chart.series.length) {
    chart.series[0].remove();
}

chart.colorCounter = 0;
chart.symbolCounter = 0;

chart.addSeries({
     data: [144.0, 176.0, 29.9, 71.5, 106.4, 129.2, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
});
chart.addSeries({
    data: [129.2, 106.4, 135.6, 95.6, 54.4, 148.5, 144.0, 176.0, 29.9, 71.5, 216.4, 194.1]
});
chart.addSeries({
    data: [106.4, 129.2, 135.6, 148.5, 144.0, 176.0, 29.9, 71.5, 194.1, 95.6, 54.4, 216.4]
});

Live example: http://jsfiddle.net/juuQs/18/

(Prior to version 4.0.3 you must use chart.counters.color = 0 and chart.counters.symbol = 0)

score:0

try using addClass() method. suppose your container is some element X having id Y. put style information inside head as,

<style>
      X.Y { /* any style info */};
</style>

then every time you are adding data to any element call addClass("Y") on that element.

score:1

Use the colors options:

$('#container').highcharts({
    colors: ['#2f7ed8', 
        '#0d233a', 
        '#8bbc21'],
    series: …

Live example: http://jsfiddle.net/juuQs/3/

Or use a static color for each series, like this:

chart.addSeries({
        data: [144.0, 176.0, 29.9, 71.5, 106.4, 129.2, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
        color: '#2f7ed8'
    });

score:1

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);
                        }
                    });
                }
}

Related Query

More Query from same tag