选中效果:
//let apiCounterDom = document.getElementById('main');
//this.apiCounterChart = this.$echarts.init(apiCounterDom);
//this.apiCounterChart.setOption(this.apiCounterOption);
//this.pieClick(this.apiCounterChart)
pieChartSel(charts) {
const that = this;
let index = 0;
//默认选中
charts.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: 0,
});
//hover选中
charts.on('mouseover', function(e) {
if (e.dataIndex != index) {
charts.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: index,
});
}
});
charts.on('mouseout', function(e) {
index = e.dataIndex;
charts.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: e.dataIndex,
});
});
//点击选中
charts.on("click", function(e) {
if (e.dataIndex != index) {
charts.dispatchAction({
type: 'downplay',
seriesIndex: 0,
dataIndex: index,
});
}
index = e.dataIndex;
charts.dispatchAction({
type: 'highlight',
seriesIndex: 0,
dataIndex: e.dataIndex,
});
});
}