javascript echarts 关系调用高亮示例 dispatchAction及其遇到的问题 - highlight&#39

📅 2026-11-30 👤 拼多多助力营销技巧 📂 拼多多助力 👁️ 544 次阅读

如图所示

// 点击左侧信息

clickLabel (index) {

this.labelList.forEach(item => {

item[0].isSelect = false

})

this.labelList[index][0].isSelect = true

this.$refs.charts.switchHigh(index,1)

}

好吧 太多了 关键是看这个

switchHigh (index, name) {

// console.log(index,name)

this.myChart.dispatchAction({

type: 'highlight',

seriesIndex: 0,

dataIndex: index,

name: name // 感觉传这个name没什么用 注释都行

})

},

遇到的问题

遇到了什么问题呢 就是 点击对应的实体 但是高亮了别的 如图 点击了 王二 但是却高亮了手机

问题原因

switchHigh 的index对应错了 点击王二 就需要传王二的index

解决方法

因为我右边的列表 是过滤了关于人的实体 手机阿 公司阿 地址阿 都不在左边的列表里面 然后 switchHigh 传的就是左边列表的index 这样就错了 应该传图谱数据的列表对应的index

因为传给图谱的chartList数组的数据里面有人有物 顺序是乱的 但是我把人的全部提取出来给了左边

所以我就把chartList数组处理了下 把人的排在前面 物在后面

let peopleList = vertex.filter(item => item.type === 'entity_person')

let thingList = vertex.filter(item => item.type !== 'entity_person')

let newVertexList = peopleList.concat(thingList)

this.chartList = [newVertexList, edge] 拼多多帮助力入口

解决了

我只是记录这个问题 说明switchHigh 的index来自哪里

标签: 拼多多助力网站平台 赚钱项目 拼多多助力网 首码项目 手赚APP
拼多多助力营销技巧