mounted() {
var chartDom = this.$refs.newEchartsRef;
this.myChart = echarts.init(chartDom);
let myChart = this.myChart; //解决echarts中this指向问题
this.option && this.myChart.setOption(this.option);
myChart.dispatchAction({ type: "highlight", seriesIndex: 0, dataIndex: 0 }); //设置默认选中高亮部分
let index = 0;
myChart.on("mouseover", function (e) {
if (e.dataIndex != index) {
myChart.dispatchAction({
type: "downplay",
seriesIndex: 0,
dataIndex: index,
});
}
});
myChart.on("mouseout", function (e) {
index = e.dataIndex;
myChart.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: e.dataIndex,
});
});
},
echarts图表环形图设置默认一项为选中状态
最新推荐文章于 2024-06-30 12:49:11 发布