You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
2.1 KiB
91 lines
2.1 KiB
/*
|
|
* @Descripttion:
|
|
* @version:
|
|
* @Author: Wiley.Yang
|
|
* @Date: 2022-02-11 17:24:08
|
|
* @LastEditors: Wiley.Yang
|
|
* @LastEditTime: 2022-02-14 16:13:15
|
|
*/
|
|
export function echartsJump(echarts, option) {
|
|
/* 自动轮换显示 */
|
|
const app = {
|
|
currentIndex: -1
|
|
}
|
|
echarts.on('restore', function(e) {
|
|
clearInterval(industryTimer)
|
|
})
|
|
// 高亮当前图形
|
|
echarts.dispatchAction({
|
|
type: 'highlight',
|
|
seriesIndex: 0,
|
|
dataIndex: 0
|
|
})
|
|
// 显示 tooltip
|
|
echarts.dispatchAction({
|
|
type: 'showTip',
|
|
seriesIndex: 0,
|
|
dataIndex: 0
|
|
})
|
|
let industryTimer = setInterval(function() {
|
|
const dataLen = option.series[0].data.length
|
|
|
|
// 取消之前高亮的图形
|
|
echarts.dispatchAction({
|
|
type: 'downplay',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
app.currentIndex = (app.currentIndex + 1) % dataLen
|
|
// 高亮当前图形
|
|
echarts.dispatchAction({
|
|
type: 'highlight',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
// 显示 tooltip
|
|
echarts.dispatchAction({
|
|
type: 'showTip',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
}, 3000)
|
|
|
|
echarts.on('mouseover', function(e) {
|
|
clearInterval(industryTimer)
|
|
if (e.dataIndex !== app.currentIndex) {
|
|
echarts.dispatchAction({
|
|
type: 'downplay',
|
|
seriesIndex: e.seriesIndex,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
app.currentIndex = e.dataIndex
|
|
}
|
|
})
|
|
|
|
echarts.on('mouseout', function() {
|
|
clearInterval(industryTimer)
|
|
industryTimer = setInterval(function() {
|
|
const dataLen = option.series[0].data.length
|
|
// 取消之前高亮的图形
|
|
echarts.dispatchAction({
|
|
type: 'downplay',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
app.currentIndex = (app.currentIndex + 1) % dataLen
|
|
// 高亮当前图形
|
|
echarts.dispatchAction({
|
|
type: 'highlight',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
// 显示 tooltip
|
|
echarts.dispatchAction({
|
|
type: 'showTip',
|
|
seriesIndex: 0,
|
|
dataIndex: app.currentIndex
|
|
})
|
|
}, 3000)
|
|
})
|
|
}
|