app.title = '极坐标系下的堆叠柱状图';
option = {
angleAxis: {
type: 'category',
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
z: 10
},
radiusAxis: {
},
polar: {
},
series: [{
type: 'bar',
data: [1, 2, 3, 4, 3, 5, 1],
coordinateSystem: 'polar',
name: 'A',
stack: 'a'
}, {
type: 'bar',
data: [2, 4, 6, 1, 3, 2, 1],
coordinateSystem: 'polar',
name: 'B',
stack: 'a'
}, {
type: 'bar',
data: [1, 2, 3, 4, 1, 2, 5],
coordinateSystem: 'polar',
name: 'C',
stack: 'a'
}],
legend: {
show: true,
data: ['A', 'B', 'C']
}
};
myChart.setOption(option);
//实时更新
var timeTicket;
clearInterval(timeTicket);
timeTicket = setInterval(function (){
option = myChart.getOption();
var arr=option.series[0].data;
var arr1=option.series[1].data;
var arr2=option.series[2].data;
if(arr.length==7){
arr.shift();
}
if(arr1.length==7){
arr1.shift();
}
if(arr2.length==7){
arr2.shift();
}
console.log(arr)
arr.push(Math.round(Math.random() * 1000));
arr1.push(Math.round(Math.random() * 1000));
arr2.push(Math.round(Math.random() * 1000));
console.log(arr)
myChart.setOption(option);
}, 100);
- echarts 3 移出了 addData方法 可以利用 数组的
shift()
方法 进行数据的移除操作然后push()
新的数据
- 效果图