Skip to content

Commit fc176de

Browse files
committed
fix: pie null value
1 parent b6900dd commit fc176de

File tree

1 file changed

+14
-5
lines changed
  • frontend/src/views/chat/component/charts

1 file changed

+14
-5
lines changed

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

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { BaseG2Chart } from '@/views/chat/component/BaseG2Chart.ts'
22
import type { ChartAxis, ChartData } from '@/views/chat/component/BaseChart.ts'
33
import type { G2Spec } from '@antv/g2'
4-
import { endsWith, replace } from 'lodash-es'
4+
import { endsWith, filter, replace } from 'lodash-es'
55

66
export class Pie extends BaseG2Chart {
77
constructor(id: string) {
@@ -17,12 +17,21 @@ export class Pie extends BaseG2Chart {
1717
return
1818
}
1919

20-
// 特殊处理 %
20+
// %
2121
const _data = []
2222
let isPercent = false
23-
if (data.length > 0) {
24-
const v = data[0][y[0].value] + ''
25-
if (endsWith(v, '%')) {
23+
const notEmptyData = filter(
24+
data,
25+
(d) =>
26+
d &&
27+
d[y[0].value] !== null &&
28+
d[y[0].value] !== undefined &&
29+
d[y[0].value] !== 0 &&
30+
d[y[0].value] !== '0'
31+
)
32+
if (notEmptyData.length > 0) {
33+
const v = notEmptyData[0][y[0].value] + ''
34+
if (endsWith(v.trim(), '%')) {
2635
isPercent = true
2736
}
2837
}

0 commit comments

Comments
 (0)