@antv/g2plot 2.4.4 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
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 处理
@@ -18,7 +18,7 @@ export interface AreaOptions extends Options, Pick<GeometryOptions, 'customInfo'
18
18
  /** 面积图形样式 */
19
19
  readonly areaStyle?: StyleAttr;
20
20
  /** 面积中折线的样式 */
21
- readonly line?: LineGeometryOptions['line'];
21
+ readonly line?: LineGeometryOptions['line'] & Pick<PointGeometryOptions, 'state'>;
22
22
  /** 面积图数据点图形样式 */
23
23
  readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
24
24
  /** 积图是否从 0 基准线开始填充 */
@@ -16,6 +16,7 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
16
16
  const { chart, options } = params;
17
17
  const { data, color, lineStyle, lineShape, point: pointMapping, area: areaMapping, seriesField } = options;
18
18
  const pointState = pointMapping?.state;
19
+ const areaState = areaMapping?.state;
19
20
 
20
21
  chart.data(data);
21
22
 
@@ -45,7 +46,7 @@ function geometry(params: Params<LineOptions>): Params<LineOptions> {
45
46
  },
46
47
  });
47
48
  const second = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
48
- const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: pointState } });
49
+ const areaParams = deepAssign({}, primary, { options: { tooltip: false, state: areaState } });
49
50
 
50
51
  line(primary);
51
52
  point(second);
@@ -28,7 +28,7 @@ export interface LineOptions extends Options, Pick<GeometryOptions, 'customInfo'
28
28
  /** 折线数据点:1、图形映射属性 2、状态样式 */
29
29
  readonly point?: PointGeometryOptions['point'] & Pick<PointGeometryOptions, 'state'>;
30
30
  /** 折线趋势填充色:1、图形映射属性 */
31
- readonly area?: AreaGeometryOptions['area'];
31
+ readonly area?: AreaGeometryOptions['area'] & Pick<PointGeometryOptions, 'state'>;
32
32
 
33
33
  // 其他
34
34
  /** 坐标轴反转配置 */