@antv/g2plot 2.4.2 → 2.4.7

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +20 -7
  2. package/dist/g2plot.min.js +4 -4
  3. package/dist/g2plot.min.js.map +1 -1
  4. package/esm/index.d.ts +1 -9
  5. package/esm/index.js +1 -9
  6. package/esm/index.js.map +1 -1
  7. package/esm/plots/area/adaptor.js +22 -22
  8. package/esm/plots/area/adaptor.js.map +1 -1
  9. package/esm/plots/area/constants.d.ts +0 -2
  10. package/esm/plots/area/constants.js +1 -2
  11. package/esm/plots/area/constants.js.map +1 -1
  12. package/esm/plots/area/index.js +4 -11
  13. package/esm/plots/area/index.js.map +1 -1
  14. package/esm/plots/area/types.d.ts +1 -1
  15. package/esm/plots/area/types.js.map +1 -1
  16. package/esm/plots/bar/constants.js +3 -0
  17. package/esm/plots/bar/constants.js.map +1 -1
  18. package/esm/plots/column/constants.js +3 -0
  19. package/esm/plots/column/constants.js.map +1 -1
  20. package/esm/plots/gauge/adaptor.js +1 -0
  21. package/esm/plots/gauge/adaptor.js.map +1 -1
  22. package/esm/plots/line/adaptor.js +19 -33
  23. package/esm/plots/line/adaptor.js.map +1 -1
  24. package/esm/plots/line/constants.d.ts +0 -2
  25. package/esm/plots/line/constants.js +1 -3
  26. package/esm/plots/line/constants.js.map +1 -1
  27. package/esm/plots/line/index.js +1 -8
  28. package/esm/plots/line/index.js.map +1 -1
  29. package/esm/plots/line/interactions/marker-active.js +11 -8
  30. package/esm/plots/line/interactions/marker-active.js.map +1 -1
  31. package/esm/plots/line/types.d.ts +1 -1
  32. package/esm/plots/line/types.js.map +1 -1
  33. package/esm/plots/liquid/adaptor.js +2 -1
  34. package/esm/plots/liquid/adaptor.js.map +1 -1
  35. package/esm/plots/liquid/shapes/liquid.js +5 -3
  36. package/esm/plots/liquid/shapes/liquid.js.map +1 -1
  37. package/esm/plots/liquid/types.d.ts +1 -0
  38. package/esm/plots/liquid/types.js.map +1 -1
  39. package/esm/plots/pie/adaptor.js +2 -0
  40. package/esm/plots/pie/adaptor.js.map +1 -1
  41. package/esm/plots/pie/contants.js +1 -0
  42. package/esm/plots/pie/contants.js.map +1 -1
  43. package/esm/plots/progress/adaptor.js +1 -0
  44. package/esm/plots/progress/adaptor.js.map +1 -1
  45. package/esm/plots/rose/constant.js +1 -0
  46. package/esm/plots/rose/constant.js.map +1 -1
  47. package/esm/plots/scatter/adaptor.d.ts +1 -1
  48. package/esm/plots/scatter/adaptor.js +2 -2
  49. package/esm/plots/scatter/adaptor.js.map +1 -1
  50. package/esm/utils/geometry.js +1 -2
  51. package/esm/utils/geometry.js.map +1 -1
  52. package/lib/index.d.ts +1 -9
  53. package/lib/index.js +5 -13
  54. package/lib/index.js.map +1 -1
  55. package/lib/plots/area/adaptor.js +20 -20
  56. package/lib/plots/area/adaptor.js.map +1 -1
  57. package/lib/plots/area/constants.d.ts +0 -2
  58. package/lib/plots/area/constants.js +2 -3
  59. package/lib/plots/area/constants.js.map +1 -1
  60. package/lib/plots/area/index.js +3 -10
  61. package/lib/plots/area/index.js.map +1 -1
  62. package/lib/plots/area/types.d.ts +1 -1
  63. package/lib/plots/area/types.js.map +1 -1
  64. package/lib/plots/bar/constants.js +3 -0
  65. package/lib/plots/bar/constants.js.map +1 -1
  66. package/lib/plots/column/constants.js +3 -0
  67. package/lib/plots/column/constants.js.map +1 -1
  68. package/lib/plots/gauge/adaptor.js +1 -0
  69. package/lib/plots/gauge/adaptor.js.map +1 -1
  70. package/lib/plots/line/adaptor.js +16 -30
  71. package/lib/plots/line/adaptor.js.map +1 -1
  72. package/lib/plots/line/constants.d.ts +0 -2
  73. package/lib/plots/line/constants.js +2 -4
  74. package/lib/plots/line/constants.js.map +1 -1
  75. package/lib/plots/line/index.js +0 -7
  76. package/lib/plots/line/index.js.map +1 -1
  77. package/lib/plots/line/interactions/marker-active.js +11 -8
  78. package/lib/plots/line/interactions/marker-active.js.map +1 -1
  79. package/lib/plots/line/types.d.ts +1 -1
  80. package/lib/plots/line/types.js.map +1 -1
  81. package/lib/plots/liquid/adaptor.js +2 -1
  82. package/lib/plots/liquid/adaptor.js.map +1 -1
  83. package/lib/plots/liquid/shapes/liquid.js +5 -3
  84. package/lib/plots/liquid/shapes/liquid.js.map +1 -1
  85. package/lib/plots/liquid/types.d.ts +1 -0
  86. package/lib/plots/liquid/types.js.map +1 -1
  87. package/lib/plots/pie/adaptor.js +2 -0
  88. package/lib/plots/pie/adaptor.js.map +1 -1
  89. package/lib/plots/pie/contants.js +1 -0
  90. package/lib/plots/pie/contants.js.map +1 -1
  91. package/lib/plots/progress/adaptor.js +1 -0
  92. package/lib/plots/progress/adaptor.js.map +1 -1
  93. package/lib/plots/rose/constant.js +1 -0
  94. package/lib/plots/rose/constant.js.map +1 -1
  95. package/lib/plots/scatter/adaptor.d.ts +1 -1
  96. package/lib/plots/scatter/adaptor.js +1 -1
  97. package/lib/plots/scatter/adaptor.js.map +1 -1
  98. package/lib/utils/geometry.js +1 -2
  99. package/lib/utils/geometry.js.map +1 -1
  100. package/package.json +2 -2
  101. package/src/index.ts +1 -9
  102. package/src/plots/area/adaptor.ts +25 -26
  103. package/src/plots/area/constants.ts +1 -3
  104. package/src/plots/area/index.ts +3 -10
  105. package/src/plots/area/types.ts +1 -1
  106. package/src/plots/bar/constants.ts +3 -0
  107. package/src/plots/column/constants.ts +3 -0
  108. package/src/plots/gauge/adaptor.ts +1 -0
  109. package/src/plots/line/adaptor.ts +28 -37
  110. package/src/plots/line/constants.ts +1 -4
  111. package/src/plots/line/index.ts +1 -8
  112. package/src/plots/line/interactions/marker-active.ts +12 -9
  113. package/src/plots/line/types.ts +1 -1
  114. package/src/plots/liquid/adaptor.ts +2 -1
  115. package/src/plots/liquid/shapes/liquid.ts +6 -3
  116. package/src/plots/liquid/types.ts +1 -0
  117. package/src/plots/pie/adaptor.ts +2 -0
  118. package/src/plots/pie/contants.ts +1 -0
  119. package/src/plots/progress/adaptor.ts +1 -0
  120. package/src/plots/rose/constant.ts +1 -0
  121. package/src/plots/scatter/adaptor.ts +3 -1
  122. package/src/utils/geometry.ts +1 -2
@@ -1,14 +1,10 @@
1
1
  import { Plot } from '../../core/plot';
2
2
  import { deepAssign } from '../../utils';
3
3
 
4
- /** point 标注点视图 */
5
- export const POINT_VIEW_ID = 'point-view';
6
-
7
4
  /**
8
5
  * 折线图默认配置项
9
6
  */
10
7
  export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
11
- syncViewPadding: true,
12
8
  tooltip: {
13
9
  shared: true,
14
10
  showMarkers: true,
@@ -19,6 +15,7 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
19
15
  },
20
16
  legend: {
21
17
  position: 'top-left',
18
+ radio: {},
22
19
  },
23
20
  isStack: false,
24
21
  });
@@ -1,10 +1,8 @@
1
- import { isNil } from '@antv/util';
2
1
  import { Plot } from '../../core/plot';
3
2
  import { Adaptor } from '../../core/adaptor';
4
- import { findViewById } from '../../utils';
5
3
  import { LineOptions } from './types';
6
4
  import { adaptor, meta } from './adaptor';
7
- import { DEFAULT_OPTIONS, POINT_VIEW_ID } from './constants';
5
+ import { DEFAULT_OPTIONS } from './constants';
8
6
  import './interactions';
9
7
 
10
8
  export type { LineOptions };
@@ -28,13 +26,8 @@ export class Line extends Plot<LineOptions> {
28
26
  public changeData(data: LineOptions['data']) {
29
27
  this.updateOption({ data });
30
28
  const { chart, options } = this;
31
- const { yField } = options;
32
29
  meta({ chart, options });
33
30
  this.chart.changeData(data);
34
- const pointView = findViewById(this.chart, POINT_VIEW_ID);
35
- if (pointView) {
36
- pointView.changeData(data.filter((d) => !isNil(d[yField])));
37
- }
38
31
  }
39
32
 
40
33
  /**
@@ -1,6 +1,5 @@
1
1
  import { each, findIndex } from '@antv/util';
2
- import { InteractionAction, View } from '@antv/g2';
3
- import { findGeometry } from '../../../utils';
2
+ import { InteractionAction, View, Geometry } from '@antv/g2';
4
3
 
5
4
  export class MarkerActiveAction extends InteractionAction {
6
5
  public active() {
@@ -9,19 +8,23 @@ export class MarkerActiveAction extends InteractionAction {
9
8
  if (evt.data) {
10
9
  // items: 数组对象,当前 tooltip 显示的每条内容
11
10
  const { items } = evt.data;
12
- const point = findGeometry(view, 'point');
13
- each(point.elements, (element) => {
14
- const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;
15
- element.setState('active', active);
11
+ const points = view.geometries.filter((geom) => geom.type === 'point');
12
+ each(points, (point: Geometry) => {
13
+ each(point.elements, (element) => {
14
+ const active = findIndex(items, (item) => (item as any).data === element.data) !== -1;
15
+ element.setState('active', active);
16
+ });
16
17
  });
17
18
  }
18
19
  }
19
20
 
20
21
  public reset() {
21
22
  const view = this.getView();
22
- const point = findGeometry(view, 'point');
23
- each(point.elements, (element) => {
24
- element.setState('active', false);
23
+ const points = view.geometries.filter((geom) => geom.type === 'point');
24
+ each(points, (point: Geometry) => {
25
+ each(point.elements, (element) => {
26
+ element.setState('active', false);
27
+ });
25
28
  });
26
29
  }
27
30
 
@@ -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
  /** 坐标轴反转配置 */
@@ -13,7 +13,7 @@ import { getLiquidData } from './utils';
13
13
  */
14
14
  function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
15
15
  const { chart, options } = params;
16
- const { percent, liquidStyle, radius, outline, wave, shape } = options;
16
+ const { percent, liquidStyle, radius, outline, wave, shape, animation } = options;
17
17
 
18
18
  chart.scale({
19
19
  percent: {
@@ -49,6 +49,7 @@ function geometry(params: Params<LiquidOptions>): Params<LiquidOptions> {
49
49
  wave,
50
50
  shape,
51
51
  background,
52
+ animation,
52
53
  };
53
54
 
54
55
  // 将 radius 传入到自定义 shape 中
@@ -212,7 +212,8 @@ function addWaterWave(
212
212
  group: IGroup,
213
213
  clip: IShape,
214
214
  radius: number,
215
- waveLength: number
215
+ waveLength: number,
216
+ animation: LiquidOptions['animation']
216
217
  ) {
217
218
  const { fill, opacity } = waveAttrs;
218
219
  const bbox = clip.getBBox();
@@ -239,6 +240,7 @@ function addWaterWave(
239
240
  });
240
241
 
241
242
  try {
243
+ if (animation === false) return;
242
244
  const matrix = transform([['t', waveLength, 0]]);
243
245
 
244
246
  wave.stopAnimate();
@@ -373,7 +375,7 @@ registerShape('interval', 'liquid-fill-gauge', {
373
375
  const cy = 0.5;
374
376
 
375
377
  const { customInfo } = cfg;
376
- const { radius: radio, shape, background } = customInfo as CustomInfo;
378
+ const { radius: radio, shape, background, animation } = customInfo as CustomInfo;
377
379
  const outline: LiquidOptions['outline'] = customInfo.outline;
378
380
  const wave: LiquidOptions['wave'] = customInfo.wave;
379
381
  const { border, distance } = outline;
@@ -430,7 +432,8 @@ registerShape('interval', 'liquid-fill-gauge', {
430
432
  waves,
431
433
  clipPath,
432
434
  radius * 2,
433
- waveLength
435
+ waveLength,
436
+ animation
434
437
  );
435
438
 
436
439
  // 2. 绘制一个 distance 宽的 border
@@ -49,4 +49,5 @@ export type CustomInfo = {
49
49
  wave?: LiquidOptions['wave'];
50
50
  shape?: LiquidOptions['shape'];
51
51
  background?: string;
52
+ animation?: LiquidOptions['animation'];
52
53
  };
@@ -42,6 +42,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
42
42
  },
43
43
  args: {
44
44
  zIndexReversed: true,
45
+ sortZIndex: true,
45
46
  },
46
47
  },
47
48
  });
@@ -62,6 +63,7 @@ function geometry(params: Params<PieOptions>): Params<PieOptions> {
62
63
  },
63
64
  args: {
64
65
  zIndexReversed: true,
66
+ sortZIndex: true,
65
67
  },
66
68
  },
67
69
  });
@@ -7,6 +7,7 @@ import { deepAssign } from '../../utils';
7
7
  export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
8
8
  legend: {
9
9
  position: 'right',
10
+ radio: {},
10
11
  },
11
12
  tooltip: {
12
13
  shared: false,
@@ -30,6 +30,7 @@ export function geometry(params: Params<ProgressOptions>): Params<ProgressOption
30
30
  },
31
31
  args: {
32
32
  zIndexReversed: true,
33
+ sortZIndex: true,
33
34
  },
34
35
  },
35
36
  });
@@ -9,6 +9,7 @@ export const DEFAULT_OPTIONS = deepAssign({}, Plot.getDefaultOptions(), {
9
9
  yAxis: false,
10
10
  legend: {
11
11
  position: 'right',
12
+ radio: {},
12
13
  },
13
14
  sectorStyle: {
14
15
  stroke: '#fff',
@@ -3,7 +3,7 @@ import { Params } from '../../core/adaptor';
3
3
  import { flow, deepAssign, pick } from '../../utils';
4
4
  import { point } from '../../adaptor/geometries';
5
5
  import { brushInteraction } from '../../adaptor/brush';
6
- import { interaction, animation, theme, scale, annotation } from '../../adaptor/common';
6
+ import { interaction, animation, theme, scale, annotation, slider, scrollbar } from '../../adaptor/common';
7
7
  import { findGeometry, transformLabel } from '../../utils';
8
8
  import { getQuadrantDefaultConfig, getPath, getMeta } from './util';
9
9
  import { ScatterOptions } from './types';
@@ -327,6 +327,8 @@ export function adaptor(params: Params<ScatterOptions>) {
327
327
  label,
328
328
  // 需要在 interaction 前面
329
329
  brushInteraction,
330
+ slider,
331
+ scrollbar,
330
332
  interaction,
331
333
  scatterAnnotation,
332
334
  animation,
@@ -7,8 +7,7 @@ import { reduce, get } from '@antv/util';
7
7
  * @param type
8
8
  */
9
9
  export function findGeometry(view: View, type: string): Geometry {
10
- const geometries = getAllGeometriesRecursively(view);
11
- return geometries.find((g: Geometry) => g.type === type);
10
+ return view.geometries.find((g: Geometry) => g.type === type);
12
11
  }
13
12
 
14
13
  /**