score:5

Accepted answer

you can do it they way jeremy mentioned, by setting the colors options for each chart. or you can override the default color array as follows

highcharts.setoptions({
    colors:['red','green','blue']
});

the benefit of this approach is you only have to call this once, before create any chart. and all charts after this will use these colors, without you needing to set this option on each chart. most of the websites have a common.js or a similar javascript file that is generally loaded before any other custom script, you just need to add this code to that file and forget about the colors thereafter

update
since you want all series in the same chart to be of a single color, you can override the colors array completely and make it have only one color

highcharts.getoptions().colors = ['red'];

this method will leave the navigator (blue mini graph at bottom in highstock) to be of default blue color, this has to be overriden in a different way from options.

p.s. the above way is not the recommended way of overriding default options, correct way would be to do setoptions(), but that would cause a merge with existing defaults and hence the array size would be more than 1.

alternately, you can just override the getcolor method as follows, to always return the color of your choice. again you need to do this before you call the chart's constructor

highcharts.series.prototype.getcolor=function(){
    this.color= '#f00';
}

setting default colors @ jsfiddle

score:1

you can define an array of hex colors, and then use that array in your chart declaration. all series in the chart object will pull from this array of colors.

if you have multiple chart declarations, you can just use the same array.

here's one of the highcharts samples, with an array of custom colors added (run with jsfiddle):

$(function () {
    var mycolors = [
        '#ff0000',
        '#ff6600',
        '#ffcc00'
    ];
    var chart;
    $(document).ready(function() {
        chart = new highcharts.chart({
            chart: {
                renderto: 'container',
                type: 'bar'
            },
            colors: mycolors,
            title: {
                text: 'stacked bar chart'
            },
            xaxis: {
                categories: ['apples', 'oranges', 'pears', 'grapes', 'bananas']
            },
            yaxis: {
                min: 0,
                title: {
                    text: 'total fruit consumption'
                }
            },
            legend: {
                backgroundcolor: '#ffffff',
                reversed: true
            },
            tooltip: {
                formatter: function() {
                    return ''+
                        this.series.name +': '+ this.y +'';
                }
            },
            plotoptions: {
                series: {
                    stacking: 'normal'
                }
            },
                series: [{
                name: 'john',
                data: [5, 3, 4, 7, 2]
            }, {
                name: 'jane',
                data: [2, 2, 3, 2, 1]
            }, {
                name: 'joe',
                data: [3, 4, 4, 2, 5]
            }]
        });
    });

});

hope this helps!


Related Query

More Query from same tag