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

时间:2020-11-01 05:30:06

标签: json colors line amcharts amcharts4

如何在amcharts v4中通过json配置手动设置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是否具有简单易行的手动设置线条颜色的方法?

1 个答案:

答案 0 :(得分:1)

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

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

JSON值与声明式语法非常紧密地排列在一起,即层次结构。您可以在github repo中找到更多完整的JSON示例。