@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.
- 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/exports.js +0 -2
- package/esm/exports.js.map +1 -1
- 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/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/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 +2 -0
- package/esm/shape/index.js +2 -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/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/exports.js +0 -2
- package/lib/exports.js.map +1 -1
- 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/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/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 +2 -0
- package/lib/shape/index.js +6 -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/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 +12 -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/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/mark/chord.ts +0 -1
- package/src/mark/point.ts +4 -0
- package/src/mark/sankey.ts +1 -1
- 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 +2 -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/theme/create.ts +4 -2
- package/src/utils/helper.ts +1 -7
- package/src/utils/marker.ts +2 -11
|
@@ -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
|
|
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
|
};
|
|
@@ -382,7 +382,7 @@ function updateMarker(root, { data, style, theme }) {
|
|
|
382
382
|
fill,
|
|
383
383
|
r: 4,
|
|
384
384
|
stroke: '#fff',
|
|
385
|
-
|
|
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])
|
package/src/interaction/utils.ts
CHANGED
|
@@ -426,7 +426,7 @@ export function renderBackground({
|
|
|
426
426
|
fillOpacity = 0.3,
|
|
427
427
|
zIndex = -2,
|
|
428
428
|
padding = 0.001,
|
|
429
|
-
|
|
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
|
-
|
|
438
|
+
lineWidth,
|
|
439
439
|
};
|
|
440
440
|
const shapeOf = isOrdinalShape() ? bandShapeOf : cloneShapeOf;
|
|
441
441
|
const shape = shapeOf(element, finalStyle);
|
package/src/mark/chord.ts
CHANGED
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'>;
|
package/src/mark/sankey.ts
CHANGED
package/src/runtime/plot.ts
CHANGED
|
@@ -1694,8 +1694,13 @@ async function applyTransform<T extends G2ViewTree>(
|
|
|
1694
1694
|
|
|
1695
1695
|
function updateBBox(selection: Selection) {
|
|
1696
1696
|
selection
|
|
1697
|
-
.style(
|
|
1698
|
-
|
|
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 {
|
|
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
|
-
|
|
1718
|
-
y,
|
|
1722
|
+
transform,
|
|
1719
1723
|
width,
|
|
1720
1724
|
height,
|
|
1721
1725
|
},
|
|
1722
1726
|
{
|
|
1723
|
-
|
|
1724
|
-
|
|
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('
|
|
92
|
+
.style('d', inferConnectorPath(P))
|
|
93
93
|
.style('stroke', color || defaultColor)
|
|
94
94
|
.style('transform', transform)
|
|
95
95
|
.style(
|
package/src/shape/gauge/round.ts
CHANGED
|
@@ -36,7 +36,7 @@ export const Round: SC<RoundOptions> = (options, context) => {
|
|
|
36
36
|
*/
|
|
37
37
|
const roundPath = document.createElement('path', {
|
|
38
38
|
style: {
|
|
39
|
-
|
|
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]],
|
package/src/shape/image/image.ts
CHANGED
|
@@ -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('
|
|
28
|
+
.style('src', src)
|
|
29
29
|
.style('stroke', color)
|
|
30
30
|
.style('transform', transform)
|
|
31
31
|
.call(applyStyle, options)
|
package/src/shape/index.ts
CHANGED
|
@@ -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,6 +30,7 @@ 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';
|
|
@@ -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('
|
|
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('
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
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,
|
|
54
|
+
return xy({ x: 0, y: 0, textAlign: 'start', textBaseline: 'top' });
|
|
55
55
|
if (position === 'top-right')
|
|
56
|
-
return xy({ x: w, y: 0,
|
|
56
|
+
return xy({ x: w, y: 0, textAlign: 'end', textBaseline: 'top' });
|
|
57
57
|
if (position === 'bottom-left')
|
|
58
|
-
return xy({ x: 0, y: h,
|
|
58
|
+
return xy({ x: 0, y: h, textAlign: 'start', textBaseline: 'bottom' });
|
|
59
59
|
if (position === 'bottom-right')
|
|
60
|
-
return xy({ x: w, y: h,
|
|
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
|
-
|
|
65
|
+
textAlign: 'center',
|
|
66
66
|
textBaseline: 'middle',
|
|
67
67
|
});
|
|
68
68
|
}
|
package/src/shape/lineXY/line.ts
CHANGED
|
@@ -38,8 +38,7 @@ function getArrowMarker(
|
|
|
38
38
|
) {
|
|
39
39
|
const arrowMarker = document.createElement('path', {
|
|
40
40
|
style: {
|
|
41
|
-
|
|
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
|
},
|