Highcharts - Change line color between points

牧云@^-^@ 提交于 2019-12-13 02:54:03

问题


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:


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



来源:https://stackoverflow.com/questions/47533162/highcharts-change-line-color-between-points

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!