gpt4 book ai didi

javascript - 具有绿色/黄色/红色渐变的 Highcharts solidgauge

转载 作者:太空宇宙 更新时间:2023-11-03 21:22:21 27 4
gpt4 key购买 nike

我想知道是否可以在“solidGauge”图表的右侧设置一个从左侧绿色(0 值)开始、中间渐变为黄色然后渐变为红色的渐变。

我在 yAxis 中尝试了一些配置,但它们没有按照我的要求进行:

            yAxis: {
plotBands: [{
color: {
linearGradient: [300, 300, 0, 0],
stops: [
[0, 'rgb(255, 255, 255)'],
[1, 'rgb(150, 200, 155)']
]
},
from: 0,
to: 100
}],
},

enter image description here

            yAxis: {
minColor:'#55BF3B',
maxColor:'#DF5353',
},

enter image description here

            yAxis: {
minColor: gaugeValue >= 80 ? '#FF0000' : (gaugeValue >= 60 ? '#FFFF00' : '#00FF00'),
maxColor: gaugeValue >= 80 ? '#FF0000' : (gaugeValue >= 60 ? '#FFFF00' : '#00FF00'),
}

enter image description here

            yAxis: {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
},

enter image description here

好吧,我知道图像有不同的颜色,因为我使用了不同的十六进制值,顺便说一句,结果总是一样的:纯色(基于 gaugeValue)。

我希望如果我的值为 90%,我可以看到从绿色到黄色再到红色的渐变。像这样:

enter image description here

欢迎提出任何建议。

谢谢

最佳答案

您需要将点的颜色设置为渐变,而不是轴。例如:http://jsfiddle.net/n9gfeor2/

series: [{
name: 'Speed',
data: [{
color: {
linearGradient: [0, 0, 300, 0],
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
]
},
y: 80
}]
}]

关于javascript - 具有绿色/黄色/红色渐变的 Highcharts solidgauge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36240478/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com