File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
frontend/src/views/chat/component/charts Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 11import { BaseG2Chart } from '@/views/chat/component/BaseG2Chart.ts'
22import type { ChartAxis , ChartData } from '@/views/chat/component/BaseChart.ts'
33import type { G2Spec } from '@antv/g2'
4- import { endsWith , replace } from 'lodash-es'
4+ import { endsWith , filter , replace } from 'lodash-es'
55
66export 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 }
You can’t perform that action at this time.
0 commit comments