@antv/g2 5.1.17 → 5.1.18

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 (190) hide show
  1. package/dist/g2.lite.min.js +1 -1
  2. package/dist/g2.min.js +1 -1
  3. package/esm/animation/growInX.js +4 -2
  4. package/esm/animation/growInX.js.map +1 -1
  5. package/esm/animation/growInY.js +4 -2
  6. package/esm/animation/growInY.js.map +1 -1
  7. package/esm/animation/morphing.js +35 -18
  8. package/esm/animation/morphing.js.map +1 -1
  9. package/esm/animation/scaleInY.js +2 -5
  10. package/esm/animation/scaleInY.js.map +1 -1
  11. package/esm/animation/utils.d.ts +10 -1
  12. package/esm/animation/utils.js +29 -3
  13. package/esm/animation/utils.js.map +1 -1
  14. package/esm/animation/waveIn.js +3 -14
  15. package/esm/animation/waveIn.js.map +1 -1
  16. package/esm/component/title.js +2 -1
  17. package/esm/component/title.js.map +1 -1
  18. package/esm/exports.js +0 -2
  19. package/esm/exports.js.map +1 -1
  20. package/esm/interaction/brushAxisHighlight.js +3 -3
  21. package/esm/interaction/brushAxisHighlight.js.map +1 -1
  22. package/esm/interaction/brushHighlight.js +4 -5
  23. package/esm/interaction/brushHighlight.js.map +1 -1
  24. package/esm/interaction/elementPointMove.js +6 -6
  25. package/esm/interaction/elementPointMove.js.map +1 -1
  26. package/esm/interaction/tooltip.js +4 -1
  27. package/esm/interaction/tooltip.js.map +1 -1
  28. package/esm/interaction/utils.js +2 -2
  29. package/esm/interaction/utils.js.map +1 -1
  30. package/esm/mark/chord.js +0 -1
  31. package/esm/mark/chord.js.map +1 -1
  32. package/esm/mark/point.js +3 -1
  33. package/esm/mark/point.js.map +1 -1
  34. package/esm/mark/sankey.js +1 -1
  35. package/esm/mark/sankey.js.map +1 -1
  36. package/esm/runtime/plot.js +4 -7
  37. package/esm/runtime/plot.js.map +1 -1
  38. package/esm/shape/connector/connector.js +1 -1
  39. package/esm/shape/connector/connector.js.map +1 -1
  40. package/esm/shape/gauge/round.js +1 -1
  41. package/esm/shape/gauge/round.js.map +1 -1
  42. package/esm/shape/image/image.js +1 -1
  43. package/esm/shape/index.d.ts +2 -0
  44. package/esm/shape/index.js +2 -0
  45. package/esm/shape/index.js.map +1 -1
  46. package/esm/shape/interval/color.js +1 -1
  47. package/esm/shape/interval/color.js.map +1 -1
  48. package/esm/shape/interval/funnel.js +1 -1
  49. package/esm/shape/interval/funnel.js.map +1 -1
  50. package/esm/shape/label/position/default.js +9 -9
  51. package/esm/shape/label/position/default.js.map +1 -1
  52. package/esm/shape/lineXY/line.js +1 -1
  53. package/esm/shape/lineXY/line.js.map +1 -1
  54. package/esm/shape/liquid/liquid.js +4 -4
  55. package/esm/shape/liquid/liquid.js.map +1 -1
  56. package/esm/shape/liquid/wave.js +2 -2
  57. package/esm/shape/liquid/wave.js.map +1 -1
  58. package/esm/shape/point/circle.d.ts +16 -0
  59. package/esm/shape/point/circle.js +56 -0
  60. package/esm/shape/point/circle.js.map +1 -0
  61. package/esm/shape/point/color.d.ts +2 -0
  62. package/esm/shape/point/color.js +2 -1
  63. package/esm/shape/point/color.js.map +1 -1
  64. package/esm/shape/point/hollowCircle.d.ts +6 -0
  65. package/esm/shape/point/hollowCircle.js +9 -0
  66. package/esm/shape/point/hollowCircle.js.map +1 -0
  67. package/esm/shape/text/advance.js +2 -1
  68. package/esm/shape/text/advance.js.map +1 -1
  69. package/esm/shape/text/badge.js +2 -3
  70. package/esm/shape/text/badge.js.map +1 -1
  71. package/esm/theme/create.d.ts +4 -2
  72. package/esm/theme/create.js +4 -2
  73. package/esm/theme/create.js.map +1 -1
  74. package/esm/utils/helper.js +1 -8
  75. package/esm/utils/helper.js.map +1 -1
  76. package/esm/utils/marker.d.ts +1 -1
  77. package/esm/utils/marker.js +2 -2
  78. package/esm/utils/marker.js.map +1 -1
  79. package/lib/animation/growInX.js +4 -2
  80. package/lib/animation/growInX.js.map +1 -1
  81. package/lib/animation/growInY.js +4 -2
  82. package/lib/animation/growInY.js.map +1 -1
  83. package/lib/animation/morphing.js +33 -16
  84. package/lib/animation/morphing.js.map +1 -1
  85. package/lib/animation/scaleInY.js +2 -5
  86. package/lib/animation/scaleInY.js.map +1 -1
  87. package/lib/animation/utils.d.ts +10 -1
  88. package/lib/animation/utils.js +30 -4
  89. package/lib/animation/utils.js.map +1 -1
  90. package/lib/animation/waveIn.js +2 -13
  91. package/lib/animation/waveIn.js.map +1 -1
  92. package/lib/component/title.js +2 -1
  93. package/lib/component/title.js.map +1 -1
  94. package/lib/exports.js +0 -2
  95. package/lib/exports.js.map +1 -1
  96. package/lib/interaction/brushAxisHighlight.js +3 -3
  97. package/lib/interaction/brushAxisHighlight.js.map +1 -1
  98. package/lib/interaction/brushHighlight.js +4 -5
  99. package/lib/interaction/brushHighlight.js.map +1 -1
  100. package/lib/interaction/elementPointMove.js +6 -6
  101. package/lib/interaction/elementPointMove.js.map +1 -1
  102. package/lib/interaction/tooltip.js +4 -1
  103. package/lib/interaction/tooltip.js.map +1 -1
  104. package/lib/interaction/utils.js +2 -2
  105. package/lib/interaction/utils.js.map +1 -1
  106. package/lib/mark/chord.js +0 -1
  107. package/lib/mark/chord.js.map +1 -1
  108. package/lib/mark/point.js +2 -0
  109. package/lib/mark/point.js.map +1 -1
  110. package/lib/mark/sankey.js +1 -1
  111. package/lib/mark/sankey.js.map +1 -1
  112. package/lib/runtime/plot.js +4 -7
  113. package/lib/runtime/plot.js.map +1 -1
  114. package/lib/shape/connector/connector.js +1 -1
  115. package/lib/shape/connector/connector.js.map +1 -1
  116. package/lib/shape/gauge/round.js +1 -1
  117. package/lib/shape/gauge/round.js.map +1 -1
  118. package/lib/shape/image/image.js +1 -1
  119. package/lib/shape/index.d.ts +2 -0
  120. package/lib/shape/index.js +6 -2
  121. package/lib/shape/index.js.map +1 -1
  122. package/lib/shape/interval/color.js +1 -1
  123. package/lib/shape/interval/color.js.map +1 -1
  124. package/lib/shape/interval/funnel.js +1 -1
  125. package/lib/shape/interval/funnel.js.map +1 -1
  126. package/lib/shape/label/position/default.js +9 -9
  127. package/lib/shape/label/position/default.js.map +1 -1
  128. package/lib/shape/lineXY/line.js +1 -1
  129. package/lib/shape/lineXY/line.js.map +1 -1
  130. package/lib/shape/liquid/liquid.js +4 -4
  131. package/lib/shape/liquid/liquid.js.map +1 -1
  132. package/lib/shape/liquid/wave.js +2 -2
  133. package/lib/shape/liquid/wave.js.map +1 -1
  134. package/lib/shape/point/circle.d.ts +16 -0
  135. package/lib/shape/point/circle.js +61 -0
  136. package/lib/shape/point/circle.js.map +1 -0
  137. package/lib/shape/point/color.d.ts +2 -0
  138. package/lib/shape/point/color.js +3 -1
  139. package/lib/shape/point/color.js.map +1 -1
  140. package/lib/shape/point/hollowCircle.d.ts +6 -0
  141. package/lib/shape/point/hollowCircle.js +13 -0
  142. package/lib/shape/point/hollowCircle.js.map +1 -0
  143. package/lib/shape/text/advance.js +2 -1
  144. package/lib/shape/text/advance.js.map +1 -1
  145. package/lib/shape/text/badge.js +2 -3
  146. package/lib/shape/text/badge.js.map +1 -1
  147. package/lib/theme/create.d.ts +4 -2
  148. package/lib/theme/create.js +4 -2
  149. package/lib/theme/create.js.map +1 -1
  150. package/lib/utils/helper.js +1 -8
  151. package/lib/utils/helper.js.map +1 -1
  152. package/lib/utils/marker.d.ts +1 -1
  153. package/lib/utils/marker.js +2 -2
  154. package/lib/utils/marker.js.map +1 -1
  155. package/package.json +12 -13
  156. package/src/animation/growInX.ts +9 -2
  157. package/src/animation/growInY.ts +9 -2
  158. package/src/animation/morphing.ts +36 -24
  159. package/src/animation/scaleInY.ts +2 -5
  160. package/src/animation/utils.ts +34 -4
  161. package/src/animation/waveIn.ts +3 -20
  162. package/src/component/title.ts +4 -0
  163. package/src/exports.ts +0 -4
  164. package/src/interaction/brushAxisHighlight.ts +5 -4
  165. package/src/interaction/brushHighlight.ts +8 -5
  166. package/src/interaction/elementPointMove.ts +6 -6
  167. package/src/interaction/tooltip.ts +4 -1
  168. package/src/interaction/utils.ts +2 -2
  169. package/src/mark/chord.ts +0 -1
  170. package/src/mark/point.ts +4 -0
  171. package/src/mark/sankey.ts +1 -1
  172. package/src/runtime/plot.ts +12 -7
  173. package/src/shape/connector/connector.ts +1 -1
  174. package/src/shape/gauge/round.ts +1 -1
  175. package/src/shape/image/image.ts +1 -1
  176. package/src/shape/index.ts +2 -0
  177. package/src/shape/interval/color.ts +1 -1
  178. package/src/shape/interval/funnel.ts +1 -1
  179. package/src/shape/label/position/default.ts +9 -9
  180. package/src/shape/lineXY/line.ts +1 -2
  181. package/src/shape/liquid/liquid.ts +4 -4
  182. package/src/shape/liquid/wave.ts +2 -2
  183. package/src/shape/point/circle.ts +57 -0
  184. package/src/shape/point/color.ts +2 -1
  185. package/src/shape/point/hollowCircle.ts +16 -0
  186. package/src/shape/text/advance.ts +3 -1
  187. package/src/shape/text/badge.ts +2 -3
  188. package/src/theme/create.ts +4 -2
  189. package/src/utils/helper.ts +1 -7
  190. package/src/utils/marker.ts +2 -11
@@ -46,7 +46,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
46
46
  if (Object.keys(backgroundStyle).length) {
47
47
  const backgroundShape = document.createElement('path', {
48
48
  style: {
49
- path: shapePath,
49
+ d: shapePath,
50
50
  fill: '#fff',
51
51
  ...backgroundStyle,
52
52
  },
@@ -60,7 +60,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
60
60
  // 3. Clip create.
61
61
  const clipShape = document.createElement('path', {
62
62
  style: {
63
- path: shapePath,
63
+ d: shapePath,
64
64
  },
65
65
  });
66
66
 
@@ -86,7 +86,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
86
86
  // 5. Draw distance.
87
87
  const distanceShape = document.createElement('path', {
88
88
  style: {
89
- path: shapePath,
89
+ d: shapePath,
90
90
  fill: 'transparent',
91
91
  lineWidth: border + 2 * distance,
92
92
  stroke: '#fff',
@@ -96,7 +96,7 @@ export const Liquid: SC<LiquidOptions> = (options, context) => {
96
96
  // 6. Draw border.
97
97
  const borderShape = document.createElement('path', {
98
98
  style: {
99
- path: shapePath,
99
+ d: shapePath,
100
100
  stroke: color,
101
101
  strokeOpacity: fillOpacity,
102
102
  lineWidth: border,
@@ -214,7 +214,7 @@ export function addWave(
214
214
  // Create wave path.
215
215
  const wave = document.createElement('path', {
216
216
  style: {
217
- path,
217
+ d: path,
218
218
  fill,
219
219
  opacity: lerp(0.2, 0.9, factor) * Number(opacity || fillOpacity),
220
220
  },
@@ -230,7 +230,7 @@ export function addWave(
230
230
  transform: 'translate(0, 0)',
231
231
  },
232
232
  {
233
- transform: `translate(${waveLength * 2}px, 0)`,
233
+ transform: `translate(${waveLength * 2}, 0)`,
234
234
  },
235
235
  ];
236
236
 
@@ -0,0 +1,57 @@
1
+ import { ShapeComponent as SC } from '../../runtime';
2
+ import { select } from '../../utils/selection';
3
+ import { applyStyle, getOrigin, toOpacityKey } from '../utils';
4
+ import { getRadius } from './color';
5
+
6
+ export type PointOptions = Record<string, any>;
7
+
8
+ type ColorOptions = {
9
+ colorAttribute: 'fill' | 'stroke';
10
+ mode?: 'fixed' | 'auto' | 'normal';
11
+ [key: string]: any;
12
+ };
13
+
14
+ /**
15
+ * Render point in different coordinate.
16
+ */
17
+ export const BaseCircle: SC<ColorOptions> = (options, context) => {
18
+ // Render border only when colorAttribute is stroke.
19
+ const { colorAttribute, mode = 'auto', ...style } = options;
20
+
21
+ const { coordinate, document } = context;
22
+ return (points, value, defaults) => {
23
+ const { lineWidth, color: defaultColor } = defaults;
24
+ const finalLineWidth = style.stroke ? lineWidth || 1 : lineWidth;
25
+ const { color = defaultColor, transform, opacity } = value;
26
+ const [cx, cy] = getOrigin(points);
27
+ const r = getRadius(mode, points, value, coordinate);
28
+ const finalRadius = r || style.r || defaults.r;
29
+ return select(document.createElement('circle', {}))
30
+ .call(applyStyle, defaults)
31
+ .style('fill', 'transparent')
32
+ .style('cx', cx)
33
+ .style('cy', cy)
34
+ .style('r', finalRadius)
35
+ .style('lineWidth', finalLineWidth)
36
+ .style('transform', transform)
37
+ .style('transformOrigin', `${cx} ${cy}`)
38
+ .style('stroke', color)
39
+ .style(toOpacityKey(options), opacity)
40
+ .style(colorAttribute, color)
41
+ .call(applyStyle, style)
42
+ .node();
43
+ };
44
+ };
45
+
46
+ /**
47
+ * ●
48
+ */
49
+ export const Circle: SC<PointOptions> = (options, context) => {
50
+ return BaseCircle({ colorAttribute: 'fill', ...options }, context);
51
+ };
52
+
53
+ Circle.props = {
54
+ defaultMarker: 'circle',
55
+ defaultEnterAnimation: 'fadeIn',
56
+ defaultExitAnimation: 'fadeOut',
57
+ };
@@ -12,7 +12,7 @@ export type ColorOptions = {
12
12
  [key: string]: any;
13
13
  };
14
14
 
15
- function getRadius(
15
+ export function getRadius(
16
16
  mode: ColorOptions['mode'],
17
17
  points: Vector2[],
18
18
  value: Record<string, any>,
@@ -51,6 +51,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
51
51
  .style('d', path(cx, cy, finalRadius))
52
52
  .style('lineWidth', finalLineWidth)
53
53
  .style('transform', transform)
54
+ .style('transformOrigin', `${cx - finalRadius} ${cy - finalRadius}`)
54
55
  .style('stroke', color)
55
56
  .style(toOpacityKey(options), opacity)
56
57
  .style(colorAttribute, color)
@@ -0,0 +1,16 @@
1
+ import { ShapeComponent as SC } from '../../runtime';
2
+ import { BaseCircle, Circle } from './circle';
3
+
4
+ export type HollowCircleOptions = Record<string, any>;
5
+
6
+ /**
7
+ * ○
8
+ */
9
+ export const HollowCircle: SC<HollowCircleOptions> = (options, context) => {
10
+ return BaseCircle({ colorAttribute: 'stroke', ...options }, context);
11
+ };
12
+
13
+ HollowCircle.props = {
14
+ defaultMarker: 'hollowPoint',
15
+ ...Circle.props,
16
+ };
@@ -151,6 +151,8 @@ export const Advance = createElement((g) => {
151
151
  ...rest
152
152
  } = g.attributes as TextShapeStyleProps;
153
153
 
154
+ g.style.transform = `translate(${x}, ${y})`;
155
+
154
156
  // Position is invalid, do not render the UI,
155
157
  // or clear previous elements.
156
158
  if ([x, y, x0, y0].some((v) => !isNumber(v))) {
@@ -220,7 +222,7 @@ export const Advance = createElement((g) => {
220
222
  select(g)
221
223
  .maybeAppend('connector', 'path')
222
224
  .style('zIndex', 0)
223
- .style('path', connectorPath)
225
+ .style('d', connectorPath)
224
226
  .style('markerStart', markerStart)
225
227
  .style('markerEnd', markerEnd)
226
228
  .call(applyStyle, connector ? connectorStyle : {});
@@ -35,7 +35,7 @@ function inferTextPosition(shape: DisplayObject) {
35
35
  }
36
36
 
37
37
  const BadgeShape = createElement((g) => {
38
- const { class: className, x: x0, y: y0, ...rest } = g.attributes;
38
+ const { class: className, x: x0, y: y0, transform, ...rest } = g.attributes;
39
39
 
40
40
  const markerStyle = subObject(rest, 'marker');
41
41
  const { size = 24 } = markerStyle;
@@ -69,8 +69,7 @@ export const Badge: SC<BadgeOptions> = (options, context) => {
69
69
  const [[x0, y0]] = points;
70
70
  return select(new BadgeShape())
71
71
  .call(applyStyle, rest)
72
- .style('x', x0)
73
- .style('y', y0)
72
+ .style('transform', `translate(${x0},${y0})`)
74
73
  .call(applyStyle, textStyle)
75
74
  .call(applyStyle, style)
76
75
  .node();
@@ -139,7 +139,7 @@ export function create({
139
139
  text: {
140
140
  fill: '#1D2129',
141
141
  fontSize: 12,
142
- strokeWidth: 0,
142
+ lineWidth: 0,
143
143
  connectorStroke: colorStroke,
144
144
  connectorStrokeOpacity: 0.45,
145
145
  connectorLineWidth: 1,
@@ -154,7 +154,7 @@ export function create({
154
154
  badge: {
155
155
  fill: '#1D2129',
156
156
  fillOpacity: 0.65,
157
- strokeWidth: 0,
157
+ lineWidth: 0,
158
158
  fontSize: 10,
159
159
  textAlign: 'center',
160
160
  textBaseline: 'middle',
@@ -249,6 +249,7 @@ export function create({
249
249
  titleSpacing: 12,
250
250
  labelSpacing: 4,
251
251
  titleTextBaseline: 'bottom',
252
+ titleTransform: 'translate(0, 8)',
252
253
  },
253
254
  axisLeft: {
254
255
  gridDirection: 'positive',
@@ -259,6 +260,7 @@ export function create({
259
260
  titleSpacing: 12,
260
261
  titleTextBaseline: 'middle',
261
262
  titleDirection: 'vertical',
263
+ titleTransform: 'rotate(-90) translate(0, -8)',
262
264
  titleTransformOrigin: 'center',
263
265
  },
264
266
  axisRight: {
@@ -46,13 +46,7 @@ export function copyAttributes(target: DisplayObject, source: DisplayObject) {
46
46
  const exclude = new Set(['id', 'className']);
47
47
  for (const [key, value] of Object.entries(attributes)) {
48
48
  if (!exclude.has(key)) {
49
- // @todo Fix in @antv/g
50
- if (key === 'transform') {
51
- target.attr(key, '');
52
- target.attr(key, value);
53
- } else {
54
- target.attr(key, value);
55
- }
49
+ target.attr(key, value);
56
50
  }
57
51
  }
58
52
  }
@@ -255,23 +255,14 @@ export const Symbols = new Map<string, SymbolFactor>([
255
255
 
256
256
  export function useMarker(
257
257
  type: string,
258
- {
259
- d,
260
- fill,
261
- strokeWidth,
262
- path,
263
- stroke,
264
- lineWidth,
265
- color,
266
- ...style
267
- }: Record<string, any>,
258
+ { d, fill, lineWidth, path, stroke, color, ...style }: Record<string, any>,
268
259
  ) {
269
260
  const symbol = Symbols.get(type) || Symbols.get('point');
270
261
  return (...args: Parameters<SymbolFactor>) => {
271
262
  const path = new Path({
272
263
  style: {
273
264
  ...style,
274
- path: symbol(...args),
265
+ d: symbol(...args),
275
266
  stroke: symbol.style.includes('stroke') ? color || stroke : '',
276
267
  fill: symbol.style.includes('fill') ? color || fill : '',
277
268
  lineWidth: symbol.style.includes('lineWidth')