在UI设计的时候,可能我们在使用echarts时,legend是用图片渲染的,未选中的legend是用置灰的图片展示的。即彩色图片,置灰图片交互切换。
主要代码如下:
//图例事件 let lgdt = this._ledgend(), lgData = lgdt.legendData,lgList = lgdt.legendList, imgs = this._icon(),imglg = imgs.length,unIng = this._lgiconUnActive(), iconUnActive = `image://${unIng}`; myChart.on('legendselectchanged', (params)=>{ let {selected,name} = params,i = lgList.indexOf(name); let theOption = lgData.find(dt => dt.name === name); let iconActive = `image://${imgs[i%imglg]}`; theOption.icon = selected[name] ? iconActive : iconUnActive; // 更新图列 this.$chart.setOption({ legend: { data: lgData } }) })
讯享网

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/103120.html