Closed zhanglongqi closed 1 year ago
it seems the situation only happens on bar chart instead of pie chart
https://stackblitz.com/edit/vue-echarts-vue-3-yzspka?file=src%2Fcomponents%2Fpower.vue,package.json
https://stackblitz.com/edit/vue-echarts-vue-3-qparwn?file=src%2Fcomponents%2Fpower.vue,src%2FApp.vue
You are setting option.series[0].data[0]
as a ref, which cannot be consumed by ECharts itself. Updating its value also won't help. So you shouldn't use ref at the first place.
Set it as ref
is my fix actually, but this fix only works on Pie
, not Bar
. the first project here does not use ref
and it does not work.
https://stackblitz.com/edit/vue-echarts-vue-3-geazy8?file=src%2Fcomponents%2Fpower.vue
- option.series[0].data[0].value = props.value;
+ option.series[0].data[0] = props.value;
Maybe I did make myself clear. I mean is it possible that the chart update with the props
without the timer at all.
// setInterval(() => {
// option.series[0].data[0] = props.value;
// }, 1000);
https://stackblitz.com/edit/vue-echarts-vue-3-akywya?file=src%2Fcomponents%2Fpower.vue
I still can’t understand what’s wrong.
Please provide the reproduction, describe current behavior and expected behavior.
the pie chart will update when the props change, but the bar chart will not. https://stackblitz.com/edit/vue-echarts-vue-3-qparwn?file=src%2Fcomponents%2Fpower.vue
You are using reactive
for your chart option but what you really want is computed
as you intended to generate a derived state from your props. This isn't related to this project.
but why do bar and pie behave so differently?
Confirmation
How are you introducing Vue-ECharts into your project?
ES Module imports
Versions
Details
the chart do not update when the props in option updated unless I use timer to update it.
Reproduction
https://stackblitz.com/edit/vue-echarts-vue-3-gernt4?file=src/App.vue