需求:tooltip自动选中轮播
直接贴代码
vue使用的话 在使用页面引入即可
<template>
<div>
<div ref="line" style="width:600px; height: 400px;"></div>
</div>
</template>
<script>
import * as echarts from 'echarts';
import { loopShowTooltip } from '@/utils/echarts-auto-tooltip'
export default {
data() {
return {
}
},
mounted() {
this.getLine()
},
methods: {
getLine() {
let myChart = echarts.init(this.$refs.line)
let tootipTimer = null;
let option = {
tooltip: {
trigger: 'axis'
},
xAxis: {
type: 'category',
boundaryGap: false,
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
name: 'Email',
type: 'line',
// stack: 'Total',
data: [120, 132, 101, 134, 90, 230, 210]
}
]
}
myChart.setOption(option)
tootipTimer && tootipTimer.clearLoop(); //调用clearLoop方法,清除定时器