@antv/g2 5.1.6-beta.1 → 5.1.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 (128) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +2 -2
  3. package/README.zh-CN.md +1 -1
  4. package/dist/g2.full.min.js +1 -1
  5. package/dist/g2.lite.min.js +1 -1
  6. package/dist/g2.min.js +1 -1
  7. package/esm/animation/growInX.js +0 -4
  8. package/esm/animation/growInX.js.map +1 -1
  9. package/esm/animation/growInY.js +0 -4
  10. package/esm/animation/growInY.js.map +1 -1
  11. package/esm/animation/scaleInX.js +5 -7
  12. package/esm/animation/scaleInX.js.map +1 -1
  13. package/esm/animation/scaleInY.js +5 -7
  14. package/esm/animation/scaleInY.js.map +1 -1
  15. package/esm/animation/scaleOutX.js +5 -7
  16. package/esm/animation/scaleOutX.js.map +1 -1
  17. package/esm/animation/scaleOutY.js +5 -7
  18. package/esm/animation/scaleOutY.js.map +1 -1
  19. package/esm/animation/zoomIn.js +4 -5
  20. package/esm/animation/zoomIn.js.map +1 -1
  21. package/esm/animation/zoomOut.js +4 -6
  22. package/esm/animation/zoomOut.js.map +1 -1
  23. package/esm/api/utils.d.ts +6 -2
  24. package/esm/api/utils.js +18 -6
  25. package/esm/api/utils.js.map +1 -1
  26. package/esm/exports.d.ts +1 -0
  27. package/esm/exports.js +1 -0
  28. package/esm/exports.js.map +1 -1
  29. package/esm/interaction/utils.js +1 -5
  30. package/esm/interaction/utils.js.map +1 -1
  31. package/esm/lib/index.d.ts +0 -1
  32. package/esm/lib/index.js +0 -1
  33. package/esm/lib/index.js.map +1 -1
  34. package/esm/mark/index.d.ts +0 -1
  35. package/esm/mark/index.js +0 -1
  36. package/esm/mark/index.js.map +1 -1
  37. package/esm/runtime/component.js +4 -2
  38. package/esm/runtime/component.js.map +1 -1
  39. package/esm/runtime/layout.js +7 -1
  40. package/esm/runtime/layout.js.map +1 -1
  41. package/esm/shape/interval/color.d.ts +4 -0
  42. package/esm/shape/interval/color.js +10 -7
  43. package/esm/shape/interval/color.js.map +1 -1
  44. package/esm/shape/interval/rect.d.ts +4 -0
  45. package/esm/shape/interval/rect.js.map +1 -1
  46. package/esm/shape/line/smooth.js +8 -4
  47. package/esm/shape/line/smooth.js.map +1 -1
  48. package/esm/theme/create.d.ts +1 -4
  49. package/esm/theme/create.js +1 -4
  50. package/esm/theme/create.js.map +1 -1
  51. package/lib/animation/growInX.js +0 -4
  52. package/lib/animation/growInX.js.map +1 -1
  53. package/lib/animation/growInY.js +0 -4
  54. package/lib/animation/growInY.js.map +1 -1
  55. package/lib/animation/scaleInX.js +5 -7
  56. package/lib/animation/scaleInX.js.map +1 -1
  57. package/lib/animation/scaleInY.js +5 -7
  58. package/lib/animation/scaleInY.js.map +1 -1
  59. package/lib/animation/scaleOutX.js +5 -7
  60. package/lib/animation/scaleOutX.js.map +1 -1
  61. package/lib/animation/scaleOutY.js +5 -7
  62. package/lib/animation/scaleOutY.js.map +1 -1
  63. package/lib/animation/zoomIn.js +4 -5
  64. package/lib/animation/zoomIn.js.map +1 -1
  65. package/lib/animation/zoomOut.js +4 -6
  66. package/lib/animation/zoomOut.js.map +1 -1
  67. package/lib/api/utils.d.ts +6 -2
  68. package/lib/api/utils.js +19 -7
  69. package/lib/api/utils.js.map +1 -1
  70. package/lib/exports.d.ts +1 -0
  71. package/lib/exports.js +7 -1
  72. package/lib/exports.js.map +1 -1
  73. package/lib/interaction/utils.js +1 -5
  74. package/lib/interaction/utils.js.map +1 -1
  75. package/lib/lib/index.d.ts +0 -1
  76. package/lib/lib/index.js +1 -3
  77. package/lib/lib/index.js.map +1 -1
  78. package/lib/mark/index.d.ts +0 -1
  79. package/lib/mark/index.js +1 -3
  80. package/lib/mark/index.js.map +1 -1
  81. package/lib/runtime/component.js +4 -2
  82. package/lib/runtime/component.js.map +1 -1
  83. package/lib/runtime/layout.js +7 -1
  84. package/lib/runtime/layout.js.map +1 -1
  85. package/lib/shape/interval/color.d.ts +4 -0
  86. package/lib/shape/interval/color.js +10 -7
  87. package/lib/shape/interval/color.js.map +1 -1
  88. package/lib/shape/interval/rect.d.ts +4 -0
  89. package/lib/shape/interval/rect.js.map +1 -1
  90. package/lib/shape/line/smooth.js +6 -2
  91. package/lib/shape/line/smooth.js.map +1 -1
  92. package/lib/theme/create.d.ts +1 -4
  93. package/lib/theme/create.js +1 -4
  94. package/lib/theme/create.js.map +1 -1
  95. package/package.json +4 -4
  96. package/src/animation/growInX.ts +1 -6
  97. package/src/animation/growInY.ts +1 -6
  98. package/src/animation/scaleInX.ts +8 -11
  99. package/src/animation/scaleInY.ts +8 -11
  100. package/src/animation/scaleOutX.ts +8 -11
  101. package/src/animation/scaleOutY.ts +8 -11
  102. package/src/animation/zoomIn.ts +4 -6
  103. package/src/animation/zoomOut.ts +4 -7
  104. package/src/api/utils.ts +28 -6
  105. package/src/exports.ts +2 -0
  106. package/src/interaction/utils.ts +1 -5
  107. package/src/lib/index.ts +0 -1
  108. package/src/mark/index.ts +0 -1
  109. package/src/runtime/component.ts +10 -2
  110. package/src/runtime/layout.ts +6 -1
  111. package/src/shape/interval/color.ts +16 -4
  112. package/src/shape/interval/rect.ts +5 -0
  113. package/src/shape/line/smooth.ts +12 -4
  114. package/src/theme/create.ts +1 -4
  115. package/esm/lib/auto.d.ts +0 -3
  116. package/esm/lib/auto.js +0 -7
  117. package/esm/lib/auto.js.map +0 -1
  118. package/esm/mark/auto.d.ts +0 -1
  119. package/esm/mark/auto.js +0 -26
  120. package/esm/mark/auto.js.map +0 -1
  121. package/lib/lib/auto.d.ts +0 -3
  122. package/lib/lib/auto.js +0 -11
  123. package/lib/lib/auto.js.map +0 -1
  124. package/lib/mark/auto.d.ts +0 -1
  125. package/lib/mark/auto.js +0 -30
  126. package/lib/mark/auto.js.map +0 -1
  127. package/src/lib/auto.ts +0 -7
  128. package/src/mark/auto.ts +0 -22
@@ -1,4 +1,4 @@
1
- import { IAnimation, Path } from '@antv/g';
1
+ import { Path } from '@antv/g';
2
2
  import { AnimationComponent as AC } from '../runtime';
3
3
  import { Animation } from './types';
4
4
  import { ScaleInX } from './scaleInX';
@@ -22,11 +22,6 @@ export const GrowInX: AC<GrowInXOptions> = (options, context) => {
22
22
 
23
23
  const animation = ScaleInX(options, context)([clipPath], to, defaults);
24
24
 
25
- (animation as IAnimation).finished.then(() => {
26
- clipPath.remove();
27
- shape.style.clipPath = null;
28
- });
29
-
30
25
  return animation;
31
26
  };
32
27
  };
@@ -1,4 +1,4 @@
1
- import { IAnimation, Path } from '@antv/g';
1
+ import { Path } from '@antv/g';
2
2
  import { AnimationComponent as AC } from '../runtime';
3
3
  import { Animation } from './types';
4
4
  import { ScaleInY } from './scaleInY';
@@ -22,11 +22,6 @@ export const GrowInY: AC<GrowInYOptions> = (options, context) => {
22
22
 
23
23
  const animation = ScaleInY(options, context)([clipPath], to, defaults);
24
24
 
25
- (animation as IAnimation).finished.then(() => {
26
- clipPath.remove();
27
- shape.style.clipPath = null;
28
- });
29
-
30
25
  return animation;
31
26
  };
32
27
  };
@@ -16,29 +16,31 @@ export const ScaleInX: AC<ScaleInXOptions> = (options, context) => {
16
16
 
17
17
  return (from, _, defaults) => {
18
18
  const [shape] = from;
19
- const { height } = shape.getBoundingClientRect();
20
19
  const {
21
20
  transform: prefix = '',
22
21
  fillOpacity = 1,
23
22
  strokeOpacity = 1,
24
23
  opacity = 1,
25
24
  } = shape.style;
26
- const [transformOrigin, transform]: [[number, number], string] =
27
- isTranspose(coordinate)
28
- ? [[0, height], `scale(1, ${ZERO})`] // left-bottom corner
29
- : [[0, 0], `scale(${ZERO}, 1)`]; // left-top corner
25
+ const [transformOrigin, transform]: [string, string] = isTranspose(
26
+ coordinate,
27
+ )
28
+ ? [`left bottom`, `scale(1, ${ZERO})`] // left-bottom corner
29
+ : [`left top`, `scale(${ZERO}, 1)`]; // left-top corner
30
30
 
31
31
  // Using a short fadeIn transition to hide element with scale(0.001)
32
32
  // which is still visible.
33
33
  const keyframes = [
34
34
  {
35
35
  transform: `${prefix} ${transform}`.trimStart(),
36
+ transformOrigin,
36
37
  fillOpacity: 0,
37
38
  strokeOpacity: 0,
38
39
  opacity: 0,
39
40
  },
40
41
  {
41
42
  transform: `${prefix} ${transform}`.trimStart(),
43
+ transformOrigin,
42
44
  fillOpacity,
43
45
  strokeOpacity,
44
46
  opacity,
@@ -46,20 +48,15 @@ export const ScaleInX: AC<ScaleInXOptions> = (options, context) => {
46
48
  },
47
49
  {
48
50
  transform: `${prefix} scale(1, 1)`.trimStart(),
51
+ transformOrigin,
49
52
  fillOpacity,
50
53
  strokeOpacity,
51
54
  opacity,
52
55
  },
53
56
  ];
54
57
 
55
- // Change transform origin for correct transform.
56
- shape.setOrigin(transformOrigin);
57
-
58
58
  const animation = shape.animate(keyframes, { ...defaults, ...options });
59
59
 
60
- // Reset transform origin to eliminate side effect for following animations.
61
- animation.finished.then(() => shape.setOrigin(0, 0));
62
-
63
60
  return animation;
64
61
  };
65
62
  };
@@ -16,29 +16,31 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
16
16
 
17
17
  return (from, _, defaults) => {
18
18
  const [shape] = from;
19
- const { height } = shape.getBoundingClientRect();
20
19
  const {
21
20
  transform: prefix = '',
22
21
  fillOpacity = 1,
23
22
  strokeOpacity = 1,
24
23
  opacity = 1,
25
24
  } = shape.style;
26
- const [transformOrigin, transform]: [[number, number], string] =
27
- isTranspose(coordinate)
28
- ? [[0, 0], `scale(${ZERO}, 1)`] // left-top corner
29
- : [[0, height], `scale(1, ${ZERO})`]; // left-bottom corner
25
+ const [transformOrigin, transform]: [string, string] = isTranspose(
26
+ coordinate,
27
+ )
28
+ ? [`left top`, `scale(${ZERO}, 1)`] // left-top corner
29
+ : [`left bottom`, `scale(1, ${ZERO})`]; // left-bottom corner
30
30
 
31
31
  // Using a short fadeIn transition to hide element with scale(0.001)
32
32
  // which is still visible.
33
33
  const keyframes = [
34
34
  {
35
35
  transform: `${prefix} ${transform}`.trimStart(),
36
+ transformOrigin,
36
37
  fillOpacity: 0,
37
38
  strokeOpacity: 0,
38
39
  opacity: 0,
39
40
  },
40
41
  {
41
42
  transform: `${prefix} ${transform}`.trimStart(),
43
+ transformOrigin,
42
44
  fillOpacity,
43
45
  strokeOpacity,
44
46
  opacity,
@@ -46,20 +48,15 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
46
48
  },
47
49
  {
48
50
  transform: `${prefix} scale(1, 1)`.trimStart(),
51
+ transformOrigin,
49
52
  fillOpacity,
50
53
  strokeOpacity,
51
54
  opacity,
52
55
  },
53
56
  ];
54
57
 
55
- // Change transform origin for correct transform.
56
- shape.setOrigin(transformOrigin);
57
-
58
58
  const animation = shape.animate(keyframes, { ...defaults, ...options });
59
59
 
60
- // Reset transform origin to eliminate side effect for following animations.
61
- animation.finished.then(() => shape.setOrigin(0, 0));
62
-
63
60
  return animation;
64
61
  };
65
62
  };
@@ -16,26 +16,28 @@ export const ScaleOutX: AC<ScaleOutXOptions> = (options, context) => {
16
16
 
17
17
  return (from, _, defaults) => {
18
18
  const [shape] = from;
19
- const { height } = shape.getBoundingClientRect();
20
19
  const {
21
20
  transform: prefix = '',
22
21
  fillOpacity = 1,
23
22
  strokeOpacity = 1,
24
23
  opacity = 1,
25
24
  } = shape.style;
26
- const [transformOrigin, transform]: [[number, number], string] =
27
- isTranspose(coordinate)
28
- ? [[0, height], `scale(1, ${ZERO})`] // left-bottom corner
29
- : [[0, 0], `scale(${ZERO}, 1)`]; // left-top corner
25
+ const [transformOrigin, transform]: [string, string] = isTranspose(
26
+ coordinate,
27
+ )
28
+ ? [`left bottom`, `scale(1, ${ZERO})`] // left-bottom corner
29
+ : [`left top`, `scale(${ZERO}, 1)`]; // left-top corner
30
30
 
31
31
  // Using a short fadeIn transition to hide element with scale(0.001)
32
32
  // which is still visible.
33
33
  const keyframes = [
34
34
  {
35
35
  transform: `${prefix} scale(1, 1)`.trimStart(),
36
+ transformOrigin,
36
37
  },
37
38
  {
38
39
  transform: `${prefix} ${transform}`.trimStart(),
40
+ transformOrigin,
39
41
  fillOpacity,
40
42
  strokeOpacity,
41
43
  opacity,
@@ -43,20 +45,15 @@ export const ScaleOutX: AC<ScaleOutXOptions> = (options, context) => {
43
45
  },
44
46
  {
45
47
  transform: `${prefix} ${transform}`.trimStart(),
48
+ transformOrigin,
46
49
  fillOpacity: 0,
47
50
  strokeOpacity: 0,
48
51
  opacity: 0,
49
52
  },
50
53
  ];
51
54
 
52
- // Change transform origin for correct transform.
53
- shape.setOrigin(transformOrigin);
54
-
55
55
  const animation = shape.animate(keyframes, { ...defaults, ...options });
56
56
 
57
- // Reset transform origin to eliminate side effect for following animations.
58
- animation.finished.then(() => shape.setOrigin(0, 0));
59
-
60
57
  return animation;
61
58
  };
62
59
  };
@@ -16,26 +16,28 @@ export const ScaleOutY: AC<ScaleOutYOptions> = (options, context) => {
16
16
 
17
17
  return (from, _, defaults) => {
18
18
  const [shape] = from;
19
- const { height } = shape.getBoundingClientRect();
20
19
  const {
21
20
  transform: prefix = '',
22
21
  fillOpacity = 1,
23
22
  strokeOpacity = 1,
24
23
  opacity = 1,
25
24
  } = shape.style;
26
- const [transformOrigin, transform]: [[number, number], string] =
27
- isTranspose(coordinate)
28
- ? [[0, 0], `scale(${ZERO}, 1)`] // left-top corner
29
- : [[0, height], `scale(1, ${ZERO})`]; // left-bottom corner
25
+ const [transformOrigin, transform]: [string, string] = isTranspose(
26
+ coordinate,
27
+ )
28
+ ? [`left top`, `scale(${ZERO}, 1)`] // left-top corner
29
+ : [`left bottom`, `scale(1, ${ZERO})`]; // left-bottom corner
30
30
 
31
31
  // Using a short fadeIn transition to hide element with scale(0.001)
32
32
  // which is still visible.
33
33
  const keyframes = [
34
34
  {
35
35
  transform: `${prefix} scale(1, 1)`.trimStart(),
36
+ transformOrigin,
36
37
  },
37
38
  {
38
39
  transform: `${prefix} ${transform}`.trimStart(),
40
+ transformOrigin,
39
41
  fillOpacity,
40
42
  strokeOpacity,
41
43
  opacity,
@@ -43,20 +45,15 @@ export const ScaleOutY: AC<ScaleOutYOptions> = (options, context) => {
43
45
  },
44
46
  {
45
47
  transform: `${prefix} ${transform}`.trimStart(),
48
+ transformOrigin,
46
49
  fillOpacity: 0,
47
50
  strokeOpacity: 0,
48
51
  opacity: 0,
49
52
  },
50
53
  ];
51
54
 
52
- // Change transform origin for correct transform.
53
- shape.setOrigin(transformOrigin);
54
-
55
55
  const animation = shape.animate(keyframes, { ...defaults, ...options });
56
56
 
57
- // Reset transform origin to eliminate side effect for following animations.
58
- animation.finished.then(() => shape.setOrigin(0, 0));
59
-
60
57
  return animation;
61
58
  };
62
59
  };
@@ -16,15 +16,18 @@ export const ZoomIn: AC<ZoomInOptions> = (options) => {
16
16
  strokeOpacity = 1,
17
17
  opacity = 1,
18
18
  } = shape.style;
19
+ const transformOrigin = 'center center';
19
20
  const keyframes = [
20
21
  {
21
22
  transform: `${prefix} scale(${ZERO})`.trimStart(),
23
+ transformOrigin,
22
24
  fillOpacity: 0,
23
25
  strokeOpacity: 0,
24
26
  opacity: 0,
25
27
  },
26
28
  {
27
29
  transform: `${prefix} scale(${ZERO})`.trimStart(),
30
+ transformOrigin,
28
31
  fillOpacity,
29
32
  strokeOpacity,
30
33
  opacity,
@@ -32,20 +35,15 @@ export const ZoomIn: AC<ZoomInOptions> = (options) => {
32
35
  },
33
36
  {
34
37
  transform: `${prefix} scale(1)`.trimStart(),
38
+ transformOrigin,
35
39
  fillOpacity,
36
40
  strokeOpacity,
37
41
  opacity,
38
42
  },
39
43
  ];
40
- const { width, height } = shape.getBoundingClientRect();
41
- // Change transform origin for correct transform.
42
- shape.setOrigin([width / 2, height / 2]);
43
44
 
44
45
  const animation = shape.animate(keyframes, { ...defaults, ...options });
45
46
 
46
- // Reset transform origin to eliminate side effect for following animations.
47
- animation.finished.then(() => shape.setOrigin(0, 0));
48
-
49
47
  return animation;
50
48
  };
51
49
  };
@@ -16,10 +16,12 @@ export const ZoomOut: AC<ZoomOutOptions> = (options) => {
16
16
  strokeOpacity = 1,
17
17
  opacity = 1,
18
18
  } = shape.style;
19
+ const transformOrigin = 'center center';
19
20
  const keyframes = [
20
- { transform: `${prefix} scale(1)`.trimStart() },
21
+ { transform: `${prefix} scale(1)`.trimStart(), transformOrigin },
21
22
  {
22
23
  transform: `${prefix} scale(${ZERO})`.trimStart(),
24
+ transformOrigin,
23
25
  fillOpacity,
24
26
  strokeOpacity,
25
27
  opacity,
@@ -27,20 +29,15 @@ export const ZoomOut: AC<ZoomOutOptions> = (options) => {
27
29
  },
28
30
  {
29
31
  transform: `${prefix} scale(${ZERO})`.trimStart(),
32
+ transformOrigin,
30
33
  fillOpacity: 0,
31
34
  strokeOpacity: 0,
32
35
  opacity: 0,
33
36
  },
34
37
  ];
35
38
 
36
- const { width, height } = shape.getBoundingClientRect();
37
- // Change transform origin for correct transform.
38
- shape.setOrigin([width / 2, height / 2]);
39
39
  const animation = shape.animate(keyframes, { ...defaults, ...options });
40
40
 
41
- // Reset transform origin to eliminate side effect for following animations.
42
- animation.finished.then(() => shape.setOrigin(0, 0));
43
-
44
41
  return animation;
45
42
  };
46
43
  };
package/src/api/utils.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { isNumber } from '@antv/util';
1
2
  import { G2ViewTree } from '../runtime';
2
3
  import { getContainerSize } from '../utils/size';
3
4
  import { deepAssign } from '../utils/helper';
@@ -33,6 +34,11 @@ export const REMOVE_FLAG = '__remove__';
33
34
 
34
35
  export const CALLBACK_NODE = '__callback__';
35
36
 
37
+ /** Minimum chart width */
38
+ export const MIN_CHART_WIDTH = 1;
39
+ /** Minimum chart height */
40
+ export const MIN_CHART_HEIGHT = 1;
41
+
36
42
  export function normalizeContainer(
37
43
  container: string | HTMLElement,
38
44
  ): HTMLElement {
@@ -70,12 +76,28 @@ export function valueOf(node: Node): Record<string, any> {
70
76
  }
71
77
 
72
78
  export function sizeOf(options, container) {
73
- const { autoFit } = options;
74
- const { width = 640, height = 480 } = autoFit
75
- ? getContainerSize(container)
76
- : options;
77
- const { depth = 0 } = options;
78
- return { width, height, depth };
79
+ const { width = 640, height = 480, autoFit, depth = 0 } = options;
80
+ let effectiveWidth = width;
81
+ let effectiveHeight = height;
82
+
83
+ if (autoFit) {
84
+ const { width: containerWidth, height: containerHeight } =
85
+ getContainerSize(container);
86
+ effectiveWidth = containerWidth || effectiveWidth;
87
+ effectiveHeight = containerHeight || effectiveHeight;
88
+ }
89
+
90
+ return {
91
+ width: Math.max(
92
+ isNumber(effectiveWidth) ? effectiveWidth : MIN_CHART_WIDTH,
93
+ MIN_CHART_WIDTH,
94
+ ),
95
+ height: Math.max(
96
+ isNumber(effectiveHeight) ? effectiveHeight : MIN_CHART_HEIGHT,
97
+ MIN_CHART_HEIGHT,
98
+ ),
99
+ depth,
100
+ };
79
101
  }
80
102
 
81
103
  export function optionsOf(node: Node): Record<string, any> {
package/src/exports.ts CHANGED
@@ -30,3 +30,5 @@ export { ChartEvent } from './utils/event';
30
30
  export type { G2Context } from './runtime';
31
31
 
32
32
  export * from './spec';
33
+
34
+ export { Light, Dark, Academy, Classic, ClassicDark } from './theme';
@@ -82,11 +82,7 @@ export function createColorKey(view) {
82
82
  }
83
83
 
84
84
  export function createXKey(view) {
85
- const { x: scaleX } = view.scale;
86
- return (element) => {
87
- const { x } = element.__data__;
88
- return scaleX.invert(x);
89
- };
85
+ return (element) => element.__data__.x;
90
86
  }
91
87
 
92
88
  export function createDatumof(view: G2ViewDescriptor | G2ViewDescriptor[]) {
package/src/lib/index.ts CHANGED
@@ -5,4 +5,3 @@ 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';
package/src/mark/index.ts CHANGED
@@ -32,7 +32,6 @@ 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';
36
35
 
37
36
  export type { IntervalOptions } from './interval';
38
37
  export type { RectOptions } from './rect';
@@ -710,7 +710,13 @@ function computeAxisSize(
710
710
 
711
711
  // Get styles to be applied.
712
712
  const style = styleOf(component, position, theme);
713
- const { tickLength = 0, labelSpacing = 0, titleSpacing = 0, ...rest } = style;
713
+ const {
714
+ tickLength = 0,
715
+ labelSpacing = 0,
716
+ titleSpacing = 0,
717
+ labelAutoRotate,
718
+ ...rest
719
+ } = style;
714
720
 
715
721
  // Compute Labels.
716
722
  const scale = createScale(component, library);
@@ -727,7 +733,9 @@ function computeAxisSize(
727
733
  // rotate 90 deg to display them.
728
734
  if (
729
735
  overflowX(scale, labelBBoxes, crossSize, crossPadding, tickFilter) &&
730
- !labelTransform
736
+ !labelTransform &&
737
+ labelAutoRotate !== false &&
738
+ labelAutoRotate !== null
731
739
  ) {
732
740
  component.labelTransform = 'rotate(90)';
733
741
  component.size = maxLabelWidth + paddingTick;
@@ -311,7 +311,6 @@ function computePadding(
311
311
 
312
312
  for (const position of positions) {
313
313
  const key = `padding${capitalizeFirst(camelCase(position))}`;
314
- const insetKey = `inset${capitalizeFirst(camelCase(position))}`;
315
314
  const components = positionComponents.get(position) || [];
316
315
  const value = layout[key];
317
316
  const defaultSizeOf = (d) => {
@@ -342,6 +341,11 @@ function computePadding(
342
341
  }
343
342
  };
344
343
 
344
+ const maybeHide = (d) => {
345
+ if (!d.type.startsWith('axis')) return;
346
+ if (d.labelAutoHide === undefined) d.labelAutoHide = true;
347
+ };
348
+
345
349
  const isHorizontal = position === 'bottom' || position === 'top';
346
350
 
347
351
  // !!!Note
@@ -356,6 +360,7 @@ function computePadding(
356
360
  // Specified padding.
357
361
  if (typeof value === 'number') {
358
362
  components.forEach(defaultSizeOf);
363
+ components.forEach(maybeHide);
359
364
  } else {
360
365
  // Compute padding dynamically.
361
366
  if (components.length === 0) {
@@ -16,6 +16,12 @@ export type ColorOptions = {
16
16
  * Maximum width of each interval.
17
17
  */
18
18
  maxWidth?: number;
19
+
20
+ /**
21
+ * Minimum height of each interval.
22
+ */
23
+ minHeight?: number;
24
+
19
25
  [key: string]: any;
20
26
  };
21
27
 
@@ -40,6 +46,7 @@ export function rect(
40
46
  radiusTopRight = radius,
41
47
  minWidth = -Infinity,
42
48
  maxWidth = Infinity,
49
+ minHeight = -Infinity,
43
50
  ...rest
44
51
  } = style;
45
52
  if (!isPolar(coordinate) && !isHelix(coordinate)) {
@@ -51,6 +58,7 @@ export function rect(
51
58
  // Deal with width or height is negative.
52
59
  const absX = width > 0 ? x : x + width;
53
60
  const absY = height > 0 ? y : y + height;
61
+
54
62
  const absWidth = Math.abs(width);
55
63
  const absHeight = Math.abs(height);
56
64
  const finalX = absX + insetLeft;
@@ -59,13 +67,15 @@ export function rect(
59
67
  const finalHeight = absHeight - (insetTop + insetBottom);
60
68
 
61
69
  const clampWidth = tpShape
62
- ? finalWidth
70
+ ? clamp(finalWidth, minHeight, Infinity)
63
71
  : clamp(finalWidth, minWidth, maxWidth);
64
72
  const clampHeight = tpShape
65
73
  ? clamp(finalHeight, minWidth, maxWidth)
66
- : finalHeight;
67
- const clampX = finalX - (clampWidth - finalWidth) / 2;
68
- const clampY = finalY - (clampHeight - finalHeight) / 2;
74
+ : clamp(finalHeight, minHeight, Infinity);
75
+ const clampX = tpShape ? finalX : finalX - (clampWidth - finalWidth) / 2;
76
+ const clampY = tpShape
77
+ ? finalY - (clampHeight - finalHeight) / 2
78
+ : finalY - (clampHeight - finalHeight);
69
79
 
70
80
  return select(document.createElement('rect', {}))
71
81
  .style('x', clampX)
@@ -145,6 +155,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
145
155
  insetTop = inset,
146
156
  minWidth,
147
157
  maxWidth,
158
+ minHeight,
148
159
  ...rest
149
160
  } = style;
150
161
  const { color = defaultColor, opacity } = value;
@@ -179,6 +190,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
179
190
  insetTop,
180
191
  minWidth,
181
192
  maxWidth,
193
+ minHeight,
182
194
  };
183
195
 
184
196
  return (
@@ -10,6 +10,11 @@ export type RectOptions = {
10
10
  * Maximum width of each interval.
11
11
  */
12
12
  maxWidth?: number;
13
+
14
+ /**
15
+ * Minimum height of each interval.
16
+ */
17
+ minHeight?: number;
13
18
  };
14
19
 
15
20
  /**
@@ -1,5 +1,9 @@
1
- import { curveCatmullRom, curveCatmullRomClosed } from 'd3-shape';
2
- import { isPolar } from '../../utils/coordinate';
1
+ import {
2
+ curveMonotoneX,
3
+ curveMonotoneY,
4
+ curveCatmullRomClosed,
5
+ } from 'd3-shape';
6
+ import { isPolar, isTranspose } from '../../utils/coordinate';
3
7
  import { ShapeComponent as SC } from '../../runtime';
4
8
  import { Curve } from './curve';
5
9
 
@@ -11,8 +15,12 @@ export const Smooth: SC<SmoothOptions> = (options, context) => {
11
15
  const { alpha = 0.5, ...rest } = options;
12
16
  const { coordinate } = context;
13
17
  return (...params) => {
14
- const curve = isPolar(coordinate) ? curveCatmullRomClosed : curveCatmullRom;
15
- return Curve({ curve: curve.alpha(alpha), ...rest }, context)(...params);
18
+ const curve = isPolar(coordinate)
19
+ ? curveCatmullRomClosed
20
+ : isTranspose(coordinate)
21
+ ? curveMonotoneY
22
+ : curveMonotoneX;
23
+ return Curve({ curve: curve, ...rest }, context)(...params);
16
24
  };
17
25
  };
18
26
 
@@ -51,6 +51,7 @@ export function create({
51
51
  fill: '',
52
52
  strokeOpacity: 1,
53
53
  lineWidth: 1,
54
+ lineCap: 'round',
54
55
  },
55
56
  },
56
57
  point: {
@@ -236,7 +237,6 @@ export function create({
236
237
  labelDirection: 'negative',
237
238
  tickDirection: 'negative',
238
239
  titlePosition: 'top',
239
- labelAutoRotate: false,
240
240
  titleSpacing: 12,
241
241
  labelSpacing: 4,
242
242
  titleTextBaseline: 'middle',
@@ -244,7 +244,6 @@ export function create({
244
244
  axisBottom: {
245
245
  gridDirection: 'negative',
246
246
  labelDirection: 'positive',
247
- labelAutoRotate: false,
248
247
  tickDirection: 'positive',
249
248
  titlePosition: 'bottom',
250
249
  titleSpacing: 12,
@@ -253,7 +252,6 @@ export function create({
253
252
  },
254
253
  axisLeft: {
255
254
  gridDirection: 'positive',
256
- labelAutoRotate: false,
257
255
  labelDirection: 'negative',
258
256
  labelSpacing: 4,
259
257
  tickDirection: 'negative',
@@ -269,7 +267,6 @@ export function create({
269
267
  labelSpacing: 4,
270
268
  tickDirection: 'positive',
271
269
  titlePosition: 'right',
272
- labelAutoRotate: false,
273
270
  titleSpacing: 12,
274
271
  titleTextBaseline: 'top',
275
272
  titleDirection: 'vertical',
package/esm/lib/auto.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export declare function autolib(): {
2
- readonly 'mark.auto': (options: any) => any;
3
- };
package/esm/lib/auto.js DELETED
@@ -1,7 +0,0 @@
1
- import { Auto } from '../mark/auto';
2
- export function autolib() {
3
- return {
4
- 'mark.auto': Auto,
5
- };
6
- }
7
- //# sourceMappingURL=auto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auto.js","sourceRoot":"src/","sources":["lib/auto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAU,OAAO;IACrB,OAAO;QACL,WAAW,EAAE,IAAI;KACT,CAAC;AACb,CAAC"}
@@ -1 +0,0 @@
1
- export declare const Auto: (options: any) => any;