1
- import { isString , isArray } from '@antv/util' ;
1
+ import { isString , isArray , isFunction } from '@antv/util' ;
2
2
import { interaction , animation , theme , scale } from '../../adaptor/common' ;
3
3
import { Params } from '../../core/adaptor' ;
4
4
import { Data } from '../../types' ;
@@ -74,6 +74,35 @@ function meta(params: Params<GaugeOptions>): Params<GaugeOptions> {
74
74
) ( params ) ;
75
75
}
76
76
77
+ /**
78
+ * 统计指标文档
79
+ * @param params
80
+ */
81
+ function statistic ( params : Params < GaugeOptions > ) : Params < GaugeOptions > {
82
+ const { chart, options } = params ;
83
+ const { statistic, percent } = options ;
84
+
85
+ const { title, content } = statistic ;
86
+
87
+ // annotation title 和 content 分别使用一个 text
88
+ [ title , content ] . forEach ( ( annotation ) => {
89
+ if ( annotation ) {
90
+ const { formatter, style, offsetX, offsetY, rotate } = annotation ;
91
+ chart . annotation ( ) . text ( {
92
+ top : true ,
93
+ position : [ '50%' , '100%' ] ,
94
+ content : isFunction ( formatter ) ? formatter ( { percent } ) : `${ percent } ` ,
95
+ style : isFunction ( style ) ? style ( { percent } ) : style ,
96
+ offsetX,
97
+ offsetY,
98
+ rotate,
99
+ } ) ;
100
+ }
101
+ } ) ;
102
+
103
+ return params ;
104
+ }
105
+
77
106
/**
78
107
* other 配置
79
108
* @param params
@@ -97,6 +126,7 @@ export function adaptor(params: Params<GaugeOptions>) {
97
126
return flow (
98
127
geometry ,
99
128
meta ,
129
+ statistic ,
100
130
interaction ,
101
131
animation ,
102
132
theme ,
0 commit comments