echarts icon indicating copy to clipboard operation
echarts copied to clipboard

如何设置legend前的icon样式,比如颜色

Open rickyzhuang opened this issue 10 years ago • 11 comments

legend icon

rickyzhuang avatar Mar 01 '16 08:03 rickyzhuang

看样子是需要自己做素材图片了,如此一来更改line的颜色,或者更改legend字体的颜色,但icon不能改也不是好的办法

rickyzhuang avatar Mar 01 '16 09:03 rickyzhuang

改 itemStyle.normal.color

pissang avatar Mar 01 '16 10:03 pissang

但是如果我series数据的color有红黄绿三种颜色,但legend我要设置成绿色,怎么办? @pissang

dev-johnny-gh avatar Jan 11 '18 04:01 dev-johnny-gh

legendModel.js 貌似没有这个选项啊itemStyle.normal.color

lcoder avatar Mar 05 '18 11:03 lcoder

与legend同级, 加一个color:['#0098FE','#FF9B00']

impguier avatar Jun 04 '18 07:06 impguier

@pissang @duxiaofeng-github 我折线图中的点有两种颜色 itemStyle: { normal: {

                            color: function (param) {
                                if (param.data == maxtime){
                                    return '#ff151a';
                                } else {
                                    return '#1ca1ff';
                                }
                            },
                            borderColor: '#1ca1ff'
                        }
                    }

这样设置了当value为某个值时设置折线的点为另一个颜色,但是legend的颜色每次都取第一个节点的颜色,同级别加color数组也不行,不知道如何自定义,难道只能设置icon吗

vic-93 avatar Nov 14 '18 07:11 vic-93

但是如果我series数据的color有红黄绿三种颜色,但legend我要设置成绿色,怎么办? @pissang

同样好气

NnnLillian avatar Apr 18 '19 13:04 NnnLillian

@andy-hu1993 我和你有同样的需求 请问你找到解决办法了么?

tucaoxingren avatar Jul 08 '19 05:07 tucaoxingren

我也有同样的需求,求解决

QutGit avatar Nov 27 '19 08:11 QutGit

@impguier 的回答有用,改变了折线的颜色,然后:

        color: ['#5A8FEE', '#ff7674'], // 图例icon颜色会变成对应的这两个颜色
        legend: {
          data: [
            {
              name: '1数',
              icon: 'circle',
              textStyle: {
                color: '#5A8FEE' // 图例文字颜色
              }
            },
            {
              name: '2数',
              icon: 'circle',
              textStyle: {
                color: '#ff7674'
              }
            }
          ]
        },

图例icon颜色和线的颜色一致,谢谢大神

shangsj avatar Jun 17 '20 02:06 shangsj

这个更灵活 echarts文档

option = {
    // 全局调色盘。
    color: ['#c23531','#2f4554', '#61a0a8', '#d48265', '#91c7ae','#749f83',  '#ca8622', '#bda29a','#6e7074', '#546570', '#c4ccd3'],
    series: [{
        type: 'bar',
        // 此系列自己的调色盘。
        color: ['#dd6b66','#759aa0','#e69d87','#8dc1a9','#ea7e53','#eedd78','#73a373','#73b9bc','#7289ab', '#91ca8c','#f49f42'],
        ...
    }, {
        type: 'pie',
        // 此系列自己的调色盘。
        color: ['#37A2DA', '#32C5E9', '#67E0E3', '#9FE6B8', '#FFDB5C','#ff9f7f', '#fb7293', '#E062AE', '#E690D1', '#e7bcf3', '#9d96f5', '#8378EA', '#96BFFF'],
        ...
    }]
}

chengwb53 avatar Oct 22 '20 02:10 chengwb53