问题遇到的现象和发生背景
请求后传值数据变了,图没变
问题相关代码,请勿粘贴截图
mounted(){
// 初始化
// this.initChart();
// this.$nextTick(res=>{
// console.log(this.echart,'echart');
// })
setTimeout(()=>{
console.log(this.echart.data,'echart');
console.log(this.chart._model.option.series[0].data,'chart');
this.chart._model.option.series[0].data=this.echart.data
console.log(this.chart._model.option.series[0].data,'chart_model.option.series[0].data');
},1000);
this.initChart();
},
props:{
echart:{Object,
default(){
return {}
}}
},
methods:{
initChart(){
this.chart=echarts.init(document.getElementById('main'))
//配置数据
this.chart.setOption({
title: [
{
text: 'Tangential Polar Bar Label Position (middle)'
}
],
title: {
text: "年龄占比",
// subtext: "Sub Title",
left: "center",
top: "10px",
textStyle: {
fontSize: 30
},
subtextStyle: {
fontSize: 20
}
},
polar: {
radius: '80%'
},
angleAxis: {
max: 100,
startAngle: 90
},
radiusAxis: {
type: 'category',
data: ['a', 'b', 'c', 'd']
},
tooltip: {},
series: {
type: 'bar',
data: [0,0,0,0],
coordinateSystem: 'polar',
label: {
show: true,
position: 'middle',
formatter: '{b}: {c}%',
bottom:'10'
}
}
})
}
}