Skip to content

Commit ab11a20

Browse files
committed
feat: bar column label position
1 parent e6839b8 commit ab11a20

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

frontend/src/views/chat/component/charts/Bar.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ export class Bar extends BaseG2Chart {
113113
}
114114
return `${value}${_data.isPercent ? '%' : ''}`
115115
},
116+
position: (data: any) => {
117+
if (data[y[0].value] < 0) {
118+
return 'left'
119+
}
120+
return 'right'
121+
},
116122
transform: [
117123
{ type: 'contrastReverse' },
118124
{ type: 'exceedAdjust' },

frontend/src/views/chat/component/charts/Column.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ export class Column extends BaseG2Chart {
102102
}
103103
return `${value}${_data.isPercent ? '%' : ''}`
104104
},
105-
position: 'top',
105+
position: (data: any) => {
106+
if (data[y[0].value] < 0) {
107+
return 'bottom'
108+
}
109+
return 'top'
110+
},
106111
transform: [
107112
{ type: 'contrastReverse' },
108113
{ type: 'exceedAdjust' },

0 commit comments

Comments
 (0)