Skip to content

Commit 1349f06

Browse files
authored
refactor: Optimize the addition of dual-indicator dashboard charts (#799)
1 parent 9eab6bc commit 1349f06

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

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

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,36 @@ function addToDashboard() {
221221
}
222222
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
223223
const chartBaseInfo = JSON.parse(props.message?.record?.chart)
224-
recordeInfo['chart'] = {
225-
type: currentChartType.value,
226-
title: chartBaseInfo.title,
227-
columns: chartBaseInfo.columns,
228-
xAxis: chartBaseInfo.axis?.x ? [chartBaseInfo.axis.x] : [],
229-
yAxis: chartBaseInfo.axis?.y ? [chartBaseInfo.axis.y] : [],
230-
series: chartBaseInfo.axis?.series ? [chartBaseInfo.axis.series] : [],
224+
if (chartBaseInfo) {
225+
let yAxis = []
226+
const axis = chartBaseInfo?.axis
227+
if (!axis?.y) {
228+
yAxis = []
229+
} else {
230+
const y = axis.y
231+
const multiQuotaValues = axis['multi-quota']?.value || []
232+
233+
// 统一处理为数组
234+
const yArray = Array.isArray(y) ? [...y] : [{ ...y }]
235+
236+
// 标记 multi-quota
237+
yAxis = yArray.map((item) => ({
238+
...item,
239+
'multi-quota': multiQuotaValues.includes(item.value),
240+
}))
241+
}
242+
243+
recordeInfo['chart'] = {
244+
type: chartBaseInfo?.type,
245+
title: chartBaseInfo?.title,
246+
columns: chartBaseInfo?.columns,
247+
xAxis: axis?.x ? [axis?.x] : [],
248+
yAxis: yAxis,
249+
series: axis?.series ? [axis?.series] : [],
250+
multiQuotaName: axis?.['multi-quota']?.name,
251+
}
231252
}
253+
232254
// @ts-expect-error eslint-disable-next-line @typescript-eslint/ban-ts-comment
233255
addViewRef.value?.optInit(recordeInfo)
234256
}

0 commit comments

Comments
 (0)