@antv/g2 5.0.22 → 5.0.24

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 (236) hide show
  1. package/CHANGELOG.md +325 -0
  2. package/dist/g2-lite.min.js +3 -3
  3. package/dist/g2.min.js +3 -3
  4. package/esm/api/chart.d.ts +9 -17
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/extend.d.ts +5 -1
  7. package/esm/api/extend.js.map +1 -1
  8. package/esm/api/index.d.ts +1 -1
  9. package/esm/api/index.js.map +1 -1
  10. package/esm/api/library.d.ts +6 -16
  11. package/esm/api/runtime.js +4 -1
  12. package/esm/api/runtime.js.map +1 -1
  13. package/esm/component/axis.js +15 -10
  14. package/esm/component/axis.js.map +1 -1
  15. package/esm/component/legendCategory.js +2 -2
  16. package/esm/component/legendCategory.js.map +1 -1
  17. package/esm/component/legendContinuous.js +4 -5
  18. package/esm/component/legendContinuous.js.map +1 -1
  19. package/esm/component/scrollbar.js +2 -0
  20. package/esm/component/scrollbar.js.map +1 -1
  21. package/esm/component/slider.js +2 -0
  22. package/esm/component/slider.js.map +1 -1
  23. package/esm/component/title.js +4 -2
  24. package/esm/component/title.js.map +1 -1
  25. package/esm/component/utils.d.ts +1 -1
  26. package/esm/component/utils.js +2 -3
  27. package/esm/component/utils.js.map +1 -1
  28. package/esm/composition/facetRect.js +2 -2
  29. package/esm/composition/facetRect.js.map +1 -1
  30. package/esm/composition/repeatMatrix.js +3 -3
  31. package/esm/composition/repeatMatrix.js.map +1 -1
  32. package/esm/index.d.ts +2 -2
  33. package/esm/index.js +1 -1
  34. package/esm/index.js.map +1 -1
  35. package/esm/interaction/brushHighlight.js.map +1 -1
  36. package/esm/interaction/tooltip.js +4 -3
  37. package/esm/interaction/tooltip.js.map +1 -1
  38. package/esm/lib/builtinlib.d.ts +13 -0
  39. package/esm/lib/builtinlib.js +21 -0
  40. package/esm/lib/builtinlib.js.map +1 -0
  41. package/esm/lib/core.d.ts +2 -12
  42. package/esm/lib/core.js +8 -19
  43. package/esm/lib/core.js.map +1 -1
  44. package/esm/lib/graph.d.ts +5 -0
  45. package/esm/lib/graph.js +7 -1
  46. package/esm/lib/graph.js.map +1 -1
  47. package/esm/lib/plot.d.ts +0 -5
  48. package/esm/lib/plot.js +2 -7
  49. package/esm/lib/plot.js.map +1 -1
  50. package/esm/lib/std.d.ts +6 -16
  51. package/esm/lib/threed.d.ts +1 -0
  52. package/esm/lib/threed.js +2 -1
  53. package/esm/lib/threed.js.map +1 -1
  54. package/esm/mark/index.d.ts +1 -0
  55. package/esm/mark/index.js +1 -0
  56. package/esm/mark/index.js.map +1 -1
  57. package/esm/mark/line3D.d.ts +7 -0
  58. package/esm/mark/line3D.js +65 -0
  59. package/esm/mark/line3D.js.map +1 -0
  60. package/esm/runtime/component.js +33 -30
  61. package/esm/runtime/component.js.map +1 -1
  62. package/esm/runtime/layout.js +79 -28
  63. package/esm/runtime/layout.js.map +1 -1
  64. package/esm/runtime/library.d.ts +1 -1
  65. package/esm/runtime/library.js +3 -1
  66. package/esm/runtime/library.js.map +1 -1
  67. package/esm/runtime/plot.js +42 -42
  68. package/esm/runtime/plot.js.map +1 -1
  69. package/esm/runtime/render.js +1 -4
  70. package/esm/runtime/render.js.map +1 -1
  71. package/esm/runtime/scale.js +2 -0
  72. package/esm/runtime/scale.js.map +1 -1
  73. package/esm/runtime/types/common.d.ts +3 -1
  74. package/esm/runtime/types/theme.d.ts +8 -2
  75. package/esm/shape/connector/connector.js +19 -30
  76. package/esm/shape/connector/connector.js.map +1 -1
  77. package/esm/shape/index.d.ts +1 -0
  78. package/esm/shape/index.js +1 -0
  79. package/esm/shape/index.js.map +1 -1
  80. package/esm/shape/line3D/line.d.ts +3 -0
  81. package/esm/shape/line3D/line.js +30 -0
  82. package/esm/shape/line3D/line.js.map +1 -0
  83. package/esm/shape/point3D/cube.js +2 -2
  84. package/esm/shape/point3D/cube.js.map +1 -1
  85. package/esm/shape/point3D/sphere.js +2 -2
  86. package/esm/shape/point3D/sphere.js.map +1 -1
  87. package/esm/theme/classic.js +54 -37
  88. package/esm/theme/classic.js.map +1 -1
  89. package/esm/theme/index.d.ts +1 -0
  90. package/esm/theme/index.js +1 -0
  91. package/esm/theme/index.js.map +1 -1
  92. package/esm/theme/light.d.ts +6 -0
  93. package/esm/theme/light.js +476 -0
  94. package/esm/theme/light.js.map +1 -0
  95. package/esm/utils/selection.d.ts +1 -1
  96. package/esm/utils/selection.js +10 -10
  97. package/esm/utils/selection.js.map +1 -1
  98. package/esm/utils/size.js +1 -1
  99. package/lib/api/chart.d.ts +9 -17
  100. package/lib/api/chart.js.map +1 -1
  101. package/lib/api/extend.d.ts +5 -1
  102. package/lib/api/extend.js.map +1 -1
  103. package/lib/api/index.d.ts +1 -1
  104. package/lib/api/index.js.map +1 -1
  105. package/lib/api/library.d.ts +6 -16
  106. package/lib/api/runtime.js +4 -1
  107. package/lib/api/runtime.js.map +1 -1
  108. package/lib/component/axis.js +14 -9
  109. package/lib/component/axis.js.map +1 -1
  110. package/lib/component/legendCategory.js +2 -2
  111. package/lib/component/legendCategory.js.map +1 -1
  112. package/lib/component/legendContinuous.js +4 -5
  113. package/lib/component/legendContinuous.js.map +1 -1
  114. package/lib/component/scrollbar.js +2 -0
  115. package/lib/component/scrollbar.js.map +1 -1
  116. package/lib/component/slider.js +2 -0
  117. package/lib/component/slider.js.map +1 -1
  118. package/lib/component/title.js +4 -2
  119. package/lib/component/title.js.map +1 -1
  120. package/lib/component/utils.d.ts +1 -1
  121. package/lib/component/utils.js +2 -3
  122. package/lib/component/utils.js.map +1 -1
  123. package/lib/composition/facetRect.js +2 -2
  124. package/lib/composition/facetRect.js.map +1 -1
  125. package/lib/composition/repeatMatrix.js +3 -3
  126. package/lib/composition/repeatMatrix.js.map +1 -1
  127. package/lib/index.d.ts +2 -2
  128. package/lib/index.js +4 -1
  129. package/lib/index.js.map +1 -1
  130. package/lib/interaction/brushHighlight.js.map +1 -1
  131. package/lib/interaction/tooltip.js +4 -3
  132. package/lib/interaction/tooltip.js.map +1 -1
  133. package/lib/lib/builtinlib.d.ts +13 -0
  134. package/lib/lib/builtinlib.js +25 -0
  135. package/lib/lib/builtinlib.js.map +1 -0
  136. package/lib/lib/core.d.ts +2 -12
  137. package/lib/lib/core.js +1 -12
  138. package/lib/lib/core.js.map +1 -1
  139. package/lib/lib/graph.d.ts +5 -0
  140. package/lib/lib/graph.js +6 -0
  141. package/lib/lib/graph.js.map +1 -1
  142. package/lib/lib/plot.d.ts +0 -5
  143. package/lib/lib/plot.js +0 -5
  144. package/lib/lib/plot.js.map +1 -1
  145. package/lib/lib/std.d.ts +6 -16
  146. package/lib/lib/threed.d.ts +1 -0
  147. package/lib/lib/threed.js +1 -0
  148. package/lib/lib/threed.js.map +1 -1
  149. package/lib/mark/index.d.ts +1 -0
  150. package/lib/mark/index.js +3 -1
  151. package/lib/mark/index.js.map +1 -1
  152. package/lib/mark/line3D.d.ts +7 -0
  153. package/lib/mark/line3D.js +69 -0
  154. package/lib/mark/line3D.js.map +1 -0
  155. package/lib/runtime/component.js +33 -30
  156. package/lib/runtime/component.js.map +1 -1
  157. package/lib/runtime/layout.js +77 -26
  158. package/lib/runtime/layout.js.map +1 -1
  159. package/lib/runtime/library.d.ts +1 -1
  160. package/lib/runtime/library.js +3 -1
  161. package/lib/runtime/library.js.map +1 -1
  162. package/lib/runtime/plot.js +42 -42
  163. package/lib/runtime/plot.js.map +1 -1
  164. package/lib/runtime/render.js +1 -4
  165. package/lib/runtime/render.js.map +1 -1
  166. package/lib/runtime/scale.js +2 -0
  167. package/lib/runtime/scale.js.map +1 -1
  168. package/lib/runtime/types/common.d.ts +3 -1
  169. package/lib/runtime/types/theme.d.ts +8 -2
  170. package/lib/shape/connector/connector.js +19 -30
  171. package/lib/shape/connector/connector.js.map +1 -1
  172. package/lib/shape/index.d.ts +1 -0
  173. package/lib/shape/index.js +8 -6
  174. package/lib/shape/index.js.map +1 -1
  175. package/lib/shape/line3D/line.d.ts +3 -0
  176. package/lib/shape/line3D/line.js +34 -0
  177. package/lib/shape/line3D/line.js.map +1 -0
  178. package/lib/shape/point3D/cube.js +1 -1
  179. package/lib/shape/point3D/cube.js.map +1 -1
  180. package/lib/shape/point3D/sphere.js +1 -1
  181. package/lib/shape/point3D/sphere.js.map +1 -1
  182. package/lib/theme/classic.js +54 -37
  183. package/lib/theme/classic.js.map +1 -1
  184. package/lib/theme/index.d.ts +1 -0
  185. package/lib/theme/index.js +3 -1
  186. package/lib/theme/index.js.map +1 -1
  187. package/lib/theme/light.d.ts +6 -0
  188. package/lib/theme/light.js +480 -0
  189. package/lib/theme/light.js.map +1 -0
  190. package/lib/utils/selection.d.ts +1 -1
  191. package/lib/utils/selection.js +10 -10
  192. package/lib/utils/selection.js.map +1 -1
  193. package/lib/utils/size.js +1 -1
  194. package/package.json +4 -4
  195. package/src/api/chart.ts +3 -0
  196. package/src/api/extend.ts +6 -1
  197. package/src/api/index.ts +1 -1
  198. package/src/api/runtime.ts +6 -3
  199. package/src/component/axis.ts +17 -13
  200. package/src/component/legendCategory.ts +3 -5
  201. package/src/component/legendContinuous.ts +4 -5
  202. package/src/component/scrollbar.ts +4 -1
  203. package/src/component/slider.ts +4 -1
  204. package/src/component/title.ts +3 -3
  205. package/src/component/utils.ts +1 -3
  206. package/src/composition/facetRect.ts +4 -3
  207. package/src/composition/repeatMatrix.ts +4 -3
  208. package/src/index.ts +10 -1
  209. package/src/interaction/brushHighlight.ts +1 -1
  210. package/src/interaction/tooltip.ts +5 -3
  211. package/src/lib/builtinlib.ts +28 -0
  212. package/src/lib/core.ts +4 -25
  213. package/src/lib/graph.ts +7 -1
  214. package/src/lib/plot.ts +2 -7
  215. package/src/lib/threed.ts +2 -1
  216. package/src/mark/index.ts +1 -0
  217. package/src/mark/line3D.ts +81 -0
  218. package/src/runtime/component.ts +57 -30
  219. package/src/runtime/layout.ts +91 -31
  220. package/src/runtime/library.ts +4 -1
  221. package/src/runtime/plot.ts +62 -40
  222. package/src/runtime/render.ts +1 -6
  223. package/src/runtime/scale.ts +1 -0
  224. package/src/runtime/types/common.ts +2 -0
  225. package/src/runtime/types/theme.ts +8 -2
  226. package/src/shape/connector/connector.ts +41 -47
  227. package/src/shape/index.ts +1 -0
  228. package/src/shape/line3D/line.ts +29 -0
  229. package/src/shape/point3D/cube.ts +2 -2
  230. package/src/shape/point3D/sphere.ts +2 -2
  231. package/src/shape/utils.ts +2 -2
  232. package/src/theme/classic.ts +54 -37
  233. package/src/theme/index.ts +1 -0
  234. package/src/theme/light.ts +483 -0
  235. package/src/utils/selection.ts +11 -11
  236. package/src/utils/size.ts +1 -1
package/src/api/extend.ts CHANGED
@@ -16,9 +16,14 @@ type CompositionOf<Library> = Of<
16
16
  CompositionOf<Library>
17
17
  >;
18
18
 
19
+ type BuiltinComposition = {
20
+ 'composition.mark': any;
21
+ 'composition.view': any;
22
+ };
23
+
19
24
  export type API<Spec, Library> = Runtime<Spec> &
20
25
  MarkOf<Library, (composite?) => MarkNode> &
21
- CompositionOf<Library>;
26
+ CompositionOf<Library & BuiltinComposition>;
22
27
 
23
28
  export function extend<
24
29
  Spec extends G2Spec = G2Spec,
package/src/api/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { Chart } from './chart';
1
+ export { Chart, type ChartOptions } from './chart';
2
2
  export { MarkNode } from './mark';
3
3
  export { CompositionNode } from './composition';
4
4
  export { register } from './library';
@@ -222,9 +222,12 @@ export class Runtime<Spec extends G2Spec = G2Spec> extends CompositionNode {
222
222
  }
223
223
 
224
224
  // Create composition generators.
225
- const compositions = Object.keys(library).filter(
226
- (key) => key.startsWith('composition.') && key !== 'composition.mark',
227
- );
225
+ const compositions = [
226
+ 'composition.view', // chat.view()
227
+ ...Object.keys(library).filter(
228
+ (key) => key.startsWith('composition.') && key !== 'composition.mark',
229
+ ),
230
+ ];
228
231
  this._compositions = Object.fromEntries(
229
232
  compositions.map((key) => {
230
233
  const name = key.split('.').pop();
@@ -2,7 +2,7 @@ import { Coordinate } from '@antv/coord';
2
2
  import type { DisplayObject } from '@antv/g';
3
3
  import { Axis as AxisComponent } from '@antv/gui';
4
4
  import { Linear as LinearScale } from '@antv/scale';
5
- import { deepMix, omit } from '@antv/util';
5
+ import { deepMix, omit, upperFirst } from '@antv/util';
6
6
  import { extent } from 'd3-array';
7
7
  import { format } from 'd3-format';
8
8
  import {
@@ -356,15 +356,15 @@ function inferAxisLinearOverrideStyle(
356
356
  // axisY
357
357
  if (orientation === 'vertical') {
358
358
  return {
359
- startPos: [x + width, y],
360
- endPos: [x + width, y + height],
359
+ startPos: [x, y],
360
+ endPos: [x, y + height],
361
361
  };
362
362
  }
363
363
  // axisX
364
364
  else if (orientation === 'horizontal') {
365
365
  return {
366
- startPos: [x, y + height],
367
- endPos: [x + width, y + height],
366
+ startPos: [x, y],
367
+ endPos: [x + width, y],
368
368
  };
369
369
  }
370
370
  // axis with rotate
@@ -478,7 +478,7 @@ const ArcAxisComponent: GCC<AxisOptions> = (options) => {
478
478
  // @fixme transform is not valid for arcAxis.
479
479
  // @ts-ignore
480
480
  style: omit(finalStyle, ['transform']),
481
- });
481
+ }) as unknown as DisplayObject;
482
482
  };
483
483
  };
484
484
 
@@ -491,12 +491,12 @@ function inferThemeStyle(
491
491
  orientation: GCO,
492
492
  ) {
493
493
  const baseStyle = theme.axis;
494
- let furtherStyle = theme.axisLinear;
495
-
496
- if (['top', 'right', 'bottom', 'left'].includes(position)) {
497
- furtherStyle = theme[`axis${capitalizeFirst(position)}`];
498
- }
499
- return Object.assign({}, baseStyle, furtherStyle);
494
+ const positionStyle = ['top', 'right', 'bottom', 'left'].includes(position)
495
+ ? theme[`axis${capitalizeFirst(position)}`]
496
+ : theme.axisLinear;
497
+ const channel = scale.getOptions().name;
498
+ const channelStyle = theme[`axis${upperFirst(channel)}`] || {};
499
+ return Object.assign({}, baseStyle, positionStyle, channelStyle);
500
500
  }
501
501
 
502
502
  function inferDefaultStyle(
@@ -634,7 +634,7 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
634
634
  return new AxisComponent({
635
635
  className: 'axis',
636
636
  style: adaptor(finalAxisStyle),
637
- });
637
+ }) as unknown as DisplayObject;
638
638
  };
639
639
  };
640
640
 
@@ -678,6 +678,8 @@ LinearAxis.props = {
678
678
  defaultPosition: 'center',
679
679
  defaultSize: 45,
680
680
  defaultOrder: 0,
681
+ defaultCrossPadding: [12, 12],
682
+ defaultPadding: [12, 12],
681
683
  };
682
684
 
683
685
  ArcAxis.props = {
@@ -685,4 +687,6 @@ ArcAxis.props = {
685
687
  defaultOrientation: 'vertical',
686
688
  defaultSize: 45,
687
689
  defaultOrder: 0,
690
+ defaultCrossPadding: [12, 12],
691
+ defaultPadding: [12, 12],
688
692
  };
@@ -2,12 +2,10 @@ import type { DisplayObject } from '@antv/g';
2
2
  import { Category } from '@antv/gui';
3
3
  import { last } from '@antv/util';
4
4
  import { format } from 'd3-format';
5
- import { Identity, Point } from '@antv/scale';
5
+ import { Identity } from '@antv/scale';
6
6
  import type {
7
7
  FlexLayout,
8
- G2Library,
9
8
  G2MarkState,
10
- G2Theme,
11
9
  GuideComponentComponent as GCC,
12
10
  GuideComponentOrientation as GCO,
13
11
  GuideComponentPosition as GCP,
@@ -244,6 +242,6 @@ LegendCategory.props = {
244
242
  defaultPosition: 'top',
245
243
  defaultOrder: 1,
246
244
  defaultSize: 40,
247
- defaultPadding: [20, 10], // [horizontal, vertical]
248
- defaultCrossPadding: [5, 10], // [horizontal, vertical]
245
+ defaultCrossPadding: [12, 12],
246
+ defaultPadding: [12, 12],
249
247
  };
@@ -65,10 +65,9 @@ function inferContinuousShape(
65
65
  options: LegendContinuousOptions,
66
66
  component: GCC,
67
67
  ): Shape {
68
- const { size, crossPadding = 0 } = options;
68
+ const { size } = options;
69
69
  const shape = inferComponentShape(value, options, component);
70
- const finalSize = size - crossPadding * 2;
71
- return updateShapeDimensions(shape, finalSize, shape.orientation);
70
+ return updateShapeDimensions(shape, size, shape.orientation);
72
71
  }
73
72
 
74
73
  function getFormatter(max: number) {
@@ -160,7 +159,7 @@ function getLinearConfig(
160
159
  ...shape,
161
160
  domain: [domainMin, domainMax],
162
161
  data: scale.getTicks().map((value) => ({ value })),
163
- color: new Array(length).fill(0).map((d, i) => {
162
+ color: new Array(Math.floor(length)).fill(0).map((d, i) => {
164
163
  const value = ((max - min) / (length - 1)) * i + min;
165
164
  const color = scale.map(value);
166
165
  const opacity = opacityScale ? opacityScale.map(value) : 1;
@@ -289,5 +288,5 @@ LegendContinuous.props = {
289
288
  defaultLength: 200,
290
289
  defaultLegendSize: 60,
291
290
  defaultPadding: [20, 10], // [horizontal, vertical]
292
- defaultCrossPadding: [5, 10], // [horizontal, vertical]
291
+ defaultCrossPadding: [12, 12], // [horizontal, vertical]
293
292
  };
@@ -1,4 +1,5 @@
1
1
  import { Scrollbar as ScrollbarComponent } from '@antv/gui';
2
+ import { DisplayObject } from '@antv/g';
2
3
  import { GuideComponentComponent as GCC } from '../runtime';
3
4
 
4
5
  export type ScrollbarOptions = {
@@ -35,7 +36,7 @@ export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
35
36
  contentLength: actualSize,
36
37
  viewportLength: mainSize,
37
38
  }),
38
- });
39
+ }) as unknown as DisplayObject;
39
40
  };
40
41
  };
41
42
 
@@ -43,4 +44,6 @@ Scrollbar.props = {
43
44
  defaultPosition: 'bottom',
44
45
  defaultSize: 24,
45
46
  defaultOrder: 1,
47
+ defaultCrossPadding: [12, 12],
48
+ defaultPadding: [12, 12],
46
49
  };
@@ -1,5 +1,6 @@
1
1
  import { Slider as SliderComponent } from '@antv/gui';
2
2
  import { format } from 'd3-format';
3
+ import { DisplayObject } from '@antv/g';
3
4
  import { isTranspose } from '../utils/coordinate';
4
5
  import { GuideComponentComponent as GCC } from '../runtime';
5
6
  import { invert } from '../utils/scale';
@@ -62,7 +63,7 @@ export const Slider: GCC<SliderOptions> = (options) => {
62
63
  ...style,
63
64
  ...rest,
64
65
  }),
65
- });
66
+ }) as unknown as DisplayObject;
66
67
  };
67
68
  };
68
69
 
@@ -70,4 +71,6 @@ Slider.props = {
70
71
  defaultPosition: 'bottom',
71
72
  defaultSize: 24,
72
73
  defaultOrder: 1,
74
+ defaultCrossPadding: [12, 12],
75
+ defaultPadding: [12, 12],
73
76
  };
@@ -44,8 +44,6 @@ function inferStyleByAlign(
44
44
  const Title = createComponent<TitleStyleProps>({
45
45
  render(attributes, container) {
46
46
  const {
47
- x,
48
- y,
49
47
  width,
50
48
  title,
51
49
  subtitle,
@@ -60,7 +58,7 @@ const Title = createComponent<TitleStyleProps>({
60
58
  const mainTitle = maybeAppend(container, '.title', 'text')
61
59
  .attr('className', 'title')
62
60
  .call(applyStyle, {
63
- ...inferStyleByAlign(0, y, width, align),
61
+ ...inferStyleByAlign(0, 0, width, align),
64
62
  fontSize: 14,
65
63
  textBaseline: 'top',
66
64
  text: title,
@@ -106,4 +104,6 @@ TitleComponent.props = {
106
104
  defaultPosition: 'top',
107
105
  defaultOrder: 2,
108
106
  defaultSize: 36,
107
+ defaultCrossPadding: [20, 20],
108
+ defaultPadding: [12, 12],
109
109
  };
@@ -124,15 +124,13 @@ export function inferComponentShape(
124
124
  position = 'top',
125
125
  size: userDefinedSize,
126
126
  length: userDefinedLength,
127
- crossPadding = 0,
128
127
  } = options;
129
128
  const isHorizontal = ['top', 'bottom', 'center'].includes(position);
130
129
  const [bboxSize, bboxLength] = isHorizontal
131
130
  ? [bbox.height, bbox.width]
132
131
  : [bbox.width, bbox.height];
133
132
  const { defaultSize, defaultLength } = component.props;
134
- const size0 = userDefinedSize || defaultSize || bboxSize;
135
- const size = size0 - crossPadding * 2;
133
+ const size = userDefinedSize || defaultSize || bboxSize;
136
134
  const length = userDefinedLength || defaultLength || bboxLength;
137
135
  const orientation = isHorizontal ? 'horizontal' : 'vertical';
138
136
  const [width, height] = isHorizontal ? [length, size] : [size, length];
@@ -184,7 +184,7 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
184
184
  layout,
185
185
  ) => {
186
186
  const { x: scaleX, y: scaleY } = scale;
187
- const { paddingLeft, paddingTop } = layout;
187
+ const { paddingLeft, paddingTop, marginLeft, marginTop } = layout;
188
188
  const { domain: domainX } = scaleX.getOptions();
189
189
  const { domain: domainY } = scaleY.getOptions();
190
190
  const index = indexOf(visualData);
@@ -252,8 +252,9 @@ export const setChildren = useOverrideAdaptor<G2ViewTree>(
252
252
  return {
253
253
  key: `${key}-${i}`,
254
254
  data: newData,
255
- x: left + paddingLeft + originX,
256
- y: top + paddingTop + originY,
255
+ margin: 0,
256
+ x: left + paddingLeft + originX + marginLeft,
257
+ y: top + paddingTop + originY + marginTop,
257
258
  parentKey: viewKey,
258
259
  width,
259
260
  height,
@@ -34,7 +34,7 @@ const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
34
34
  } = options;
35
35
  const createChildren = (visualData, scale, layout) => {
36
36
  const { x: scaleX, y: scaleY } = scale;
37
- const { paddingLeft, paddingTop } = layout;
37
+ const { paddingLeft, paddingTop, marginLeft, marginTop } = layout;
38
38
  const { domain: domainX } = scaleX.getOptions();
39
39
  const { domain: domainY } = scaleY.getOptions();
40
40
  const index = indexOf(visualData);
@@ -84,10 +84,11 @@ const setChildren = useOverrideAdaptor<G2ViewTree>((options) => {
84
84
  data,
85
85
  parentKey: viewKey,
86
86
  key: `${key}-${i}`,
87
- x: left + paddingLeft + originX,
88
- y: top + paddingTop + originY,
87
+ x: left + paddingLeft + originX + marginLeft,
88
+ y: top + paddingTop + originY + marginTop,
89
89
  width,
90
90
  height,
91
+ margin: 0,
91
92
  paddingLeft: 0,
92
93
  paddingRight: 0,
93
94
  paddingTop: 0,
package/src/index.ts CHANGED
@@ -15,7 +15,15 @@ export {
15
15
  AREA_CLASS_NAME,
16
16
  } from './runtime';
17
17
 
18
- export { corelib, stdlib, litelib, threedlib } from './lib';
18
+ export {
19
+ corelib,
20
+ stdlib,
21
+ litelib,
22
+ graphlib,
23
+ plotlib,
24
+ geolib,
25
+ threedlib,
26
+ } from './lib';
19
27
 
20
28
  export * from './mark';
21
29
 
@@ -26,6 +34,7 @@ export {
26
34
  register,
27
35
  Runtime,
28
36
  extend,
37
+ type ChartOptions,
29
38
  } from './api';
30
39
 
31
40
  export { ChartEvent } from './utils/event';
@@ -2,7 +2,7 @@ import { DisplayObject, Rect, Path } from '@antv/g';
2
2
  import { subObject, omitPrefixObject } from '../utils/helper';
3
3
  import { selectionOf, pixelsOf } from '../utils/scale';
4
4
  import { createElement } from '../utils/createElement';
5
- import { select, Selection } from '../utils/selection';
5
+ import { G2Element, select, Selection } from '../utils/selection';
6
6
  import {
7
7
  selectG2Elements,
8
8
  selectPlotArea,
@@ -333,14 +333,17 @@ function hideRuleY(root) {
333
333
  }
334
334
  }
335
335
 
336
- function updateMarker(root, { data, style, items }) {
336
+ // @todo Fill for composite g component.
337
+ function updateMarker(root, { data, style }) {
337
338
  if (root.markers) root.markers.forEach((d) => d.remove());
338
339
  const markers = data.map((d) => {
339
340
  const [{ color, element }, point] = d;
340
341
  const fill =
341
342
  color || // encode value
342
343
  element.style.fill ||
343
- element.style.stroke;
344
+ element.style.stroke ||
345
+ '#000';
346
+
344
347
  const shape = new Circle({
345
348
  style: {
346
349
  cx: point[0],
@@ -609,7 +612,6 @@ export function seriesTooltip(
609
612
  const markerStyles = subObject(style, 'marker');
610
613
  updateMarker(root, {
611
614
  data: filteredSeriesData,
612
- items: tooltipData.items,
613
615
  style: markerStyles,
614
616
  });
615
617
  }
@@ -0,0 +1,28 @@
1
+ import {
2
+ AxisLinear,
3
+ AxisArc,
4
+ AxisRadar,
5
+ LegendContinuousBlock,
6
+ LegendContinuousBlockSize,
7
+ LegendContinuousSize,
8
+ } from '../component';
9
+ import { Mark, View } from '../composition';
10
+ import { LabelShape } from '../shape';
11
+ import { Event } from '../interaction/event';
12
+
13
+ // Some private visual components, they are not public to
14
+ // users, only for runtime.
15
+ export function builtinlib() {
16
+ return {
17
+ 'component.axisRadar': AxisRadar,
18
+ 'component.axisLinear': AxisLinear,
19
+ 'component.axisArc': AxisArc,
20
+ 'component.legendContinuousBlock': LegendContinuousBlock,
21
+ 'component.legendContinuousBlockSize': LegendContinuousBlockSize,
22
+ 'component.legendContinuousSize': LegendContinuousSize,
23
+ 'interaction.event': Event,
24
+ 'composition.mark': Mark,
25
+ 'composition.view': View,
26
+ 'shape.label.label': LabelShape,
27
+ } as const;
28
+ }
package/src/lib/core.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import {
2
2
  Cartesian,
3
3
  Polar,
4
- Helix,
5
4
  Transpose,
6
5
  Theta,
7
6
  Parallel,
@@ -39,7 +38,7 @@ import {
39
38
  Linear as ScaleLinear,
40
39
  Ordinal as ScaleOrdinal,
41
40
  Band as ScaleBand,
42
- Identity as ScaleIdenity,
41
+ Identity as ScaleIdentity,
43
42
  Point as ScalePoint,
44
43
  Time as ScaleTime,
45
44
  Log as ScaleLog,
@@ -51,18 +50,12 @@ import {
51
50
  Sequential as ScaleSequential,
52
51
  Constant as ScaleConstant,
53
52
  } from '../scale';
54
- import { Classic, ClassicDark, Academy } from '../theme';
53
+ import { Classic, ClassicDark, Academy, Light } from '../theme';
55
54
  import {
56
- AxisLinear,
57
- AxisArc,
58
55
  AxisX,
59
56
  AxisY,
60
- AxisRadar,
61
57
  LegendCategory,
62
58
  LegendContinuous,
63
- LegendContinuousBlock,
64
- LegendContinuousBlockSize,
65
- LegendContinuousSize,
66
59
  TitleComponent,
67
60
  SliderX,
68
61
  SliderY,
@@ -106,14 +99,11 @@ import {
106
99
  BrushYFilter,
107
100
  SliderFilter,
108
101
  Poptip,
109
- Event,
110
102
  ScrollbarFilter,
111
103
  } from '../interaction';
112
104
  import {
113
105
  SpaceLayer,
114
106
  SpaceFlex,
115
- Mark,
116
- View,
117
107
  FacetRect,
118
108
  FacetCircle,
119
109
  RepeatMatrix,
@@ -167,7 +157,6 @@ import {
167
157
  ContrastReverse,
168
158
  OverlapHide,
169
159
  } from '../label-transform';
170
- import { LabelShape } from '../shape';
171
160
 
172
161
  export function corelib() {
173
162
  return {
@@ -211,7 +200,6 @@ export function corelib() {
211
200
  'transform.filter': Filter,
212
201
  'coordinate.cartesian': Cartesian,
213
202
  'coordinate.polar': Polar,
214
- 'coordinate.helix': Helix,
215
203
  'coordinate.transpose': Transpose,
216
204
  'coordinate.theta': Theta,
217
205
  'coordinate.parallel': Parallel,
@@ -244,13 +232,12 @@ export function corelib() {
244
232
  'mark.shape': Shape,
245
233
  'mark.density': Density,
246
234
  'mark.heatmap': Heatmap,
247
- 'shape.label.label': LabelShape,
248
235
  'palette.category10': Category10,
249
236
  'palette.category20': Category20,
250
237
  'scale.linear': ScaleLinear,
251
238
  'scale.ordinal': ScaleOrdinal,
252
239
  'scale.band': ScaleBand,
253
- 'scale.identity': ScaleIdenity,
240
+ 'scale.identity': ScaleIdentity,
254
241
  'scale.point': ScalePoint,
255
242
  'scale.time': ScaleTime,
256
243
  'scale.log': ScaleLog,
@@ -264,16 +251,11 @@ export function corelib() {
264
251
  'theme.classic': Classic,
265
252
  'theme.classicDark': ClassicDark,
266
253
  'theme.academy': Academy,
254
+ 'theme.light': Light,
267
255
  'component.axisX': AxisX,
268
256
  'component.axisY': AxisY,
269
- 'component.axisRadar': AxisRadar,
270
- 'component.axisLinear': AxisLinear,
271
- 'component.axisArc': AxisArc,
272
257
  'component.legendCategory': LegendCategory,
273
258
  'component.legendContinuous': LegendContinuous,
274
- 'component.legendContinuousBlock': LegendContinuousBlock,
275
- 'component.legendContinuousBlockSize': LegendContinuousBlockSize,
276
- 'component.legendContinuousSize': LegendContinuousSize,
277
259
  'component.legends': Legends,
278
260
  'component.title': TitleComponent,
279
261
  'component.sliderX': SliderX,
@@ -314,11 +296,8 @@ export function corelib() {
314
296
  'interaction.sliderFilter': SliderFilter,
315
297
  'interaction.scrollbarFilter': ScrollbarFilter,
316
298
  'interaction.poptip': Poptip,
317
- 'interaction.event': Event,
318
299
  'composition.spaceLayer': SpaceLayer,
319
300
  'composition.spaceFlex': SpaceFlex,
320
- 'composition.mark': Mark,
321
- 'composition.view': View,
322
301
  'composition.facetRect': FacetRect,
323
302
  'composition.repeatMatrix': RepeatMatrix,
324
303
  'composition.facetCircle': FacetCircle,
package/src/lib/graph.ts CHANGED
@@ -1,8 +1,14 @@
1
- import { ForceGraph, Tree } from '../mark';
1
+ import { Sankey, Treemap, Pack, ForceGraph, Tree } from '../mark';
2
+ import { Arc, Cluster } from '../data';
2
3
 
3
4
  export function graphlib() {
4
5
  return {
6
+ 'data.arc': Arc,
7
+ 'data.cluster': Cluster,
5
8
  'mark.forceGraph': ForceGraph,
6
9
  'mark.tree': Tree,
10
+ 'mark.pack': Pack,
11
+ 'mark.sankey': Sankey,
12
+ 'mark.treemap': Treemap,
7
13
  } as const;
8
14
  }
package/src/lib/plot.ts CHANGED
@@ -1,15 +1,10 @@
1
- import { Sankey, Treemap, Pack, Boxplot, WordCloud, Gauge } from '../mark';
2
- import { Arc, Cluster, Venn } from '../data';
1
+ import { Boxplot, WordCloud, Gauge } from '../mark';
2
+ import { Venn } from '../data';
3
3
 
4
4
  export function plotlib() {
5
5
  return {
6
6
  'data.venn': Venn,
7
- 'data.arc': Arc,
8
- 'data.cluster': Cluster,
9
- 'mark.sankey': Sankey,
10
- 'mark.treemap': Treemap,
11
7
  'mark.boxplot': Boxplot,
12
- 'mark.pack': Pack,
13
8
  'mark.gauge': Gauge,
14
9
  'mark.wordCloud': WordCloud,
15
10
  } as const;
package/src/lib/threed.ts CHANGED
@@ -1,11 +1,12 @@
1
1
  import { Cartesian3D } from '../coordinate';
2
2
  import { AxisZ } from '../component';
3
- import { Point3D } from '../mark';
3
+ import { Point3D, Line3D } from '../mark';
4
4
 
5
5
  export function threedlib() {
6
6
  return {
7
7
  'coordinate.cartesian3D': Cartesian3D,
8
8
  'component.axisZ': AxisZ,
9
9
  'mark.point3D': Point3D,
10
+ 'mark.line3D': Line3D,
10
11
  } as const;
11
12
  }
package/src/mark/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { Interval } from './interval';
2
2
  export { Rect } from './rect';
3
3
  export { Line } from './line';
4
+ export { Line3D } from './line3D';
4
5
  export { Point } from './point';
5
6
  export { Point3D } from './point3D';
6
7
  export { Text } from './text';
@@ -0,0 +1,81 @@
1
+ import { group } from 'd3-array';
2
+ import { Mark, MarkComponent as MC, SingleMark, Vector3 } from '../runtime';
3
+ import { LineMark } from '../spec';
4
+ import { Line3DShape } from '../shape';
5
+ import { MaybeSeries } from '../transform';
6
+ import {
7
+ baseGeometryChannels,
8
+ basePostInference,
9
+ basePreInference,
10
+ tooltip3d,
11
+ } from './utils';
12
+
13
+ const shape = {
14
+ line: Line3DShape,
15
+ };
16
+
17
+ export type LineOptions = Omit<LineMark, 'type'>;
18
+
19
+ const line: Mark = (index, scale, value, coordinate) => {
20
+ const { series: S, x: X, y: Y, z: Z } = value;
21
+ const { x, y, z } = scale;
22
+
23
+ // Because x and y channel is not strictly required in Line.props,
24
+ // it should throw error with empty x, y or z channels.
25
+ if (X === undefined || Y === undefined || Z === undefined) {
26
+ throw new Error('Missing encode for x, y or z channel.');
27
+ }
28
+
29
+ // Group data into series.
30
+ // There is only one series without specified series encode.
31
+ const series = S ? Array.from(group(index, (i) => S[i]).values()) : [index];
32
+ const I = series.map((group) => group[0]).filter((i) => i !== undefined);
33
+
34
+ // A group of data corresponds to one line.
35
+ const xoffset = (x?.getBandWidth?.() || 0) / 2;
36
+ const yoffset = (y?.getBandWidth?.() || 0) / 2;
37
+ const zoffset = (z?.getBandWidth?.() || 0) / 2;
38
+ const P = Array.from(series, (I) => {
39
+ return I.map((i) =>
40
+ coordinate.map([
41
+ (+X[i] || 0) + xoffset,
42
+ (+Y[i] || 0) + yoffset,
43
+ (+Z[i] || 0) + zoffset,
44
+ ]),
45
+ ) as Vector3[];
46
+ });
47
+ return [I, P, series];
48
+ };
49
+
50
+ /**
51
+ * Convert value for each channel to line shapes.
52
+ */
53
+ export const Line3D: MC<LineOptions> = () => {
54
+ return (index, scale, value, coordinate) => {
55
+ const mark = line;
56
+ return (mark as SingleMark)(index, scale, value, coordinate);
57
+ };
58
+ };
59
+
60
+ Line3D.props = {
61
+ defaultShape: 'line',
62
+ defaultLabelShape: 'label',
63
+ composite: false,
64
+ shape,
65
+ channels: [
66
+ ...baseGeometryChannels({ shapes: Object.keys(shape) }),
67
+ { name: 'x' },
68
+ { name: 'y' },
69
+ { name: 'z' },
70
+ { name: 'position', independent: true },
71
+ { name: 'size' },
72
+ { name: 'series', scale: 'identity' },
73
+ ],
74
+ preInference: [...basePreInference(), { type: MaybeSeries }],
75
+ postInference: [...basePostInference(), ...tooltip3d()],
76
+ interaction: {
77
+ shareTooltip: false,
78
+ seriesTooltip: false,
79
+ crosshairs: false,
80
+ },
81
+ };