Vinay
Vinay

Reputation: 1

How to change color on the Highchart Sparkline line only?

I need help on how to change the HighChart Sparkline line only.

In the demo below, the line and background is blue https://www.highcharts.com/demo/sparkline

I need the line color to be changed. Please let me know how to achieve this.

Upvotes: 0

Views: 1568

Answers (2)

Constantine
Constantine

Reputation: 554

color: Color The main color or the series. In line type series it applies to the line and the point markers unless otherwise specified. In bar type series it applies to the bars unless a color is specified per point. The default value is pulled from the options.colors array.

Code example:

Highcharts.chart('container', {
xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
plotOptions: {
    series: {
        color: '#FF0000' // series color
    }
},

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

jsFiddle: fiddle

Links to change series style

series color

series lineWidth

dashStyle

Upvotes: 1

ewolden
ewolden

Reputation: 5803

I was going to say you should have a look at the Highcharts API, but then realized that I could not find the solution there.

If you add lineColor to plotOptions.series you can choose the color you would like on the line. This is probably one of several ways to achieve what you want.

See jsfiddle where I set lineColor: 'red'.

Upvotes: 1

Related Questions