1、設置 legend 屬性: selectedMode: 'single'
2、使用 myCharts.dispatchAction 來設置legend的聚焦
broadcast (v) { // 如果是false,則消滅輪播 if (v === false) return clearInterval(this.timer) // 獲取legend的data const data = this.myChart.getOption().legend[0].data // 首次總是從0開始的 let i = 0 // 開始輪播 this.timer = setInterval(() => { // 激活 this.myChart.dispatchAction({ type: 'legendToggleSelect', name: data[ ++i % data.length ] }) }, 3500) }
