var chartOptions = function(seriesData) {
let option = {
xAxis: {
min: 0,
max: 11
},
yAxis: {
min: 0,
max: 11
},
series: [{
name: "Series 1",
type: 'scatter',
data: seriesData,
color: "red",
animationDelay: function(idx) {
return idx * 250;
},
animationEasingUpdate: "linear"
}, ]
};
return option;
};
var nextSeries = function(seriesData) {
let series = {
series: [{
name: "Next series",
type: 'scatter',
data: seriesData,
color: "blue",
animationDelay: function(idx) {
return idx * 250;
},
animationEasingUpdate: "linear"
}, ]
};
return series;
};
var series1 = [
[1, 1],
[2, 2],
[3, 3],
[4, 4],
[5, 5]
];
var series2 = [
[10, 10],
[9, 9],
[8, 8],
[7, 7],
[6, 6]
];
var series3 = [
[10, 10],
[1, 1],
[8, 8],
[2, 2],
[6, 6]
];
var seriesAll = [series1, series2, series3]
var options = chartOptions(series1);
var chart1 = echarts.init(document.getElementById("ChartView"));
chart1.setOption(options);
var i = 0;
var timer = setInterval(function() {
i++;
if (i >= seriesAll.length) {
clearInterval(timer)
} else {
var nextOptions = nextSeries(seriesAll[i])
chart1.setOption(nextSeries([]));
chart1.setOption(nextOptions);
};
}, 2000);
<script src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js" > </script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/echarts/4.1.0/echarts-en.js"> </script>
<div id = "ChartView" style = "height:300px;max-width:300px;" >
</div>