@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.
- package/dist/g2.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/animation/growInX.js +4 -2
- package/esm/animation/growInX.js.map +1 -1
- package/esm/animation/growInY.js +4 -2
- package/esm/animation/growInY.js.map +1 -1
- package/esm/animation/morphing.js +35 -18
- package/esm/animation/morphing.js.map +1 -1
- package/esm/animation/scaleInY.js +2 -5
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/utils.d.ts +10 -1
- package/esm/animation/utils.js +29 -3
- package/esm/animation/utils.js.map +1 -1
- package/esm/animation/waveIn.js +3 -14
- package/esm/animation/waveIn.js.map +1 -1
- package/esm/component/title.js +2 -1
- package/esm/component/title.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/exports.js +0 -2
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +4 -2
- package/esm/interaction/brushAxisHighlight.js +3 -3
- package/esm/interaction/brushAxisHighlight.js.map +1 -1
- package/esm/interaction/brushHighlight.js +4 -5
- package/esm/interaction/brushHighlight.js.map +1 -1
- package/esm/interaction/elementPointMove.js +6 -6
- package/esm/interaction/elementPointMove.js.map +1 -1
- package/esm/interaction/tooltip.js +4 -1
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/interaction/utils.js +2 -2
- package/esm/interaction/utils.js.map +1 -1
- package/esm/lib/core.d.ts +2 -0
- package/esm/lib/core.js +4 -2
- package/esm/lib/core.js.map +1 -1
- package/esm/lib/std.d.ts +2 -1
- package/esm/mark/chord.js +0 -1
- package/esm/mark/chord.js.map +1 -1
- package/esm/mark/point.js +3 -1
- package/esm/mark/point.js.map +1 -1
- package/esm/mark/sankey.js +1 -1
- package/esm/mark/sankey.js.map +1 -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 +4 -7
- package/esm/runtime/plot.js.map +1 -1
- package/esm/shape/connector/connector.js +1 -1
- package/esm/shape/connector/connector.js.map +1 -1
- package/esm/shape/gauge/round.js +1 -1
- package/esm/shape/gauge/round.js.map +1 -1
- package/esm/shape/image/image.js +1 -1
- package/esm/shape/index.d.ts +4 -0
- package/esm/shape/index.js +3 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/interval/color.js +1 -1
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/funnel.js +1 -1
- package/esm/shape/interval/funnel.js.map +1 -1
- package/esm/shape/label/position/default.js +9 -9
- package/esm/shape/label/position/default.js.map +1 -1
- package/esm/shape/lineXY/line.js +1 -1
- package/esm/shape/lineXY/line.js.map +1 -1
- package/esm/shape/liquid/liquid.js +4 -4
- package/esm/shape/liquid/liquid.js.map +1 -1
- package/esm/shape/liquid/wave.js +2 -2
- package/esm/shape/liquid/wave.js.map +1 -1
- package/esm/shape/point/circle.d.ts +16 -0
- package/esm/shape/point/circle.js +56 -0
- package/esm/shape/point/circle.js.map +1 -0
- package/esm/shape/point/color.d.ts +2 -0
- package/esm/shape/point/color.js +2 -1
- package/esm/shape/point/color.js.map +1 -1
- package/esm/shape/point/hollowCircle.d.ts +6 -0
- package/esm/shape/point/hollowCircle.js +9 -0
- package/esm/shape/point/hollowCircle.js.map +1 -0
- package/esm/shape/text/advance.js +2 -1
- package/esm/shape/text/advance.js.map +1 -1
- package/esm/shape/text/badge.js +2 -3
- package/esm/shape/text/badge.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/theme/create.d.ts +4 -2
- package/esm/theme/create.js +4 -2
- package/esm/theme/create.js.map +1 -1
- package/esm/utils/helper.js +1 -8
- package/esm/utils/helper.js.map +1 -1
- package/esm/utils/marker.d.ts +1 -1
- package/esm/utils/marker.js +2 -2
- package/esm/utils/marker.js.map +1 -1
- package/lib/animation/growInX.js +4 -2
- package/lib/animation/growInX.js.map +1 -1
- package/lib/animation/growInY.js +4 -2
- package/lib/animation/growInY.js.map +1 -1
- package/lib/animation/morphing.js +33 -16
- package/lib/animation/morphing.js.map +1 -1
- package/lib/animation/scaleInY.js +2 -5
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/utils.d.ts +10 -1
- package/lib/animation/utils.js +30 -4
- package/lib/animation/utils.js.map +1 -1
- package/lib/animation/waveIn.js +2 -13
- package/lib/animation/waveIn.js.map +1 -1
- package/lib/component/title.js +2 -1
- package/lib/component/title.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/exports.js +0 -2
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/interaction/brushAxisHighlight.js +3 -3
- package/lib/interaction/brushAxisHighlight.js.map +1 -1
- package/lib/interaction/brushHighlight.js +4 -5
- package/lib/interaction/brushHighlight.js.map +1 -1
- package/lib/interaction/elementPointMove.js +6 -6
- package/lib/interaction/elementPointMove.js.map +1 -1
- package/lib/interaction/tooltip.js +4 -1
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/interaction/utils.js +2 -2
- package/lib/interaction/utils.js.map +1 -1
- package/lib/lib/core.d.ts +2 -0
- package/lib/lib/core.js +2 -0
- package/lib/lib/core.js.map +1 -1
- package/lib/lib/std.d.ts +2 -1
- package/lib/mark/chord.js +0 -1
- package/lib/mark/chord.js.map +1 -1
- package/lib/mark/point.js +2 -0
- package/lib/mark/point.js.map +1 -1
- package/lib/mark/sankey.js +1 -1
- package/lib/mark/sankey.js.map +1 -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 +4 -7
- package/lib/runtime/plot.js.map +1 -1
- package/lib/shape/connector/connector.js +1 -1
- package/lib/shape/connector/connector.js.map +1 -1
- package/lib/shape/gauge/round.js +1 -1
- package/lib/shape/gauge/round.js.map +1 -1
- package/lib/shape/image/image.js +1 -1
- package/lib/shape/index.d.ts +4 -0
- package/lib/shape/index.js +8 -2
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/interval/color.js +1 -1
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/funnel.js +1 -1
- package/lib/shape/interval/funnel.js.map +1 -1
- package/lib/shape/label/position/default.js +9 -9
- package/lib/shape/label/position/default.js.map +1 -1
- package/lib/shape/lineXY/line.js +1 -1
- package/lib/shape/lineXY/line.js.map +1 -1
- package/lib/shape/liquid/liquid.js +4 -4
- package/lib/shape/liquid/liquid.js.map +1 -1
- package/lib/shape/liquid/wave.js +2 -2
- package/lib/shape/liquid/wave.js.map +1 -1
- package/lib/shape/point/circle.d.ts +16 -0
- package/lib/shape/point/circle.js +61 -0
- package/lib/shape/point/circle.js.map +1 -0
- package/lib/shape/point/color.d.ts +2 -0
- package/lib/shape/point/color.js +3 -1
- package/lib/shape/point/color.js.map +1 -1
- package/lib/shape/point/hollowCircle.d.ts +6 -0
- package/lib/shape/point/hollowCircle.js +13 -0
- package/lib/shape/point/hollowCircle.js.map +1 -0
- package/lib/shape/text/advance.js +2 -1
- package/lib/shape/text/advance.js.map +1 -1
- package/lib/shape/text/badge.js +2 -3
- package/lib/shape/text/badge.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/theme/create.d.ts +4 -2
- package/lib/theme/create.js +4 -2
- package/lib/theme/create.js.map +1 -1
- package/lib/utils/helper.js +1 -8
- package/lib/utils/helper.js.map +1 -1
- package/lib/utils/marker.d.ts +1 -1
- package/lib/utils/marker.js +2 -2
- package/lib/utils/marker.js.map +1 -1
- package/package.json +13 -13
- package/src/animation/growInX.ts +9 -2
- package/src/animation/growInY.ts +9 -2
- package/src/animation/morphing.ts +36 -24
- package/src/animation/scaleInY.ts +2 -5
- package/src/animation/utils.ts +34 -4
- package/src/animation/waveIn.ts +3 -20
- package/src/component/title.ts +4 -0
- package/src/data/utils/d3-cloud/index.ts +1 -0
- package/src/data/wordCloud.ts +112 -7
- package/src/exports.ts +0 -4
- package/src/interaction/brushAxisHighlight.ts +5 -4
- package/src/interaction/brushHighlight.ts +8 -5
- package/src/interaction/elementPointMove.ts +6 -6
- package/src/interaction/tooltip.ts +4 -1
- package/src/interaction/utils.ts +2 -2
- package/src/lib/core.ts +4 -0
- package/src/mark/chord.ts +0 -1
- package/src/mark/point.ts +4 -0
- package/src/mark/sankey.ts +1 -1
- package/src/mark/text.ts +4 -3
- package/src/mark/wordCloud.ts +16 -18
- package/src/runtime/plot.ts +12 -7
- package/src/shape/connector/connector.ts +1 -1
- package/src/shape/gauge/round.ts +1 -1
- package/src/shape/image/image.ts +1 -1
- package/src/shape/index.ts +4 -0
- package/src/shape/interval/color.ts +1 -1
- package/src/shape/interval/funnel.ts +1 -1
- package/src/shape/label/position/default.ts +9 -9
- package/src/shape/lineXY/line.ts +1 -2
- package/src/shape/liquid/liquid.ts +4 -4
- package/src/shape/liquid/wave.ts +2 -2
- package/src/shape/point/circle.ts +57 -0
- package/src/shape/point/color.ts +2 -1
- package/src/shape/point/hollowCircle.ts +16 -0
- package/src/shape/text/advance.ts +3 -1
- package/src/shape/text/badge.ts +2 -3
- package/src/shape/text/tag.ts +44 -0
- package/src/theme/create.ts +4 -2
- package/src/utils/helper.ts +1 -7
- package/src/utils/marker.ts +2 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/g2",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.19",
|
|
4
4
|
"description": "the Grammar of Graphics in Javascript",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -59,12 +59,12 @@
|
|
|
59
59
|
"animation"
|
|
60
60
|
],
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@antv/component": "^
|
|
62
|
+
"@antv/component": "^2.0.0",
|
|
63
63
|
"@antv/coord": "^0.4.6",
|
|
64
64
|
"@antv/event-emitter": "^0.1.3",
|
|
65
|
-
"@antv/g": "^
|
|
66
|
-
"@antv/g-canvas": "^
|
|
67
|
-
"@antv/g-plugin-dragndrop": "^
|
|
65
|
+
"@antv/g": "^6.0.0",
|
|
66
|
+
"@antv/g-canvas": "^2.0.0",
|
|
67
|
+
"@antv/g-plugin-dragndrop": "^2.0.0",
|
|
68
68
|
"@antv/path-util": "^3.0.1",
|
|
69
69
|
"@antv/scale": "^0.4.12",
|
|
70
70
|
"@antv/util": "^3.3.5",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
},
|
|
85
85
|
"devDependencies": {
|
|
86
86
|
"@antv/data-set": "^0.11.8",
|
|
87
|
-
"@antv/g-pattern": "^
|
|
88
|
-
"@antv/g-plugin-3d": "^
|
|
89
|
-
"@antv/g-plugin-control": "^
|
|
90
|
-
"@antv/g-plugin-rough-canvas-renderer": "^
|
|
91
|
-
"@antv/g-plugin-rough-svg-renderer": "^
|
|
92
|
-
"@antv/g-svg": "^
|
|
93
|
-
"@antv/g-webgl": "^
|
|
87
|
+
"@antv/g-pattern": "^2.0.0",
|
|
88
|
+
"@antv/g-plugin-3d": "^2.0.0",
|
|
89
|
+
"@antv/g-plugin-control": "^2.0.0",
|
|
90
|
+
"@antv/g-plugin-rough-canvas-renderer": "^2.0.0",
|
|
91
|
+
"@antv/g-plugin-rough-svg-renderer": "^2.0.0",
|
|
92
|
+
"@antv/g-svg": "^2.0.0",
|
|
93
|
+
"@antv/g-webgl": "^2.0.0",
|
|
94
94
|
"@antv/g2-extension-3d": "^0.1.3",
|
|
95
95
|
"@antv/g2-extension-ava": "^0.1.1",
|
|
96
96
|
"@antv/g2-extension-plot": "^0.1.0",
|
|
@@ -154,7 +154,7 @@
|
|
|
154
154
|
"limit-size": [
|
|
155
155
|
{
|
|
156
156
|
"path": "dist/g2.min.js",
|
|
157
|
-
"limit": "
|
|
157
|
+
"limit": "285 Kb",
|
|
158
158
|
"gzip": true
|
|
159
159
|
},
|
|
160
160
|
{
|
package/src/animation/growInX.ts
CHANGED
|
@@ -11,10 +11,17 @@ export type GrowInXOptions = Animation;
|
|
|
11
11
|
export const GrowInX: AC<GrowInXOptions> = (options, context) => {
|
|
12
12
|
return (from, to, defaults) => {
|
|
13
13
|
const [shape] = from;
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
min: [x, y],
|
|
16
|
+
halfExtents,
|
|
17
|
+
} = shape.getLocalBounds();
|
|
18
|
+
const width = halfExtents[0] * 2;
|
|
19
|
+
const height = halfExtents[1] * 2;
|
|
15
20
|
const clipPath = new Path({
|
|
16
21
|
style: {
|
|
17
|
-
|
|
22
|
+
d: `M${x},${y}L${x + width},${y}L${x + width},${y + height}L${x},${
|
|
23
|
+
y + height
|
|
24
|
+
}Z`,
|
|
18
25
|
},
|
|
19
26
|
});
|
|
20
27
|
shape.appendChild(clipPath);
|
package/src/animation/growInY.ts
CHANGED
|
@@ -11,10 +11,17 @@ export type GrowInYOptions = Animation;
|
|
|
11
11
|
export const GrowInY: AC<GrowInYOptions> = (options, context) => {
|
|
12
12
|
return (from, to, defaults) => {
|
|
13
13
|
const [shape] = from;
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
min: [x, y],
|
|
16
|
+
halfExtents,
|
|
17
|
+
} = shape.getLocalBounds();
|
|
18
|
+
const width = halfExtents[0] * 2;
|
|
19
|
+
const height = halfExtents[1] * 2;
|
|
15
20
|
const clipPath = new Path({
|
|
16
21
|
style: {
|
|
17
|
-
|
|
22
|
+
d: `M${x},${y}L${x + width},${y}L${x + width},${y + height}L${x},${
|
|
23
|
+
y + height
|
|
24
|
+
}Z`,
|
|
18
25
|
},
|
|
19
26
|
});
|
|
20
27
|
shape.appendChild(clipPath);
|
|
@@ -3,11 +3,12 @@ import {
|
|
|
3
3
|
DisplayObject,
|
|
4
4
|
IAnimation as GAnimation,
|
|
5
5
|
Path,
|
|
6
|
+
Shape,
|
|
6
7
|
} from '@antv/g';
|
|
7
8
|
import { AnimationComponent as AC } from '../runtime';
|
|
8
9
|
import { copyAttributes } from '../utils/helper';
|
|
9
10
|
import { Animation } from './types';
|
|
10
|
-
import { attributeKeys, attributeOf } from './utils';
|
|
11
|
+
import { attributeKeys, attributeOf, GEOMETRY_ATTRIBUTES } from './utils';
|
|
11
12
|
|
|
12
13
|
export type MorphingOptions = Animation & { split: 'pack' | SplitFunction };
|
|
13
14
|
|
|
@@ -66,38 +67,44 @@ function normalizeSplit(
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
/**
|
|
69
|
-
*
|
|
70
|
+
* Use attributes relative to geometry to do shape to shape animation.
|
|
71
|
+
*
|
|
72
|
+
* For example, the x, y, width, height of `Rect`, the cx, cy, r of `Circle`.
|
|
73
|
+
* And for `Group`, it will use the bbox of the group.
|
|
70
74
|
*/
|
|
71
75
|
function shapeToShape(
|
|
72
76
|
from: DisplayObject,
|
|
73
77
|
to: DisplayObject,
|
|
74
78
|
timeEffect: Record<string, any>,
|
|
75
79
|
): GAnimation {
|
|
76
|
-
|
|
77
|
-
const { transform: fromTransform } = from.style;
|
|
80
|
+
let { transform: fromTransform } = from.style;
|
|
78
81
|
const { transform: toTransform } = to.style;
|
|
79
82
|
|
|
80
83
|
// Replace first to get right bbox after mounting.
|
|
81
84
|
replaceChild(to, from);
|
|
82
85
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
let keys = attributeKeys;
|
|
87
|
+
if (from.nodeName === Shape.GROUP) {
|
|
88
|
+
// Apply translate and scale transform.
|
|
89
|
+
const [x0, y0, w0, h0] = localBBoxOf(from);
|
|
90
|
+
const [x1, y1, w1, h1] = localBBoxOf(to);
|
|
91
|
+
const dx = x0 - x1;
|
|
92
|
+
const dy = y0 - y1;
|
|
93
|
+
const sx = w0 / w1;
|
|
94
|
+
const sy = h0 / h1;
|
|
95
|
+
fromTransform = `translate(${dx}, ${dy}) scale(${sx}, ${sy})`;
|
|
96
|
+
} else {
|
|
97
|
+
keys = keys.concat(GEOMETRY_ATTRIBUTES[from.nodeName] || []);
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
const keyframes = [
|
|
90
101
|
{
|
|
91
|
-
transform:
|
|
92
|
-
|
|
93
|
-
}translate(${dx}, ${dy}) scale(${sx}, ${sy})`,
|
|
94
|
-
...attributeOf(from, attributeKeys),
|
|
102
|
+
transform: fromTransform ?? 'none',
|
|
103
|
+
...attributeOf(from, keys, true),
|
|
95
104
|
},
|
|
96
105
|
{
|
|
97
|
-
transform:
|
|
98
|
-
|
|
99
|
-
}translate(0, 0) scale(1, 1)`,
|
|
100
|
-
...attributeOf(to, attributeKeys),
|
|
106
|
+
transform: toTransform ?? 'none',
|
|
107
|
+
...attributeOf(to, keys, true),
|
|
101
108
|
},
|
|
102
109
|
];
|
|
103
110
|
const animation = to.animate(keyframes, timeEffect);
|
|
@@ -172,21 +179,26 @@ function oneToOne(
|
|
|
172
179
|
const pathShape = maybePath(shape, fromPath);
|
|
173
180
|
// Convert Path will take transform, anchor, etc into account,
|
|
174
181
|
// so there is no need to specify these attributes in keyframes.
|
|
175
|
-
const keyframes = [
|
|
182
|
+
const keyframes: Keyframe[] = [
|
|
176
183
|
{
|
|
177
|
-
path: fromPath,
|
|
178
184
|
...attributeOf(from, attributeKeys),
|
|
179
185
|
},
|
|
180
186
|
{
|
|
181
|
-
path: toPath,
|
|
182
187
|
...attributeOf(to, attributeKeys),
|
|
183
188
|
},
|
|
184
189
|
];
|
|
190
|
+
if (fromPath !== toPath) {
|
|
191
|
+
keyframes[0].d = fromPath;
|
|
192
|
+
keyframes[1].d = toPath;
|
|
193
|
+
}
|
|
185
194
|
const animation = pathShape.animate(keyframes, timeEffect);
|
|
186
195
|
|
|
187
196
|
animation.onfinish = () => {
|
|
188
|
-
|
|
197
|
+
// Should keep the original path definition.
|
|
198
|
+
const d = pathShape.style.d;
|
|
189
199
|
copyAttributes(pathShape, to);
|
|
200
|
+
pathShape.style.d = d;
|
|
201
|
+
pathShape.style.transform = 'none';
|
|
190
202
|
};
|
|
191
203
|
|
|
192
204
|
// Remove transform because it already applied in path
|
|
@@ -207,7 +219,7 @@ function oneToMultiple(
|
|
|
207
219
|
return to.map((shape, i) => {
|
|
208
220
|
const path = new Path({
|
|
209
221
|
style: {
|
|
210
|
-
|
|
222
|
+
d: D[i],
|
|
211
223
|
...attributeOf(from, attributeKeys),
|
|
212
224
|
},
|
|
213
225
|
});
|
|
@@ -236,7 +248,7 @@ function multipleToOne(
|
|
|
236
248
|
const animations = from.map((shape, i) => {
|
|
237
249
|
const path = new Path({
|
|
238
250
|
style: {
|
|
239
|
-
|
|
251
|
+
d: D[i],
|
|
240
252
|
fill: to.style.fill,
|
|
241
253
|
},
|
|
242
254
|
});
|
|
@@ -51,7 +51,6 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
|
|
|
51
51
|
.cornerRadius(radius as number)
|
|
52
52
|
.padAngle((inset * Math.PI) / 180);
|
|
53
53
|
const pathForConversion = new Path({});
|
|
54
|
-
const center = coordinate.getCenter();
|
|
55
54
|
const createArcPath = (arcParams: {
|
|
56
55
|
startAngle: number;
|
|
57
56
|
endAngle: number;
|
|
@@ -60,10 +59,8 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
|
|
|
60
59
|
}) => {
|
|
61
60
|
pathForConversion.attr({
|
|
62
61
|
d: path(arcParams),
|
|
63
|
-
transform: `translate(${center[0]}, ${center[1]})`,
|
|
64
62
|
});
|
|
65
63
|
const convertedPathDefinition = convertToPath(pathForConversion);
|
|
66
|
-
pathForConversion.style.transform = '';
|
|
67
64
|
return convertedPathDefinition;
|
|
68
65
|
};
|
|
69
66
|
|
|
@@ -91,14 +88,14 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
|
|
|
91
88
|
|
|
92
89
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
93
90
|
animation.onframe = function () {
|
|
94
|
-
shape.style.
|
|
91
|
+
shape.style.d = createArcPath({
|
|
95
92
|
...arcObject,
|
|
96
93
|
outerRadius: Number(shape.style.scaleInYRadius),
|
|
97
94
|
});
|
|
98
95
|
};
|
|
99
96
|
|
|
100
97
|
animation.onfinish = function () {
|
|
101
|
-
shape.style.
|
|
98
|
+
shape.style.d = createArcPath({
|
|
102
99
|
...arcObject,
|
|
103
100
|
outerRadius: outerRadius,
|
|
104
101
|
});
|
package/src/animation/utils.ts
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
|
-
import { DisplayObject } from '@antv/g';
|
|
1
|
+
import { DisplayObject, Shape } from '@antv/g';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const DEFAULT_ATTRIBUTE_VALUE = {
|
|
4
|
+
opacity: 1,
|
|
5
|
+
strokeOpacity: 1,
|
|
6
|
+
fillOpacity: 1,
|
|
7
|
+
lineWidth: 0,
|
|
8
|
+
x: 0,
|
|
9
|
+
y: 0,
|
|
10
|
+
cx: 0,
|
|
11
|
+
cy: 0,
|
|
12
|
+
r: 0,
|
|
13
|
+
rx: 0,
|
|
14
|
+
ry: 0,
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const GEOMETRY_ATTRIBUTES = {
|
|
20
|
+
[Shape.CIRCLE]: ['cx', 'cy', 'r'],
|
|
21
|
+
[Shape.ELLIPSE]: ['cx', 'cy', 'rx', 'ry'],
|
|
22
|
+
[Shape.RECT]: ['x', 'y', 'width', 'height'],
|
|
23
|
+
[Shape.IMAGE]: ['x', 'y', 'width', 'height'],
|
|
24
|
+
[Shape.LINE]: ['x1', 'y1', 'x2', 'y2'],
|
|
25
|
+
[Shape.POLYLINE]: ['points'],
|
|
26
|
+
[Shape.POLYGON]: ['points'],
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export function attributeOf(
|
|
30
|
+
shape: DisplayObject,
|
|
31
|
+
keys: string[],
|
|
32
|
+
useDefaultValue = false,
|
|
33
|
+
) {
|
|
6
34
|
const attribute = {};
|
|
7
35
|
for (const key of keys) {
|
|
8
36
|
const value = shape.style[key];
|
|
9
37
|
if (value) {
|
|
10
38
|
attribute[key] = value;
|
|
39
|
+
} else if (useDefaultValue) {
|
|
40
|
+
attribute[key] = DEFAULT_ATTRIBUTE_VALUE[key];
|
|
11
41
|
}
|
|
12
42
|
}
|
|
13
43
|
return attribute;
|
package/src/animation/waveIn.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { arc } from 'd3-shape';
|
|
2
|
-
import {
|
|
2
|
+
import { CSS, PropertySyntax } from '@antv/g';
|
|
3
3
|
import { G2Element } from '../utils/selection';
|
|
4
4
|
import { AnimationComponent as AC } from '../runtime';
|
|
5
5
|
import { getArcObject } from '../shape/utils';
|
|
@@ -33,7 +33,6 @@ export const WaveIn: AC<WaveInOptions> = (options, context) => {
|
|
|
33
33
|
return ScaleInX(options, context)(from, to, defaults);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
const center = coordinate.getCenter();
|
|
37
36
|
const { __data__, style } = shape as G2Element;
|
|
38
37
|
const {
|
|
39
38
|
radius = 0,
|
|
@@ -50,22 +49,6 @@ export const WaveIn: AC<WaveInOptions> = (options, context) => {
|
|
|
50
49
|
.padAngle((inset * Math.PI) / 180);
|
|
51
50
|
const arcObject = getArcObject(coordinate, points, [y, y1]);
|
|
52
51
|
const { startAngle, endAngle } = arcObject;
|
|
53
|
-
const pathForConversion = new Path({});
|
|
54
|
-
|
|
55
|
-
const createArcPath = (arcParams: {
|
|
56
|
-
startAngle: number;
|
|
57
|
-
endAngle: number;
|
|
58
|
-
innerRadius: number;
|
|
59
|
-
outerRadius: number;
|
|
60
|
-
}) => {
|
|
61
|
-
pathForConversion.attr({
|
|
62
|
-
d: path(arcParams),
|
|
63
|
-
transform: `translate(${center[0]}, ${center[1]})`,
|
|
64
|
-
});
|
|
65
|
-
const convertedPathDefinition = convertToPath(pathForConversion);
|
|
66
|
-
pathForConversion.style.transform = '';
|
|
67
|
-
return convertedPathDefinition;
|
|
68
|
-
};
|
|
69
52
|
|
|
70
53
|
const keyframes = [
|
|
71
54
|
// Use custom interpolable CSS property.
|
|
@@ -92,13 +75,13 @@ export const WaveIn: AC<WaveInOptions> = (options, context) => {
|
|
|
92
75
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
93
76
|
|
|
94
77
|
animation.onframe = function () {
|
|
95
|
-
shape.style.
|
|
78
|
+
shape.style.d = path({
|
|
96
79
|
...arcObject,
|
|
97
80
|
endAngle: Number(shape.style.waveInArcAngle),
|
|
98
81
|
});
|
|
99
82
|
};
|
|
100
83
|
animation.onfinish = function () {
|
|
101
|
-
shape.style.
|
|
84
|
+
shape.style.d = path({
|
|
102
85
|
...arcObject,
|
|
103
86
|
endAngle: endAngle,
|
|
104
87
|
});
|
package/src/component/title.ts
CHANGED
|
@@ -49,9 +49,13 @@ const Title = createComponent<TitleStyleProps>({
|
|
|
49
49
|
subtitle,
|
|
50
50
|
spacing = 2,
|
|
51
51
|
align = 'left',
|
|
52
|
+
x,
|
|
53
|
+
y,
|
|
52
54
|
...style
|
|
53
55
|
} = attributes;
|
|
54
56
|
|
|
57
|
+
container.style.transform = `translate(${x}, ${y})`;
|
|
58
|
+
|
|
55
59
|
const titleStyle = subObject(style, 'title');
|
|
56
60
|
const subtitleStyle = subObject(style, 'subtitle');
|
|
57
61
|
|
|
@@ -357,6 +357,7 @@ export function tagCloud() {
|
|
|
357
357
|
const context = canvas.getContext('2d') as CanvasRenderingContext2D;
|
|
358
358
|
context.fillStyle = context.strokeStyle = 'red';
|
|
359
359
|
context.textAlign = 'center';
|
|
360
|
+
context.textBaseline = 'middle';
|
|
360
361
|
return { context, ratio };
|
|
361
362
|
}
|
|
362
363
|
|
package/src/data/wordCloud.ts
CHANGED
|
@@ -1,15 +1,112 @@
|
|
|
1
1
|
import { min, max } from 'd3-array';
|
|
2
2
|
import { DataComponent as DC } from '../runtime';
|
|
3
|
-
import { tagCloud } from './utils/d3-cloud';
|
|
4
3
|
import { flow } from './utils/flow';
|
|
4
|
+
import { tagCloud } from './utils/d3-cloud';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
type Callable<T> = T | ((datum: any, i: number) => T);
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* See the document here: https://github.com/jasondavies/d3-cloud.
|
|
10
|
+
*/
|
|
11
|
+
export type WordCloudOptions = {
|
|
12
|
+
/**
|
|
13
|
+
* Internally, the layout uses setInterval to avoid locking up the browser’s event loop.
|
|
14
|
+
* If specified, time is the maximum amount of time that can be spent during the current timestep.
|
|
15
|
+
* If not specified, returns the current maximum time interval, which defaults to Infinity.
|
|
16
|
+
*/
|
|
17
|
+
timeInterval: number;
|
|
18
|
+
/**
|
|
19
|
+
* If specified, sets the words array. If not specified, returns the current words array, which defaults to [].
|
|
20
|
+
*/
|
|
21
|
+
words: any[];
|
|
22
|
+
/**
|
|
23
|
+
* If specified, sets the rectangular [width, height] of the layout.
|
|
24
|
+
* If not specified, returns the current size, which defaults to [1, 1].
|
|
25
|
+
*/
|
|
26
|
+
size: [number, number];
|
|
27
|
+
/**
|
|
28
|
+
* If specified, sets the font accessor function, which indicates the font face for each word.
|
|
29
|
+
* If not specified, returns the current font accessor function, which defaults to "serif".
|
|
30
|
+
* A constant may be specified instead of a function.
|
|
31
|
+
*/
|
|
32
|
+
font: Callable<CSSStyleDeclaration['fontFamily']>;
|
|
33
|
+
/**
|
|
34
|
+
* TODO: Cname of font.
|
|
35
|
+
*/
|
|
36
|
+
fontFamily: Callable<CSSStyleDeclaration['fontFamily']>;
|
|
37
|
+
/**
|
|
38
|
+
* If specified, sets the fontStyle accessor function, which indicates the font style for each word.
|
|
39
|
+
* If not specified, returns the current fontStyle accessor function, which defaults to "normal".
|
|
40
|
+
* A constant may be specified instead of a function.
|
|
41
|
+
*/
|
|
42
|
+
fontStyle: Callable<CSSStyleDeclaration['fontFamily']>;
|
|
43
|
+
/**
|
|
44
|
+
* If specified, sets the fontWeight accessor function, which indicates the font weight for each word.
|
|
45
|
+
* If not specified, returns the current fontWeight accessor function, which defaults to "normal".
|
|
46
|
+
* A constant may be specified instead of a function.
|
|
47
|
+
*/
|
|
48
|
+
fontWeight: Callable<CSSStyleDeclaration['fontFamily']>;
|
|
49
|
+
/**
|
|
50
|
+
* If specified, sets the fontSize accessor function, which indicates the numerical font size for each word.
|
|
51
|
+
* If not specified, returns the current fontSize accessor function, which defaults to:
|
|
52
|
+
*
|
|
53
|
+
* > function(d) { return Math.sqrt(d.value); }
|
|
54
|
+
*
|
|
55
|
+
* A constant may be specified instead of a function.
|
|
56
|
+
*
|
|
57
|
+
* If the fontSize is an array, it will be normalized to the range of [min, max] of the data value.
|
|
58
|
+
* If the fontSize is a function, it will be called with the data value.
|
|
59
|
+
* If the fontSize is a number, it will be used as the constant value.
|
|
60
|
+
*/
|
|
61
|
+
fontSize: number | [number, number] | ((d: any) => number);
|
|
62
|
+
/**
|
|
63
|
+
* If specified, sets the rotate accessor function, which indicates the rotation angle (in degrees) for each word.
|
|
64
|
+
* If not specified, returns the current rotate accessor function, which defaults to:
|
|
65
|
+
*
|
|
66
|
+
* function() { return (~~(Math.random() * 6) - 3) * 30; }
|
|
67
|
+
*
|
|
68
|
+
* A constant may be specified instead of a function.
|
|
69
|
+
*/
|
|
70
|
+
rotate: Callable<number>;
|
|
71
|
+
/**
|
|
72
|
+
* If specified, sets the text accessor function, which indicates the text for each word.
|
|
73
|
+
* If not specified, returns the current text accessor function, which defaults to:
|
|
74
|
+
*
|
|
75
|
+
* function(d) { return d.text; }
|
|
76
|
+
*
|
|
77
|
+
* A constant may be specified instead of a function.
|
|
78
|
+
*/
|
|
79
|
+
text: Callable<string>;
|
|
80
|
+
/**
|
|
81
|
+
* If specified, sets the padding accessor function, which indicates the numerical padding for each word.
|
|
82
|
+
* If not specified, returns the current padding, which defaults to 1.
|
|
83
|
+
*/
|
|
84
|
+
padding: Callable<number>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* If specified, sets the internal random number generator, used for selecting the initial position of each word,
|
|
88
|
+
* and the clockwise/counterclockwise direction of the spiral for each word.
|
|
89
|
+
* This should return a number in the range [0, 1).
|
|
90
|
+
* If not specified, returns the current random number generator, which defaults to Math.random.
|
|
91
|
+
*/
|
|
92
|
+
random: () => number;
|
|
93
|
+
spiral: any;
|
|
94
|
+
};
|
|
7
95
|
|
|
8
|
-
const DEFAULT_OPTIONS
|
|
9
|
-
|
|
10
|
-
|
|
96
|
+
const DEFAULT_OPTIONS = {
|
|
97
|
+
fontSize: [20, 60],
|
|
98
|
+
font: 'Impact',
|
|
99
|
+
padding: 2,
|
|
100
|
+
rotate: function () {
|
|
101
|
+
return (~~(Math.random() * 6) - 3) * 30;
|
|
102
|
+
},
|
|
11
103
|
};
|
|
12
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Process the image mask of wordCloud.
|
|
107
|
+
* @param img
|
|
108
|
+
* @returns
|
|
109
|
+
*/
|
|
13
110
|
export function processImageMask(
|
|
14
111
|
img: HTMLImageElement | string,
|
|
15
112
|
): Promise<HTMLImageElement> {
|
|
@@ -33,6 +130,12 @@ export function processImageMask(
|
|
|
33
130
|
});
|
|
34
131
|
}
|
|
35
132
|
|
|
133
|
+
/**
|
|
134
|
+
* normalize fontSize range to d3-cloud fontSize function.
|
|
135
|
+
* @param fontSize
|
|
136
|
+
* @param range
|
|
137
|
+
* @returns
|
|
138
|
+
*/
|
|
36
139
|
export function normalizeFontSize(fontSize: any, range?: [number, number]) {
|
|
37
140
|
if (typeof fontSize === 'function') return fontSize;
|
|
38
141
|
|
|
@@ -48,7 +151,7 @@ export function normalizeFontSize(fontSize: any, range?: [number, number]) {
|
|
|
48
151
|
return () => fontSize;
|
|
49
152
|
}
|
|
50
153
|
|
|
51
|
-
export const WordCloud: DC<WordCloudOptions
|
|
154
|
+
export const WordCloud: DC<Partial<WordCloudOptions>> = (options) => {
|
|
52
155
|
return async (data) => {
|
|
53
156
|
const cloudOptions = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
54
157
|
const layout = tagCloud();
|
|
@@ -80,12 +183,14 @@ export const WordCloud: DC<WordCloudOptions> = (options) => {
|
|
|
80
183
|
{ x: 0, y: 0 },
|
|
81
184
|
{ x: cw, y: ch },
|
|
82
185
|
];
|
|
186
|
+
|
|
83
187
|
const { _bounds: bounds = defaultBounds, _tags, hasImage } = result;
|
|
84
188
|
|
|
85
|
-
const tags = _tags.map(({ x, y, ...rest }) => ({
|
|
189
|
+
const tags = _tags.map(({ x, y, font, ...rest }) => ({
|
|
86
190
|
...rest,
|
|
87
191
|
x: x + cw / 2,
|
|
88
192
|
y: y + ch / 2,
|
|
193
|
+
fontFamily: font,
|
|
89
194
|
}));
|
|
90
195
|
|
|
91
196
|
// Append two data to replace the corner of top-left and bottom-right, avoid calculate the actual bounds will occur some error.
|
package/src/exports.ts
CHANGED
|
@@ -54,9 +54,10 @@ function verticalBrush(axis, { cross, offsetX, offsetY, ...style }) {
|
|
|
54
54
|
style: {
|
|
55
55
|
// If it is not cross, draw brush in both side of axisLine,
|
|
56
56
|
// otherwise the draw brush within bounds area.
|
|
57
|
-
x: cross ? minX : lineX - size / 2,
|
|
58
57
|
width: cross ? size / 2 : size,
|
|
59
|
-
|
|
58
|
+
transform: `translate(${(cross ? minX : lineX - size / 2).toFixed(
|
|
59
|
+
2,
|
|
60
|
+
)}, ${minY})`,
|
|
60
61
|
height: maxY - minY,
|
|
61
62
|
...style,
|
|
62
63
|
},
|
|
@@ -86,12 +87,11 @@ function horizontalBrush(axis, { offsetY, offsetX, cross = false, ...style }) {
|
|
|
86
87
|
hotZone: new Rect({
|
|
87
88
|
className: AXIS_HOT_AREA_CLASS_NAME,
|
|
88
89
|
style: {
|
|
89
|
-
x: minX,
|
|
90
90
|
width: maxX - minX,
|
|
91
91
|
// If it is not cross, draw brush in both side of axisLine,
|
|
92
92
|
// otherwise the draw brush within bounds area.
|
|
93
|
-
y: cross ? minY : lineY - size,
|
|
94
93
|
height: cross ? size : size * 2,
|
|
94
|
+
transform: `translate(${minX}, ${cross ? minY : lineY - size})`,
|
|
95
95
|
...style,
|
|
96
96
|
},
|
|
97
97
|
}),
|
|
@@ -222,6 +222,7 @@ export function brushAxisHighlight(
|
|
|
222
222
|
fill: 'transparent', // Make it interactive.
|
|
223
223
|
});
|
|
224
224
|
axis.parentNode.appendChild(hotZone);
|
|
225
|
+
|
|
225
226
|
const brushHandler = brush(hotZone, {
|
|
226
227
|
...brushStyle,
|
|
227
228
|
reverse,
|
|
@@ -113,8 +113,7 @@ const ResizableMask = createElement((g) => {
|
|
|
113
113
|
|
|
114
114
|
const renderHandle = (g, renderNode) => {
|
|
115
115
|
const { id } = g;
|
|
116
|
-
const
|
|
117
|
-
const handle = renderNode(g, { x: 0, y: 0, ...style }, document);
|
|
116
|
+
const handle = renderNode(g, g.attributes, document);
|
|
118
117
|
handle.id = id;
|
|
119
118
|
handle.style.draggable = true;
|
|
120
119
|
};
|
|
@@ -128,15 +127,19 @@ const ResizableMask = createElement((g) => {
|
|
|
128
127
|
|
|
129
128
|
const container = select(g)
|
|
130
129
|
.attr('className', className)
|
|
131
|
-
.style('
|
|
132
|
-
.style('y', y)
|
|
130
|
+
.style('transform', `translate(${x}, ${y})`)
|
|
133
131
|
.style('draggable', true);
|
|
134
132
|
|
|
135
133
|
container
|
|
136
134
|
.maybeAppend('selection', 'rect')
|
|
137
135
|
.style('draggable', true)
|
|
138
136
|
.style('fill', 'transparent')
|
|
139
|
-
.call(applyStyle, {
|
|
137
|
+
.call(applyStyle, {
|
|
138
|
+
width,
|
|
139
|
+
height,
|
|
140
|
+
...omitPrefixObject(style, 'handle'),
|
|
141
|
+
transform: undefined,
|
|
142
|
+
});
|
|
140
143
|
|
|
141
144
|
container
|
|
142
145
|
.maybeAppend('handle-n', appendHandle(handleNRender))
|
|
@@ -395,7 +395,7 @@ export function ElementPointMove(
|
|
|
395
395
|
'text',
|
|
396
396
|
ratioTransform(scaleY.invert(y)).toFixed(precision),
|
|
397
397
|
);
|
|
398
|
-
pathShape.attr('
|
|
398
|
+
pathShape.attr('d', newPath);
|
|
399
399
|
circle.attr('cx', newX);
|
|
400
400
|
circle.attr('cy', newY);
|
|
401
401
|
} else {
|
|
@@ -414,7 +414,7 @@ export function ElementPointMove(
|
|
|
414
414
|
'text',
|
|
415
415
|
ratioTransform(scaleY.invert(y)).toFixed(precision),
|
|
416
416
|
);
|
|
417
|
-
pathShape.attr('
|
|
417
|
+
pathShape.attr('d', newPath);
|
|
418
418
|
circle.attr('cy', newCy);
|
|
419
419
|
}
|
|
420
420
|
} else {
|
|
@@ -426,7 +426,7 @@ export function ElementPointMove(
|
|
|
426
426
|
points[index + 1],
|
|
427
427
|
]);
|
|
428
428
|
labelShape.attr('text', scaleY.invert(y).toFixed(precision));
|
|
429
|
-
pathShape.attr('
|
|
429
|
+
pathShape.attr('d', newPath);
|
|
430
430
|
circle.attr('cy', newCy);
|
|
431
431
|
}
|
|
432
432
|
};
|
|
@@ -528,7 +528,7 @@ export function ElementPointMove(
|
|
|
528
528
|
'text',
|
|
529
529
|
ratioTransform(scaleY.invert(x)).toFixed(precision),
|
|
530
530
|
);
|
|
531
|
-
pathShape.attr('
|
|
531
|
+
pathShape.attr('d', newPath);
|
|
532
532
|
circle.attr('cx', newCx);
|
|
533
533
|
} else if (isTheta) {
|
|
534
534
|
// Pie chart.
|
|
@@ -559,7 +559,7 @@ export function ElementPointMove(
|
|
|
559
559
|
'text',
|
|
560
560
|
ratioTransform(percent, true).toFixed(precision),
|
|
561
561
|
);
|
|
562
|
-
pathShape.attr('
|
|
562
|
+
pathShape.attr('d', newPath);
|
|
563
563
|
circle.attr('cx', newXOut);
|
|
564
564
|
circle.attr('cy', newYOut);
|
|
565
565
|
} else {
|
|
@@ -585,7 +585,7 @@ export function ElementPointMove(
|
|
|
585
585
|
'text',
|
|
586
586
|
ratioTransform(scaleY.invert(y)).toFixed(precision),
|
|
587
587
|
);
|
|
588
|
-
pathShape.attr('
|
|
588
|
+
pathShape.attr('d', newPath);
|
|
589
589
|
circle.attr('cy', newCy);
|
|
590
590
|
}
|
|
591
591
|
};
|