我们可以根据数据以外的变量在 highcharts stockchart 中添加负色吗?
Can we add negative color in highcharts stockchart based on a variable other that data?
我们可以根据数据以外的变量在高图中添加负色吗?因为,我拥有的数据都是正值,但我需要根据一个将为负的变量以红色显示图表。
series: [{
type: 'area',
data: [-12,24,54,-9,-12],
visible: false,
gapSize: 0,
tooltip: {
valueDecimals: 2
},
marker: {
enabled: false,
symbol: 'circle',
radius: 4,
lineWidth: 0,
states: {
hover: {
fillColor: '#58aa00',
}
},
},
lineColor: '#58aa00',
negativeColor: 'red',
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1,
},
stops: [
[0, '#c6e1b2'],
[1, Highcharts.color('#eaf4e2')
.setOpacity(0)
.get("rgba"),
],
],
}
现在从上面的代码中,只要有负值,我就会得到负色,但是我想根据不同的值使图表变红,比如我有一个不存在的变量 x = -20在数据数组中。
如有任何帮助,我们将不胜感激。提前致谢。
负值取自 threshold
值,因此您可以轻松 define/change 它。
演示:https://jsfiddle.net/BlackLabel/t9zhuakp/
API: https://api.highcharts.com/highcharts/plotOptions.series.threshold
我们可以根据数据以外的变量在高图中添加负色吗?因为,我拥有的数据都是正值,但我需要根据一个将为负的变量以红色显示图表。
series: [{
type: 'area',
data: [-12,24,54,-9,-12],
visible: false,
gapSize: 0,
tooltip: {
valueDecimals: 2
},
marker: {
enabled: false,
symbol: 'circle',
radius: 4,
lineWidth: 0,
states: {
hover: {
fillColor: '#58aa00',
}
},
},
lineColor: '#58aa00',
negativeColor: 'red',
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1,
},
stops: [
[0, '#c6e1b2'],
[1, Highcharts.color('#eaf4e2')
.setOpacity(0)
.get("rgba"),
],
],
}
现在从上面的代码中,只要有负值,我就会得到负色,但是我想根据不同的值使图表变红,比如我有一个不存在的变量 x = -20在数据数组中。
如有任何帮助,我们将不胜感激。提前致谢。
负值取自 threshold
值,因此您可以轻松 define/change 它。
演示:https://jsfiddle.net/BlackLabel/t9zhuakp/
API: https://api.highcharts.com/highcharts/plotOptions.series.threshold