@antv/g2 5.1.5-beta.0 → 5.1.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +436 -0
  2. package/dist/g2.full.min.js +1 -0
  3. package/dist/g2.lite.min.js +1 -0
  4. package/dist/g2.min.js +1 -1
  5. package/esm/api/chart.d.ts +2 -164
  6. package/esm/api/library.d.ts +1 -163
  7. package/esm/api/library.js +1 -2
  8. package/esm/api/library.js.map +1 -1
  9. package/esm/api/runtime.d.ts +1 -1
  10. package/esm/api/runtime.js +6 -1
  11. package/esm/api/runtime.js.map +1 -1
  12. package/esm/exports.d.ts +5 -0
  13. package/esm/exports.js +7 -0
  14. package/esm/exports.js.map +1 -0
  15. package/esm/index.d.ts +338 -7
  16. package/esm/index.js +9 -8
  17. package/esm/index.js.map +1 -1
  18. package/esm/interaction/tooltip.js +0 -1
  19. package/esm/interaction/tooltip.js.map +1 -1
  20. package/esm/lib/auto.d.ts +3 -0
  21. package/esm/lib/auto.js +7 -0
  22. package/esm/lib/auto.js.map +1 -0
  23. package/esm/lib/index.d.ts +1 -0
  24. package/esm/lib/index.js +1 -0
  25. package/esm/lib/index.js.map +1 -1
  26. package/esm/lib/std.d.ts +29 -29
  27. package/esm/mark/auto.d.ts +1 -0
  28. package/esm/mark/auto.js +26 -0
  29. package/esm/mark/auto.js.map +1 -0
  30. package/esm/mark/index.d.ts +1 -0
  31. package/esm/mark/index.js +1 -0
  32. package/esm/mark/index.js.map +1 -1
  33. package/esm/runtime/plot.js +2 -2
  34. package/esm/runtime/plot.js.map +1 -1
  35. package/esm/shape/index.d.ts +1 -1
  36. package/esm/spec/index.d.ts +3 -3
  37. package/esm/spec/mark.d.ts +4 -2
  38. package/esm/utils/event.d.ts +31 -32
  39. package/esm/utils/event.js +2 -12
  40. package/esm/utils/event.js.map +1 -1
  41. package/lib/api/chart.d.ts +2 -164
  42. package/lib/api/library.d.ts +1 -163
  43. package/lib/api/library.js +1 -2
  44. package/lib/api/library.js.map +1 -1
  45. package/lib/api/runtime.d.ts +1 -1
  46. package/lib/api/runtime.js +6 -1
  47. package/lib/api/runtime.js.map +1 -1
  48. package/lib/exports.d.ts +5 -0
  49. package/lib/exports.js +39 -0
  50. package/lib/exports.js.map +1 -0
  51. package/lib/index.d.ts +338 -7
  52. package/lib/index.js +11 -28
  53. package/lib/index.js.map +1 -1
  54. package/lib/interaction/tooltip.js +0 -1
  55. package/lib/interaction/tooltip.js.map +1 -1
  56. package/lib/lib/auto.d.ts +3 -0
  57. package/lib/lib/auto.js +11 -0
  58. package/lib/lib/auto.js.map +1 -0
  59. package/lib/lib/index.d.ts +1 -0
  60. package/lib/lib/index.js +3 -1
  61. package/lib/lib/index.js.map +1 -1
  62. package/lib/lib/std.d.ts +29 -29
  63. package/lib/mark/auto.d.ts +1 -0
  64. package/lib/mark/auto.js +30 -0
  65. package/lib/mark/auto.js.map +1 -0
  66. package/lib/mark/index.d.ts +1 -0
  67. package/lib/mark/index.js +3 -1
  68. package/lib/mark/index.js.map +1 -1
  69. package/lib/runtime/plot.js +2 -2
  70. package/lib/runtime/plot.js.map +1 -1
  71. package/lib/shape/index.d.ts +1 -1
  72. package/lib/spec/index.d.ts +3 -3
  73. package/lib/spec/mark.d.ts +4 -2
  74. package/lib/utils/event.d.ts +31 -32
  75. package/lib/utils/event.js +2 -12
  76. package/lib/utils/event.js.map +1 -1
  77. package/package.json +23 -8
  78. package/src/api/chart.ts +1 -1
  79. package/src/api/library.ts +1 -2
  80. package/src/api/runtime.ts +7 -2
  81. package/src/exports.ts +32 -0
  82. package/src/index.ts +13 -41
  83. package/src/interaction/tooltip.ts +0 -1
  84. package/src/lib/auto.ts +7 -0
  85. package/src/lib/index.ts +1 -0
  86. package/src/mark/auto.ts +22 -0
  87. package/src/mark/index.ts +1 -0
  88. package/src/runtime/plot.ts +2 -2
  89. package/src/shape/index.ts +1 -1
  90. package/src/spec/index.ts +3 -3
  91. package/src/spec/mark.ts +4 -0
  92. package/src/utils/event.ts +32 -45
  93. package/dist/g2-lite.min.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2",
3
- "version": "5.1.5-beta.0",
3
+ "version": "5.1.5",
4
4
  "description": "the Grammar of Graphics in Javascript",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -13,6 +13,9 @@
13
13
  "require": "./lib/index.js"
14
14
  }
15
15
  },
16
+ "sideEffects": [
17
+ "./esm/exports.js"
18
+ ],
16
19
  "files": [
17
20
  "src",
18
21
  "lib",
@@ -30,7 +33,8 @@
30
33
  "test": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest __tests__/ --coverage -i --logHeapUsage",
31
34
  "test:unit": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest __tests__/unit/ --coverage -i --logHeapUsage",
32
35
  "test:integration": "node --expose-gc --max-old-space-size=4096 --unhandled-rejections=strict node_modules/jest/bin/jest __tests__/integration/ --coverage -i --logHeapUsage",
33
- "build:umd": "rimraf ./dist && rollup -c && npm run size",
36
+ "preview": "vite preview",
37
+ "build:umd": "rimraf ./dist && node --expose-gc --max-old-space-size=4096 node_modules/rollup/dist/bin/rollup -c && npm run size",
34
38
  "build:cjs": "rimraf ./lib && tsc --module commonjs --outDir lib",
35
39
  "build:esm": "rimraf ./esm && tsc --module ESNext --outDir esm",
36
40
  "build": "run-p build:*",
@@ -41,9 +45,6 @@
41
45
  "upload": "node scripts/upload/snapshot.js",
42
46
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
43
47
  },
44
- "sideEffects": [
45
- "./esm/index.js"
46
- ],
47
48
  "keywords": [
48
49
  "antv",
49
50
  "g2",
@@ -55,6 +56,7 @@
55
56
  "animation"
56
57
  ],
57
58
  "dependencies": {
59
+ "@antv/ava": "^3.0.7",
58
60
  "@antv/coord": "^0.4.1",
59
61
  "@antv/event-emitter": "^0.1.3",
60
62
  "@antv/g": "^5.18.6",
@@ -89,7 +91,9 @@
89
91
  "@antv/g-webgl": "^1.9.8",
90
92
  "@commitlint/cli": "^11.0.0",
91
93
  "@commitlint/config-conventional": "^17.4.4",
94
+ "@optimize-lodash/rollup-plugin": "^4.0.3",
92
95
  "@rollup/plugin-commonjs": "^21.0.2",
96
+ "@rollup/plugin-json": "^6.0.0",
93
97
  "@rollup/plugin-node-resolve": "^15.2.1",
94
98
  "@rollup/plugin-terser": "^0.4.3",
95
99
  "@types/d3-array": "3.0.5",
@@ -146,17 +150,28 @@
146
150
  "limit-size": [
147
151
  {
148
152
  "path": "dist/g2.min.js",
149
- "limit": "400 Kb",
153
+ "limit": "280 Kb",
150
154
  "gzip": true
151
155
  },
152
156
  {
153
157
  "path": "dist/g2.min.js",
154
- "limit": "1.5 Mb"
158
+ "limit": "950 Kb",
159
+ "gzip": false
160
+ },
161
+ {
162
+ "path": "dist/g2.lite.min.js",
163
+ "limit": "240 Kb",
164
+ "gzip": true
165
+ },
166
+ {
167
+ "path": "dist/g2.full.min.js",
168
+ "limit": "350 Kb",
169
+ "gzip": true
155
170
  }
156
171
  ],
157
172
  "author": {
158
173
  "name": "AntV",
159
- "url": "https://antv.vision/"
174
+ "url": "https://antv.antgroup.com/"
160
175
  },
161
176
  "repository": {
162
177
  "type": "git",
package/src/api/chart.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G2Spec } from '../spec';
1
+ import type { G2Spec } from '../spec';
2
2
  import { extend, API, CompositionAPI } from './extend';
3
3
  import { library } from './library';
4
4
  import { Runtime } from './runtime';
@@ -1,7 +1,6 @@
1
- import { stdlib } from '../lib/std';
2
1
  import { G2ComponentNamespaces, G2Component } from '../runtime';
3
2
 
4
- export const library = stdlib();
3
+ export const library = {};
5
4
 
6
5
  // @todo Warn if override existing key.
7
6
  export function register(
@@ -6,7 +6,7 @@ import EventEmitter from '@antv/event-emitter';
6
6
  import { G2Context, render, destroy } from '../runtime';
7
7
  import { G2Spec, ViewComposition } from '../spec';
8
8
  import { ChartEvent } from '../utils/event';
9
- import { G2Library } from '../runtime/types/options';
9
+ import type { G2Library } from '../runtime/types/options';
10
10
  import {
11
11
  normalizeContainer,
12
12
  removeContainer,
@@ -20,6 +20,7 @@ import { CompositionNode } from './composition';
20
20
  import { Node } from './node';
21
21
  import { defineProps, nodeProps } from './define';
22
22
  import { MarkNode } from './mark';
23
+ import { library } from './library';
23
24
 
24
25
  export const G2_CHART_KEY = 'G2_CHART_KEY';
25
26
 
@@ -58,7 +59,11 @@ export class Runtime<Spec extends G2Spec = G2Spec> extends CompositionNode {
58
59
  this._plugins = plugins || [];
59
60
  this._container = normalizeContainer(container);
60
61
  this._emitter = new EventEmitter();
61
- this._context = { library: lib, emitter: this._emitter, canvas };
62
+ this._context = {
63
+ library: { ...lib, ...library },
64
+ emitter: this._emitter,
65
+ canvas,
66
+ };
62
67
  this._create();
63
68
  }
64
69
 
package/src/exports.ts ADDED
@@ -0,0 +1,32 @@
1
+ import { runtime } from '@antv/g';
2
+
3
+ runtime.enableCSSParsing = false;
4
+
5
+ export {
6
+ render,
7
+ renderToMountedElement,
8
+ MAIN_LAYER_CLASS_NAME,
9
+ LABEL_LAYER_CLASS_NAME,
10
+ ELEMENT_CLASS_NAME,
11
+ VIEW_CLASS_NAME,
12
+ PLOT_CLASS_NAME,
13
+ COMPONENT_CLASS_NAME,
14
+ LABEL_CLASS_NAME,
15
+ AREA_CLASS_NAME,
16
+ MASK_CLASS_NAME,
17
+ } from './runtime';
18
+
19
+ export {
20
+ type MarkNode,
21
+ type CompositionNode,
22
+ register,
23
+ Runtime,
24
+ extend,
25
+ type ChartOptions,
26
+ } from './api';
27
+
28
+ export { ChartEvent } from './utils/event';
29
+
30
+ export type { G2Context } from './runtime';
31
+
32
+ export * from './spec';
package/src/index.ts CHANGED
@@ -1,45 +1,17 @@
1
- import { runtime } from '@antv/g';
1
+ import { corelib, plotlib, graphlib, geolib, stdlib, threedlib } from './lib';
2
+ import { extend, Runtime } from './api';
3
+ import { API, CompositionAPI } from './api/extend';
4
+ import { G2Spec } from './spec';
2
5
 
3
- runtime.enableCSSParsing = false;
6
+ export { corelib, plotlib, graphlib, geolib, stdlib, threedlib };
4
7
 
5
- export {
6
- render,
7
- renderToMountedElement,
8
- MAIN_LAYER_CLASS_NAME,
9
- LABEL_LAYER_CLASS_NAME,
10
- ELEMENT_CLASS_NAME,
11
- VIEW_CLASS_NAME,
12
- PLOT_CLASS_NAME,
13
- COMPONENT_CLASS_NAME,
14
- LABEL_CLASS_NAME,
15
- AREA_CLASS_NAME,
16
- MASK_CLASS_NAME,
17
- } from './runtime';
8
+ export * from './exports';
18
9
 
19
- export {
20
- corelib,
21
- stdlib,
22
- litelib,
23
- graphlib,
24
- plotlib,
25
- geolib,
26
- threedlib,
27
- } from './lib';
10
+ /**
11
+ * G2 standard library initial all the libs except 3D and auto.
12
+ */
13
+ const library = { ...stdlib() };
28
14
 
29
- export * from './mark';
30
-
31
- export {
32
- Chart,
33
- type MarkNode,
34
- type CompositionNode,
35
- register,
36
- Runtime,
37
- extend,
38
- type ChartOptions,
39
- } from './api';
40
-
41
- export { ChartEvent } from './utils/event';
42
-
43
- export type { G2Context } from './runtime';
44
-
45
- export * from './spec';
15
+ export const Chart = extend(Runtime, library);
16
+ export interface Chart extends API<G2Spec, typeof library> {}
17
+ export interface CompositionNode extends CompositionAPI<typeof library> {}
@@ -864,7 +864,6 @@ export function tooltip(
864
864
  root.removeEventListener('pointermove', pointerover);
865
865
  root.removeEventListener('pointerout', pointerout);
866
866
  }
867
- destroyTooltip({ root, single });
868
867
  };
869
868
 
870
869
  const onTooltipShow = ({ nativeEvent, data }) => {
@@ -0,0 +1,7 @@
1
+ import { Auto } from '../mark/auto';
2
+
3
+ export function autolib() {
4
+ return {
5
+ 'mark.auto': Auto,
6
+ } as const;
7
+ }
package/src/lib/index.ts CHANGED
@@ -5,3 +5,4 @@ export { plotlib } from './plot';
5
5
  export { threedlib } from './threed';
6
6
  export { stdlib } from './std';
7
7
  export { litelib } from './lite';
8
+ export { autolib } from './auto';
@@ -0,0 +1,22 @@
1
+ import { Advisor } from '@antv/ava';
2
+ import { deepMix } from '@antv/util';
3
+
4
+ export const Auto = (options) => {
5
+ const chartAdvisor = new Advisor();
6
+ const {
7
+ data,
8
+ dataProps,
9
+ fields,
10
+ options: o,
11
+ colorOptions,
12
+ ...rest
13
+ } = options;
14
+ const results = chartAdvisor.advise({
15
+ data,
16
+ dataProps,
17
+ fields,
18
+ options: o,
19
+ colorOptions,
20
+ });
21
+ return deepMix({}, rest, results?.[0].spec);
22
+ };
package/src/mark/index.ts CHANGED
@@ -32,6 +32,7 @@ export { Gauge } from './gauge';
32
32
  export { Density } from './density';
33
33
  export { Heatmap } from './heatmap';
34
34
  export { Liquid } from './liquid';
35
+ export { Auto } from './auto';
35
36
 
36
37
  export type { IntervalOptions } from './interval';
37
38
  export type { RectOptions } from './rect';
@@ -424,8 +424,8 @@ function updateTooltip(
424
424
  container: selection.node(),
425
425
  update: (options) => Promise.resolve(options),
426
426
  };
427
- const newTooltip = applyTooltip(target, [], context.emitter);
428
- nameInteraction.set('tooltip', newTooltip);
427
+ const destroy = applyTooltip(target, [], context.emitter);
428
+ nameInteraction.set('tooltip', { destroy });
429
429
  }
430
430
 
431
431
  async function initializeView(
@@ -66,7 +66,7 @@ export { Liquid as LiquidShape } from './liquid/liquid';
66
66
  export type { RectOptions as IntervalShapeOptions } from './interval/rect';
67
67
  export type { HollowOptions as IntervalHollowOptions } from './interval/hollow';
68
68
  export type { FunnelOptions as IntervalFunnelOptions } from './interval/funnel';
69
- export type { PyramidOptions as IntervalPyline3DramidOptions } from './interval/pyramid';
69
+ export type { PyramidOptions as IntervalPyramidOptions } from './interval/pyramid';
70
70
  export type { LineOptions as LineShapeOptions } from './line/line';
71
71
  export type { SmoothOptions as LineSmoothOptions } from './line/smooth';
72
72
  export type { HVOptions as LineHVOptions } from './line/hv';
package/src/spec/index.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { AxisComponent, LegendComponent } from './component';
2
- import { Composition } from './composition';
3
- import { Mark } from './mark';
1
+ import type { AxisComponent, LegendComponent } from './component';
2
+ import type { Composition } from './composition';
3
+ import type { Mark } from './mark';
4
4
 
5
5
  export type G2Spec = (Mark | Composition | AxisComponent | LegendComponent) & {
6
6
  width?: number;
package/src/spec/mark.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { AdviseParams } from '@antv/ava';
1
2
  import { MarkComponent } from '../runtime';
2
3
  import { Encode } from './encode';
3
4
  import { Transform } from './transform';
@@ -18,6 +19,7 @@ import {
18
19
  import { Closeable, Literal2Object, Padding } from './utils';
19
20
 
20
21
  export type Mark =
22
+ | AutoMark
21
23
  | IntervalMark
22
24
  | RectMark
23
25
  | LineMark
@@ -51,6 +53,7 @@ export type Mark =
51
53
  | CompositeMark;
52
54
 
53
55
  export type MarkTypes =
56
+ | 'auto'
54
57
  | 'interval'
55
58
  | 'rect'
56
59
  | 'line'
@@ -391,3 +394,4 @@ export type HeatmapMark = BaseMark<'heatmap'>;
391
394
  export type LiquidMark = BaseMark<'liquid'>;
392
395
 
393
396
  export type CustomMark = BaseMark<MarkComponent, ChannelTypes>;
397
+ export type AutoMark = BaseMark<'auto'> & AdviseParams;
@@ -1,52 +1,39 @@
1
1
  // to prevent users from tampering with internal values.
2
- const ChartEvent = new Proxy(
3
- {
4
- BEFORE_RENDER: 'beforerender',
5
- AFTER_RENDER: 'afterrender',
2
+ export const ChartEvent = {
3
+ BEFORE_RENDER: 'beforerender',
4
+ AFTER_RENDER: 'afterrender',
6
5
 
7
- BEFORE_PAINT: 'beforepaint',
8
- AFTER_PAINT: 'afterpaint',
6
+ BEFORE_PAINT: 'beforepaint',
7
+ AFTER_PAINT: 'afterpaint',
9
8
 
10
- BEFORE_CHANGE_DATA: 'beforechangedata',
11
- AFTER_CHANGE_DATA: 'afterchangedata',
9
+ BEFORE_CHANGE_DATA: 'beforechangedata',
10
+ AFTER_CHANGE_DATA: 'afterchangedata',
12
11
 
13
- BEFORE_CLEAR: 'beforeclear',
14
- AFTER_CLEAR: 'afterclear',
12
+ BEFORE_CLEAR: 'beforeclear',
13
+ AFTER_CLEAR: 'afterclear',
15
14
 
16
- BEFORE_DESTROY: 'beforedestroy',
17
- AFTER_DESTROY: 'afterdestroy',
15
+ BEFORE_DESTROY: 'beforedestroy',
16
+ AFTER_DESTROY: 'afterdestroy',
18
17
 
19
- BEFORE_CHANGE_SIZE: 'beforechangesize',
20
- AFTER_CHANGE_SIZE: 'afterchangesize',
18
+ BEFORE_CHANGE_SIZE: 'beforechangesize',
19
+ AFTER_CHANGE_SIZE: 'afterchangesize',
21
20
 
22
- POINTER_TAP: 'pointertap',
23
- POINTER_DOWN: 'pointerdown',
24
- POINTER_UP: 'pointerup',
25
- POINTER_OVER: 'pointerover',
26
- POINTER_OUT: 'pointerout',
27
- POINTER_MOVE: 'pointermove',
28
- POINTER_ENTER: 'pointerenter',
29
- POINTER_LEAVE: 'pointerleave',
30
- POINTER_UPOUTSIDE: 'pointerupoutside',
31
- DRAG_START: 'dragstart',
32
- DRAG: 'drag',
33
- DRAG_END: 'dragend',
34
- DRAG_ENTER: 'dragenter',
35
- DRAG_LEAVE: 'dragleave',
36
- DRAG_OVER: 'dragover',
37
- DROP: 'DROP',
38
- CLICK: 'click',
39
- DBLCLICK: 'dblclick',
40
- } as const,
41
- {
42
- get(target, prop) {
43
- if (prop in target) return target[prop];
44
- return undefined;
45
- },
46
- set() {
47
- return true;
48
- },
49
- },
50
- );
51
-
52
- export { ChartEvent };
21
+ POINTER_TAP: 'pointertap',
22
+ POINTER_DOWN: 'pointerdown',
23
+ POINTER_UP: 'pointerup',
24
+ POINTER_OVER: 'pointerover',
25
+ POINTER_OUT: 'pointerout',
26
+ POINTER_MOVE: 'pointermove',
27
+ POINTER_ENTER: 'pointerenter',
28
+ POINTER_LEAVE: 'pointerleave',
29
+ POINTER_UPOUTSIDE: 'pointerupoutside',
30
+ DRAG_START: 'dragstart',
31
+ DRAG: 'drag',
32
+ DRAG_END: 'dragend',
33
+ DRAG_ENTER: 'dragenter',
34
+ DRAG_LEAVE: 'dragleave',
35
+ DRAG_OVER: 'dragover',
36
+ DROP: 'DROP',
37
+ CLICK: 'click',
38
+ DBLCLICK: 'dblclick',
39
+ };