效果图
![每隔3秒刷新数据](https://i-blog.csdnimg.cn/blog_migrate/ff2405633ff0267e1c8eb791a7bafcbf.gif#pic_center)
option = {
xAxis:{
type: 'category',
boundaryGap: true,
data: [],
},
yAxis: {
type: 'value',
},
series: [
{
name: '预购队列',
type: 'bar',
data: [],
itemStyle: {
color: 'red'
}
},
{
name: '预购队列',
type: 'bar',
data: [],
itemStyle: {
color: 'blue'
}
},
{
name: '预购队列',
type: 'bar',
data: [],
itemStyle: {
color: 'green'
}
},
]
};
myChart.showLoading()
setTimeout(function() {
myChart.hideLoading();
setInterval(function (){
var axisData = (new Date()).toLocaleTimeString().replace(/^\D*/, '');
var data0 = option.series[0].data;
data0.shift();
data0.push(100);
var data1 = option.series[1].data;
data1.shift();
data1.push(500);
var data2 = option.series[2].data;
data2.shift();
data2.push(100);
option.xAxis.data.shift();
option.xAxis.data.push(axisData);
console.log('数据配置', option)
myChart.setOption(option);
}, 3000);
}, 2000);