admin管理员组文章数量:1415100
How can I change the color of an area type plot depending on y-values which are in same series ?
type of chart - area
y- values possible - 1, 2 and 3
desired output - Green color area for values between 3 & 2, red color area for values between 2 & 1
How can I change the color of an area type plot depending on y-values which are in same series ?
type of chart - area
y- values possible - 1, 2 and 3
desired output - Green color area for values between 3 & 2, red color area for values between 2 & 1
Share Improve this question asked Jul 7, 2014 at 20:00 AdityaKapreShrewsburyBostonAdityaKapreShrewsburyBoston 1,1432 gold badges18 silver badges38 bronze badges 1- Please explain clearly what you want, and create a reference fiddle ! – Rahul Gupta Commented Jul 8, 2014 at 5:24
1 Answer
Reset to default 6There are two options, your desrciption lacks of information, so I show you both of them: http://jsfiddle/4vzEt/13/
Threshold with negative color:
$("#container1").highcharts({ series: [{ threshold: 2, negativeColor: 'red', color: 'green', type: 'area', data: [1, 2, 2, 1, 3, 3, 2, 3, 2, 1, 1, 3, 1, 1] }] });
Note: Threshold sets starting y-value of series in that value.
Gradient color:
$("#container2").highcharts({ series: [{ threshold: 1, color: { linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 }, stops: [ [0, 'green'], [0.49, 'green'], [0.5, 'red'], [1, 'red'] ] }, type: 'area', data: [1, 2, 2, 1, 3, 3, 2, 3, 2, 1, 1, 3, 1, 1] }] });
Note: Markers inherit series color. Disable them, or set for each point color directly.
本文标签: javascripthighchartschanging color of area depending on yvalueStack Overflow
版权声明:本文标题:javascript - highcharts - changing color of area depending on y-value - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745172588a2646066.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论