echarts 修改legend样式

参考连接:https://www.cnblogs.com/goloving/p/9113830.htmlhtml

 

折线图时,legend默认时rect形式,若是须要改图例形状,能够本身设置legend的icon属性spa

legend: {
    icon:'stack'
},

自定义每一个图例样式:为data的每一个对象修改icon属性code

legend:{
    show:true,
    orient:'horizontal',
    borderColor:'#df3434',
    borderWidth:2,
    data:[
        {
            name:'蒸发量',
            textStyle:{
                fontSize:12,
                fontWeight:'bolder',
                color:'#cccccc'
            },
            icon:'stack'
        },
        {
            name:'降水量',
            textStyle:{
                fontSize:12,
                fontWeight:'bolder',
                color:'#df3434'
            },
            icon:'pie'
        }
    ]
}

修改图例的图标为自定义图片htm

图片放在根目录下的images文件夹下对象

legend:{
    show:true,
    orient:'horizontal',
    borderColor:'#df3434',
    borderWidth:2,
    data:[
        {
            name:'蒸发量',
            textStyle:{
                fontSize:12,
                fontWeight:'bolder',
                color:'#cccccc'
            },
            icon:'image://./images/icon1.png'//格式为'image://+icon文件地址',其中image::后的//不能省略
        },
        {
            name:'降水量',
            textStyle:{
                fontSize:12,
                fontWeight:'bolder',
                icon:'image://./images/icon2.png'//格式为'image://+icon文件地址',其中image::后的//不能省略
            },
            icon:'pie'
        }
    ]
}
相关文章
相关标签/搜索