HighCharts : Can I customize the colors of individual series?

Posted by user1091114 on Stack Overflow See other posts from Stack Overflow or by user1091114
Published on 2012-04-01T11:11:20Z Indexed on 2012/04/01 11:28 UTC
Read the original article Hit count: 326

Filed under:
|

I am using HighCharts for a line graph and i am attemping to change the line color for each series. I did find this example here but the data is hard coded. My data is pulled from an Sql database and passed to the HTML page using some VB code.

        var chart; 
        $(document).ready(function () {
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                    defaultSeriesType: 'column'
                },
                title: {
                    text: 'Chart Title'
                },
                subtitle: {
                    text: 'Chart subtitle'
                },
                xAxis: {
                    categories: [<%= GraphDate %>]
                    ,
                    labels:
                    {
                        rotation: -45,
                        align: 'right',
                        style:
                        {

                        }
                    }
                },
                yAxis: {
                    min: 160,
                    title: {
                        text: 'Temp'
                    }
                },
                legend: {
                    layout: 'vertical',
                    backgroundColor: '#FFFFFF',
                    align: 'left',
                    verticalAlign: 'top',
                    x: 400,
                    y: 0,
                    floating: true,
                    shadow: true
                },
                tooltip: {
                    formatter: function () {
                        return '' +
                            this.x + ': ' + this.y + ' ºC';
                    }
                },
                plotOptions: {
                    column: {
                        pointPadding: 0.2,
                        borderWidth: 0
                    }
                },
                series: 

                [<%= GraphSeries %>],
            });

I tried to style it using the other post however it failed to generate a chart. The main problem is though, the line graph has two series, so the below method would set the color for both series i assume? So, would i maybe need to format the series in my vb code somehow?

series: [{ 
    color: 'yellow',
    data: [
        [<%= GraphSeries %>]
    ]},

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about highcharts