Echarts图例legend过多,采用翻页处理

589 阅读1分钟

legend过多需要出现滚动条的办法:

legend中的属性这样设置即可:type:’scroll

echarts 图例lengend滚动翻页修改颜色
legend: {  
    show: true,  
    top: '10%',  
    type: 'scroll',  
    pageIconColor: '#aaa', // 翻页按钮的颜色  
    pageIconInactiveColor: '#2f4554', // 翻页按钮不激活时(即翻页到头时)的颜色  
    pageTextStyle: { // 图例页信息的文字样式  
    color: '#cbcbcb'  
},  
textStyle: {  
    color: 'rgba(212, 232, 254, 1)',  
    fontSize: 12  
},  
itemWidth: 10,  
itemHeight: 10,  
data: this.legend  
},

echarts legend 不允许点击切换

实现

可以通过legend.selectedMode来设置关闭,默认是开启的

legend: {
	icon: "circle",
	selectedMode: false
},

图例选择的模式,控制是否可以通过点击图例改变系列的显示状态。默认开启图例选择,可以设成 false 关闭。

除此之外也可以设成 'single' 或者 'multiple' 使用单选或者多选模式。