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'
        }
    ]
}
相關文章
相關標籤/搜索