data(){
return{
lbtime:"",
option:{}
}}
dataZoom: [{
startValue:0,
endValue:4,
}]
option 下方加
if (this.linechart.lineData.length > this.option.dataZoom[0].endValue) {
this.autoMove();
}
加入方法
autoMove(){
if (this.lbtime) {
clearInterval(this.lbtime);
}
this.lbtime = setInterval(() => {
//datazoom默认显示数量<x轴数据长度时开始轮播
if (this.option.dataZoom[0].endValue == this.linechart.lineData.length) {
this.option.dataZoom[0].endValue = 2;
this.option.dataZoom[0].startValue = 0;
} else {
this.option.dataZoom[0].endValue = this.option.dataZoom[0].endValue + 1;
this.option.dataZoom[0].startValue = this.option.dataZoom[0].startValue + 1;
}
this.myChart.clear();
this.myChart.setOption(this.option);
// tools.loopShowTooltip(myChart, option, {loopSeries: true}); // 使用本插件
window.onresize = this.myChart.resize();
var option1 = this.myChart.getOption();
this.myChart.clear();
this.myChart.setOption(option1);
}, 5000)
},
stop(){
clearInterval(this.lbtime);
},
goMove(){
this.autoMove();
}
鼠标移入暂停,移出开始
$('.LineChart').mouseover(()=>{
this.stop();
});
$('.LineChart').mouseout(()=>{
this.goMove();
});