|
1 | 1 | <script setup lang="ts"> |
2 | | -import {computed, onMounted, onUnmounted, ref} from "vue"; |
| 2 | +import {computed, onMounted, onUnmounted} from "vue"; |
3 | 3 | import {getChartInstance} from "@/views/chat/component/index.ts"; |
4 | 4 | import type {BaseChart} from "@/views/chat/component/BaseChart.ts"; |
5 | 5 |
|
@@ -35,21 +35,21 @@ const axis = computed(() => { |
35 | 35 | return _list |
36 | 36 | }) |
37 | 37 |
|
38 | | -const chartInstance = ref<BaseChart>() |
| 38 | +let chartInstance: BaseChart | undefined |
39 | 39 |
|
40 | 40 | function renderChart() { |
41 | | - chartInstance.value = getChartInstance(params.type, chartId.value) |
42 | | - console.log(chartInstance.value) |
43 | | - if (chartInstance.value) { |
44 | | - chartInstance.value.init(axis.value, params.data) |
45 | | - chartInstance.value.render() |
| 41 | + chartInstance = getChartInstance(params.type, chartId.value) |
| 42 | + console.log(chartInstance) |
| 43 | + if (chartInstance) { |
| 44 | + chartInstance.init(axis.value, params.data) |
| 45 | + chartInstance.render() |
46 | 46 | } |
47 | 47 | } |
48 | 48 |
|
49 | 49 | function destroyChart() { |
50 | | - if (chartInstance.value) { |
51 | | - chartInstance.value.destroy() |
52 | | - chartInstance.value = undefined |
| 50 | + if (chartInstance) { |
| 51 | + chartInstance.destroy() |
| 52 | + chartInstance = undefined |
53 | 53 | } |
54 | 54 | } |
55 | 55 |
|
|
0 commit comments