@antv/g2 5.0.2 → 5.0.3
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 +16 -10
- package/dist/g2-lite.min.js +3 -3
- package/dist/g2.min.js +1 -1
- package/esm/shape/interval/funnel.js +20 -4
- package/esm/shape/interval/funnel.js.map +1 -1
- package/esm/shape/interval/pyramid.js +3 -2
- package/esm/shape/interval/pyramid.js.map +1 -1
- package/lib/shape/interval/funnel.js +20 -4
- package/lib/shape/interval/funnel.js.map +1 -1
- package/lib/shape/interval/pyramid.js +3 -2
- package/lib/shape/interval/pyramid.js.map +1 -1
- package/package.json +1 -1
- package/src/shape/interval/funnel.ts +23 -12
- package/src/shape/interval/pyramid.ts +0 -2
|
@@ -9,8 +9,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
+
import { Path } from '@antv/g';
|
|
13
|
+
import { line, curveLinearClosed } from 'd3-shape';
|
|
12
14
|
import { isTranspose } from '../../utils/coordinate';
|
|
13
|
-
import {
|
|
15
|
+
import { select } from '../../utils/selection';
|
|
16
|
+
import { applyStyle, getShapeTheme, reorder } from '../utils';
|
|
14
17
|
/**
|
|
15
18
|
* Adjust and return the new `points`.
|
|
16
19
|
*/
|
|
@@ -31,11 +34,24 @@ function getFunnelPoints(points, nextPoints, coordinate) {
|
|
|
31
34
|
export const Funnel = (options) => {
|
|
32
35
|
const { adjustPoints = getFunnelPoints } = options, style = __rest(options, ["adjustPoints"]);
|
|
33
36
|
return (points, value, coordinate, theme, point2d, ...args) => {
|
|
34
|
-
const { index } = value;
|
|
37
|
+
const { index, mark, shape, defaultShape } = value;
|
|
38
|
+
const _a = getShapeTheme(theme, mark, shape, defaultShape), { defaultColor } = _a, defaults = __rest(_a, ["defaultColor"]);
|
|
35
39
|
const nextPoints = point2d[index + 1];
|
|
36
40
|
const funnelPoints = adjustPoints(points, nextPoints, coordinate);
|
|
37
|
-
|
|
41
|
+
const tpShape = !!isTranspose(coordinate);
|
|
42
|
+
const [p0, p1, p2, p3] = tpShape ? reorder(funnelPoints) : funnelPoints;
|
|
43
|
+
const { color = defaultColor, opacity } = value;
|
|
44
|
+
const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
|
|
45
|
+
return select(new Path({}))
|
|
46
|
+
.call(applyStyle, defaults)
|
|
47
|
+
.style('path', b)
|
|
48
|
+
.style('fill', color)
|
|
49
|
+
.style('fillOpacity', opacity)
|
|
50
|
+
.call(applyStyle, style)
|
|
51
|
+
.node();
|
|
38
52
|
};
|
|
39
53
|
};
|
|
40
|
-
Funnel.props =
|
|
54
|
+
Funnel.props = {
|
|
55
|
+
defaultMarker: 'square',
|
|
56
|
+
};
|
|
41
57
|
//# sourceMappingURL=funnel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funnel.js","sourceRoot":"src/","sources":["shape/interval/funnel.ts"],"names":[],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"funnel.js","sourceRoot":"src/","sources":["shape/interval/funnel.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,OAAO,EAAgB,MAAM,UAAU,CAAC;AAW5E;;GAEG;AACH,SAAS,eAAe,CACtB,MAAiB,EACjB,UAAqB,EACrB,UAAsB;IAEtB,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC;IAEhC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;QAC3B,MA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el } from './funnel';
|
|
4
3
|
/**
|
|
5
4
|
* Adjust and return the new `points`.
|
|
@@ -33,5 +32,7 @@ function getPyramidPoints(points, nextPoints, coordinate) {
|
|
|
33
32
|
export const Pyramid = (options) => {
|
|
34
33
|
return Funnel(Object.assign({ adjustPoints: getPyramidPoints }, options));
|
|
35
34
|
};
|
|
36
|
-
Pyramid.props =
|
|
35
|
+
Pyramid.props = {
|
|
36
|
+
defaultMarker: 'square',
|
|
37
|
+
};
|
|
37
38
|
//# sourceMappingURL=pyramid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyramid.js","sourceRoot":"src/","sources":["shape/interval/pyramid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"pyramid.js","sourceRoot":"src/","sources":["shape/interval/pyramid.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAIlC;;GAEG;AACH,SAAS,gBAAgB,CACvB,MAAiB,EACjB,UAAqB,EACrB,UAAsB;IAEtB,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,GAAG,MAAM,CAAC;IAEhC,IAAI,WAAW,CAAC,UAAU,CAAC,EAAE;QAC3B,MAAM,KAAK,GAAY;YACrB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACnD,EAAE,CAAC,CAAC,CAAC;SACN,CAAC;QACF,MAAM,KAAK,GAAY;YACrB,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACnD,EAAE,CAAC,CAAC,CAAC;SACN,CAAC;QACF,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;KAC/B;IACD,MAAM,KAAK,GAAY;QACrB,EAAE,CAAC,CAAC,CAAC;QACL,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;KACpD,CAAC;IACF,MAAM,KAAK,GAAY;QACrB,EAAE,CAAC,CAAC,CAAC;QACL,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;KACpD,CAAC;IACF,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAAuB,CAAC,OAAO,EAAE,EAAE;IACrD,OAAO,MAAM,iBAAG,YAAY,EAAE,gBAAgB,IAAK,OAAO,EAAG,CAAC;AAChE,CAAC,CAAC;AAEF,OAAO,CAAC,KAAK,GAAG;IACd,aAAa,EAAE,QAAQ;CACxB,CAAC"}
|
|
@@ -12,8 +12,11 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports.Funnel = void 0;
|
|
15
|
+
const g_1 = require("@antv/g");
|
|
16
|
+
const d3_shape_1 = require("d3-shape");
|
|
15
17
|
const coordinate_1 = require("../../utils/coordinate");
|
|
16
|
-
const
|
|
18
|
+
const selection_1 = require("../../utils/selection");
|
|
19
|
+
const utils_1 = require("../utils");
|
|
17
20
|
/**
|
|
18
21
|
* Adjust and return the new `points`.
|
|
19
22
|
*/
|
|
@@ -34,12 +37,25 @@ function getFunnelPoints(points, nextPoints, coordinate) {
|
|
|
34
37
|
const Funnel = (options) => {
|
|
35
38
|
const { adjustPoints = getFunnelPoints } = options, style = __rest(options, ["adjustPoints"]);
|
|
36
39
|
return (points, value, coordinate, theme, point2d, ...args) => {
|
|
37
|
-
const { index } = value;
|
|
40
|
+
const { index, mark, shape, defaultShape } = value;
|
|
41
|
+
const _a = (0, utils_1.getShapeTheme)(theme, mark, shape, defaultShape), { defaultColor } = _a, defaults = __rest(_a, ["defaultColor"]);
|
|
38
42
|
const nextPoints = point2d[index + 1];
|
|
39
43
|
const funnelPoints = adjustPoints(points, nextPoints, coordinate);
|
|
40
|
-
|
|
44
|
+
const tpShape = !!(0, coordinate_1.isTranspose)(coordinate);
|
|
45
|
+
const [p0, p1, p2, p3] = tpShape ? (0, utils_1.reorder)(funnelPoints) : funnelPoints;
|
|
46
|
+
const { color = defaultColor, opacity } = value;
|
|
47
|
+
const b = (0, d3_shape_1.line)().curve(d3_shape_1.curveLinearClosed)([p0, p1, p2, p3]);
|
|
48
|
+
return (0, selection_1.select)(new g_1.Path({}))
|
|
49
|
+
.call(utils_1.applyStyle, defaults)
|
|
50
|
+
.style('path', b)
|
|
51
|
+
.style('fill', color)
|
|
52
|
+
.style('fillOpacity', opacity)
|
|
53
|
+
.call(utils_1.applyStyle, style)
|
|
54
|
+
.node();
|
|
41
55
|
};
|
|
42
56
|
};
|
|
43
57
|
exports.Funnel = Funnel;
|
|
44
|
-
exports.Funnel.props =
|
|
58
|
+
exports.Funnel.props = {
|
|
59
|
+
defaultMarker: 'square',
|
|
60
|
+
};
|
|
45
61
|
//# sourceMappingURL=funnel.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"funnel.js","sourceRoot":"src/","sources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AC,CAAC;aACxB,IAAI,CAAC,kBAAU,EAAE,QAAQ,CAAC;aAC1B,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;aAChB,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;aACpB,KAAK,CAAC,aAAa,EAAE,OAAO,CAAC;aAC7B,IAAI,CAAC,kBAAU,EAAE,KAAK,CAAC;aACvB,IAAI,EAAE,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC,CAAC;AAzBW,QAAA,MAAM,UAyBjB;AAEF,cAAM,CAAC,KAAK,GAAG;IACb,aAAa,EAAE,QAAQ;CACxB,CAAC"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Pyramid = void 0;
|
|
4
4
|
const coordinate_1 = require("../../utils/coordinate");
|
|
5
|
-
const color_1 = require("./color");
|
|
6
5
|
const funnel_1 = require("./funnel");
|
|
7
6
|
/**
|
|
8
7
|
* Adjust and return the new `points`.
|
|
@@ -37,5 +36,7 @@ const Pyramid = (options) => {
|
|
|
37
36
|
return (0, funnel_1.Funnel)(Object.assign({ adjustPoints: getPyramidPoints }, options));
|
|
38
37
|
};
|
|
39
38
|
exports.Pyramid = Pyramid;
|
|
40
|
-
exports.Pyramid.props =
|
|
39
|
+
exports.Pyramid.props = {
|
|
40
|
+
defaultMarker: 'square',
|
|
41
|
+
};
|
|
41
42
|
//# sourceMappingURL=pyramid.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pyramid.js","sourceRoot":"src/","sources":["shape/interval/pyramid.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AAErD,
|
|
1
|
+
{"version":3,"file":"pyramid.js","sourceRoot":"src/","sources":["shape/interval/pyramid.ts"],"names":[],"mappings":";;;AACA,uDAAqD;AAErD,qCAAkC;AAIlC;;GAEG;AACH,SAAS,gBAAgB,CACvB,MAAiB,EACjB,UAAqB,EACrB,UAAsB;IAEtB,MAAM,CAAC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,OAAO,GAAuB,CAAC,OAAO,EAAE,EAAE;IACrD,OAAO,IAAA,eAAM,kBAAG,YAAY,EAAE,gBAAgB,IAAK,OAAO,EAAG,CAAC;AAChE,CAAC,CAAC;AAFW,QAAA,OAAO,WAElB;AAEF,eAAO,CAAC,KAAK,GAAG;IACd,aAAa,EAAE,QAAQ;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { Path } from '@antv/g';
|
|
2
|
+
import { line, curveLinearClosed } from 'd3-shape';
|
|
1
3
|
import { Coordinate } from '@antv/coord';
|
|
2
4
|
import { isTranspose } from '../../utils/coordinate';
|
|
3
5
|
import { ShapeComponent as SC, Vector2 } from '../../runtime';
|
|
4
|
-
import {
|
|
6
|
+
import { select } from '../../utils/selection';
|
|
7
|
+
import { applyStyle, getShapeTheme, reorder, toOpacityKey } from '../utils';
|
|
5
8
|
|
|
6
9
|
export type FunnelOptions = {
|
|
7
10
|
adjustPoints?: (
|
|
@@ -38,22 +41,30 @@ function getFunnelPoints(
|
|
|
38
41
|
export const Funnel: SC<FunnelOptions> = (options) => {
|
|
39
42
|
const { adjustPoints = getFunnelPoints, ...style } = options;
|
|
40
43
|
return (points, value, coordinate, theme, point2d, ...args) => {
|
|
41
|
-
const { index } = value;
|
|
44
|
+
const { index, mark, shape, defaultShape } = value;
|
|
45
|
+
const { defaultColor, ...defaults } = getShapeTheme(
|
|
46
|
+
theme,
|
|
47
|
+
mark,
|
|
48
|
+
shape,
|
|
49
|
+
defaultShape,
|
|
50
|
+
);
|
|
42
51
|
const nextPoints = point2d[index + 1];
|
|
43
52
|
const funnelPoints = adjustPoints(points, nextPoints, coordinate);
|
|
53
|
+
const tpShape = !!isTranspose(coordinate);
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
const [p0, p1, p2, p3] = tpShape ? reorder(funnelPoints) : funnelPoints;
|
|
56
|
+
const { color = defaultColor, opacity } = value;
|
|
57
|
+
const b = line().curve(curveLinearClosed)([p0, p1, p2, p3]);
|
|
58
|
+
return select(new Path({}))
|
|
59
|
+
.call(applyStyle, defaults)
|
|
60
|
+
.style('path', b)
|
|
61
|
+
.style('fill', color)
|
|
62
|
+
.style('fillOpacity', opacity)
|
|
63
|
+
.call(applyStyle, style)
|
|
64
|
+
.node();
|
|
53
65
|
};
|
|
54
66
|
};
|
|
55
67
|
|
|
56
68
|
Funnel.props = {
|
|
57
|
-
|
|
58
|
-
defaultMarker: 'funnel',
|
|
69
|
+
defaultMarker: 'square',
|
|
59
70
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Coordinate } from '@antv/coord';
|
|
2
2
|
import { isTranspose } from '../../utils/coordinate';
|
|
3
3
|
import { ShapeComponent as SC, Vector2 } from '../../runtime';
|
|
4
|
-
import { Color } from './color';
|
|
5
4
|
import { Funnel } from './funnel';
|
|
6
5
|
|
|
7
6
|
export type PyramidOptions = Record<string, any>;
|
|
@@ -46,6 +45,5 @@ export const Pyramid: SC<PyramidOptions> = (options) => {
|
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
Pyramid.props = {
|
|
49
|
-
...Color.props,
|
|
50
48
|
defaultMarker: 'square',
|
|
51
49
|
};
|