1
1
import { Geometry } from '@antv/g2' ;
2
- import { each } from '@antv/util' ;
2
+ import { each , omit } from '@antv/util' ;
3
3
import { tooltip , slider , interaction , animation , theme , annotation , limitInPlot , pattern } from '../../adaptor/common' ;
4
4
import { findGeometry } from '../../utils' ;
5
5
import { Params } from '../../core/adaptor' ;
@@ -48,12 +48,6 @@ function geometry(params: Params<AreaOptions>): Params<AreaOptions> {
48
48
const primary = deepAssign ( { } , params , {
49
49
options : {
50
50
area : { color, style : areaStyle } ,
51
- // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。
52
- // 如果存在,才设置,否则为空
53
- line : lineMapping && {
54
- color,
55
- ...lineMapping ,
56
- } ,
57
51
point : pointMapping && {
58
52
color,
59
53
...pointMapping ,
@@ -66,10 +60,26 @@ function geometry(params: Params<AreaOptions>): Params<AreaOptions> {
66
60
} ,
67
61
} ,
68
62
} ) ;
69
- // 线默认 2px
70
- const lineParams = deepAssign ( { options : { line : { size : 2 } } } , primary , {
71
- options : { sizeField : seriesField , tooltip : false } ,
72
- } ) ;
63
+ // 线默认 2px (折线不能复用面积图的 state,因为 fill 和 stroke 不匹配)
64
+ const lineParams = {
65
+ chart,
66
+ options : deepAssign ( { line : { size : 2 } } , omit ( options as any , [ 'state' ] ) , {
67
+ // 颜色保持一致,因为如果颜色不一致,会导致 tooltip 中元素重复。
68
+ // 如果存在,才设置,否则为空
69
+ line : lineMapping && {
70
+ color,
71
+ ...lineMapping ,
72
+ } ,
73
+ sizeField : seriesField ,
74
+ state : lineMapping ?. state ,
75
+ tooltip : false ,
76
+ // label 不传递给各个 geometry adaptor,由 label adaptor 处理
77
+ label : undefined ,
78
+ args : {
79
+ startOnZero,
80
+ } ,
81
+ } ) ,
82
+ } ;
73
83
const pointParams = deepAssign ( { } , primary , { options : { tooltip : false , state : pointState } } ) ;
74
84
75
85
// area geometry 处理
0 commit comments