Skip to content

Commit ab4c947

Browse files
committed
fix: fix chartRef
1 parent 4b354a2 commit ab4c947

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/components/base.tsx

+6-7
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,24 @@ const BaseChart = defineComponent<
4242
return this.$attrs
4343
},
4444
chartData() {
45-
const { chart, chartRef, ...restProps } = this.attrConfig
46-
const { data } = restProps
45+
const { data } = this.attrConfig
4746
return data || []
4847
},
4948
chartConfig() {
50-
const { chart, chartRef, ...restProps } = this.attrConfig
51-
const { data, ...config } = restProps
49+
const { chart, chartRef, data, ...config } = this.attrConfig
5250
return config
5351
},
5452
},
5553
mounted() {
56-
const { chart: Chart } = this.$attrs as {
57-
chart: Plot<Options>
58-
}
54+
const { chart: Chart, chartRef } = this.attrConfig
5955
this.plot = new Chart(this.$el as HTMLElement, {
6056
data: this.chartData,
6157
...this.chartConfig,
6258
})
6359
this.plot.render()
60+
if (chartRef) {
61+
chartRef.value = this.plot
62+
}
6463
},
6564
beforeUnmount() {
6665
/* istanbul ignore else */

0 commit comments

Comments
 (0)