页面树结构
转至元数据结尾
转至元数据起始

(本文档仅供参考)

问题

如何修改线图线条颜色、图例图标颜色及图例文字颜色?

解决方案

可以使用扩展属性实现

{
    "series": [{
        //线条颜色设置
        "lineStyle": {
            "normal": {
                "color": "black"
            }
        },
        //图例中图标颜色设置
        "color": "green"
    }, {
        "lineStyle": {
            "normal": {
                "color": "red"
            }
        },
        "color": "red"
    }],
    "legend": {
        "icon": "line",
        //图例对应文字颜色设置
        "textStyle": {
            "color": "green"
        }
    }
}
  • 无标签

评论

  1. 张承峥 发表:

    如果发现图例的颜色并没有修改成功默认是主题色,需要加多一个itemstlyle修改:

    {
         "series": [{
             "type": "line",
             itemStyle: {
                 "normal": {
                     "color": "#2ca3d3" //2ca3d3
                 }
             },          /*因此要添加多一个itemStyle*/


             "lineStyle": {
                 "normal": {
                     "color": "#2ca3d3" //2ca3d3
                 }
             },
         }, {
             "type": "line",
             itemStyle: {
                 "normal": {
                     "color": "#7132a3" //2ca3d3
                 }
             },
           "lineStyle": {
                 "normal": {
                     "color": "#7132a3" //40eaea
                 }
             }
         }],
         "legend": {
             "icon": "line",
             "itemWidth": 14, //20
             "itemHeight": 14, //8
             "align": "left",
             "data": [{
                 "name": "销售额",
                 "icon": "line",
             }, {
                 "name": "销售量",
                 "icon": "line",
             }]
         }
    }