Skip to content

Commit dbb721d

Browse files
committed
feat: init chart
1 parent 53964a3 commit dbb721d

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

frontend/src/views/chat/ChatAnswer.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const chartRef = ref()
8585
8686
function onTypeChange(type: string) {
8787
console.log(type)
88-
nextTick(()=>{
88+
nextTick(() => {
8989
chartRef.value?.destroyChart()
9090
chartRef.value?.renderChart()
9191
})
@@ -102,9 +102,10 @@ function onTypeChange(type: string) {
102102
<el-tabs v-model="settings.type" class="type-tabs" @tab-click="handleClick" tab-position="top">
103103
<el-tab-pane label="Chart" name="chart">
104104
<template #label>
105-
<el-select v-model="chartType" style="width: 80px" :disabled="settings.type!== 'chart'" @change="onTypeChange">
105+
<el-select v-model="chartType" style="width: 80px" :disabled="settings.type!== 'chart'"
106+
@change="onTypeChange">
106107
<el-option value="table">table</el-option>
107-
<el-option value="cloumn">cloumn</el-option>
108+
<el-option value="column">column</el-option>
108109
<el-option value="bar">bar</el-option>
109110
<el-option value="line">line</el-option>
110111
<el-option value="pie">pie</el-option>

frontend/src/views/chat/component/Component.vue

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import {computed, onMounted, onUnmounted, ref} from "vue";
2+
import {computed, onMounted, onUnmounted} from "vue";
33
import {getChartInstance} from "@/views/chat/component/index.ts";
44
import type {BaseChart} from "@/views/chat/component/BaseChart.ts";
55
@@ -35,21 +35,21 @@ const axis = computed(() => {
3535
return _list
3636
})
3737
38-
const chartInstance = ref<BaseChart>()
38+
let chartInstance: BaseChart | undefined
3939
4040
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()
4646
}
4747
}
4848
4949
function destroyChart() {
50-
if (chartInstance.value) {
51-
chartInstance.value.destroy()
52-
chartInstance.value = undefined
50+
if (chartInstance) {
51+
chartInstance.destroy()
52+
chartInstance = undefined
5353
}
5454
}
5555

0 commit comments

Comments
 (0)