echarts
echarts copied to clipboard
legend 中的图例有没有方法做到最少保留一个不被取消选中?
One-line summary [问题简述]
legend 中的图例有没有方法做到最少保留一个不被取消选中?
Version & Environment [版本及环境]
- ECharts version [ECharts 版本]:
- Browser version [浏览器类型和版本]:
- OS Version [操作系统类型和版本]:

Expected behaviour [期望结果]
保留一个不被选 中
ECharts option [ECharts配置项]
option = {
legend: {
type: 'scroll',
width: '90%',
pageIconSize: 10,
pageIconColor: '#1890ff',
pageIconInactiveColor: '#1890ff4d',
pageTextStyle: {
color: '#8c8c8c'
},
data: ["何布月对", "正命速会", "极内取量", "方管形低"]
},
}
Other comments [其他信息]
mychart.on('legendselectchanged', params => {
let selected = params.selected;
let count = Object.keys(selected).reduce((acc, val) => {
return acc + (selected[val] ? 1 : 0);
}, 0);
if (count === 0) {
mychart.dispatchAction({
type: 'legendSelect',
name: params.name
});
}
});
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.