123456789101112131415161718192021222324252627282930313233
// 写一个函数,参数为chart图表的ref参数, 自动播放的间隔时间time// 注意chart的option配置项series 要写成数据的形式,如果为对象 修改函数里面series的判断autoPlayToopTip (chartRef, time = 1500) { let dataIndex = -1 let dataLen = 0 if (typeof chartRef !== 'undefined' && typeof chartRef.options.series !== 'undefined') { if (chartRef.options.series.length > 0 && typeof chartRef.options.series[0].data !== 'undefined') { dataLen = chartRef.options.series[0].data.length } setInterval(() => { chartRef.dispatchAction({ type: 'downplay', playState: true, seriesIndex: 0, dataIndex }) dataIndex = (dataIndex + 1) % dataLen chartRef.dispatchAction({ type: 'highlight', playState: true, seriesIndex: 0, dataIndex }) // 显示 tooltip chartRef.dispatchAction({ type: 'showTip', seriesIndex: 0, playState: true, dataIndex }) }, time) } },
Norah
An imaginative front-end worker
Beijing
Entradas
58
Categorias
28
Etiquetas
51
TypeScript
uni-app
Babel 进阶
JavaScript 小知识
Update your browser to view this website correctly. Update my browser now
×