1
+ import { isObject , deepMix } from '@antv/util' ;
1
2
import { P , G2 } from '@antv/g2plot' ;
2
3
3
4
// 自定义图形
4
5
G2 . registerShape ( 'interval' , 'hill' , {
5
6
draw ( info , container ) {
6
- const { points, style } = info ;
7
+ const { points, style, defaultStyle = { } } = info ;
7
8
8
9
let path = [
9
10
[ 'M' , points [ 0 ] . x , points [ 0 ] . y ] ,
@@ -17,6 +18,7 @@ G2.registerShape('interval', 'hill', {
17
18
return container . addShape ( 'path' , {
18
19
attrs : {
19
20
path,
21
+ ...defaultStyle ,
20
22
...style ,
21
23
} ,
22
24
} ) ;
@@ -31,7 +33,7 @@ const defaultOptions = {
31
33
// 2. adaptor 实现
32
34
function adaptor ( params ) {
33
35
const { chart, options } = params ;
34
- const { data, xField, yField, columnWidthRatio, columnStyle, seriesField } = options ;
36
+ const { data, xField, yField, columnWidthRatio, columnStyle, theme } = options ;
35
37
36
38
// 数据
37
39
chart . data ( data ) ;
@@ -46,9 +48,11 @@ function adaptor(params) {
46
48
} ) ;
47
49
48
50
// 设置重叠比率
49
- chart . theme ( {
50
- columnWidthRatio : columnWidthRatio ,
51
- } ) ;
51
+ chart . theme (
52
+ deepMix ( { } , isObject ( theme ) ? theme : G2 . getTheme ( theme ) , {
53
+ columnWidthRatio : columnWidthRatio ,
54
+ } )
55
+ ) ;
52
56
53
57
const gap = ( 1 / data . length / 2 ) * columnWidthRatio ; // 左右预留
54
58
chart . scale ( {
@@ -86,7 +90,6 @@ const hill = new P(
86
90
yField : 'sold' ,
87
91
columnStyle : {
88
92
fillOpacity : 0.3 ,
89
- fill : 'red' ,
90
93
} ,
91
94
} ,
92
95
adaptor ,
0 commit comments