如何通过在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",
},
因为我可以使用negativeBase属性设置下限。 如何设置上限?
答案 0 :(得分:1)
虽然没有正的基本设置,但是可以组合使用negativeLineColor和lineColor来切换图形颜色,具体取决于图形颜色的减小还是增大。
这里有一个例子: https://codepen.io/team/amcharts/pen/155bbc984311730a95242f38c84f78d1
"graphs": [{
"useNegativeColorIfDown": true,
"lineColor": "#cddd00",
"negativeLineColor": "#ccb7dc",
图形将在增加时为lineColor,在减少时为negativeLineColor。
https://docs.amcharts.com/3/javascriptcharts/AmGraph#useNegativeColorIfDown https://docs.amcharts.com/3/javascriptcharts/AmGraph#negativeLineColor
OR
您可以从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],
}