bug
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| <template> | ||||
|   <section class="AiEchart"> | ||||
|     <div ref="AiEchart" class="chart" :style="{minWidth:grid.width,minHeight:grid.height}"/> | ||||
|     <div :ref="AiEchart" class="chart" :style="{minWidth:grid.width,minHeight:grid.height}"/> | ||||
|     <slot v-if="$slots.default"/> | ||||
|     <render-component v-else-if="ops.render" :render="ops.render" :options="chartOptions" :data="data"/> | ||||
|   </section> | ||||
| @@ -39,7 +39,8 @@ export default { | ||||
|   data() { | ||||
|     return { | ||||
|       chart: null, | ||||
|       timer: null | ||||
|       timer: null, | ||||
|       AiEchart: `AiEchart-${new Date().getTime()}` | ||||
|     } | ||||
|   }, | ||||
|   computed: { | ||||
| @@ -176,14 +177,14 @@ export default { | ||||
|       } | ||||
|     }, | ||||
|     initChart() { | ||||
|       this.chart = echarts.init(this.$refs.AiEchart) | ||||
|       this.chart = echarts.init(this.$refs[this.AiEchart]) | ||||
|       this.chart.setOption(this.chartOptions || {}) | ||||
|     }, | ||||
|     watchResize() { | ||||
|       this.timer && clearInterval(this.timer) | ||||
|       this.timer = setInterval(() => { | ||||
|         if (this.chart?.getHeight() != this.$refs.AiEchart?.clientHeight || | ||||
|             this.chart?.getWidth() != this.$refs.AiEchart?.clientWidth) { | ||||
|         if (this.chart?.getHeight() != this.$refs[this.AiEchart]?.clientHeight || | ||||
|             this.chart?.getWidth() != this.$refs[this.AiEchart]?.clientWidth) { | ||||
|           this.chart?.resize() | ||||
|         } | ||||
|       }, 1000) | ||||
| @@ -196,6 +197,7 @@ export default { | ||||
|   }, | ||||
|   mounted() { | ||||
|     this.$nextTick(() => { | ||||
|     console.log(this.$refs[this.AiEchart]) | ||||
|       this.watchResize() | ||||
|       this.initChart() | ||||
|       this.getChartData() | ||||
|   | ||||
		Reference in New Issue
	
	Block a user