export function highlightLoop(echart, length, callback) {
let index = 0;
return setInterval(function () {
if(index !== 0){ //取消高亮
echart.dispatchAction({
type: 'downplay',
dataIndex: index - 1,
});
}
if (index == length) {
index = 0;
}
echart.dispatchAction({ //设置高亮
type: 'highlight',
dataIndex: index,
});
if (callback) {
callback(index);
}
index++;
}, 2000);
}
const echartElement = useRef<HTMLDivElement>();
const pieChart = echart.init(echartElement.current, 'yunlu');
pieChart.setOption(option);
highlightLoop(pieChart, length,() => {})
return <div
id="pie"
className="chart-container"
style={props.style}
ref={e => {
if (e != null) {
echartElement.current = e;
}
}}
/>