getMsg() {
var myChart = echarts.init(document.getElementById("left"));
let option = {
tooltip: {
trigger: "item",
formatter: "{b} : {c} ({d}%)"
},
legend: {
bottom: 10,
left: "center",
data: this.topInfo.list,
textStyle: {
color: "#333333",
fontSize: "10",
fontWeight: 400
},
type: "scroll"
},
series: [
{
type: "pie",
radius: "65%",
center: ["50%", "45%"],
selectedMode: "single",
data: this.topInfo.details,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)"
}
}
}
]
};
console.log(myChart);
myChart.setOption(option);
const selectPie = () => {
var dataLen = option.series[0].data.length;
currentIndex = (currentIndex + 1) % dataLen;
highlightPie();
};
let currentIndex = -1;
let changePieInterval = setInterval(selectPie, 2000);
const highlightPie = () => {
for (var idx in option.series[0].data)
myChart.dispatchAction({
type: "downplay",
seriesIndex: 0,
dataIndex: idx
});
myChart.dispatchAction({
type: "highlight",
seriesIndex: 0,
dataIndex: currentIndex
});
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: currentIndex
});
};
myChart.on("mouseover", params => {
clearInterval(changePieInterval);
currentIndex = params.dataIndex;
highlightPie();
});
myChart.on("mouseout", () => {
if (changePieInterval) clearInterval(changePieInterval);
changePieInterval = setInterval(selectPie, 2000);
});
},