@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.
- package/dist/g2.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/animation/morphing.js +14 -12
- package/esm/animation/morphing.js.map +1 -1
- package/esm/data/utils/d3-cloud/index.js +1 -0
- package/esm/data/utils/d3-cloud/index.js.map +1 -1
- package/esm/data/wordCloud.d.ts +100 -2
- package/esm/data/wordCloud.js +20 -5
- package/esm/data/wordCloud.js.map +1 -1
- package/esm/index.d.ts +6 -2
- package/esm/interaction/brushHighlight.js +11 -8
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/label-transform/exceedAdjust.d.ts +7 -0
- package/esm/label-transform/exceedAdjust.js +45 -0
- package/esm/label-transform/exceedAdjust.js.map +1 -0
- package/esm/label-transform/index.d.ts +2 -0
- package/esm/label-transform/index.js +1 -0
- package/esm/label-transform/index.js.map +1 -1
- package/esm/lib/core.d.ts +3 -0
- package/esm/lib/core.js +6 -3
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +3 -1
- package/esm/mark/text.js +4 -3
- package/esm/mark/text.js.map +1 -1
- package/esm/mark/wordCloud.js +11 -12
- package/esm/mark/wordCloud.js.map +1 -1
- package/esm/runtime/plot.js +8 -4
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/types/component.d.ts +5 -2
- package/esm/shape/index.d.ts +2 -0
- package/esm/shape/index.js +1 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/text/tag.d.ts +7 -0
- package/esm/shape/text/tag.js +40 -0
- package/esm/shape/text/tag.js.map +1 -0
- package/esm/spec/labelTransform.d.ts +3 -0
- package/lib/animation/morphing.js +14 -12
- package/lib/animation/morphing.js.map +1 -1
- package/lib/data/utils/d3-cloud/index.js +1 -0
- package/lib/data/utils/d3-cloud/index.js.map +1 -1
- package/lib/data/wordCloud.d.ts +100 -2
- package/lib/data/wordCloud.js +20 -5
- package/lib/data/wordCloud.js.map +1 -1
- package/lib/index.d.ts +6 -2
- package/lib/interaction/brushHighlight.js +11 -8
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/label-transform/exceedAdjust.d.ts +7 -0
- package/lib/label-transform/exceedAdjust.js +49 -0
- package/lib/label-transform/exceedAdjust.js.map +1 -0
- package/lib/label-transform/index.d.ts +2 -0
- package/lib/label-transform/index.js +3 -1
- package/lib/label-transform/index.js.map +1 -1
- package/lib/lib/core.d.ts +3 -0
- package/lib/lib/core.js +3 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +3 -1
- package/lib/mark/text.js +3 -2
- package/lib/mark/text.js.map +1 -1
- package/lib/mark/wordCloud.js +11 -12
- package/lib/mark/wordCloud.js.map +1 -1
- package/lib/runtime/plot.js +7 -3
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/types/component.d.ts +5 -2
- package/lib/shape/index.d.ts +2 -0
- package/lib/shape/index.js +4 -2
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/text/tag.d.ts +7 -0
- package/lib/shape/text/tag.js +44 -0
- package/lib/shape/text/tag.js.map +1 -0
- package/lib/spec/labelTransform.d.ts +3 -0
- package/package.json +3 -2
- package/src/animation/morphing.ts +15 -12
- package/src/data/utils/d3-cloud/index.ts +1 -0
- package/src/data/wordCloud.ts +112 -7
- package/src/interaction/brushHighlight.ts +13 -8
- package/src/label-transform/exceedAdjust.ts +61 -0
- package/src/label-transform/index.ts +2 -0
- package/src/lib/core.ts +6 -0
- package/src/mark/text.ts +4 -3
- package/src/mark/wordCloud.ts +16 -18
- package/src/runtime/plot.ts +9 -3
- package/src/runtime/types/component.ts +10 -2
- package/src/shape/index.ts +2 -0
- package/src/shape/text/tag.ts +44 -0
- 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
|
+
};
|