var base = +new Date(2019, 5, 3); var oneDay = 24 * 3600 * 1000; var date = []; var data = [Math.random() * 150]; var now = new Date(base); function addData(shift) { now = [now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'); date.push(now); data.push((Math.random() - 0.4) * 10 + data[data.length - 1]); if (shift) { date.shift(); data.shift(); } now = new Date(+new Date(now) + oneDay); } for (var i = 1; i < 12; i++) { addData(); } option = { title : { text: '某地区蒸发量', subtext: '纯属虚构' }, tooltip : { trigger: 'axis' }, legend: { data:['蒸发量'] }, calculable : true, xAxis : [ { type : 'category', data : date } ], yAxis : [ { type : 'value' } ], series : [ { name:'蒸发量', type:'bar', data:data, } ] }; setInterval(function () { addData(true); myChart.setOption({ xAxis: { data: date }, series: [{ name:'蒸发量', data: data }] }); }, 5000);