@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
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
99
|
+
d: shapePath,
|
|
100
100
|
stroke: color,
|
|
101
101
|
strokeOpacity: fillOpacity,
|
|
102
102
|
lineWidth: border,
|
package/src/shape/liquid/wave.ts
CHANGED
|
@@ -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}
|
|
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
|
+
};
|
package/src/shape/point/color.ts
CHANGED
|
@@ -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('
|
|
225
|
+
.style('d', connectorPath)
|
|
224
226
|
.style('markerStart', markerStart)
|
|
225
227
|
.style('markerEnd', markerEnd)
|
|
226
228
|
.call(applyStyle, connector ? connectorStyle : {});
|
package/src/shape/text/badge.ts
CHANGED
|
@@ -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('
|
|
73
|
-
.style('y', y0)
|
|
72
|
+
.style('transform', `translate(${x0},${y0})`)
|
|
74
73
|
.call(applyStyle, textStyle)
|
|
75
74
|
.call(applyStyle, style)
|
|
76
75
|
.node();
|
package/src/theme/create.ts
CHANGED
|
@@ -139,7 +139,7 @@ export function create({
|
|
|
139
139
|
text: {
|
|
140
140
|
fill: '#1D2129',
|
|
141
141
|
fontSize: 12,
|
|
142
|
-
|
|
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
|
-
|
|
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: {
|
package/src/utils/helper.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
}
|
package/src/utils/marker.ts
CHANGED
|
@@ -255,23 +255,14 @@ export const Symbols = new Map<string, SymbolFactor>([
|
|
|
255
255
|
|
|
256
256
|
export function useMarker(
|
|
257
257
|
type: string,
|
|
258
|
-
{
|
|
259
|
-
d,
|
|
260
|
-
fill,
|
|
261
|
-
strokeWidth,
|
|
262
|
-
path,
|
|
263
|
-
stroke,
|
|
264
|
-
lineWidth,
|
|
265
|
-
color,
|
|
266
|
-
...style
|
|
267
|
-
}: Record<string, any>,
|
|
258
|
+
{ d, fill, lineWidth, path, stroke, color, ...style }: Record<string, any>,
|
|
268
259
|
) {
|
|
269
260
|
const symbol = Symbols.get(type) || Symbols.get('point');
|
|
270
261
|
return (...args: Parameters<SymbolFactor>) => {
|
|
271
262
|
const path = new Path({
|
|
272
263
|
style: {
|
|
273
264
|
...style,
|
|
274
|
-
|
|
265
|
+
d: symbol(...args),
|
|
275
266
|
stroke: symbol.style.includes('stroke') ? color || stroke : '',
|
|
276
267
|
fill: symbol.style.includes('fill') ? color || fill : '',
|
|
277
268
|
lineWidth: symbol.style.includes('lineWidth')
|