From ab11a20e2ecb3b9003ee9d2079b6daf1070bf301 Mon Sep 17 00:00:00 2001 From: ulleo Date: Tue, 29 Jul 2025 15:49:17 +0800 Subject: [PATCH] feat: bar column label position --- frontend/src/views/chat/component/charts/Bar.ts | 6 ++++++ frontend/src/views/chat/component/charts/Column.ts | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/chat/component/charts/Bar.ts b/frontend/src/views/chat/component/charts/Bar.ts index f54fece9..d78c8e38 100644 --- a/frontend/src/views/chat/component/charts/Bar.ts +++ b/frontend/src/views/chat/component/charts/Bar.ts @@ -113,6 +113,12 @@ export class Bar extends BaseG2Chart { } return `${value}${_data.isPercent ? '%' : ''}` }, + position: (data: any) => { + if (data[y[0].value] < 0) { + return 'left' + } + return 'right' + }, transform: [ { type: 'contrastReverse' }, { type: 'exceedAdjust' }, diff --git a/frontend/src/views/chat/component/charts/Column.ts b/frontend/src/views/chat/component/charts/Column.ts index ad437abb..0159f81d 100644 --- a/frontend/src/views/chat/component/charts/Column.ts +++ b/frontend/src/views/chat/component/charts/Column.ts @@ -102,7 +102,12 @@ export class Column extends BaseG2Chart { } return `${value}${_data.isPercent ? '%' : ''}` }, - position: 'top', + position: (data: any) => { + if (data[y[0].value] < 0) { + return 'bottom' + } + return 'top' + }, transform: [ { type: 'contrastReverse' }, { type: 'exceedAdjust' },