【问题标题】:How to specify limit color for line chart如何为折线图指定限制颜色
【发布时间】:2018-09-11 13:14:46
【问题描述】:

如何通过在 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 属性设置下限。 如何设置上限?

【问题讨论】:

    标签: javascript angular graph amcharts


    【解决方案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

    您可以从 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],
      }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-06
      • 2016-06-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多