@antv/g2 5.1.6 → 5.1.8-beta.1

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 (265) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +1 -1
  3. package/dist/g2.full.min.js +1 -1
  4. package/dist/g2.lite.min.js +1 -1
  5. package/dist/g2.min.js +1 -1
  6. package/esm/animation/growInX.js +0 -4
  7. package/esm/animation/growInX.js.map +1 -1
  8. package/esm/animation/growInY.js +0 -4
  9. package/esm/animation/growInY.js.map +1 -1
  10. package/esm/animation/scaleInX.js +5 -7
  11. package/esm/animation/scaleInX.js.map +1 -1
  12. package/esm/animation/scaleInY.js +5 -7
  13. package/esm/animation/scaleInY.js.map +1 -1
  14. package/esm/animation/scaleOutX.js +5 -7
  15. package/esm/animation/scaleOutX.js.map +1 -1
  16. package/esm/animation/scaleOutY.js +5 -7
  17. package/esm/animation/scaleOutY.js.map +1 -1
  18. package/esm/animation/zoomIn.js +4 -5
  19. package/esm/animation/zoomIn.js.map +1 -1
  20. package/esm/animation/zoomOut.js +4 -6
  21. package/esm/animation/zoomOut.js.map +1 -1
  22. package/esm/component/axis.js +1 -5
  23. package/esm/component/axis.js.map +1 -1
  24. package/esm/component/index.d.ts +0 -1
  25. package/esm/component/index.js +0 -1
  26. package/esm/component/index.js.map +1 -1
  27. package/esm/component/legendContinuous.js +1 -1
  28. package/esm/component/legendContinuous.js.map +1 -1
  29. package/esm/coordinate/index.d.ts +0 -2
  30. package/esm/coordinate/index.js +0 -1
  31. package/esm/coordinate/index.js.map +1 -1
  32. package/esm/exports.d.ts +6 -1
  33. package/esm/exports.js +4 -0
  34. package/esm/exports.js.map +1 -1
  35. package/esm/index.d.ts +114 -114
  36. package/esm/index.js +2 -2
  37. package/esm/index.js.map +1 -1
  38. package/esm/lib/builtinlib.d.ts +7 -7
  39. package/esm/lib/core.d.ts +32 -32
  40. package/esm/lib/index.d.ts +0 -2
  41. package/esm/lib/index.js +0 -2
  42. package/esm/lib/index.js.map +1 -1
  43. package/esm/lib/lite.d.ts +18 -18
  44. package/esm/lib/std.d.ts +56 -56
  45. package/esm/mark/index.d.ts +0 -4
  46. package/esm/mark/index.js +0 -4
  47. package/esm/mark/index.js.map +1 -1
  48. package/esm/mark/liquid.js +2 -1
  49. package/esm/mark/liquid.js.map +1 -1
  50. package/esm/runtime/component.js +1 -3
  51. package/esm/runtime/component.js.map +1 -1
  52. package/esm/runtime/types/component.d.ts +1 -6
  53. package/esm/shape/index.d.ts +0 -4
  54. package/esm/shape/index.js +0 -4
  55. package/esm/shape/index.js.map +1 -1
  56. package/esm/shape/interval/color.d.ts +4 -0
  57. package/esm/shape/interval/color.js +10 -7
  58. package/esm/shape/interval/color.js.map +1 -1
  59. package/esm/shape/interval/rect.d.ts +4 -0
  60. package/esm/shape/interval/rect.js.map +1 -1
  61. package/esm/shape/line/smooth.js +8 -4
  62. package/esm/shape/line/smooth.js.map +1 -1
  63. package/esm/spec/coordinate.d.ts +1 -4
  64. package/esm/spec/mark.d.ts +1 -3
  65. package/esm/theme/create.d.ts +1 -0
  66. package/esm/theme/create.js +1 -0
  67. package/esm/theme/create.js.map +1 -1
  68. package/esm/transform/filter.js +3 -1
  69. package/esm/transform/filter.js.map +1 -1
  70. package/esm/transform/maybeTitle.js +6 -1
  71. package/esm/transform/maybeTitle.js.map +1 -1
  72. package/esm/utils/dateFormat.d.ts +1 -0
  73. package/esm/utils/dateFormat.js +18 -0
  74. package/esm/utils/dateFormat.js.map +1 -0
  75. package/esm/utils/number.d.ts +4 -0
  76. package/esm/utils/number.js +8 -0
  77. package/esm/utils/number.js.map +1 -1
  78. package/lib/animation/growInX.js +0 -4
  79. package/lib/animation/growInX.js.map +1 -1
  80. package/lib/animation/growInY.js +0 -4
  81. package/lib/animation/growInY.js.map +1 -1
  82. package/lib/animation/scaleInX.js +5 -7
  83. package/lib/animation/scaleInX.js.map +1 -1
  84. package/lib/animation/scaleInY.js +5 -7
  85. package/lib/animation/scaleInY.js.map +1 -1
  86. package/lib/animation/scaleOutX.js +5 -7
  87. package/lib/animation/scaleOutX.js.map +1 -1
  88. package/lib/animation/scaleOutY.js +5 -7
  89. package/lib/animation/scaleOutY.js.map +1 -1
  90. package/lib/animation/zoomIn.js +4 -5
  91. package/lib/animation/zoomIn.js.map +1 -1
  92. package/lib/animation/zoomOut.js +4 -6
  93. package/lib/animation/zoomOut.js.map +1 -1
  94. package/lib/component/axis.js +3 -7
  95. package/lib/component/axis.js.map +1 -1
  96. package/lib/component/index.d.ts +0 -1
  97. package/lib/component/index.js +1 -3
  98. package/lib/component/index.js.map +1 -1
  99. package/lib/component/legendContinuous.js +1 -1
  100. package/lib/component/legendContinuous.js.map +1 -1
  101. package/lib/coordinate/index.d.ts +0 -2
  102. package/lib/coordinate/index.js +1 -3
  103. package/lib/coordinate/index.js.map +1 -1
  104. package/lib/exports.d.ts +6 -1
  105. package/lib/exports.js +13 -1
  106. package/lib/exports.js.map +1 -1
  107. package/lib/index.d.ts +114 -114
  108. package/lib/index.js +1 -2
  109. package/lib/index.js.map +1 -1
  110. package/lib/lib/builtinlib.d.ts +7 -7
  111. package/lib/lib/core.d.ts +32 -32
  112. package/lib/lib/index.d.ts +0 -2
  113. package/lib/lib/index.js +1 -5
  114. package/lib/lib/index.js.map +1 -1
  115. package/lib/lib/lite.d.ts +18 -18
  116. package/lib/lib/std.d.ts +56 -56
  117. package/lib/mark/index.d.ts +0 -4
  118. package/lib/mark/index.js +1 -9
  119. package/lib/mark/index.js.map +1 -1
  120. package/lib/mark/liquid.js +2 -1
  121. package/lib/mark/liquid.js.map +1 -1
  122. package/lib/runtime/component.js +2 -4
  123. package/lib/runtime/component.js.map +1 -1
  124. package/lib/runtime/types/component.d.ts +1 -6
  125. package/lib/shape/index.d.ts +0 -4
  126. package/lib/shape/index.js +6 -14
  127. package/lib/shape/index.js.map +1 -1
  128. package/lib/shape/interval/color.d.ts +4 -0
  129. package/lib/shape/interval/color.js +10 -7
  130. package/lib/shape/interval/color.js.map +1 -1
  131. package/lib/shape/interval/rect.d.ts +4 -0
  132. package/lib/shape/interval/rect.js.map +1 -1
  133. package/lib/shape/line/smooth.js +6 -2
  134. package/lib/shape/line/smooth.js.map +1 -1
  135. package/lib/spec/coordinate.d.ts +1 -4
  136. package/lib/spec/mark.d.ts +1 -3
  137. package/lib/theme/create.d.ts +1 -0
  138. package/lib/theme/create.js +1 -0
  139. package/lib/theme/create.js.map +1 -1
  140. package/lib/transform/filter.js +3 -1
  141. package/lib/transform/filter.js.map +1 -1
  142. package/lib/transform/maybeTitle.js +6 -1
  143. package/lib/transform/maybeTitle.js.map +1 -1
  144. package/lib/utils/dateFormat.d.ts +1 -0
  145. package/lib/utils/dateFormat.js +22 -0
  146. package/lib/utils/dateFormat.js.map +1 -0
  147. package/lib/utils/number.d.ts +4 -0
  148. package/lib/utils/number.js +10 -1
  149. package/lib/utils/number.js.map +1 -1
  150. package/package.json +10 -17
  151. package/src/animation/growInX.ts +1 -6
  152. package/src/animation/growInY.ts +1 -6
  153. package/src/animation/scaleInX.ts +8 -11
  154. package/src/animation/scaleInY.ts +8 -11
  155. package/src/animation/scaleOutX.ts +8 -11
  156. package/src/animation/scaleOutY.ts +8 -11
  157. package/src/animation/zoomIn.ts +4 -6
  158. package/src/animation/zoomOut.ts +4 -7
  159. package/src/component/axis.ts +1 -5
  160. package/src/component/index.ts +0 -1
  161. package/src/component/legendContinuous.ts +1 -1
  162. package/src/coordinate/index.ts +0 -2
  163. package/src/exports.ts +18 -2
  164. package/src/index.ts +2 -2
  165. package/src/lib/index.ts +0 -2
  166. package/src/mark/index.ts +0 -4
  167. package/src/mark/liquid.ts +2 -1
  168. package/src/runtime/component.ts +1 -4
  169. package/src/runtime/types/component.ts +2 -9
  170. package/src/shape/index.ts +0 -4
  171. package/src/shape/interval/color.ts +16 -4
  172. package/src/shape/interval/rect.ts +5 -0
  173. package/src/shape/line/smooth.ts +12 -4
  174. package/src/spec/coordinate.ts +0 -5
  175. package/src/spec/mark.ts +0 -3
  176. package/src/theme/create.ts +1 -0
  177. package/src/transform/filter.ts +3 -1
  178. package/src/transform/maybeTitle.ts +8 -1
  179. package/src/utils/dateFormat.ts +22 -0
  180. package/src/utils/number.ts +8 -0
  181. package/CHANGELOG.md +0 -417
  182. package/esm/component/axisZ.d.ts +0 -8
  183. package/esm/component/axisZ.js +0 -14
  184. package/esm/component/axisZ.js.map +0 -1
  185. package/esm/coordinate/cartesian3D.d.ts +0 -7
  186. package/esm/coordinate/cartesian3D.js +0 -6
  187. package/esm/coordinate/cartesian3D.js.map +0 -1
  188. package/esm/lib/auto.d.ts +0 -3
  189. package/esm/lib/auto.js +0 -7
  190. package/esm/lib/auto.js.map +0 -1
  191. package/esm/lib/threed.d.ts +0 -7
  192. package/esm/lib/threed.js +0 -13
  193. package/esm/lib/threed.js.map +0 -1
  194. package/esm/mark/auto.d.ts +0 -1
  195. package/esm/mark/auto.js +0 -26
  196. package/esm/mark/auto.js.map +0 -1
  197. package/esm/mark/interval3D.d.ts +0 -8
  198. package/esm/mark/interval3D.js +0 -65
  199. package/esm/mark/interval3D.js.map +0 -1
  200. package/esm/mark/line3D.d.ts +0 -7
  201. package/esm/mark/line3D.js +0 -65
  202. package/esm/mark/line3D.js.map +0 -1
  203. package/esm/mark/point3D.d.ts +0 -9
  204. package/esm/mark/point3D.js +0 -76
  205. package/esm/mark/point3D.js.map +0 -1
  206. package/esm/shape/interval3D/cube.d.ts +0 -6
  207. package/esm/shape/interval3D/cube.js +0 -71
  208. package/esm/shape/interval3D/cube.js.map +0 -1
  209. package/esm/shape/line3D/line.d.ts +0 -3
  210. package/esm/shape/line3D/line.js +0 -30
  211. package/esm/shape/line3D/line.js.map +0 -1
  212. package/esm/shape/point3D/cube.d.ts +0 -6
  213. package/esm/shape/point3D/cube.js +0 -70
  214. package/esm/shape/point3D/cube.js.map +0 -1
  215. package/esm/shape/point3D/sphere.d.ts +0 -6
  216. package/esm/shape/point3D/sphere.js +0 -70
  217. package/esm/shape/point3D/sphere.js.map +0 -1
  218. package/lib/component/axisZ.d.ts +0 -8
  219. package/lib/component/axisZ.js +0 -19
  220. package/lib/component/axisZ.js.map +0 -1
  221. package/lib/coordinate/cartesian3D.d.ts +0 -7
  222. package/lib/coordinate/cartesian3D.js +0 -10
  223. package/lib/coordinate/cartesian3D.js.map +0 -1
  224. package/lib/lib/auto.d.ts +0 -3
  225. package/lib/lib/auto.js +0 -11
  226. package/lib/lib/auto.js.map +0 -1
  227. package/lib/lib/threed.d.ts +0 -7
  228. package/lib/lib/threed.js +0 -17
  229. package/lib/lib/threed.js.map +0 -1
  230. package/lib/mark/auto.d.ts +0 -1
  231. package/lib/mark/auto.js +0 -30
  232. package/lib/mark/auto.js.map +0 -1
  233. package/lib/mark/interval3D.d.ts +0 -8
  234. package/lib/mark/interval3D.js +0 -69
  235. package/lib/mark/interval3D.js.map +0 -1
  236. package/lib/mark/line3D.d.ts +0 -7
  237. package/lib/mark/line3D.js +0 -69
  238. package/lib/mark/line3D.js.map +0 -1
  239. package/lib/mark/point3D.d.ts +0 -9
  240. package/lib/mark/point3D.js +0 -80
  241. package/lib/mark/point3D.js.map +0 -1
  242. package/lib/shape/interval3D/cube.d.ts +0 -6
  243. package/lib/shape/interval3D/cube.js +0 -75
  244. package/lib/shape/interval3D/cube.js.map +0 -1
  245. package/lib/shape/line3D/line.d.ts +0 -3
  246. package/lib/shape/line3D/line.js +0 -34
  247. package/lib/shape/line3D/line.js.map +0 -1
  248. package/lib/shape/point3D/cube.d.ts +0 -6
  249. package/lib/shape/point3D/cube.js +0 -74
  250. package/lib/shape/point3D/cube.js.map +0 -1
  251. package/lib/shape/point3D/sphere.d.ts +0 -6
  252. package/lib/shape/point3D/sphere.js +0 -74
  253. package/lib/shape/point3D/sphere.js.map +0 -1
  254. package/src/component/axisZ.ts +0 -25
  255. package/src/coordinate/cartesian3D.ts +0 -11
  256. package/src/lib/auto.ts +0 -7
  257. package/src/lib/threed.ts +0 -13
  258. package/src/mark/auto.ts +0 -22
  259. package/src/mark/interval3D.ts +0 -100
  260. package/src/mark/line3D.ts +0 -81
  261. package/src/mark/point3D.ts +0 -90
  262. package/src/shape/interval3D/cube.ts +0 -69
  263. package/src/shape/line3D/line.ts +0 -29
  264. package/src/shape/point3D/cube.ts +0 -68
  265. package/src/shape/point3D/sphere.ts +0 -68
@@ -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
 
@@ -7,7 +7,6 @@ export type Coordinate =
7
7
  | ThetaCoordinate
8
8
  | CustomCoordinate
9
9
  | CartesianCoordinate
10
- | Cartesian3DCoordinate
11
10
  | ParallelCoordinate
12
11
  | RadialCoordinate
13
12
  | RadarCoordinate
@@ -72,10 +71,6 @@ export type CartesianCoordinate = BaseCoordinate<{
72
71
  type?: 'cartesian';
73
72
  }>;
74
73
 
75
- export type Cartesian3DCoordinate = BaseCoordinate<{
76
- type?: 'cartesian3D';
77
- }>;
78
-
79
74
  export type ParallelCoordinate = BaseCoordinate<{
80
75
  type?: 'parallel';
81
76
  }>;
package/src/spec/mark.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { AdviseParams } from '@antv/ava';
2
1
  import { MarkComponent } from '../runtime';
3
2
  import { Encode } from './encode';
4
3
  import { Transform } from './transform';
@@ -19,7 +18,6 @@ import {
19
18
  import { Closeable, Literal2Object, Padding } from './utils';
20
19
 
21
20
  export type Mark =
22
- | AutoMark
23
21
  | IntervalMark
24
22
  | RectMark
25
23
  | LineMark
@@ -394,4 +392,3 @@ export type HeatmapMark = BaseMark<'heatmap'>;
394
392
  export type LiquidMark = BaseMark<'liquid'>;
395
393
 
396
394
  export type CustomMark = BaseMark<MarkComponent, ChannelTypes>;
397
- export type AutoMark = BaseMark<'auto'> & AdviseParams;
@@ -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: {
@@ -48,7 +48,9 @@ export const Filter: TC<FilterOptions> = (options = {}) => {
48
48
  key,
49
49
  {
50
50
  ...encode,
51
- value: newIndex.map((i) => encode.value[FI[i]]),
51
+ value: newIndex
52
+ .map((i) => encode.value[FI[i]])
53
+ .filter((v) => v !== undefined),
52
54
  },
53
55
  ];
54
56
  });
@@ -1,6 +1,7 @@
1
1
  import { deepMix } from '@antv/util';
2
2
  import { isUnset } from '../utils/helper';
3
3
  import { TransformComponent as TC } from '../runtime';
4
+ import { dynamicFormatDateTime } from '../utils/dateFormat';
4
5
  import { columnOf } from './utils/helper';
5
6
 
6
7
  export type MaybeTitleOptions = {
@@ -27,7 +28,13 @@ export const MaybeTitle: TC<MaybeTitleOptions> = (options = {}) => {
27
28
  if (titles.length === 0) return [I, mark];
28
29
  const T = [];
29
30
  for (const i of I) {
30
- T[i] = { value: titles.map((t) => t[i]).join(', ') };
31
+ T[i] = {
32
+ value: titles
33
+ .map((t) =>
34
+ t[i] instanceof Date ? dynamicFormatDateTime(t[i] as Date) : t[i],
35
+ )
36
+ .join(', '),
37
+ };
31
38
  }
32
39
  return [
33
40
  I,
@@ -0,0 +1,22 @@
1
+ function fillZero(digit: number) {
2
+ if (Math.abs(digit) > 10) return String(digit);
3
+ return digit.toString().padStart(2, '0');
4
+ }
5
+
6
+ export function dynamicFormatDateTime(date: Date) {
7
+ const year = date.getFullYear();
8
+ const month = fillZero(date.getMonth() + 1);
9
+ const day = fillZero(date.getDate());
10
+
11
+ const yyyyMMDD = `${year}-${month}-${day}`;
12
+
13
+ const hour = date.getHours();
14
+ const minutes = date.getMinutes();
15
+ const seconds = date.getSeconds();
16
+
17
+ if (hour || minutes || seconds)
18
+ return `${yyyyMMDD} ${fillZero(hour)}:${fillZero(minutes)}:${fillZero(
19
+ seconds,
20
+ )}`;
21
+ return yyyyMMDD;
22
+ }
@@ -4,3 +4,11 @@
4
4
  export function clamp(v: number, lower: number, upper: number): number {
5
5
  return Math.max(lower, Math.min(v, upper));
6
6
  }
7
+
8
+ /**
9
+ * Precision conversion
10
+ */
11
+ export function prettyNumber(n: number, precision = 10) {
12
+ if (typeof n !== 'number') return n;
13
+ return Math.abs(n) < 1e-15 ? n : parseFloat(n.toFixed(precision));
14
+ }