如何指定折线图的限制颜色



如何通过在 Amchart 中指定上限和下限来为线条指定不同的颜色。

请在下面找到折线图的代码。

{
'id': 'g3',
"title": "Temperature",
'balloonText':'[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>',
'bullet': 'round',
'bulletSize': 8,
"lineColor": "#9524a3",
'lineThickness': 1,
'negativeLineColor': '#FF0000',
'type': 'smoothedLine',
"negativeBase":8,
'valueField':"temperature",
},

因为我能够使用负基础属性设置下限。 如何设置上限?

虽然没有正基设置,但您可以使用负线颜色和线颜色的组合来切换图形颜色,具体取决于它是减少还是增加。

这里有一个例子: https://codepen.io/team/amcharts/pen/155bbc984311730a95242f38c84f78d1

"graphs": [{
"useNegativeColorIfDown": true,
"lineColor": "#cddd00",
"negativeLineColor": "#ccb7dc",

图形在增加时为线颜色,在减少时为负线颜色。

https://docs.amcharts.com/3/javascriptcharts/AmGraph#useNegativeColorIfDown https://docs.amcharts.com/3/javascriptcharts/AmGraph#negativeLineColor

您可以从 json 中获取颜色值并使用 lineColorField。

请在下面找到 json 和折线图对象

{
"DeviceName": "1Device",
"Date": "2018-09-11 20:10:55",
"temperature": 10.00,
"Color temperature": "#ff3232",
"humidity": 10.00,
"Color humidity": "#17c723",
"co2": 10.00,
"Color co2": "#ff3232",
"airpressure": 10.00,
"Color airpressure": "#9bbd3b"
}
{
'id': "g"+i,
"title": data["Parameter"][i],
'balloonText':'[[category]]<br><b><span style='font-size:14px;'>[[value]]</span></b>',
'bullet': 'round',
'bulletSize': 8,
"lineColor": data["Colors"][i],
//  "legendColorField": "Color "+data["Parameter"][i],
"lineColorField": "Color "+data["Parameter"][i],
'lineThickness': 1,
//  "negativeBase":5,
//'negativeLineColor': '#FF0000',
'type': 'smoothedLine',
'valueField': data["Parameter"][i],
}

最新更新