@antv/g2 5.1.18 → 5.1.20

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 (85) hide show
  1. package/dist/g2.lite.min.js +1 -1
  2. package/dist/g2.min.js +1 -1
  3. package/esm/animation/morphing.js +14 -12
  4. package/esm/animation/morphing.js.map +1 -1
  5. package/esm/data/utils/d3-cloud/index.js +1 -0
  6. package/esm/data/utils/d3-cloud/index.js.map +1 -1
  7. package/esm/data/wordCloud.d.ts +100 -2
  8. package/esm/data/wordCloud.js +20 -5
  9. package/esm/data/wordCloud.js.map +1 -1
  10. package/esm/index.d.ts +6 -2
  11. package/esm/interaction/brushHighlight.js +11 -8
  12. package/esm/interaction/brushHighlight.js.map +1 -1
  13. package/esm/label-transform/exceedAdjust.d.ts +7 -0
  14. package/esm/label-transform/exceedAdjust.js +45 -0
  15. package/esm/label-transform/exceedAdjust.js.map +1 -0
  16. package/esm/label-transform/index.d.ts +2 -0
  17. package/esm/label-transform/index.js +1 -0
  18. package/esm/label-transform/index.js.map +1 -1
  19. package/esm/lib/core.d.ts +3 -0
  20. package/esm/lib/core.js +6 -3
  21. package/esm/lib/core.js.map +1 -1
  22. package/esm/lib/std.d.ts +3 -1
  23. package/esm/mark/text.js +4 -3
  24. package/esm/mark/text.js.map +1 -1
  25. package/esm/mark/wordCloud.js +11 -12
  26. package/esm/mark/wordCloud.js.map +1 -1
  27. package/esm/runtime/plot.js +8 -4
  28. package/esm/runtime/plot.js.map +1 -1
  29. package/esm/runtime/types/component.d.ts +5 -2
  30. package/esm/shape/index.d.ts +2 -0
  31. package/esm/shape/index.js +1 -0
  32. package/esm/shape/index.js.map +1 -1
  33. package/esm/shape/text/tag.d.ts +7 -0
  34. package/esm/shape/text/tag.js +40 -0
  35. package/esm/shape/text/tag.js.map +1 -0
  36. package/esm/spec/labelTransform.d.ts +3 -0
  37. package/lib/animation/morphing.js +14 -12
  38. package/lib/animation/morphing.js.map +1 -1
  39. package/lib/data/utils/d3-cloud/index.js +1 -0
  40. package/lib/data/utils/d3-cloud/index.js.map +1 -1
  41. package/lib/data/wordCloud.d.ts +100 -2
  42. package/lib/data/wordCloud.js +20 -5
  43. package/lib/data/wordCloud.js.map +1 -1
  44. package/lib/index.d.ts +6 -2
  45. package/lib/interaction/brushHighlight.js +11 -8
  46. package/lib/interaction/brushHighlight.js.map +1 -1
  47. package/lib/label-transform/exceedAdjust.d.ts +7 -0
  48. package/lib/label-transform/exceedAdjust.js +49 -0
  49. package/lib/label-transform/exceedAdjust.js.map +1 -0
  50. package/lib/label-transform/index.d.ts +2 -0
  51. package/lib/label-transform/index.js +3 -1
  52. package/lib/label-transform/index.js.map +1 -1
  53. package/lib/lib/core.d.ts +3 -0
  54. package/lib/lib/core.js +3 -0
  55. package/lib/lib/core.js.map +1 -1
  56. package/lib/lib/std.d.ts +3 -1
  57. package/lib/mark/text.js +3 -2
  58. package/lib/mark/text.js.map +1 -1
  59. package/lib/mark/wordCloud.js +11 -12
  60. package/lib/mark/wordCloud.js.map +1 -1
  61. package/lib/runtime/plot.js +7 -3
  62. package/lib/runtime/plot.js.map +1 -1
  63. package/lib/runtime/types/component.d.ts +5 -2
  64. package/lib/shape/index.d.ts +2 -0
  65. package/lib/shape/index.js +4 -2
  66. package/lib/shape/index.js.map +1 -1
  67. package/lib/shape/text/tag.d.ts +7 -0
  68. package/lib/shape/text/tag.js +44 -0
  69. package/lib/shape/text/tag.js.map +1 -0
  70. package/lib/spec/labelTransform.d.ts +3 -0
  71. package/package.json +3 -2
  72. package/src/animation/morphing.ts +15 -12
  73. package/src/data/utils/d3-cloud/index.ts +1 -0
  74. package/src/data/wordCloud.ts +112 -7
  75. package/src/interaction/brushHighlight.ts +13 -8
  76. package/src/label-transform/exceedAdjust.ts +61 -0
  77. package/src/label-transform/index.ts +2 -0
  78. package/src/lib/core.ts +6 -0
  79. package/src/mark/text.ts +4 -3
  80. package/src/mark/wordCloud.ts +16 -18
  81. package/src/runtime/plot.ts +9 -3
  82. package/src/runtime/types/component.ts +10 -2
  83. package/src/shape/index.ts +2 -0
  84. package/src/shape/text/tag.ts +44 -0
  85. package/src/spec/labelTransform.ts +4 -0
@@ -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
+ };
@@ -37,3 +37,7 @@ export type ContrastReverseLabelTransform = {
37
37
  export type OverflowHideLabelTransform = {
38
38
  type: 'overflowHide';
39
39
  };
40
+
41
+ export type ExceedAdjustLabel = {
42
+ type: 'exceedAdjust';
43
+ };