const option = {}
this.chart = echarts.init(this.$refs.weight)
this.chart.setOption(option)
let erd = resizeDetector()
erd.listenTo(this.$refs.weight, () => {
this.$nextTick(function () {
this.chart.resize()
})
})
this.weightData.xData.push('测试1')
this.weightData.yData.push(30)
if (this.weightData.xData.length > 8) {
this.weightData.xData.splice(0, 1)
this.weightData.yData.splice(0, 1)
}
this.chart.setOption({
series: [
{
data: this.weightData.yData,
type: 'line'
},
],
xAxis: {
type: 'category',
data: this.weightData.xData
}
})