Skip to content

Commit 5c48efa

Browse files
committed
pref: null data in charts
1 parent 247792b commit 5c48efa

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ export class Bar extends BaseG2Chart {
106106
},
107107
labels: [
108108
{
109-
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
109+
text: (data: any) => {
110+
const value = data[y[0].value]
111+
if (value === undefined || value === null) {
112+
return ''
113+
}
114+
return `${value}${_data.isPercent ? '%' : ''}`
115+
},
110116
transform: [
111117
{ type: 'contrastReverse' },
112118
{ type: 'exceedAdjust' },

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ export class Column extends BaseG2Chart {
9595
},
9696
labels: [
9797
{
98-
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
98+
text: (data: any) => {
99+
const value = data[y[0].value]
100+
if (value === undefined || value === null) {
101+
return ''
102+
}
103+
return `${value}${_data.isPercent ? '%' : ''}`
104+
},
99105
position: 'top',
100106
transform: [
101107
{ type: 'contrastReverse' },

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,13 @@ export class Line extends BaseG2Chart {
6161
},
6262
labels: [
6363
{
64-
text: (data: any) => `${data[y[0].value]}${_data.isPercent ? '%' : ''}`,
64+
text: (data: any) => {
65+
const value = data[y[0].value]
66+
if (value === undefined || value === null) {
67+
return ''
68+
}
69+
return `${value}${_data.isPercent ? '%' : ''}`
70+
},
6571
style: {
6672
dx: -10,
6773
dy: -12,

0 commit comments

Comments
 (0)