@antv/g2 5.0.0 → 5.0.2

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 (54) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.en-US.md +1 -1
  3. package/README.md +1 -1
  4. package/dist/g2-lite.min.js +4 -4
  5. package/dist/g2.min.js +4 -4
  6. package/esm/animation/morphing.js +4 -2
  7. package/esm/animation/morphing.js.map +1 -1
  8. package/esm/api/chart.d.ts +1 -2
  9. package/esm/api/chart.js.map +1 -1
  10. package/esm/component/axis.js +1 -1
  11. package/esm/component/axis.js.map +1 -1
  12. package/esm/interaction/fisheye.js +3 -1
  13. package/esm/interaction/fisheye.js.map +1 -1
  14. package/esm/interaction/tooltip.d.ts +1 -1
  15. package/esm/interaction/tooltip.js +8 -4
  16. package/esm/interaction/tooltip.js.map +1 -1
  17. package/esm/runtime/render.d.ts +1 -1
  18. package/esm/runtime/render.js +16 -6
  19. package/esm/runtime/render.js.map +1 -1
  20. package/esm/spec/composition.d.ts +7 -6
  21. package/esm/spec/interaction.d.ts +19 -33
  22. package/esm/transform/maybeTitle.js +5 -1
  23. package/esm/transform/maybeTitle.js.map +1 -1
  24. package/lib/animation/morphing.js +4 -2
  25. package/lib/animation/morphing.js.map +1 -1
  26. package/lib/api/chart.d.ts +1 -2
  27. package/lib/api/chart.js.map +1 -1
  28. package/lib/component/axis.js +1 -1
  29. package/lib/component/axis.js.map +1 -1
  30. package/lib/interaction/fisheye.js +3 -1
  31. package/lib/interaction/fisheye.js.map +1 -1
  32. package/lib/interaction/tooltip.d.ts +1 -1
  33. package/lib/interaction/tooltip.js +7 -3
  34. package/lib/interaction/tooltip.js.map +1 -1
  35. package/lib/runtime/render.d.ts +1 -1
  36. package/lib/runtime/render.js +16 -6
  37. package/lib/runtime/render.js.map +1 -1
  38. package/lib/spec/composition.d.ts +7 -6
  39. package/lib/spec/interaction.d.ts +19 -33
  40. package/lib/transform/maybeTitle.js +5 -1
  41. package/lib/transform/maybeTitle.js.map +1 -1
  42. package/package.json +26 -23
  43. package/src/animation/morphing.ts +8 -2
  44. package/src/api/chart.ts +0 -2
  45. package/src/component/axis.ts +1 -1
  46. package/src/interaction/fisheye.ts +4 -1
  47. package/src/interaction/tooltip.ts +9 -4
  48. package/src/runtime/render.ts +18 -7
  49. package/src/spec/composition.ts +7 -6
  50. package/src/spec/interaction.ts +19 -43
  51. package/src/transform/maybeTitle.ts +5 -1
  52. package/src/.DS_Store +0 -0
  53. package/src/data/.DS_Store +0 -0
  54. package/src/shape/.DS_Store +0 -0
@@ -41,6 +41,7 @@ export type ViewComposition = {
41
41
  theme?: Theme;
42
42
  children?: Mark[];
43
43
  scale?: Record<string, Scale>;
44
+ frame?: boolean;
44
45
  labelTransform?: LabelTransform[];
45
46
  axis?: Record<string, any>;
46
47
  legend?: Record<string, any>;
@@ -108,8 +109,8 @@ export type FacetRectComposition = {
108
109
  shareData?: boolean;
109
110
  shareSize?: boolean;
110
111
  children?: Node[] | ((facet: FacetContext) => Node);
111
- axis?: Record<string, any>;
112
- legend?: Record<string, any>;
112
+ axis?: Record<string, any> | boolean;
113
+ legend?: Record<string, any> | boolean;
113
114
  };
114
115
  export type RepeatMatrixComposition = {
115
116
  type?: 'repeatMatrix';
@@ -136,8 +137,8 @@ export type RepeatMatrixComposition = {
136
137
  y?: Scale;
137
138
  color?: Scale;
138
139
  };
139
- axis?: Record<string, any>;
140
- legend?: Record<string, any>;
140
+ axis?: Record<string, any> | boolean;
141
+ legend?: Record<string, any> | boolean;
141
142
  children?: Node[] | ((facet: FacetContext) => Node);
142
143
  };
143
144
  export type FacetCircleComposition = {
@@ -164,8 +165,8 @@ export type FacetCircleComposition = {
164
165
  color?: Scale;
165
166
  };
166
167
  children?: Node[] | ((facet: FacetContext) => Node);
167
- axis?: Record<string, any>;
168
- legend?: Record<string, any>;
168
+ axis?: Record<string, any> | boolean;
169
+ legend?: Record<string, any> | boolean;
169
170
  };
170
171
  export type TimingKeyframeComposition = {
171
172
  type?: 'timingKeyframe';
@@ -2,94 +2,83 @@ import type { TooltipStyleProps } from '@antv/gui';
2
2
  import { InteractionComponent } from '../runtime';
3
3
  import { FisheyeCoordinate } from './coordinateTransform';
4
4
  import { TooltipItemValue } from './component';
5
- import { AtheisticChanelTypes } from './mark';
6
5
  export type Interaction = ElementHighlightInteraction | ElementHighlightByColorInteraction | ElementHighlightByXInteraction | ElementSelectByColorInteraction | ElementSelectByXInteraction | ElementSelectInteraction | TooltipInteraction | FisheyeInteraction | ChartIndexInteraction | CustomInteraction | LegendFilterInteraction | LegendHighlightInteraction | BrushHighlightInteraction | BrushXHighlightInteraction | BrushYHighlightInteraction | BrushAxisHighlightInteraction | BrushFilterInteraction | BrushYFilterInteraction | BrushXFilterInteraction | SliderFilterInteraction | PoptipInteraction;
7
6
  export type InteractionTypes = 'elementHighlight' | 'elementHighlightByX' | 'elementHighlightByColor' | 'fisheye' | 'chartIndex' | 'elementSelect' | 'elementSelectByX' | 'elementSelectByColor' | 'fisheye' | 'tooltip' | 'legendFilter' | 'legendHighlight' | 'brushXHighlight' | 'brushYHighlight' | 'brushHighlight' | 'brushFilter' | 'brushXFilter' | 'brushYFilter' | 'sliderFilter' | 'poptip' | InteractionComponent;
8
- export type BrushInteraction = {
9
- type?: 'brush';
10
- brushType?: 'rect' | 'rectX' | 'rectY' | 'polygon';
11
- };
12
7
  export type BrushHighlightInteraction = {
13
8
  type?: 'brushHighlight';
14
9
  brushKey?: string;
15
10
  reverse?: boolean;
16
- shared?: boolean;
17
11
  series?: boolean;
18
12
  facet?: boolean;
19
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
13
+ } & Record<`${'mask'}${any}`, any>;
20
14
  export type BrushXHighlightInteraction = {
21
15
  type?: 'brushXHighlight';
22
16
  brushKey?: string;
23
17
  reverse?: boolean;
24
- shared?: boolean;
25
18
  series?: boolean;
26
19
  facet?: boolean;
27
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
20
+ } & Record<`${'mask'}${any}`, any>;
28
21
  export type BrushYHighlightInteraction = {
29
22
  type?: 'brushYHighlight';
30
23
  brushKey?: string;
31
24
  reverse?: boolean;
32
- shared?: boolean;
33
25
  series?: boolean;
34
26
  facet?: boolean;
35
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
27
+ } & Record<`${'mask'}${any}`, any>;
36
28
  export type BrushAxisHighlightInteraction = {
37
29
  type?: 'brushAxisHighlight';
38
30
  reverse?: boolean;
39
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
31
+ brushKey?: string;
32
+ } & Record<`${'mask'}${any}`, any>;
40
33
  export type BrushFilterInteraction = {
41
34
  type?: 'brushFilter';
42
35
  reverse?: boolean;
43
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
36
+ } & Record<`${'mask'}${any}`, any>;
44
37
  export type BrushXFilterInteraction = {
45
38
  type?: 'brushXFilter';
46
39
  reverse?: boolean;
47
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
40
+ } & Record<`${'mask'}${any}`, any>;
48
41
  export type BrushYFilterInteraction = {
49
42
  type?: 'brushYFilter';
50
43
  reverse?: boolean;
51
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
52
- export type BrushVisibleInteraction = {
53
- type?: 'brushVisible';
54
- brushType?: 'rect' | 'rectX' | 'rectY' | 'polygon';
55
- };
44
+ } & Record<`${'mask'}${any}`, any>;
56
45
  export type ElementHighlightInteraction = {
57
46
  type?: 'elementHighlight';
58
47
  link?: boolean;
59
48
  background?: boolean;
60
49
  offset?: number;
61
- } & Record<`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`, any>;
50
+ } & Record<`${'link' | 'background'}${any}`, any>;
62
51
  export type ElementSelectInteraction = {
63
52
  type?: 'elementSelect';
64
53
  single?: boolean;
65
- background?: true;
54
+ background?: boolean;
66
55
  offset?: number;
67
- } & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
56
+ } & Record<`${'link' | 'background'}${any}`, any>;
68
57
  export type ElementSelectByColorInteraction = {
69
58
  type?: 'elementSelectByColor';
70
59
  single?: boolean;
71
60
  offset?: number;
72
- } & Record<`${'selected' | 'link' | 'unselected'}${any}`, any>;
61
+ background?: boolean;
62
+ } & Record<`${'link' | 'background'}${any}`, any>;
73
63
  export type ElementSelectByXInteraction = {
74
64
  type?: 'elementSelectByX';
75
65
  single?: boolean;
76
- background?: true;
66
+ background?: boolean;
77
67
  offset?: number;
78
- } & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
68
+ } & Record<`${'link' | 'background'}${any}`, any>;
79
69
  export type ElementHighlightByXInteraction = {
80
70
  type?: 'elementHighlightByX';
81
- x?: string;
82
71
  link?: boolean;
83
72
  background?: boolean;
84
73
  offset?: number;
85
- } & Record<`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`, any>;
74
+ } & Record<`${'link' | 'background'}${any}`, any>;
86
75
  export type ElementHighlightByColorInteraction = {
87
76
  type?: 'elementHighlightByColor';
88
77
  color?: string;
89
78
  background?: boolean;
90
79
  link?: boolean;
91
80
  offset?: number;
92
- } & Record<`${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`, any>;
81
+ } & Record<`${'link' | 'background'}${any}`, any>;
93
82
  export type PoptipInteraction = {
94
83
  type?: 'poptip';
95
84
  offsetX?: number;
@@ -97,13 +86,10 @@ export type PoptipInteraction = {
97
86
  } & Record<`tip${any}`, any>;
98
87
  export type LegendFilterInteraction = {
99
88
  type?: 'legendFilter';
100
- channel?: AtheisticChanelTypes;
101
- [key: string]: any;
102
- } & Record<`${'marker' | 'label'}Unselected${any}`, any>;
89
+ };
103
90
  export type LegendHighlightInteraction = {
104
91
  type?: 'legendHighlight';
105
- [key: string]: any;
106
- } & Record<`${'marker' | 'label'}Unhighlighted${any}`, any>;
92
+ };
107
93
  export type ChartIndexInteraction = {
108
94
  type?: 'chartIndex';
109
95
  wait?: number;
@@ -25,11 +25,15 @@ const MaybeTitle = (options = {}) => {
25
25
  .map((d) => d[0]);
26
26
  if (titles.length === 0)
27
27
  return [I, mark];
28
+ const T = [];
29
+ for (const i of I) {
30
+ T[i] = { value: titles.map((t) => t[i]).join(', ') };
31
+ }
28
32
  return [
29
33
  I,
30
34
  (0, util_1.deepMix)({}, mark, {
31
35
  tooltip: {
32
- title: I.map((i) => ({ value: titles.map((t) => t[i]).join(', ') })),
36
+ title: T,
33
37
  },
34
38
  }),
35
39
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"maybeTitle.js","sourceRoot":"src/","sources":["transform/maybeTitle.ts"],"names":[],"mappings":";;;AAAA,qCAAqC;AACrC,4CAA0C;AAE1C,2CAA0C;AAM1C;;GAEG;AACI,MAAM,UAAU,GAA0B,CAAC,OAAO,GAAG,EAAE,EAAE,EAAE;IAChE,MAAM,EAAE,OAAO,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;IAClC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;QACjB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QACzB,IAAI,IAAA,gBAAO,EAAC,OAAO,CAAC;YAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QACvC,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;QAC1B,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aAC/B,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;aACxC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,QAAQ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AC;AA5BW,QAAA,UAAU,cA4BrB;AAEF,kBAAU,CAAC,KAAK,GAAG,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/g2",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "the Grammar of Graphics in Javascript",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
@@ -31,7 +31,8 @@
31
31
  "ci": "run-s lint test build",
32
32
  "prepublishOnly": "npm run ci",
33
33
  "prepare": "husky install",
34
- "upload": "node scripts/uploadSnapshot.js"
34
+ "upload": "node scripts/uploadSnapshot.js",
35
+ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s"
35
36
  },
36
37
  "keywords": [
37
38
  "antv",
@@ -43,11 +44,32 @@
43
44
  "interaction",
44
45
  "animation"
45
46
  ],
47
+ "dependencies": {
48
+ "@antv/coord": "^0.4.1",
49
+ "@antv/event-emitter": "^0.1.3",
50
+ "@antv/g": "^5.7.4",
51
+ "@antv/g-canvas": "^1.7.4",
52
+ "@antv/g-plugin-dragndrop": "^1.6.1",
53
+ "@antv/gui": "^0.5.0-alpha.15",
54
+ "@antv/path-util": "^3.0.1",
55
+ "@antv/scale": "^0.4.7",
56
+ "@antv/util": "^3.3.2",
57
+ "d3-array": "^3.2.2",
58
+ "d3-dsv": "^3.0.1",
59
+ "d3-force": "^3.0.0",
60
+ "d3-format": "^3.1.0",
61
+ "d3-geo": "^3.0.1",
62
+ "d3-hierarchy": "^3.1.2",
63
+ "d3-scale-chromatic": "^3.0.0",
64
+ "d3-shape": "^3.1.0",
65
+ "d3-voronoi": "^1.1.4"
66
+ },
46
67
  "devDependencies": {
47
68
  "@antv/g-plugin-rough-canvas-renderer": "^1.7.9",
48
69
  "@antv/g-plugin-rough-svg-renderer": "^1.7.9",
49
70
  "@antv/g-svg": "^1.8.6",
50
71
  "@commitlint/cli": "^11.0.0",
72
+ "@commitlint/config-conventional": "^17.4.4",
51
73
  "@rollup/plugin-commonjs": "^21.0.2",
52
74
  "@types/d3-array": "^3.0.2",
53
75
  "@types/d3-shape": "^3.0.2",
@@ -58,7 +80,8 @@
58
80
  "@typescript-eslint/parser": "^4.18.0",
59
81
  "ali-oss": "^6.17.1",
60
82
  "archiver": "^5.3.1",
61
- "canvas": "^2.10.2",
83
+ "canvas": "2.11.0",
84
+ "conventional-changelog-cli": "^2.2.2",
62
85
  "cross-env": "^7.0.3",
63
86
  "d3-dsv": "^3.0.1",
64
87
  "d3-fetch": "^3.0.1",
@@ -121,25 +144,5 @@
121
144
  },
122
145
  "bugs": {
123
146
  "url": "https://github.com/antvis/g2/issues"
124
- },
125
- "dependencies": {
126
- "@antv/coord": "^0.4.1",
127
- "@antv/event-emitter": "^0.1.3",
128
- "@antv/g": "^5.7.4",
129
- "@antv/g-canvas": "^1.7.4",
130
- "@antv/g-plugin-dragndrop": "^1.6.1",
131
- "@antv/gui": "^0.5.0-alpha.8",
132
- "@antv/path-util": "^3.0.1",
133
- "@antv/scale": "^0.4.7",
134
- "@antv/util": "^3.3.2",
135
- "d3-array": "^3.2.2",
136
- "d3-dsv": "^3.0.1",
137
- "d3-force": "^3.0.0",
138
- "d3-format": "^3.1.0",
139
- "d3-geo": "^3.0.1",
140
- "d3-hierarchy": "^3.1.2",
141
- "d3-scale-chromatic": "^3.0.0",
142
- "d3-shape": "^3.1.0",
143
- "d3-voronoi": "^1.1.4"
144
147
  }
145
148
  }
@@ -73,6 +73,8 @@ function shapeToShape(
73
73
  timeEffect: Record<string, any>,
74
74
  ): GAnimation {
75
75
  const [x0, y0, w0, h0] = localBBoxOf(from);
76
+ const { transform: fromTransform } = from.style;
77
+ const { transform: toTransform } = to.style;
76
78
 
77
79
  // Replace first to get right bbox after mounting.
78
80
  replaceChild(to, from);
@@ -85,11 +87,15 @@ function shapeToShape(
85
87
  const sy = h0 / h1;
86
88
  const keyframes = [
87
89
  {
88
- transform: `translate(${dx}, ${dy}) scale(${sx}, ${sy})`,
90
+ transform: `${
91
+ fromTransform ? fromTransform + ' ' : ''
92
+ }translate(${dx}, ${dy}) scale(${sx}, ${sy})`,
89
93
  ...attributeOf(from, attributeKeys),
90
94
  },
91
95
  {
92
- transform: `translate(0, 0) scale(1, 1)`,
96
+ transform: `${
97
+ toTransform ? toTransform + ' ' : ''
98
+ }translate(0, 0) scale(1, 1)`,
93
99
  ...attributeOf(to, attributeKeys),
94
100
  },
95
101
  ];
package/src/api/chart.ts CHANGED
@@ -129,8 +129,6 @@ export type ChartOptions = ViewComposition & {
129
129
  type ChartProps = Concrete<ViewComposition>;
130
130
 
131
131
  export interface Chart extends Composition, Mark {
132
- render(): void;
133
- node(): HTMLElement;
134
132
  data: ValueAttribute<ChartProps['data'], Chart>;
135
133
  width: ValueAttribute<ChartProps['width'], Chart>;
136
134
  height: ValueAttribute<ChartProps['height'], Chart>;
@@ -313,7 +313,7 @@ function inferAxisLinearOverrideStyle(
313
313
  const [cx, cy] = coordinate.getCenter();
314
314
  const [innerRadius, outerRadius] = radiusOf(coordinate);
315
315
  const [startAngle, endAngle] = angleOf(coordinate);
316
- const r = height / 2;
316
+ const r = Math.min(width, height) / 2;
317
317
 
318
318
  const innerR = innerRadius * r;
319
319
  const outerR = outerRadius * r;
@@ -32,7 +32,10 @@ export function Fisheye({
32
32
  const updateFocus = throttle(
33
33
  (event) => {
34
34
  const focus = mousePosition(plotArea, event);
35
- if (!focus) return;
35
+ if (!focus) {
36
+ update(options);
37
+ return;
38
+ }
36
39
  const [x, y] = focus;
37
40
  const fisheye = maybeCoordinate(clonedOptions);
38
41
  fisheye.focusX = x;
@@ -1,6 +1,6 @@
1
1
  import { DisplayObject, IElement, Line } from '@antv/g';
2
2
  import { sort, group, mean, bisector } from 'd3-array';
3
- import { lowerFirst, throttle } from '@antv/util';
3
+ import { deepMix, lowerFirst, throttle } from '@antv/util';
4
4
  import { Tooltip as TooltipComponent } from '@antv/gui';
5
5
  import { Constant, Identity } from '@antv/scale';
6
6
  import { defined, subObject } from '../utils/helper';
@@ -275,7 +275,6 @@ export function seriesTooltip(
275
275
  coordinate,
276
276
  crosshairs,
277
277
  render,
278
- style,
279
278
  groupName = true,
280
279
  wait = 50,
281
280
  leading = true,
@@ -286,11 +285,14 @@ export function seriesTooltip(
286
285
  single = true,
287
286
  position,
288
287
  enterable,
288
+ style: _style = {},
289
+ ...rest
289
290
  }: Record<string, any>,
290
291
  ) {
291
292
  const elements = elementsof(root);
292
293
  const transposed = isTranspose(coordinate);
293
294
  const polar = isPolar(coordinate);
295
+ const style = deepMix(_style, rest);
294
296
  const { innerWidth: width, innerHeight: height } = coordinate.getOptions();
295
297
 
296
298
  // Split elements into series elements and item elements.
@@ -386,7 +388,7 @@ export function seriesTooltip(
386
388
  selectedSeriesElements.push(element);
387
389
  const d = seriesData(element, index);
388
390
  const { x, y } = d;
389
- const p = coordinate.map([x + offsetX, y]);
391
+ const p = coordinate.map([(x || 0) + offsetX, y || 0]);
390
392
  selectedSeriesData.push([d, p] as const);
391
393
  }
392
394
  }
@@ -495,7 +497,10 @@ export function tooltip(
495
497
  const pointerover = throttle(
496
498
  (event) => {
497
499
  const { target: element } = event;
498
- if (!elementSet.has(element)) return;
500
+ if (!elementSet.has(element)) {
501
+ hideTooltip(root, single);
502
+ return;
503
+ }
499
504
  const k = groupKey(element);
500
505
  const group = keyGroup.get(k);
501
506
  const data =
@@ -94,8 +94,11 @@ export function render<T extends G2ViewTree = G2ViewTree>(
94
94
  plot<T>({ ...keyed, width, height }, selection, library, context),
95
95
  )
96
96
  .then(() => {
97
- emitter.emit(ChartEvent.AFTER_RENDER);
98
- resolve?.();
97
+ // Wait for the next tick.
98
+ canvas.requestAnimationFrame(() => {
99
+ emitter.emit(ChartEvent.AFTER_RENDER);
100
+ resolve?.();
101
+ });
99
102
  })
100
103
  .catch((e) => {
101
104
  reject?.(e);
@@ -108,7 +111,8 @@ export function render<T extends G2ViewTree = G2ViewTree>(
108
111
  export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
109
112
  options: T,
110
113
  context: G2Context = {},
111
- callback?: () => void,
114
+ resolve?: () => void,
115
+ reject?: (e: Error) => void,
112
116
  ): DisplayObject {
113
117
  // Initialize the context if it is not provided.
114
118
  const { width = 640, height = 480, on } = options;
@@ -133,10 +137,17 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
133
137
  emitter.emit(ChartEvent.BEFORE_RENDER);
134
138
  // Plot the chart and mutate context.
135
139
  // Make sure that plot chart after container is ready for every time.
136
- plot<T>({ ...keyed, width, height }, selection, library, context).then(() => {
137
- emitter.emit(ChartEvent.AFTER_RENDER);
138
- callback?.();
139
- });
140
+ plot<T>({ ...keyed, width, height }, selection, library, context)
141
+ .then(() => {
142
+ const canvas = group.ownerDocument.defaultView;
143
+ canvas.requestAnimationFrame(() => {
144
+ emitter.emit(ChartEvent.AFTER_RENDER);
145
+ resolve?.();
146
+ });
147
+ })
148
+ .catch((e) => {
149
+ reject?.(e);
150
+ });
140
151
 
141
152
  // Return the Group wraps the canvas or svg element.
142
153
  return group;
@@ -62,6 +62,7 @@ export type ViewComposition = {
62
62
  theme?: Theme;
63
63
  children?: Mark[];
64
64
  scale?: Record<string, Scale>;
65
+ frame?: boolean;
65
66
  labelTransform?: LabelTransform[];
66
67
  // @todo
67
68
  axis?: Record<string, any>;
@@ -141,9 +142,9 @@ export type FacetRectComposition = {
141
142
  shareSize?: boolean;
142
143
  children?: Node[] | ((facet: FacetContext) => Node);
143
144
  // @todo
144
- axis?: Record<string, any>;
145
+ axis?: Record<string, any> | boolean;
145
146
  // @todo
146
- legend?: Record<string, any>;
147
+ legend?: Record<string, any> | boolean;
147
148
  };
148
149
 
149
150
  export type RepeatMatrixComposition = {
@@ -172,9 +173,9 @@ export type RepeatMatrixComposition = {
172
173
  color?: Scale;
173
174
  };
174
175
  // @todo
175
- axis?: Record<string, any>;
176
+ axis?: Record<string, any> | boolean;
176
177
  // @todo
177
- legend?: Record<string, any>;
178
+ legend?: Record<string, any> | boolean;
178
179
  children?: Node[] | ((facet: FacetContext) => Node);
179
180
  };
180
181
 
@@ -203,9 +204,9 @@ export type FacetCircleComposition = {
203
204
  };
204
205
  children?: Node[] | ((facet: FacetContext) => Node);
205
206
  // @todo
206
- axis?: Record<string, any>;
207
+ axis?: Record<string, any> | boolean;
207
208
  // @todo
208
- legend?: Record<string, any>;
209
+ legend?: Record<string, any> | boolean;
209
210
  };
210
211
 
211
212
  export type TimingKeyframeComposition = {
@@ -50,62 +50,50 @@ export type InteractionTypes =
50
50
  | 'poptip'
51
51
  | InteractionComponent;
52
52
 
53
- export type BrushInteraction = {
54
- type?: 'brush';
55
- brushType?: 'rect' | 'rectX' | 'rectY' | 'polygon';
56
- };
57
-
58
53
  export type BrushHighlightInteraction = {
59
54
  type?: 'brushHighlight';
60
55
  brushKey?: string;
61
56
  reverse?: boolean;
62
- shared?: boolean;
63
57
  series?: boolean;
64
58
  facet?: boolean;
65
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
59
+ } & Record<`${'mask'}${any}`, any>;
66
60
 
67
61
  export type BrushXHighlightInteraction = {
68
62
  type?: 'brushXHighlight';
69
63
  brushKey?: string;
70
64
  reverse?: boolean;
71
- shared?: boolean;
72
65
  series?: boolean;
73
66
  facet?: boolean;
74
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
67
+ } & Record<`${'mask'}${any}`, any>;
75
68
 
76
69
  export type BrushYHighlightInteraction = {
77
70
  type?: 'brushYHighlight';
78
71
  brushKey?: string;
79
72
  reverse?: boolean;
80
- shared?: boolean;
81
73
  series?: boolean;
82
74
  facet?: boolean;
83
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
75
+ } & Record<`${'mask'}${any}`, any>;
84
76
 
85
77
  export type BrushAxisHighlightInteraction = {
86
78
  type?: 'brushAxisHighlight';
87
79
  reverse?: boolean;
88
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
80
+ brushKey?: string;
81
+ } & Record<`${'mask'}${any}`, any>;
89
82
 
90
83
  export type BrushFilterInteraction = {
91
84
  type?: 'brushFilter';
92
85
  reverse?: boolean;
93
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
86
+ } & Record<`${'mask'}${any}`, any>;
94
87
 
95
88
  export type BrushXFilterInteraction = {
96
89
  type?: 'brushXFilter';
97
90
  reverse?: boolean;
98
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
91
+ } & Record<`${'mask'}${any}`, any>;
99
92
 
100
93
  export type BrushYFilterInteraction = {
101
94
  type?: 'brushYFilter';
102
95
  reverse?: boolean;
103
- } & Record<`${'mask' | 'highlighted' | 'unhighlighted'}${any}`, any>;
104
-
105
- export type BrushVisibleInteraction = {
106
- type?: 'brushVisible';
107
- brushType?: 'rect' | 'rectX' | 'rectY' | 'polygon';
108
- };
96
+ } & Record<`${'mask'}${any}`, any>;
109
97
 
110
98
  export type ElementHighlightInteraction = {
111
99
  type?: 'elementHighlight';
@@ -113,41 +101,35 @@ export type ElementHighlightInteraction = {
113
101
  link?: boolean;
114
102
  background?: boolean;
115
103
  offset?: number;
116
- } & Record<
117
- `${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
118
- any
119
- >;
104
+ } & Record<`${'link' | 'background'}${any}`, any>;
120
105
 
121
106
  export type ElementSelectInteraction = {
122
107
  type?: 'elementSelect';
123
108
  single?: boolean;
124
- background?: true;
109
+ background?: boolean;
125
110
  offset?: number;
126
- } & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
111
+ } & Record<`${'link' | 'background'}${any}`, any>;
127
112
 
128
113
  export type ElementSelectByColorInteraction = {
129
114
  type?: 'elementSelectByColor';
130
115
  single?: boolean;
131
116
  offset?: number;
132
- } & Record<`${'selected' | 'link' | 'unselected'}${any}`, any>;
117
+ background?: boolean;
118
+ } & Record<`${'link' | 'background'}${any}`, any>;
133
119
 
134
120
  export type ElementSelectByXInteraction = {
135
121
  type?: 'elementSelectByX';
136
122
  single?: boolean;
137
- background?: true;
123
+ background?: boolean;
138
124
  offset?: number;
139
- } & Record<`${'selected' | 'link' | 'unselected' | 'background'}${any}`, any>;
125
+ } & Record<`${'link' | 'background'}${any}`, any>;
140
126
 
141
127
  export type ElementHighlightByXInteraction = {
142
128
  type?: 'elementHighlightByX';
143
- x?: string;
144
129
  link?: boolean;
145
130
  background?: boolean;
146
131
  offset?: number;
147
- } & Record<
148
- `${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
149
- any
150
- >;
132
+ } & Record<`${'link' | 'background'}${any}`, any>;
151
133
 
152
134
  export type ElementHighlightByColorInteraction = {
153
135
  type?: 'elementHighlightByColor';
@@ -155,10 +137,7 @@ export type ElementHighlightByColorInteraction = {
155
137
  background?: boolean;
156
138
  link?: boolean;
157
139
  offset?: number;
158
- } & Record<
159
- `${'link' | 'highlighted' | 'unhighlighted' | 'background'}${any}`,
160
- any
161
- >;
140
+ } & Record<`${'link' | 'background'}${any}`, any>;
162
141
 
163
142
  export type PoptipInteraction = {
164
143
  type?: 'poptip';
@@ -168,14 +147,11 @@ export type PoptipInteraction = {
168
147
 
169
148
  export type LegendFilterInteraction = {
170
149
  type?: 'legendFilter';
171
- channel?: AtheisticChanelTypes;
172
- [key: string]: any; // @todo
173
- } & Record<`${'marker' | 'label'}Unselected${any}`, any>;
150
+ };
174
151
 
175
152
  export type LegendHighlightInteraction = {
176
153
  type?: 'legendHighlight';
177
- [key: string]: any; // @todo
178
- } & Record<`${'marker' | 'label'}Unhighlighted${any}`, any>;
154
+ };
179
155
 
180
156
  export type ChartIndexInteraction = {
181
157
  type?: 'chartIndex';
@@ -25,11 +25,15 @@ export const MaybeTitle: TC<MaybeTitleOptions> = (options = {}) => {
25
25
  .filter(([T]) => T)
26
26
  .map((d) => d[0]);
27
27
  if (titles.length === 0) return [I, mark];
28
+ const T = [];
29
+ for (const i of I) {
30
+ T[i] = { value: titles.map((t) => t[i]).join(', ') };
31
+ }
28
32
  return [
29
33
  I,
30
34
  deepMix({}, mark, {
31
35
  tooltip: {
32
- title: I.map((i) => ({ value: titles.map((t) => t[i]).join(', ') })),
36
+ title: T,
33
37
  },
34
38
  }),
35
39
  ];
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file