@antv/g2 5.1.6-beta.1 → 5.1.7
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/CHANGELOG.md +24 -0
- package/README.md +2 -2
- package/README.zh-CN.md +1 -1
- package/dist/g2.full.min.js +1 -1
- package/dist/g2.lite.min.js +1 -1
- package/dist/g2.min.js +1 -1
- package/esm/animation/growInX.js +0 -4
- package/esm/animation/growInX.js.map +1 -1
- package/esm/animation/growInY.js +0 -4
- package/esm/animation/growInY.js.map +1 -1
- package/esm/animation/scaleInX.js +5 -7
- package/esm/animation/scaleInX.js.map +1 -1
- package/esm/animation/scaleInY.js +5 -7
- package/esm/animation/scaleInY.js.map +1 -1
- package/esm/animation/scaleOutX.js +5 -7
- package/esm/animation/scaleOutX.js.map +1 -1
- package/esm/animation/scaleOutY.js +5 -7
- package/esm/animation/scaleOutY.js.map +1 -1
- package/esm/animation/zoomIn.js +4 -5
- package/esm/animation/zoomIn.js.map +1 -1
- package/esm/animation/zoomOut.js +4 -6
- package/esm/animation/zoomOut.js.map +1 -1
- package/esm/api/utils.d.ts +6 -2
- package/esm/api/utils.js +18 -6
- package/esm/api/utils.js.map +1 -1
- package/esm/exports.d.ts +1 -0
- package/esm/exports.js +1 -0
- package/esm/exports.js.map +1 -1
- package/esm/interaction/utils.js +1 -5
- package/esm/interaction/utils.js.map +1 -1
- package/esm/lib/index.d.ts +0 -1
- package/esm/lib/index.js +0 -1
- package/esm/lib/index.js.map +1 -1
- package/esm/mark/index.d.ts +0 -1
- package/esm/mark/index.js +0 -1
- package/esm/mark/index.js.map +1 -1
- package/esm/runtime/component.js +4 -2
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/layout.js +7 -1
- package/esm/runtime/layout.js.map +1 -1
- package/esm/shape/interval/color.d.ts +4 -0
- package/esm/shape/interval/color.js +10 -7
- package/esm/shape/interval/color.js.map +1 -1
- package/esm/shape/interval/rect.d.ts +4 -0
- package/esm/shape/interval/rect.js.map +1 -1
- package/esm/shape/line/smooth.js +8 -4
- package/esm/shape/line/smooth.js.map +1 -1
- package/esm/theme/create.d.ts +1 -4
- package/esm/theme/create.js +1 -4
- package/esm/theme/create.js.map +1 -1
- package/lib/animation/growInX.js +0 -4
- package/lib/animation/growInX.js.map +1 -1
- package/lib/animation/growInY.js +0 -4
- package/lib/animation/growInY.js.map +1 -1
- package/lib/animation/scaleInX.js +5 -7
- package/lib/animation/scaleInX.js.map +1 -1
- package/lib/animation/scaleInY.js +5 -7
- package/lib/animation/scaleInY.js.map +1 -1
- package/lib/animation/scaleOutX.js +5 -7
- package/lib/animation/scaleOutX.js.map +1 -1
- package/lib/animation/scaleOutY.js +5 -7
- package/lib/animation/scaleOutY.js.map +1 -1
- package/lib/animation/zoomIn.js +4 -5
- package/lib/animation/zoomIn.js.map +1 -1
- package/lib/animation/zoomOut.js +4 -6
- package/lib/animation/zoomOut.js.map +1 -1
- package/lib/api/utils.d.ts +6 -2
- package/lib/api/utils.js +19 -7
- package/lib/api/utils.js.map +1 -1
- package/lib/exports.d.ts +1 -0
- package/lib/exports.js +7 -1
- package/lib/exports.js.map +1 -1
- package/lib/interaction/utils.js +1 -5
- package/lib/interaction/utils.js.map +1 -1
- package/lib/lib/index.d.ts +0 -1
- package/lib/lib/index.js +1 -3
- package/lib/lib/index.js.map +1 -1
- package/lib/mark/index.d.ts +0 -1
- package/lib/mark/index.js +1 -3
- package/lib/mark/index.js.map +1 -1
- package/lib/runtime/component.js +4 -2
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/layout.js +7 -1
- package/lib/runtime/layout.js.map +1 -1
- package/lib/shape/interval/color.d.ts +4 -0
- package/lib/shape/interval/color.js +10 -7
- package/lib/shape/interval/color.js.map +1 -1
- package/lib/shape/interval/rect.d.ts +4 -0
- package/lib/shape/interval/rect.js.map +1 -1
- package/lib/shape/line/smooth.js +6 -2
- package/lib/shape/line/smooth.js.map +1 -1
- package/lib/theme/create.d.ts +1 -4
- package/lib/theme/create.js +1 -4
- package/lib/theme/create.js.map +1 -1
- package/package.json +4 -4
- package/src/animation/growInX.ts +1 -6
- package/src/animation/growInY.ts +1 -6
- package/src/animation/scaleInX.ts +8 -11
- package/src/animation/scaleInY.ts +8 -11
- package/src/animation/scaleOutX.ts +8 -11
- package/src/animation/scaleOutY.ts +8 -11
- package/src/animation/zoomIn.ts +4 -6
- package/src/animation/zoomOut.ts +4 -7
- package/src/api/utils.ts +28 -6
- package/src/exports.ts +2 -0
- package/src/interaction/utils.ts +1 -5
- package/src/lib/index.ts +0 -1
- package/src/mark/index.ts +0 -1
- package/src/runtime/component.ts +10 -2
- package/src/runtime/layout.ts +6 -1
- package/src/shape/interval/color.ts +16 -4
- package/src/shape/interval/rect.ts +5 -0
- package/src/shape/line/smooth.ts +12 -4
- package/src/theme/create.ts +1 -4
- package/esm/lib/auto.d.ts +0 -3
- package/esm/lib/auto.js +0 -7
- package/esm/lib/auto.js.map +0 -1
- package/esm/mark/auto.d.ts +0 -1
- package/esm/mark/auto.js +0 -26
- package/esm/mark/auto.js.map +0 -1
- package/lib/lib/auto.d.ts +0 -3
- package/lib/lib/auto.js +0 -11
- package/lib/lib/auto.js.map +0 -1
- package/lib/mark/auto.d.ts +0 -1
- package/lib/mark/auto.js +0 -30
- package/lib/mark/auto.js.map +0 -1
- package/src/lib/auto.ts +0 -7
- package/src/mark/auto.ts +0 -22
package/src/animation/growInX.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Path } from '@antv/g';
|
|
2
2
|
import { AnimationComponent as AC } from '../runtime';
|
|
3
3
|
import { Animation } from './types';
|
|
4
4
|
import { ScaleInX } from './scaleInX';
|
|
@@ -22,11 +22,6 @@ export const GrowInX: AC<GrowInXOptions> = (options, context) => {
|
|
|
22
22
|
|
|
23
23
|
const animation = ScaleInX(options, context)([clipPath], to, defaults);
|
|
24
24
|
|
|
25
|
-
(animation as IAnimation).finished.then(() => {
|
|
26
|
-
clipPath.remove();
|
|
27
|
-
shape.style.clipPath = null;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
25
|
return animation;
|
|
31
26
|
};
|
|
32
27
|
};
|
package/src/animation/growInY.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Path } from '@antv/g';
|
|
2
2
|
import { AnimationComponent as AC } from '../runtime';
|
|
3
3
|
import { Animation } from './types';
|
|
4
4
|
import { ScaleInY } from './scaleInY';
|
|
@@ -22,11 +22,6 @@ export const GrowInY: AC<GrowInYOptions> = (options, context) => {
|
|
|
22
22
|
|
|
23
23
|
const animation = ScaleInY(options, context)([clipPath], to, defaults);
|
|
24
24
|
|
|
25
|
-
(animation as IAnimation).finished.then(() => {
|
|
26
|
-
clipPath.remove();
|
|
27
|
-
shape.style.clipPath = null;
|
|
28
|
-
});
|
|
29
|
-
|
|
30
25
|
return animation;
|
|
31
26
|
};
|
|
32
27
|
};
|
|
@@ -16,29 +16,31 @@ export const ScaleInX: AC<ScaleInXOptions> = (options, context) => {
|
|
|
16
16
|
|
|
17
17
|
return (from, _, defaults) => {
|
|
18
18
|
const [shape] = from;
|
|
19
|
-
const { height } = shape.getBoundingClientRect();
|
|
20
19
|
const {
|
|
21
20
|
transform: prefix = '',
|
|
22
21
|
fillOpacity = 1,
|
|
23
22
|
strokeOpacity = 1,
|
|
24
23
|
opacity = 1,
|
|
25
24
|
} = shape.style;
|
|
26
|
-
const [transformOrigin, transform]: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const [transformOrigin, transform]: [string, string] = isTranspose(
|
|
26
|
+
coordinate,
|
|
27
|
+
)
|
|
28
|
+
? [`left bottom`, `scale(1, ${ZERO})`] // left-bottom corner
|
|
29
|
+
: [`left top`, `scale(${ZERO}, 1)`]; // left-top corner
|
|
30
30
|
|
|
31
31
|
// Using a short fadeIn transition to hide element with scale(0.001)
|
|
32
32
|
// which is still visible.
|
|
33
33
|
const keyframes = [
|
|
34
34
|
{
|
|
35
35
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
36
|
+
transformOrigin,
|
|
36
37
|
fillOpacity: 0,
|
|
37
38
|
strokeOpacity: 0,
|
|
38
39
|
opacity: 0,
|
|
39
40
|
},
|
|
40
41
|
{
|
|
41
42
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
43
|
+
transformOrigin,
|
|
42
44
|
fillOpacity,
|
|
43
45
|
strokeOpacity,
|
|
44
46
|
opacity,
|
|
@@ -46,20 +48,15 @@ export const ScaleInX: AC<ScaleInXOptions> = (options, context) => {
|
|
|
46
48
|
},
|
|
47
49
|
{
|
|
48
50
|
transform: `${prefix} scale(1, 1)`.trimStart(),
|
|
51
|
+
transformOrigin,
|
|
49
52
|
fillOpacity,
|
|
50
53
|
strokeOpacity,
|
|
51
54
|
opacity,
|
|
52
55
|
},
|
|
53
56
|
];
|
|
54
57
|
|
|
55
|
-
// Change transform origin for correct transform.
|
|
56
|
-
shape.setOrigin(transformOrigin);
|
|
57
|
-
|
|
58
58
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
59
59
|
|
|
60
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
61
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
62
|
-
|
|
63
60
|
return animation;
|
|
64
61
|
};
|
|
65
62
|
};
|
|
@@ -16,29 +16,31 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
|
|
|
16
16
|
|
|
17
17
|
return (from, _, defaults) => {
|
|
18
18
|
const [shape] = from;
|
|
19
|
-
const { height } = shape.getBoundingClientRect();
|
|
20
19
|
const {
|
|
21
20
|
transform: prefix = '',
|
|
22
21
|
fillOpacity = 1,
|
|
23
22
|
strokeOpacity = 1,
|
|
24
23
|
opacity = 1,
|
|
25
24
|
} = shape.style;
|
|
26
|
-
const [transformOrigin, transform]: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const [transformOrigin, transform]: [string, string] = isTranspose(
|
|
26
|
+
coordinate,
|
|
27
|
+
)
|
|
28
|
+
? [`left top`, `scale(${ZERO}, 1)`] // left-top corner
|
|
29
|
+
: [`left bottom`, `scale(1, ${ZERO})`]; // left-bottom corner
|
|
30
30
|
|
|
31
31
|
// Using a short fadeIn transition to hide element with scale(0.001)
|
|
32
32
|
// which is still visible.
|
|
33
33
|
const keyframes = [
|
|
34
34
|
{
|
|
35
35
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
36
|
+
transformOrigin,
|
|
36
37
|
fillOpacity: 0,
|
|
37
38
|
strokeOpacity: 0,
|
|
38
39
|
opacity: 0,
|
|
39
40
|
},
|
|
40
41
|
{
|
|
41
42
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
43
|
+
transformOrigin,
|
|
42
44
|
fillOpacity,
|
|
43
45
|
strokeOpacity,
|
|
44
46
|
opacity,
|
|
@@ -46,20 +48,15 @@ export const ScaleInY: AC<ScaleInYOptions> = (options, context) => {
|
|
|
46
48
|
},
|
|
47
49
|
{
|
|
48
50
|
transform: `${prefix} scale(1, 1)`.trimStart(),
|
|
51
|
+
transformOrigin,
|
|
49
52
|
fillOpacity,
|
|
50
53
|
strokeOpacity,
|
|
51
54
|
opacity,
|
|
52
55
|
},
|
|
53
56
|
];
|
|
54
57
|
|
|
55
|
-
// Change transform origin for correct transform.
|
|
56
|
-
shape.setOrigin(transformOrigin);
|
|
57
|
-
|
|
58
58
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
59
59
|
|
|
60
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
61
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
62
|
-
|
|
63
60
|
return animation;
|
|
64
61
|
};
|
|
65
62
|
};
|
|
@@ -16,26 +16,28 @@ export const ScaleOutX: AC<ScaleOutXOptions> = (options, context) => {
|
|
|
16
16
|
|
|
17
17
|
return (from, _, defaults) => {
|
|
18
18
|
const [shape] = from;
|
|
19
|
-
const { height } = shape.getBoundingClientRect();
|
|
20
19
|
const {
|
|
21
20
|
transform: prefix = '',
|
|
22
21
|
fillOpacity = 1,
|
|
23
22
|
strokeOpacity = 1,
|
|
24
23
|
opacity = 1,
|
|
25
24
|
} = shape.style;
|
|
26
|
-
const [transformOrigin, transform]: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const [transformOrigin, transform]: [string, string] = isTranspose(
|
|
26
|
+
coordinate,
|
|
27
|
+
)
|
|
28
|
+
? [`left bottom`, `scale(1, ${ZERO})`] // left-bottom corner
|
|
29
|
+
: [`left top`, `scale(${ZERO}, 1)`]; // left-top corner
|
|
30
30
|
|
|
31
31
|
// Using a short fadeIn transition to hide element with scale(0.001)
|
|
32
32
|
// which is still visible.
|
|
33
33
|
const keyframes = [
|
|
34
34
|
{
|
|
35
35
|
transform: `${prefix} scale(1, 1)`.trimStart(),
|
|
36
|
+
transformOrigin,
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
40
|
+
transformOrigin,
|
|
39
41
|
fillOpacity,
|
|
40
42
|
strokeOpacity,
|
|
41
43
|
opacity,
|
|
@@ -43,20 +45,15 @@ export const ScaleOutX: AC<ScaleOutXOptions> = (options, context) => {
|
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
47
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
48
|
+
transformOrigin,
|
|
46
49
|
fillOpacity: 0,
|
|
47
50
|
strokeOpacity: 0,
|
|
48
51
|
opacity: 0,
|
|
49
52
|
},
|
|
50
53
|
];
|
|
51
54
|
|
|
52
|
-
// Change transform origin for correct transform.
|
|
53
|
-
shape.setOrigin(transformOrigin);
|
|
54
|
-
|
|
55
55
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
56
56
|
|
|
57
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
58
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
59
|
-
|
|
60
57
|
return animation;
|
|
61
58
|
};
|
|
62
59
|
};
|
|
@@ -16,26 +16,28 @@ export const ScaleOutY: AC<ScaleOutYOptions> = (options, context) => {
|
|
|
16
16
|
|
|
17
17
|
return (from, _, defaults) => {
|
|
18
18
|
const [shape] = from;
|
|
19
|
-
const { height } = shape.getBoundingClientRect();
|
|
20
19
|
const {
|
|
21
20
|
transform: prefix = '',
|
|
22
21
|
fillOpacity = 1,
|
|
23
22
|
strokeOpacity = 1,
|
|
24
23
|
opacity = 1,
|
|
25
24
|
} = shape.style;
|
|
26
|
-
const [transformOrigin, transform]: [
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const [transformOrigin, transform]: [string, string] = isTranspose(
|
|
26
|
+
coordinate,
|
|
27
|
+
)
|
|
28
|
+
? [`left top`, `scale(${ZERO}, 1)`] // left-top corner
|
|
29
|
+
: [`left bottom`, `scale(1, ${ZERO})`]; // left-bottom corner
|
|
30
30
|
|
|
31
31
|
// Using a short fadeIn transition to hide element with scale(0.001)
|
|
32
32
|
// which is still visible.
|
|
33
33
|
const keyframes = [
|
|
34
34
|
{
|
|
35
35
|
transform: `${prefix} scale(1, 1)`.trimStart(),
|
|
36
|
+
transformOrigin,
|
|
36
37
|
},
|
|
37
38
|
{
|
|
38
39
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
40
|
+
transformOrigin,
|
|
39
41
|
fillOpacity,
|
|
40
42
|
strokeOpacity,
|
|
41
43
|
opacity,
|
|
@@ -43,20 +45,15 @@ export const ScaleOutY: AC<ScaleOutYOptions> = (options, context) => {
|
|
|
43
45
|
},
|
|
44
46
|
{
|
|
45
47
|
transform: `${prefix} ${transform}`.trimStart(),
|
|
48
|
+
transformOrigin,
|
|
46
49
|
fillOpacity: 0,
|
|
47
50
|
strokeOpacity: 0,
|
|
48
51
|
opacity: 0,
|
|
49
52
|
},
|
|
50
53
|
];
|
|
51
54
|
|
|
52
|
-
// Change transform origin for correct transform.
|
|
53
|
-
shape.setOrigin(transformOrigin);
|
|
54
|
-
|
|
55
55
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
56
56
|
|
|
57
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
58
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
59
|
-
|
|
60
57
|
return animation;
|
|
61
58
|
};
|
|
62
59
|
};
|
package/src/animation/zoomIn.ts
CHANGED
|
@@ -16,15 +16,18 @@ export const ZoomIn: AC<ZoomInOptions> = (options) => {
|
|
|
16
16
|
strokeOpacity = 1,
|
|
17
17
|
opacity = 1,
|
|
18
18
|
} = shape.style;
|
|
19
|
+
const transformOrigin = 'center center';
|
|
19
20
|
const keyframes = [
|
|
20
21
|
{
|
|
21
22
|
transform: `${prefix} scale(${ZERO})`.trimStart(),
|
|
23
|
+
transformOrigin,
|
|
22
24
|
fillOpacity: 0,
|
|
23
25
|
strokeOpacity: 0,
|
|
24
26
|
opacity: 0,
|
|
25
27
|
},
|
|
26
28
|
{
|
|
27
29
|
transform: `${prefix} scale(${ZERO})`.trimStart(),
|
|
30
|
+
transformOrigin,
|
|
28
31
|
fillOpacity,
|
|
29
32
|
strokeOpacity,
|
|
30
33
|
opacity,
|
|
@@ -32,20 +35,15 @@ export const ZoomIn: AC<ZoomInOptions> = (options) => {
|
|
|
32
35
|
},
|
|
33
36
|
{
|
|
34
37
|
transform: `${prefix} scale(1)`.trimStart(),
|
|
38
|
+
transformOrigin,
|
|
35
39
|
fillOpacity,
|
|
36
40
|
strokeOpacity,
|
|
37
41
|
opacity,
|
|
38
42
|
},
|
|
39
43
|
];
|
|
40
|
-
const { width, height } = shape.getBoundingClientRect();
|
|
41
|
-
// Change transform origin for correct transform.
|
|
42
|
-
shape.setOrigin([width / 2, height / 2]);
|
|
43
44
|
|
|
44
45
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
45
46
|
|
|
46
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
47
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
48
|
-
|
|
49
47
|
return animation;
|
|
50
48
|
};
|
|
51
49
|
};
|
package/src/animation/zoomOut.ts
CHANGED
|
@@ -16,10 +16,12 @@ export const ZoomOut: AC<ZoomOutOptions> = (options) => {
|
|
|
16
16
|
strokeOpacity = 1,
|
|
17
17
|
opacity = 1,
|
|
18
18
|
} = shape.style;
|
|
19
|
+
const transformOrigin = 'center center';
|
|
19
20
|
const keyframes = [
|
|
20
|
-
{ transform: `${prefix} scale(1)`.trimStart() },
|
|
21
|
+
{ transform: `${prefix} scale(1)`.trimStart(), transformOrigin },
|
|
21
22
|
{
|
|
22
23
|
transform: `${prefix} scale(${ZERO})`.trimStart(),
|
|
24
|
+
transformOrigin,
|
|
23
25
|
fillOpacity,
|
|
24
26
|
strokeOpacity,
|
|
25
27
|
opacity,
|
|
@@ -27,20 +29,15 @@ export const ZoomOut: AC<ZoomOutOptions> = (options) => {
|
|
|
27
29
|
},
|
|
28
30
|
{
|
|
29
31
|
transform: `${prefix} scale(${ZERO})`.trimStart(),
|
|
32
|
+
transformOrigin,
|
|
30
33
|
fillOpacity: 0,
|
|
31
34
|
strokeOpacity: 0,
|
|
32
35
|
opacity: 0,
|
|
33
36
|
},
|
|
34
37
|
];
|
|
35
38
|
|
|
36
|
-
const { width, height } = shape.getBoundingClientRect();
|
|
37
|
-
// Change transform origin for correct transform.
|
|
38
|
-
shape.setOrigin([width / 2, height / 2]);
|
|
39
39
|
const animation = shape.animate(keyframes, { ...defaults, ...options });
|
|
40
40
|
|
|
41
|
-
// Reset transform origin to eliminate side effect for following animations.
|
|
42
|
-
animation.finished.then(() => shape.setOrigin(0, 0));
|
|
43
|
-
|
|
44
41
|
return animation;
|
|
45
42
|
};
|
|
46
43
|
};
|
package/src/api/utils.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isNumber } from '@antv/util';
|
|
1
2
|
import { G2ViewTree } from '../runtime';
|
|
2
3
|
import { getContainerSize } from '../utils/size';
|
|
3
4
|
import { deepAssign } from '../utils/helper';
|
|
@@ -33,6 +34,11 @@ export const REMOVE_FLAG = '__remove__';
|
|
|
33
34
|
|
|
34
35
|
export const CALLBACK_NODE = '__callback__';
|
|
35
36
|
|
|
37
|
+
/** Minimum chart width */
|
|
38
|
+
export const MIN_CHART_WIDTH = 1;
|
|
39
|
+
/** Minimum chart height */
|
|
40
|
+
export const MIN_CHART_HEIGHT = 1;
|
|
41
|
+
|
|
36
42
|
export function normalizeContainer(
|
|
37
43
|
container: string | HTMLElement,
|
|
38
44
|
): HTMLElement {
|
|
@@ -70,12 +76,28 @@ export function valueOf(node: Node): Record<string, any> {
|
|
|
70
76
|
}
|
|
71
77
|
|
|
72
78
|
export function sizeOf(options, container) {
|
|
73
|
-
const { autoFit } = options;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
const { width = 640, height = 480, autoFit, depth = 0 } = options;
|
|
80
|
+
let effectiveWidth = width;
|
|
81
|
+
let effectiveHeight = height;
|
|
82
|
+
|
|
83
|
+
if (autoFit) {
|
|
84
|
+
const { width: containerWidth, height: containerHeight } =
|
|
85
|
+
getContainerSize(container);
|
|
86
|
+
effectiveWidth = containerWidth || effectiveWidth;
|
|
87
|
+
effectiveHeight = containerHeight || effectiveHeight;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
width: Math.max(
|
|
92
|
+
isNumber(effectiveWidth) ? effectiveWidth : MIN_CHART_WIDTH,
|
|
93
|
+
MIN_CHART_WIDTH,
|
|
94
|
+
),
|
|
95
|
+
height: Math.max(
|
|
96
|
+
isNumber(effectiveHeight) ? effectiveHeight : MIN_CHART_HEIGHT,
|
|
97
|
+
MIN_CHART_HEIGHT,
|
|
98
|
+
),
|
|
99
|
+
depth,
|
|
100
|
+
};
|
|
79
101
|
}
|
|
80
102
|
|
|
81
103
|
export function optionsOf(node: Node): Record<string, any> {
|
package/src/exports.ts
CHANGED
package/src/interaction/utils.ts
CHANGED
|
@@ -82,11 +82,7 @@ export function createColorKey(view) {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export function createXKey(view) {
|
|
85
|
-
|
|
86
|
-
return (element) => {
|
|
87
|
-
const { x } = element.__data__;
|
|
88
|
-
return scaleX.invert(x);
|
|
89
|
-
};
|
|
85
|
+
return (element) => element.__data__.x;
|
|
90
86
|
}
|
|
91
87
|
|
|
92
88
|
export function createDatumof(view: G2ViewDescriptor | G2ViewDescriptor[]) {
|
package/src/lib/index.ts
CHANGED
package/src/mark/index.ts
CHANGED
|
@@ -32,7 +32,6 @@ export { Gauge } from './gauge';
|
|
|
32
32
|
export { Density } from './density';
|
|
33
33
|
export { Heatmap } from './heatmap';
|
|
34
34
|
export { Liquid } from './liquid';
|
|
35
|
-
export { Auto } from './auto';
|
|
36
35
|
|
|
37
36
|
export type { IntervalOptions } from './interval';
|
|
38
37
|
export type { RectOptions } from './rect';
|
package/src/runtime/component.ts
CHANGED
|
@@ -710,7 +710,13 @@ function computeAxisSize(
|
|
|
710
710
|
|
|
711
711
|
// Get styles to be applied.
|
|
712
712
|
const style = styleOf(component, position, theme);
|
|
713
|
-
const {
|
|
713
|
+
const {
|
|
714
|
+
tickLength = 0,
|
|
715
|
+
labelSpacing = 0,
|
|
716
|
+
titleSpacing = 0,
|
|
717
|
+
labelAutoRotate,
|
|
718
|
+
...rest
|
|
719
|
+
} = style;
|
|
714
720
|
|
|
715
721
|
// Compute Labels.
|
|
716
722
|
const scale = createScale(component, library);
|
|
@@ -727,7 +733,9 @@ function computeAxisSize(
|
|
|
727
733
|
// rotate 90 deg to display them.
|
|
728
734
|
if (
|
|
729
735
|
overflowX(scale, labelBBoxes, crossSize, crossPadding, tickFilter) &&
|
|
730
|
-
!labelTransform
|
|
736
|
+
!labelTransform &&
|
|
737
|
+
labelAutoRotate !== false &&
|
|
738
|
+
labelAutoRotate !== null
|
|
731
739
|
) {
|
|
732
740
|
component.labelTransform = 'rotate(90)';
|
|
733
741
|
component.size = maxLabelWidth + paddingTick;
|
package/src/runtime/layout.ts
CHANGED
|
@@ -311,7 +311,6 @@ function computePadding(
|
|
|
311
311
|
|
|
312
312
|
for (const position of positions) {
|
|
313
313
|
const key = `padding${capitalizeFirst(camelCase(position))}`;
|
|
314
|
-
const insetKey = `inset${capitalizeFirst(camelCase(position))}`;
|
|
315
314
|
const components = positionComponents.get(position) || [];
|
|
316
315
|
const value = layout[key];
|
|
317
316
|
const defaultSizeOf = (d) => {
|
|
@@ -342,6 +341,11 @@ function computePadding(
|
|
|
342
341
|
}
|
|
343
342
|
};
|
|
344
343
|
|
|
344
|
+
const maybeHide = (d) => {
|
|
345
|
+
if (!d.type.startsWith('axis')) return;
|
|
346
|
+
if (d.labelAutoHide === undefined) d.labelAutoHide = true;
|
|
347
|
+
};
|
|
348
|
+
|
|
345
349
|
const isHorizontal = position === 'bottom' || position === 'top';
|
|
346
350
|
|
|
347
351
|
// !!!Note
|
|
@@ -356,6 +360,7 @@ function computePadding(
|
|
|
356
360
|
// Specified padding.
|
|
357
361
|
if (typeof value === 'number') {
|
|
358
362
|
components.forEach(defaultSizeOf);
|
|
363
|
+
components.forEach(maybeHide);
|
|
359
364
|
} else {
|
|
360
365
|
// Compute padding dynamically.
|
|
361
366
|
if (components.length === 0) {
|
|
@@ -16,6 +16,12 @@ export type ColorOptions = {
|
|
|
16
16
|
* Maximum width of each interval.
|
|
17
17
|
*/
|
|
18
18
|
maxWidth?: number;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Minimum height of each interval.
|
|
22
|
+
*/
|
|
23
|
+
minHeight?: number;
|
|
24
|
+
|
|
19
25
|
[key: string]: any;
|
|
20
26
|
};
|
|
21
27
|
|
|
@@ -40,6 +46,7 @@ export function rect(
|
|
|
40
46
|
radiusTopRight = radius,
|
|
41
47
|
minWidth = -Infinity,
|
|
42
48
|
maxWidth = Infinity,
|
|
49
|
+
minHeight = -Infinity,
|
|
43
50
|
...rest
|
|
44
51
|
} = style;
|
|
45
52
|
if (!isPolar(coordinate) && !isHelix(coordinate)) {
|
|
@@ -51,6 +58,7 @@ export function rect(
|
|
|
51
58
|
// Deal with width or height is negative.
|
|
52
59
|
const absX = width > 0 ? x : x + width;
|
|
53
60
|
const absY = height > 0 ? y : y + height;
|
|
61
|
+
|
|
54
62
|
const absWidth = Math.abs(width);
|
|
55
63
|
const absHeight = Math.abs(height);
|
|
56
64
|
const finalX = absX + insetLeft;
|
|
@@ -59,13 +67,15 @@ export function rect(
|
|
|
59
67
|
const finalHeight = absHeight - (insetTop + insetBottom);
|
|
60
68
|
|
|
61
69
|
const clampWidth = tpShape
|
|
62
|
-
? finalWidth
|
|
70
|
+
? clamp(finalWidth, minHeight, Infinity)
|
|
63
71
|
: clamp(finalWidth, minWidth, maxWidth);
|
|
64
72
|
const clampHeight = tpShape
|
|
65
73
|
? clamp(finalHeight, minWidth, maxWidth)
|
|
66
|
-
: finalHeight;
|
|
67
|
-
const clampX = finalX - (clampWidth - finalWidth) / 2;
|
|
68
|
-
const clampY =
|
|
74
|
+
: clamp(finalHeight, minHeight, Infinity);
|
|
75
|
+
const clampX = tpShape ? finalX : finalX - (clampWidth - finalWidth) / 2;
|
|
76
|
+
const clampY = tpShape
|
|
77
|
+
? finalY - (clampHeight - finalHeight) / 2
|
|
78
|
+
: finalY - (clampHeight - finalHeight);
|
|
69
79
|
|
|
70
80
|
return select(document.createElement('rect', {}))
|
|
71
81
|
.style('x', clampX)
|
|
@@ -145,6 +155,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
|
|
|
145
155
|
insetTop = inset,
|
|
146
156
|
minWidth,
|
|
147
157
|
maxWidth,
|
|
158
|
+
minHeight,
|
|
148
159
|
...rest
|
|
149
160
|
} = style;
|
|
150
161
|
const { color = defaultColor, opacity } = value;
|
|
@@ -179,6 +190,7 @@ export const Color: SC<ColorOptions> = (options, context) => {
|
|
|
179
190
|
insetTop,
|
|
180
191
|
minWidth,
|
|
181
192
|
maxWidth,
|
|
193
|
+
minHeight,
|
|
182
194
|
};
|
|
183
195
|
|
|
184
196
|
return (
|
package/src/shape/line/smooth.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
curveMonotoneX,
|
|
3
|
+
curveMonotoneY,
|
|
4
|
+
curveCatmullRomClosed,
|
|
5
|
+
} from 'd3-shape';
|
|
6
|
+
import { isPolar, isTranspose } from '../../utils/coordinate';
|
|
3
7
|
import { ShapeComponent as SC } from '../../runtime';
|
|
4
8
|
import { Curve } from './curve';
|
|
5
9
|
|
|
@@ -11,8 +15,12 @@ export const Smooth: SC<SmoothOptions> = (options, context) => {
|
|
|
11
15
|
const { alpha = 0.5, ...rest } = options;
|
|
12
16
|
const { coordinate } = context;
|
|
13
17
|
return (...params) => {
|
|
14
|
-
const curve = isPolar(coordinate)
|
|
15
|
-
|
|
18
|
+
const curve = isPolar(coordinate)
|
|
19
|
+
? curveCatmullRomClosed
|
|
20
|
+
: isTranspose(coordinate)
|
|
21
|
+
? curveMonotoneY
|
|
22
|
+
: curveMonotoneX;
|
|
23
|
+
return Curve({ curve: curve, ...rest }, context)(...params);
|
|
16
24
|
};
|
|
17
25
|
};
|
|
18
26
|
|
package/src/theme/create.ts
CHANGED
|
@@ -51,6 +51,7 @@ export function create({
|
|
|
51
51
|
fill: '',
|
|
52
52
|
strokeOpacity: 1,
|
|
53
53
|
lineWidth: 1,
|
|
54
|
+
lineCap: 'round',
|
|
54
55
|
},
|
|
55
56
|
},
|
|
56
57
|
point: {
|
|
@@ -236,7 +237,6 @@ export function create({
|
|
|
236
237
|
labelDirection: 'negative',
|
|
237
238
|
tickDirection: 'negative',
|
|
238
239
|
titlePosition: 'top',
|
|
239
|
-
labelAutoRotate: false,
|
|
240
240
|
titleSpacing: 12,
|
|
241
241
|
labelSpacing: 4,
|
|
242
242
|
titleTextBaseline: 'middle',
|
|
@@ -244,7 +244,6 @@ export function create({
|
|
|
244
244
|
axisBottom: {
|
|
245
245
|
gridDirection: 'negative',
|
|
246
246
|
labelDirection: 'positive',
|
|
247
|
-
labelAutoRotate: false,
|
|
248
247
|
tickDirection: 'positive',
|
|
249
248
|
titlePosition: 'bottom',
|
|
250
249
|
titleSpacing: 12,
|
|
@@ -253,7 +252,6 @@ export function create({
|
|
|
253
252
|
},
|
|
254
253
|
axisLeft: {
|
|
255
254
|
gridDirection: 'positive',
|
|
256
|
-
labelAutoRotate: false,
|
|
257
255
|
labelDirection: 'negative',
|
|
258
256
|
labelSpacing: 4,
|
|
259
257
|
tickDirection: 'negative',
|
|
@@ -269,7 +267,6 @@ export function create({
|
|
|
269
267
|
labelSpacing: 4,
|
|
270
268
|
tickDirection: 'positive',
|
|
271
269
|
titlePosition: 'right',
|
|
272
|
-
labelAutoRotate: false,
|
|
273
270
|
titleSpacing: 12,
|
|
274
271
|
titleTextBaseline: 'top',
|
|
275
272
|
titleDirection: 'vertical',
|
package/esm/lib/auto.d.ts
DELETED
package/esm/lib/auto.js
DELETED
package/esm/lib/auto.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto.js","sourceRoot":"src/","sources":["lib/auto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,MAAM,UAAU,OAAO;IACrB,OAAO;QACL,WAAW,EAAE,IAAI;KACT,CAAC;AACb,CAAC"}
|
package/esm/mark/auto.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const Auto: (options: any) => any;
|