Skip to content

Commit 65366d0

Browse files
committed
pref: improve show label button in chart display
1 parent a3b4575 commit 65366d0

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

frontend/src/views/chat/answer/ChartAnswer.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,7 @@ function stop() {
259259
}
260260
261261
const enableThousandsSeparatorList = ref<Array<string>>([])
262+
const showLabel = ref<boolean>(false)
262263
263264
onBeforeUnmount(() => {
264265
stop()
@@ -276,6 +277,7 @@ defineExpose({ sendMessage, index: () => index.value, stop })
276277
<template>
277278
<BaseAnswer v-if="message" :message="message" :reasoning-name="reasoningName" :loading="_loading">
278279
<ChartBlock
280+
v-model:show-label="showLabel"
279281
v-model:thousands-separator-list="enableThousandsSeparatorList"
280282
style="margin-top: 6px"
281283
:message="message"

frontend/src/views/chat/answer/PredictAnswer.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ function stop() {
258258
}
259259
260260
const enableThousandsSeparatorList = ref<Array<string>>([])
261+
const showLabel = ref<boolean>(false)
261262
262263
onBeforeUnmount(() => {
263264
stop()
@@ -278,6 +279,7 @@ defineExpose({ sendMessage, index: () => index.value, chatList: () => _chatList,
278279
<ChartBlock
279280
v-if="message.record?.predict_data?.length > 0 && message.record?.data"
280281
ref="chartBlockRef"
282+
v-model:show-label="showLabel"
281283
v-model:thousands-separator-list="enableThousandsSeparatorList"
282284
style="margin-top: 12px"
283285
:record-id="recordId"

frontend/src/views/chat/chat-block/ChartBlock.vue

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ const props = withDefaults(
3939
chatType?: ChartTypes
4040
enlarge?: boolean
4141
loadingData?: boolean
42-
thousandsSeparatorList?: Array<string>
42+
thousandsSeparatorList: Array<string>
43+
showLabel: boolean
4344
}>(),
4445
{
4546
recordId: undefined,
@@ -48,14 +49,15 @@ const props = withDefaults(
4849
enlarge: false,
4950
loadingData: false,
5051
thousandsSeparatorList: () => [],
52+
showLabel: false,
5153
}
5254
)
5355
5456
const { copy } = useClipboard({ legacy: true })
5557
const loading = ref<boolean>(false)
5658
const { t } = useI18n()
5759
const addViewRef = ref(null)
58-
const emits = defineEmits(['exitFullScreen', 'update:thousandsSeparatorList'])
60+
const emits = defineEmits(['exitFullScreen', 'update:thousandsSeparatorList', 'update:showLabel'])
5961
6062
const dataObject = computed<{
6163
fields: Array<string>
@@ -229,8 +231,6 @@ function showSql() {
229231
sqlShow.value = true
230232
}
231233
232-
const showLabel = ref(false)
233-
234234
function addToDashboard() {
235235
const recordeInfo = {
236236
id: '1-1',
@@ -368,6 +368,15 @@ watch(
368368
}
369369
)
370370
371+
const _showLabel = computed({
372+
get() {
373+
return props.showLabel
374+
},
375+
set(v) {
376+
emits('update:showLabel', v)
377+
},
378+
})
379+
371380
const enableThousandsSeparatorList = computed({
372381
get() {
373382
return props.thousandsSeparatorList
@@ -434,14 +443,14 @@ function getBaseAxis() {
434443
<el-tooltip
435444
effect="dark"
436445
:offset="8"
437-
:content="showLabel ? t('chat.hide_label') : t('chat.show_label')"
446+
:content="_showLabel ? t('chat.hide_label') : t('chat.show_label')"
438447
placement="top"
439448
>
440449
<el-button
441450
class="tool-btn"
442-
:class="{ 'chart-active': showLabel }"
451+
:class="{ 'chart-active': _showLabel }"
443452
text
444-
@click="showLabel = !showLabel"
453+
@click="_showLabel = !_showLabel"
445454
>
446455
<el-icon size="16">
447456
<ICON_STYLE />
@@ -589,7 +598,7 @@ function getBaseAxis() {
589598
:message="message"
590599
:data="data"
591600
:loading-data="loadingData"
592-
:show-label="showLabel"
601+
:show-label="_showLabel"
593602
:thousands-separator-list="enableThousandsSeparatorList"
594603
/>
595604
</div>
@@ -610,6 +619,7 @@ function getBaseAxis() {
610619
>
611620
<ChartBlock
612621
v-if="dialogVisible && !enlarge"
622+
v-model:show-label="_showLabel"
613623
v-model:thousands-separator-list="enableThousandsSeparatorList"
614624
:message="message"
615625
:record-id="recordId"

0 commit comments

Comments
 (0)