javascript
option = {
title: { text: '销售数据' },
tooltip: { trigger: 'axis' },
legend: { data: ['销量', '库存'] },
xAxis: {
type: 'category',
data: ['衬衫', '羊毛衫', '雪纺衫']
},
yAxis: { type: 'value' },
series: [
{ name: '销量', type: 'bar', data: [5, 20, 36] },
{ name: '库存', type: 'line', data: [10, 25, 30] }
]
}
javascript
// 在组件中
const updateData = () => {
const newData = [Math.random() * 100, ...chartOption.series[0].data.slice(0,6)]
chartOption.series[0].data = newData
}
参考: