Highcharts - Change line color between points

2019-08-23 03:49发布

I have a line chart graph as can be seen on this fiddle http://jsfiddle.net/qjmjd34d/5/

And with this code:

Highcharts.chart('container', {
    plotOptions: {
        series: {
            color: 'purple'
        }
    },

    series: [{
    data: [{x: 1, y: 435, color:'blue'},
           {x: 2, y: 437, color:'blue'}, 
           {x: 3, y: 455, color:'blue'}, 
           {x: 4, y: 475, color:'blue'}, 
           {x: 5, y: 555, color:'blue'},
           {x: 6, y: 435, color:'blue'}]
    }]
});

Modifying the color of the points is oblivious however, how is it possible to change the color of the line between them?

Suppose I want the line in the given example on the fiddle to be green only between x = 3 and x = 5 - how is that possible?

1条回答
\"骚年 ilove
2楼-- · 2019-08-23 04:31

To color part of the graph, you can use zones.

If you include this in the series you have above it will color 3 to 5 red.

zoneAxis: 'x',
zones: [{value: 3}, {value: 5, color: 'red'}]

Zones work by coloring up to value. That means that we have to make one element with value 3 and no color to pass on whatever color is set elsewhere. The element with value 5 will therefore color from 3 to 5.

Working example: http://jsfiddle.net/qjmjd34d/6/

API on series.line.zones: https://api.highcharts.com/highcharts/series.line.zones

查看更多
登录 后发表回答