1
1
import { isString } from '@antv/util' ;
2
2
import { interaction , animation , theme , scale , annotation } from '../../adaptor/common' ;
3
+ import { interval } from '../../adaptor/geometries' ;
3
4
import { AXIS_META_CONFIG_KEYS } from '../../constant' ;
4
5
import { Params } from '../../core/adaptor' ;
5
- import { Data } from '../../types' ;
6
6
import { deepAssign , flow , pick , renderGaugeStatistic } from '../../utils' ;
7
7
import {
8
8
RANGE_TYPE ,
@@ -13,7 +13,7 @@ import {
13
13
RANGE_VIEW_ID ,
14
14
MASK_VIEW_ID ,
15
15
} from './constants' ;
16
- import { GaugeOptions } from './types' ;
16
+ import { GaugeCustomInfo , GaugeOptions } from './types' ;
17
17
import { getIndicatorData , getRangeData } from './utils' ;
18
18
19
19
/**
@@ -22,7 +22,7 @@ import { getIndicatorData, getRangeData } from './utils';
22
22
*/
23
23
function geometry ( params : Params < GaugeOptions > ) : Params < GaugeOptions > {
24
24
const { chart, options } = params ;
25
- const { percent, range, radius, innerRadius, startAngle, endAngle, axis, indicator } = options ;
25
+ const { percent, range, radius, innerRadius, startAngle, endAngle, axis, indicator, gaugeStyle } = options ;
26
26
const { color } = range ;
27
27
28
28
// 指标 & 指针
@@ -54,14 +54,30 @@ function geometry(params: Params<GaugeOptions>): Params<GaugeOptions> {
54
54
}
55
55
56
56
// 辅助 range
57
- // [{ range: 1, type: '0' }]
58
- const rangeData : Data = getRangeData ( percent , options . range ) ;
57
+ // [{ range: 1, type: '0', percent: 原始进度百分比 }]
58
+ const rangeData = getRangeData ( percent , options . range ) ;
59
59
const v2 = chart . createView ( { id : RANGE_VIEW_ID } ) ;
60
60
v2 . data ( rangeData ) ;
61
61
62
62
const rangeColor = isString ( color ) ? [ color , DEFAULT_COLOR ] : color ;
63
63
64
- v2 . interval ( ) . position ( `1*${ RANGE_VALUE } ` ) . color ( RANGE_TYPE , rangeColor ) . adjust ( 'stack' ) ;
64
+ interval ( {
65
+ chart : v2 ,
66
+ options : {
67
+ xField : '1' ,
68
+ yField : RANGE_VALUE ,
69
+ seriesField : RANGE_TYPE ,
70
+ rawFields : [ PERCENT ] ,
71
+ isStack : true ,
72
+ interval : {
73
+ color : rangeColor ,
74
+ style : gaugeStyle ,
75
+ } ,
76
+ args : {
77
+ zIndexReversed : true ,
78
+ } ,
79
+ } ,
80
+ } ) ;
65
81
66
82
v2 . coordinate ( 'polar' , {
67
83
innerRadius,
@@ -93,12 +109,8 @@ function meterView(params: Params<GaugeOptions>): Params<GaugeOptions> {
93
109
94
110
const v3 = chart . createView ( { id : MASK_VIEW_ID } ) ;
95
111
v3 . data ( [ { [ RANGE_TYPE ] : '1' , [ RANGE_VALUE ] : 1 } ] ) ;
96
- v3 . interval ( )
97
- . position ( `1*${ RANGE_VALUE } ` )
98
- . color ( color )
99
- . adjust ( 'stack' )
100
- . shape ( 'meter-gauge' )
101
- . customInfo ( meter || { } ) ;
112
+ const customInfo : GaugeCustomInfo = { meter } ;
113
+ v3 . interval ( ) . position ( `1*${ RANGE_VALUE } ` ) . color ( color ) . adjust ( 'stack' ) . shape ( 'meter-gauge' ) . customInfo ( customInfo ) ;
102
114
v3 . coordinate ( 'polar' , { innerRadius, radius, startAngle, endAngle } ) . transpose ( ) ;
103
115
}
104
116
0 commit comments