Search code examples
highchartsdotnethighcharts

How to change the series color and mark after I draw the line chart in highcharts?Does it has databound event?


How to change the series color and mark after I draw the line chart in highcharts?Does it has databound event? I get the json from the server,if my json do not defined the series color and mark,after draw some series can I change their color and mark(such as "circle","triangle","cross" and so on)?Now use this method,Why I can change the default color,but can not change the default symbal of mark?

$(function () {
 var marks = new Array("square",  "diamond", "triangle");
Highcharts.setOptions({
    colors: ['red', '#50B432', '#ED561B', '#DDDF00', '#24CBE5', '#64E572', '#FF9655', '#FFF263', '#6AF9C4'],
    symbol:marks
});

$('#container').highcharts({
    chart: {
        type: 'line'
    },

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

});


Solution

  • Yes, this is available in the series.update() method. You would do something like:

    chart.series[0].update({
        color: color ? null : Highcharts.getOptions().colors[1]
    });
    

    Where series[0] is the index of the series you want to update.