【问题标题】:How to manually set a color of a LineSeries via json config in amcharts v4?如何在 amcharts v4 中通过 json 配置手动设置 LineSeries 的颜色?
【发布时间】:2020-11-01 05:30:06
【问题描述】:

如何在 amcharts v4 中通过 json config 手动设置 LineSeries 的颜色?

我试过很多属性都没有效果:

    ...
    "series": [
        {
            "type": "LineSeries",
            "propertyFields": {
                "stroke": "#color",
                "fill":   "#color"
            }
        },
        {
            "type": "LineSeries",
            "color": "#color"
        },
        {
            "type": "LineSeries",
            "fill": "#color"
        },
        {
            "type": "LineSeries",
            "sprite": {
                "color": "#color"
            }
        },
        {
            "type": "LineSeries",
            "sprite": {
                "fill": "#color"
            }
        },
        {
            "type": "LineSeries",
            "stroke": {
                "color": "#color"
            }
        },
        {
            "type": "LineSeries",
            "stroke": {
                "fill": "#color"
            }
        }
    ]

amcharts v4 有没有简单易行的手动设置线条颜色的方法?

【问题讨论】:

    标签: json colors line amcharts amcharts4


    【解决方案1】:

    你几乎拥有它。您必须在 LineSeries 定义的顶层设置stroke (see JSON tab in the docs):

    "series": [{
      "type": "LineSeries",
      "stroke": "#567890",
      // ...
    },
    // ...
    ]
    

    JSON 值在层次结构方面与声明性语法非常接近。您可以在github repo 中找到更多完整的 JSON 示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-26
      • 1970-01-01
      • 2016-02-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多