@antv/g2 5.1.17 → 5.1.19

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 (230) 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/data/utils/d3-cloud/index.js +1 -0
  19. package/esm/data/utils/d3-cloud/index.js.map +1 -1
  20. package/esm/data/wordCloud.d.ts +100 -2
  21. package/esm/data/wordCloud.js +20 -5
  22. package/esm/data/wordCloud.js.map +1 -1
  23. package/esm/exports.js +0 -2
  24. package/esm/exports.js.map +1 -1
  25. package/esm/index.d.ts +4 -2
  26. package/esm/interaction/brushAxisHighlight.js +3 -3
  27. package/esm/interaction/brushAxisHighlight.js.map +1 -1
  28. package/esm/interaction/brushHighlight.js +4 -5
  29. package/esm/interaction/brushHighlight.js.map +1 -1
  30. package/esm/interaction/elementPointMove.js +6 -6
  31. package/esm/interaction/elementPointMove.js.map +1 -1
  32. package/esm/interaction/tooltip.js +4 -1
  33. package/esm/interaction/tooltip.js.map +1 -1
  34. package/esm/interaction/utils.js +2 -2
  35. package/esm/interaction/utils.js.map +1 -1
  36. package/esm/lib/core.d.ts +2 -0
  37. package/esm/lib/core.js +4 -2
  38. package/esm/lib/core.js.map +1 -1
  39. package/esm/lib/std.d.ts +2 -1
  40. package/esm/mark/chord.js +0 -1
  41. package/esm/mark/chord.js.map +1 -1
  42. package/esm/mark/point.js +3 -1
  43. package/esm/mark/point.js.map +1 -1
  44. package/esm/mark/sankey.js +1 -1
  45. package/esm/mark/sankey.js.map +1 -1
  46. package/esm/mark/text.js +4 -3
  47. package/esm/mark/text.js.map +1 -1
  48. package/esm/mark/wordCloud.js +11 -12
  49. package/esm/mark/wordCloud.js.map +1 -1
  50. package/esm/runtime/plot.js +4 -7
  51. package/esm/runtime/plot.js.map +1 -1
  52. package/esm/shape/connector/connector.js +1 -1
  53. package/esm/shape/connector/connector.js.map +1 -1
  54. package/esm/shape/gauge/round.js +1 -1
  55. package/esm/shape/gauge/round.js.map +1 -1
  56. package/esm/shape/image/image.js +1 -1
  57. package/esm/shape/index.d.ts +4 -0
  58. package/esm/shape/index.js +3 -0
  59. package/esm/shape/index.js.map +1 -1
  60. package/esm/shape/interval/color.js +1 -1
  61. package/esm/shape/interval/color.js.map +1 -1
  62. package/esm/shape/interval/funnel.js +1 -1
  63. package/esm/shape/interval/funnel.js.map +1 -1
  64. package/esm/shape/label/position/default.js +9 -9
  65. package/esm/shape/label/position/default.js.map +1 -1
  66. package/esm/shape/lineXY/line.js +1 -1
  67. package/esm/shape/lineXY/line.js.map +1 -1
  68. package/esm/shape/liquid/liquid.js +4 -4
  69. package/esm/shape/liquid/liquid.js.map +1 -1
  70. package/esm/shape/liquid/wave.js +2 -2
  71. package/esm/shape/liquid/wave.js.map +1 -1
  72. package/esm/shape/point/circle.d.ts +16 -0
  73. package/esm/shape/point/circle.js +56 -0
  74. package/esm/shape/point/circle.js.map +1 -0
  75. package/esm/shape/point/color.d.ts +2 -0
  76. package/esm/shape/point/color.js +2 -1
  77. package/esm/shape/point/color.js.map +1 -1
  78. package/esm/shape/point/hollowCircle.d.ts +6 -0
  79. package/esm/shape/point/hollowCircle.js +9 -0
  80. package/esm/shape/point/hollowCircle.js.map +1 -0
  81. package/esm/shape/text/advance.js +2 -1
  82. package/esm/shape/text/advance.js.map +1 -1
  83. package/esm/shape/text/badge.js +2 -3
  84. package/esm/shape/text/badge.js.map +1 -1
  85. package/esm/shape/text/tag.d.ts +7 -0
  86. package/esm/shape/text/tag.js +40 -0
  87. package/esm/shape/text/tag.js.map +1 -0
  88. package/esm/theme/create.d.ts +4 -2
  89. package/esm/theme/create.js +4 -2
  90. package/esm/theme/create.js.map +1 -1
  91. package/esm/utils/helper.js +1 -8
  92. package/esm/utils/helper.js.map +1 -1
  93. package/esm/utils/marker.d.ts +1 -1
  94. package/esm/utils/marker.js +2 -2
  95. package/esm/utils/marker.js.map +1 -1
  96. package/lib/animation/growInX.js +4 -2
  97. package/lib/animation/growInX.js.map +1 -1
  98. package/lib/animation/growInY.js +4 -2
  99. package/lib/animation/growInY.js.map +1 -1
  100. package/lib/animation/morphing.js +33 -16
  101. package/lib/animation/morphing.js.map +1 -1
  102. package/lib/animation/scaleInY.js +2 -5
  103. package/lib/animation/scaleInY.js.map +1 -1
  104. package/lib/animation/utils.d.ts +10 -1
  105. package/lib/animation/utils.js +30 -4
  106. package/lib/animation/utils.js.map +1 -1
  107. package/lib/animation/waveIn.js +2 -13
  108. package/lib/animation/waveIn.js.map +1 -1
  109. package/lib/component/title.js +2 -1
  110. package/lib/component/title.js.map +1 -1
  111. package/lib/data/utils/d3-cloud/index.js +1 -0
  112. package/lib/data/utils/d3-cloud/index.js.map +1 -1
  113. package/lib/data/wordCloud.d.ts +100 -2
  114. package/lib/data/wordCloud.js +20 -5
  115. package/lib/data/wordCloud.js.map +1 -1
  116. package/lib/exports.js +0 -2
  117. package/lib/exports.js.map +1 -1
  118. package/lib/index.d.ts +4 -2
  119. package/lib/interaction/brushAxisHighlight.js +3 -3
  120. package/lib/interaction/brushAxisHighlight.js.map +1 -1
  121. package/lib/interaction/brushHighlight.js +4 -5
  122. package/lib/interaction/brushHighlight.js.map +1 -1
  123. package/lib/interaction/elementPointMove.js +6 -6
  124. package/lib/interaction/elementPointMove.js.map +1 -1
  125. package/lib/interaction/tooltip.js +4 -1
  126. package/lib/interaction/tooltip.js.map +1 -1
  127. package/lib/interaction/utils.js +2 -2
  128. package/lib/interaction/utils.js.map +1 -1
  129. package/lib/lib/core.d.ts +2 -0
  130. package/lib/lib/core.js +2 -0
  131. package/lib/lib/core.js.map +1 -1
  132. package/lib/lib/std.d.ts +2 -1
  133. package/lib/mark/chord.js +0 -1
  134. package/lib/mark/chord.js.map +1 -1
  135. package/lib/mark/point.js +2 -0
  136. package/lib/mark/point.js.map +1 -1
  137. package/lib/mark/sankey.js +1 -1
  138. package/lib/mark/sankey.js.map +1 -1
  139. package/lib/mark/text.js +3 -2
  140. package/lib/mark/text.js.map +1 -1
  141. package/lib/mark/wordCloud.js +11 -12
  142. package/lib/mark/wordCloud.js.map +1 -1
  143. package/lib/runtime/plot.js +4 -7
  144. package/lib/runtime/plot.js.map +1 -1
  145. package/lib/shape/connector/connector.js +1 -1
  146. package/lib/shape/connector/connector.js.map +1 -1
  147. package/lib/shape/gauge/round.js +1 -1
  148. package/lib/shape/gauge/round.js.map +1 -1
  149. package/lib/shape/image/image.js +1 -1
  150. package/lib/shape/index.d.ts +4 -0
  151. package/lib/shape/index.js +8 -2
  152. package/lib/shape/index.js.map +1 -1
  153. package/lib/shape/interval/color.js +1 -1
  154. package/lib/shape/interval/color.js.map +1 -1
  155. package/lib/shape/interval/funnel.js +1 -1
  156. package/lib/shape/interval/funnel.js.map +1 -1
  157. package/lib/shape/label/position/default.js +9 -9
  158. package/lib/shape/label/position/default.js.map +1 -1
  159. package/lib/shape/lineXY/line.js +1 -1
  160. package/lib/shape/lineXY/line.js.map +1 -1
  161. package/lib/shape/liquid/liquid.js +4 -4
  162. package/lib/shape/liquid/liquid.js.map +1 -1
  163. package/lib/shape/liquid/wave.js +2 -2
  164. package/lib/shape/liquid/wave.js.map +1 -1
  165. package/lib/shape/point/circle.d.ts +16 -0
  166. package/lib/shape/point/circle.js +61 -0
  167. package/lib/shape/point/circle.js.map +1 -0
  168. package/lib/shape/point/color.d.ts +2 -0
  169. package/lib/shape/point/color.js +3 -1
  170. package/lib/shape/point/color.js.map +1 -1
  171. package/lib/shape/point/hollowCircle.d.ts +6 -0
  172. package/lib/shape/point/hollowCircle.js +13 -0
  173. package/lib/shape/point/hollowCircle.js.map +1 -0
  174. package/lib/shape/text/advance.js +2 -1
  175. package/lib/shape/text/advance.js.map +1 -1
  176. package/lib/shape/text/badge.js +2 -3
  177. package/lib/shape/text/badge.js.map +1 -1
  178. package/lib/shape/text/tag.d.ts +7 -0
  179. package/lib/shape/text/tag.js +44 -0
  180. package/lib/shape/text/tag.js.map +1 -0
  181. package/lib/theme/create.d.ts +4 -2
  182. package/lib/theme/create.js +4 -2
  183. package/lib/theme/create.js.map +1 -1
  184. package/lib/utils/helper.js +1 -8
  185. package/lib/utils/helper.js.map +1 -1
  186. package/lib/utils/marker.d.ts +1 -1
  187. package/lib/utils/marker.js +2 -2
  188. package/lib/utils/marker.js.map +1 -1
  189. package/package.json +13 -13
  190. package/src/animation/growInX.ts +9 -2
  191. package/src/animation/growInY.ts +9 -2
  192. package/src/animation/morphing.ts +36 -24
  193. package/src/animation/scaleInY.ts +2 -5
  194. package/src/animation/utils.ts +34 -4
  195. package/src/animation/waveIn.ts +3 -20
  196. package/src/component/title.ts +4 -0
  197. package/src/data/utils/d3-cloud/index.ts +1 -0
  198. package/src/data/wordCloud.ts +112 -7
  199. package/src/exports.ts +0 -4
  200. package/src/interaction/brushAxisHighlight.ts +5 -4
  201. package/src/interaction/brushHighlight.ts +8 -5
  202. package/src/interaction/elementPointMove.ts +6 -6
  203. package/src/interaction/tooltip.ts +4 -1
  204. package/src/interaction/utils.ts +2 -2
  205. package/src/lib/core.ts +4 -0
  206. package/src/mark/chord.ts +0 -1
  207. package/src/mark/point.ts +4 -0
  208. package/src/mark/sankey.ts +1 -1
  209. package/src/mark/text.ts +4 -3
  210. package/src/mark/wordCloud.ts +16 -18
  211. package/src/runtime/plot.ts +12 -7
  212. package/src/shape/connector/connector.ts +1 -1
  213. package/src/shape/gauge/round.ts +1 -1
  214. package/src/shape/image/image.ts +1 -1
  215. package/src/shape/index.ts +4 -0
  216. package/src/shape/interval/color.ts +1 -1
  217. package/src/shape/interval/funnel.ts +1 -1
  218. package/src/shape/label/position/default.ts +9 -9
  219. package/src/shape/lineXY/line.ts +1 -2
  220. package/src/shape/liquid/liquid.ts +4 -4
  221. package/src/shape/liquid/wave.ts +2 -2
  222. package/src/shape/point/circle.ts +57 -0
  223. package/src/shape/point/color.ts +2 -1
  224. package/src/shape/point/hollowCircle.ts +16 -0
  225. package/src/shape/text/advance.ts +3 -1
  226. package/src/shape/text/badge.ts +2 -3
  227. package/src/shape/text/tag.ts +44 -0
  228. package/src/theme/create.ts +4 -2
  229. package/src/utils/helper.ts +1 -7
  230. package/src/utils/marker.ts +2 -11
@@ -382,7 +382,7 @@ function updateMarker(root, { data, style, theme }) {
382
382
  fill,
383
383
  r: 4,
384
384
  stroke: '#fff',
385
- strokeWidth: 2,
385
+ lineWidth: 2,
386
386
  ...style,
387
387
  },
388
388
  });
@@ -818,6 +818,9 @@ export function tooltip(
818
818
  }
819
819
  const k = groupKey(element);
820
820
  const group = keyGroup.get(k);
821
+ if (!group) {
822
+ return;
823
+ }
821
824
  const data =
822
825
  group.length === 1 && !shared
823
826
  ? singleItem(group[0])
@@ -426,7 +426,7 @@ export function renderBackground({
426
426
  fillOpacity = 0.3,
427
427
  zIndex = -2,
428
428
  padding = 0.001,
429
- strokeWidth = 0,
429
+ lineWidth = 0,
430
430
  ...style
431
431
  } = mapObject(rest, (d) => valueof(d, element));
432
432
  const finalStyle = {
@@ -435,7 +435,7 @@ export function renderBackground({
435
435
  fillOpacity,
436
436
  zIndex,
437
437
  padding,
438
- strokeWidth,
438
+ lineWidth,
439
439
  };
440
440
  const shapeOf = isOrdinalShape() ? bandShapeOf : cloneShapeOf;
441
441
  const shape = shapeOf(element, finalStyle);
package/src/lib/core.ts CHANGED
@@ -32,6 +32,7 @@ import {
32
32
  Shape,
33
33
  Density,
34
34
  Heatmap,
35
+ WordCloud as WordCloudGeometry,
35
36
  } from '../mark';
36
37
  import { Category10, Category20 } from '../palette';
37
38
  import {
@@ -153,6 +154,7 @@ import {
153
154
  Sort as DataSort,
154
155
  KDE as DataKDE,
155
156
  Log as DataLog,
157
+ WordCloud,
156
158
  } from '../data';
157
159
  import {
158
160
  OverlapDodgeY,
@@ -177,6 +179,7 @@ export function corelib() {
177
179
  'data.join': DataJoin,
178
180
  'data.kde': DataKDE,
179
181
  'data.log': DataLog,
182
+ 'data.wordCloud': WordCloud,
180
183
  'transform.stackY': StackY,
181
184
  'transform.binX': BinX,
182
185
  'transform.bin': Bin,
@@ -236,6 +239,7 @@ export function corelib() {
236
239
  'mark.shape': Shape,
237
240
  'mark.density': Density,
238
241
  'mark.heatmap': Heatmap,
242
+ 'mark.wordCloud': WordCloudGeometry,
239
243
  'palette.category10': Category10,
240
244
  'palette.category20': Category20,
241
245
  'scale.linear': ScaleLinear,
package/src/mark/chord.ts CHANGED
@@ -51,7 +51,6 @@ const DEFAULT_LINK_OPTIONS = {
51
51
  style: {
52
52
  opacity: 0.5,
53
53
  lineWidth: 1,
54
- strokeWidth: 1,
55
54
  },
56
55
  };
57
56
 
package/src/mark/point.ts CHANGED
@@ -20,6 +20,8 @@ import {
20
20
  PointShape,
21
21
  PointTick,
22
22
  PointTriangle,
23
+ PointCircle,
24
+ PointHollowCircle,
23
25
  } from '../shape';
24
26
  import { MaybeZeroX, MaybeZeroY, MaybeSize } from '../transform';
25
27
  import {
@@ -38,6 +40,7 @@ const shape = {
38
40
  hollowTriangleDown: PointHollowTriangleDown,
39
41
  hollowTriangle: PointHollowTriangle,
40
42
  hollowBowtie: PointHollowBowtie,
43
+ hollowCircle: PointHollowCircle,
41
44
  point: PointShape,
42
45
  plus: PointPlus,
43
46
  diamond: PointDiamond,
@@ -50,6 +53,7 @@ const shape = {
50
53
  line: PointLine,
51
54
  tick: PointTick,
52
55
  triangleDown: PointTriangleDown,
56
+ circle: PointCircle,
53
57
  };
54
58
 
55
59
  export type PointOptions = Omit<PointMark, 'type'>;
@@ -136,7 +136,7 @@ export const Sankey: CC<SankeyOptions> = (options) => {
136
136
  labels: linkLabels,
137
137
  style: {
138
138
  fill: linkEncode.color ? undefined : '#aaa',
139
- strokeWidth: 0,
139
+ lineWidth: 0,
140
140
  ...subObject(style, 'link'),
141
141
  },
142
142
  tooltip: linkTooltip,
package/src/mark/text.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { MarkComponent as MC, Vector2, Mark } from '../runtime';
2
2
  import { TextMark } from '../spec';
3
- import { TextShape, TextBadge } from '../shape';
3
+ import { TextShape, TextBadge, TextTag } from '../shape';
4
4
  import { MaybeTuple, MaybeVisualPosition } from '../transform';
5
5
  import {
6
6
  baseGeometryChannels,
@@ -14,6 +14,7 @@ import {
14
14
  const shape = {
15
15
  text: TextShape,
16
16
  badge: TextBadge,
17
+ tag: TextTag,
17
18
  };
18
19
 
19
20
  export type TextOptions = Omit<TextMark, 'type'>;
@@ -42,8 +43,8 @@ Text.props = {
42
43
  { name: 'x', required: true },
43
44
  { name: 'y', required: true },
44
45
  { name: 'text', scale: 'identity' },
45
- { name: 'fontSize' },
46
- { name: 'rotate' },
46
+ { name: 'fontSize', scale: 'identity' },
47
+ { name: 'rotate', scale: 'identity' },
47
48
  ],
48
49
  preInference: [
49
50
  ...basePreInference(),
@@ -1,7 +1,6 @@
1
1
  import { deepMix } from '@antv/util';
2
2
  import { CompositeMarkComponent as CC } from '../runtime';
3
3
  import { WordCloudMark } from '../spec';
4
- import { WordCloud as WordCloudTransform } from '../data';
5
4
 
6
5
  export type WordCloudOptions = Omit<WordCloudMark, 'type'>;
7
6
 
@@ -14,11 +13,7 @@ function initializeData(data, encode) {
14
13
  }));
15
14
  }
16
15
 
17
- const GET_DEFAULT_LAYOUT_OPTIONS = (width, height) => ({
18
- size: [width, height],
19
- });
20
-
21
- const GET_DEFAULT_OPTIONS = (width, height) => ({
16
+ const GET_DEFAULT_OPTIONS = () => ({
22
17
  axis: false,
23
18
  type: 'text',
24
19
  encode: {
@@ -27,15 +22,14 @@ const GET_DEFAULT_OPTIONS = (width, height) => ({
27
22
  text: 'text',
28
23
  rotate: 'rotate',
29
24
  fontSize: 'size',
25
+ shape: 'tag',
30
26
  },
31
27
  scale: {
32
- x: { domain: [0, width], range: [0, 1] },
33
- y: { domain: [0, height], range: [0, 1] },
34
- fontSize: { type: 'identity' },
35
- rotate: { type: 'identity' },
28
+ x: { range: [0, 1] },
29
+ y: { range: [0, 1] },
36
30
  },
37
31
  style: {
38
- textAlign: 'center',
32
+ fontFamily: (d) => d.fontFamily,
39
33
  },
40
34
  });
41
35
 
@@ -53,13 +47,17 @@ export const WordCloud: CC<WordCloudOptions> = async (options, context) => {
53
47
 
54
48
  const initializedData = initializeData(data, encode);
55
49
 
56
- const transformData = await WordCloudTransform({
57
- ...GET_DEFAULT_LAYOUT_OPTIONS(width, height),
58
- ...layout,
59
- })(initializedData);
60
-
61
- return deepMix({}, GET_DEFAULT_OPTIONS(width, height), {
62
- data: transformData,
50
+ return deepMix({}, GET_DEFAULT_OPTIONS(), {
51
+ data: {
52
+ value: initializedData,
53
+ transform: [
54
+ {
55
+ type: 'wordCloud',
56
+ size: [width, height],
57
+ ...layout,
58
+ },
59
+ ],
60
+ },
63
61
  encode,
64
62
  scale,
65
63
  style,
@@ -1694,8 +1694,13 @@ async function applyTransform<T extends G2ViewTree>(
1694
1694
 
1695
1695
  function updateBBox(selection: Selection) {
1696
1696
  selection
1697
- .style('x', (d) => d.paddingLeft + d.marginLeft)
1698
- .style('y', (d) => d.paddingTop + d.marginTop)
1697
+ .style(
1698
+ 'transform',
1699
+ (d) =>
1700
+ `translate(${d.paddingLeft + d.marginLeft}, ${
1701
+ d.paddingTop + d.marginTop
1702
+ })`,
1703
+ )
1699
1704
  .style('width', (d) => d.innerWidth)
1700
1705
  .style('height', (d) => d.innerHeight);
1701
1706
  }
@@ -1703,7 +1708,7 @@ function updateBBox(selection: Selection) {
1703
1708
  function animateBBox(selection: Selection, extent: [number, number]) {
1704
1709
  const [delay, duration] = extent;
1705
1710
  selection.transition(function (data, i, element) {
1706
- const { x, y, width, height } = element.style;
1711
+ const { transform, width, height } = element.style;
1707
1712
  const {
1708
1713
  paddingLeft,
1709
1714
  paddingTop,
@@ -1714,14 +1719,14 @@ function animateBBox(selection: Selection, extent: [number, number]) {
1714
1719
  } = data;
1715
1720
  const keyframes = [
1716
1721
  {
1717
- x,
1718
- y,
1722
+ transform,
1719
1723
  width,
1720
1724
  height,
1721
1725
  },
1722
1726
  {
1723
- x: paddingLeft + marginLeft,
1724
- y: paddingTop + marginTop,
1727
+ transform: `translate(${paddingLeft + marginLeft}, ${
1728
+ paddingTop + marginTop
1729
+ })`,
1725
1730
  width: innerWidth,
1726
1731
  height: innerHeight,
1727
1732
  },
@@ -89,7 +89,7 @@ export const Connector: SC<ConnectorOptions> = (options, context) => {
89
89
 
90
90
  return select(new Path())
91
91
  .call(applyStyle, rest)
92
- .style('path', inferConnectorPath(P))
92
+ .style('d', inferConnectorPath(P))
93
93
  .style('stroke', color || defaultColor)
94
94
  .style('transform', transform)
95
95
  .style(
@@ -36,7 +36,7 @@ export const Round: SC<RoundOptions> = (options, context) => {
36
36
  */
37
37
  const roundPath = document.createElement('path', {
38
38
  style: {
39
- path: [
39
+ d: [
40
40
  ['M', ...points[0]],
41
41
  ['A', minR, minR, 0, 1, 0, ...points[1]],
42
42
  ['A', maxR + minR * 2, maxR + minR * 2, 0, 0, 0, ...points[2]],
@@ -25,7 +25,7 @@ export const Image: SC<ImageOptions> = (options, context) => {
25
25
  .call(applyStyle, rest)
26
26
  .style('x', x)
27
27
  .style('y', y)
28
- .style('img', src)
28
+ .style('src', src)
29
29
  .style('stroke', color)
30
30
  .style('transform', transform)
31
31
  .call(applyStyle, options)
@@ -17,6 +17,7 @@ export { HollowPoint as PointHollow } from './point/hollow';
17
17
  export { HollowSquare as PointHollowSquare } from './point/hollowSquare';
18
18
  export { HollowTriangle as PointHollowTriangle } from './point/hollowTriangle';
19
19
  export { HollowTriangleDown as PointHollowTriangleDown } from './point/hollowTriangleDown';
20
+ export { HollowCircle as PointHollowCircle } from './point/hollowCircle';
20
21
  export { Bowtie as PointBowtie } from './point/bowtie';
21
22
  export { Cross as PointCross } from './point/cross';
22
23
  export { Diamond as PointDiamond } from './point/diamond';
@@ -29,9 +30,11 @@ export { Square as PointSquare } from './point/square';
29
30
  export { Tick as PointTick } from './point/tick';
30
31
  export { Triangle as PointTriangle } from './point/triangle';
31
32
  export { TriangleDown as PointTriangleDown } from './point/triangleDown';
33
+ export { Circle as PointCircle } from './point/circle';
32
34
  export { Vector as VectorShape } from './vector/vector';
33
35
  export { Text as TextShape } from './text/text';
34
36
  export { Badge as TextBadge } from './text/badge';
37
+ export { Tag as TextTag } from './text/tag';
35
38
  export { Area as AreaShape } from './area/area';
36
39
  export { Smooth as AreaSmooth } from './area/smooth';
37
40
  export { HVH as AreaHVH } from './area/hvh';
@@ -92,6 +95,7 @@ export type { TriangleDownOptions as PointTriangleDownOptions } from './point/tr
92
95
  export type { VectorOptions as VectorShapeOptions } from './vector/vector';
93
96
  export type { TextOptions as TextShapeOptions } from './text/text';
94
97
  export type { BadgeOptions as TextBadgeOptions } from './text/badge';
98
+ export type { TagOptions as TextTagOptions } from './text/tag';
95
99
  export type { AreaOptions as AreaShapeOptions } from './area/area';
96
100
  export type { SmoothOptions as AreaSmoothOptions } from './area/smooth';
97
101
  export type { HVHOptions as AreaHVHAreaOptions } from './area/hvh';
@@ -101,7 +101,7 @@ export function rect(
101
101
  .padAngle((inset * Math.PI) / 180);
102
102
 
103
103
  return select(document.createElement('path', {}))
104
- .style('path', path(arcObject))
104
+ .style('d', path(arcObject))
105
105
  .style('transform', `translate(${center[0]}, ${center[1]})`)
106
106
  .style('radius', radius)
107
107
  .style('inset', inset)
@@ -51,7 +51,7 @@ export const Funnel: SC<FunnelOptions> = (options, context) => {
51
51
  const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
52
52
  return select(document.createElement('path', {}))
53
53
  .call(applyStyle, rest)
54
- .style('path', b)
54
+ .style('d', b)
55
55
  .style('fill', color)
56
56
  .style('fillOpacity', opacity)
57
57
  .call(applyStyle, style)
@@ -42,27 +42,27 @@ export function inferNonCircularStyle(
42
42
  };
43
43
  // 4 direction.
44
44
  if (position === 'left')
45
- return xy({ x: 0, y: h / 2, textAnchor: 'start', textBaseline: 'middle' });
45
+ return xy({ x: 0, y: h / 2, textAlign: 'start', textBaseline: 'middle' });
46
46
  if (position === 'right')
47
- return xy({ x: w, y: h / 2, textAnchor: 'end', textBaseline: 'middle' });
47
+ return xy({ x: w, y: h / 2, textAlign: 'end', textBaseline: 'middle' });
48
48
  if (position === 'top')
49
- return xy({ x: w / 2, y: 0, textAnchor: 'center', textBaseline: 'top' });
49
+ return xy({ x: w / 2, y: 0, textAlign: 'center', textBaseline: 'top' });
50
50
  if (position === 'bottom')
51
- return xy({ x: w / 2, y: h, textAnchor: 'center', textBaseline: 'bottom' });
51
+ return xy({ x: w / 2, y: h, textAlign: 'center', textBaseline: 'bottom' });
52
52
  // 4 corner position.
53
53
  if (position === 'top-left')
54
- return xy({ x: 0, y: 0, textAnchor: 'start', textBaseline: 'top' });
54
+ return xy({ x: 0, y: 0, textAlign: 'start', textBaseline: 'top' });
55
55
  if (position === 'top-right')
56
- return xy({ x: w, y: 0, textAnchor: 'end', textBaseline: 'top' });
56
+ return xy({ x: w, y: 0, textAlign: 'end', textBaseline: 'top' });
57
57
  if (position === 'bottom-left')
58
- return xy({ x: 0, y: h, textAnchor: 'start', textBaseline: 'bottom' });
58
+ return xy({ x: 0, y: h, textAlign: 'start', textBaseline: 'bottom' });
59
59
  if (position === 'bottom-right')
60
- return xy({ x: w, y: h, textAnchor: 'end', textBaseline: 'bottom' });
60
+ return xy({ x: w, y: h, textAlign: 'end', textBaseline: 'bottom' });
61
61
  // default return 'inside'
62
62
  return xy({
63
63
  x: w / 2,
64
64
  y: h / 2,
65
- textAnchor: 'center',
65
+ textAlign: 'center',
66
66
  textBaseline: 'middle',
67
67
  });
68
68
  }
@@ -38,8 +38,7 @@ function getArrowMarker(
38
38
  ) {
39
39
  const arrowMarker = document.createElement('path', {
40
40
  style: {
41
- path: `M ${arrowSize},${arrowSize} L -${arrowSize},0 L ${arrowSize},-${arrowSize} L 0,0 Z`,
42
- anchor: '0.5 0.5',
41
+ d: `M ${arrowSize},${arrowSize} L -${arrowSize},0 L ${arrowSize},-${arrowSize} L 0,0 Z`,
43
42
  transformOrigin: 'center',
44
43
  ...arrowStyle,
45
44
  },
@@ -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();
@@ -0,0 +1,44 @@
1
+ import { Text } from '@antv/g';
2
+ import { ShapeComponent as SC } from '../../runtime';
3
+ import { applyStyle } from '../../shape/utils';
4
+ import { select } from '../../utils/selection';
5
+
6
+ export type TagOptions = Record<string, any>;
7
+
8
+ /**
9
+ * @todo autoRotate when in polar coordinate
10
+ * Tag shape for Text mark, used in wordCloud plot.
11
+ */
12
+ export const Tag: SC<TagOptions> = (options, context) => {
13
+ const { coordinate } = context;
14
+ return (points, value, defaults) => {
15
+ const { color, text = '', fontSize, rotate = 0, transform = '' } = value;
16
+ const textStyle = {
17
+ text: String(text),
18
+ stroke: color,
19
+ fill: color,
20
+ fontSize,
21
+ textAlign: 'center',
22
+ textBaseline: 'middle',
23
+ };
24
+ const [[x0, y0]] = points;
25
+ const n = select(new Text())
26
+ .style('x', x0)
27
+ .style('y', y0)
28
+ .call(applyStyle, defaults)
29
+ .style('transformOrigin', 'center center')
30
+ .style('transform', `${transform}rotate(${rotate}deg)`)
31
+ .style('coordCenter', coordinate.getCenter())
32
+ .call(applyStyle, textStyle)
33
+ .call(applyStyle, options)
34
+ .node();
35
+ return n;
36
+ };
37
+ };
38
+
39
+ Tag.props = {
40
+ defaultMarker: 'point',
41
+ defaultEnterAnimation: 'fadeIn',
42
+ defaultUpdateAnimation: 'morphing',
43
+ defaultExitAnimation: 'fadeOut',
44
+ };
@@ -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
  }