@antv/g2 5.1.3 → 5.1.4
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/api/runtime.js +3 -2
- package/esm/api/runtime.js.map +1 -1
- package/esm/api/utils.d.ts +1 -0
- package/esm/api/utils.js +6 -2
- package/esm/api/utils.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +2 -2
- package/esm/interaction/tooltip.js +47 -22
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/lib/threed.d.ts +1 -0
- package/esm/lib/threed.js +2 -1
- package/esm/lib/threed.js.map +1 -1
- package/esm/mark/index.d.ts +1 -0
- package/esm/mark/index.js +1 -0
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/interval3D.d.ts +8 -0
- package/esm/mark/interval3D.js +65 -0
- package/esm/mark/interval3D.js.map +1 -0
- package/esm/shape/index.d.ts +2 -1
- package/esm/shape/index.js +1 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/interval3D/cube.d.ts +6 -0
- package/esm/shape/interval3D/cube.js +71 -0
- package/esm/shape/interval3D/cube.js.map +1 -0
- package/esm/spec/interaction.d.ts +1 -0
- package/lib/api/runtime.js +2 -1
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/utils.d.ts +1 -0
- package/lib/api/utils.js +7 -3
- package/lib/api/utils.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +2 -2
- package/lib/interaction/tooltip.js +47 -22
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/lib/threed.d.ts +1 -0
- package/lib/lib/threed.js +1 -0
- package/lib/lib/threed.js.map +1 -1
- package/lib/mark/index.d.ts +1 -0
- package/lib/mark/index.js +3 -1
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/interval3D.d.ts +8 -0
- package/lib/mark/interval3D.js +69 -0
- package/lib/mark/interval3D.js.map +1 -0
- package/lib/shape/index.d.ts +2 -1
- package/lib/shape/index.js +4 -2
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/interval3D/cube.d.ts +6 -0
- package/lib/shape/interval3D/cube.js +75 -0
- package/lib/shape/interval3D/cube.js.map +1 -0
- package/lib/spec/interaction.d.ts +1 -0
- package/package.json +1 -1
- package/src/api/runtime.ts +2 -1
- package/src/api/utils.ts +7 -1
- package/src/interaction/tooltip.ts +49 -17
- package/src/lib/threed.ts +2 -1
- package/src/mark/index.ts +1 -0
- package/src/mark/interval3D.ts +100 -0
- package/src/shape/index.ts +2 -1
- package/src/shape/interval3D/cube.ts +69 -0
- package/src/spec/interaction.ts +1 -0
- package/CHANGELOG.md +0 -385
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Interval3D = void 0;
|
|
4
|
+
const transform_1 = require("../transform");
|
|
5
|
+
const shape_1 = require("../shape");
|
|
6
|
+
const utils_1 = require("./utils");
|
|
7
|
+
/**
|
|
8
|
+
* Convert value for each channel to rect shapes.
|
|
9
|
+
* return two 3D points, which represents the bounding box of a rect.
|
|
10
|
+
*/
|
|
11
|
+
const Interval3D = (options) => {
|
|
12
|
+
return (index, scale, value, coordinate) => {
|
|
13
|
+
const { x: X, y: Y, y1: Y1, z: Z, size: SZ, dx: DX, dy: DY, dz: DZ, } = value;
|
|
14
|
+
// The scales for x and series channels must be band scale.
|
|
15
|
+
const x = scale.x;
|
|
16
|
+
const z = scale.x;
|
|
17
|
+
const [width, height, depth] = coordinate.getSize();
|
|
18
|
+
const x1x2 = (x, w, i) => [x, x + w];
|
|
19
|
+
// Calc the points of bounding box for the interval.
|
|
20
|
+
// They are start from left-top corner in clock wise order.
|
|
21
|
+
// TODO: series support
|
|
22
|
+
const P = Array.from(index, (i) => {
|
|
23
|
+
const groupWidthX = bandWidth(x, X[i]);
|
|
24
|
+
const groupWidthZ = bandWidth(z, Z[i]);
|
|
25
|
+
const x0 = +X[i];
|
|
26
|
+
const z0 = +Z[i];
|
|
27
|
+
const [x1, x2] = x1x2(x0, groupWidthX, i);
|
|
28
|
+
const [z1, z2] = x1x2(z0, groupWidthZ, i);
|
|
29
|
+
const y1 = +Y[i];
|
|
30
|
+
const y2 = +Y1[i];
|
|
31
|
+
const p1 = [x1, y1, z1];
|
|
32
|
+
const p2 = [x2, y2, z2];
|
|
33
|
+
return [
|
|
34
|
+
coordinate.map([...p1]),
|
|
35
|
+
coordinate.map([...p2]),
|
|
36
|
+
];
|
|
37
|
+
});
|
|
38
|
+
return [index, P];
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
exports.Interval3D = Interval3D;
|
|
42
|
+
function bandWidth(scale, xz) {
|
|
43
|
+
return scale.getBandWidth(scale.invert(xz));
|
|
44
|
+
}
|
|
45
|
+
const shape = {
|
|
46
|
+
cube: shape_1.IntervalCube,
|
|
47
|
+
};
|
|
48
|
+
exports.Interval3D.props = {
|
|
49
|
+
defaultShape: 'cube',
|
|
50
|
+
defaultLabelShape: 'label',
|
|
51
|
+
composite: false,
|
|
52
|
+
shape,
|
|
53
|
+
channels: [
|
|
54
|
+
...(0, utils_1.baseGeometryChannels)({ shapes: Object.keys(shape) }),
|
|
55
|
+
{ name: 'x', scale: 'band', required: true },
|
|
56
|
+
{ name: 'z', scale: 'band', required: true },
|
|
57
|
+
{ name: 'y', required: true },
|
|
58
|
+
{ name: 'series', scale: 'band' },
|
|
59
|
+
{ name: 'size' },
|
|
60
|
+
],
|
|
61
|
+
preInference: [
|
|
62
|
+
...(0, utils_1.basePreInference)(),
|
|
63
|
+
{ type: transform_1.MaybeZeroX },
|
|
64
|
+
{ type: transform_1.MaybeZeroY1 },
|
|
65
|
+
{ type: transform_1.MaybeZeroZ },
|
|
66
|
+
],
|
|
67
|
+
postInference: [...(0, utils_1.basePostInference)(), { type: transform_1.MaybeSize }, ...(0, utils_1.tooltip3d)()],
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=interval3D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IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5C,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC7B,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE;QACjC,EAAE,IAAI,EAAE,MAAM,EAAE;KACjB;IACD,YAAY,EAAE;QACZ,GAAG,IAAA,wBAAgB,GAAE;QACrB,EAAE,IAAI,EAAE,sBAAU,EAAE;QACpB,EAAE,IAAI,EAAE,uBAAW,EAAE;QACrB,EAAE,IAAI,EAAE,sBAAU,EAAE;KACrB;IACD,aAAa,EAAE,CAAC,GAAG,IAAA,yBAAiB,GAAE,EAAE,EAAE,IAAI,EAAE,qBAAS,EAAE,EAAE,GAAG,IAAA,iBAAS,GAAE,CAAC;CAC7E,CAAC"}
|
package/lib/shape/index.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { Triangle as PointTriangle } from './point/triangle';
|
|
|
32
32
|
export { TriangleDown as PointTriangleDown } from './point/triangleDown';
|
|
33
33
|
export { Sphere } from './point3D/sphere';
|
|
34
34
|
export { Cube } from './point3D/cube';
|
|
35
|
+
export { Cube as IntervalCube } from './interval3D/cube';
|
|
35
36
|
export { Vector as VectorShape } from './vector/vector';
|
|
36
37
|
export { Text as TextShape } from './text/text';
|
|
37
38
|
export { Badge as TextBadge } from './text/badge';
|
|
@@ -64,7 +65,7 @@ export { Liquid as LiquidShape } from './liquid/liquid';
|
|
|
64
65
|
export type { RectOptions as IntervalShapeOptions } from './interval/rect';
|
|
65
66
|
export type { HollowOptions as IntervalHollowOptions } from './interval/hollow';
|
|
66
67
|
export type { FunnelOptions as IntervalFunnelOptions } from './interval/funnel';
|
|
67
|
-
export type { PyramidOptions as
|
|
68
|
+
export type { PyramidOptions as IntervalPyline3DramidOptions } from './interval/pyramid';
|
|
68
69
|
export type { LineOptions as LineShapeOptions } from './line/line';
|
|
69
70
|
export type { SmoothOptions as LineSmoothOptions } from './line/smooth';
|
|
70
71
|
export type { HVOptions as LineHVOptions } from './line/hv';
|
package/lib/shape/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.LiquidShape = exports.ShapeShape = exports.RectHollow = exports.RectShape = exports.RangeShape = exports.HeatmapShape = exports.DensityShape = exports.PathHollow = exports.PathShape = exports.LabelShape = exports.ConnectorShape = exports.LineXY = exports.BoxViolin = void 0;
|
|
3
|
+
exports.PolygonRibbon = exports.PolygonShape = exports.ImageShape = exports.LinkArc = exports.LinkVHV = exports.LinkSmooth = exports.LinkShape = exports.AreaHV = exports.AreaVH = exports.AreaHVH = exports.AreaSmooth = exports.AreaShape = exports.TextBadge = exports.TextShape = exports.VectorShape = exports.IntervalCube = exports.Cube = exports.Sphere = exports.PointTriangleDown = exports.PointTriangle = exports.PointTick = exports.PointSquare = exports.PointShape = exports.PointPlus = exports.PointLine = exports.PointHyphen = exports.PointHexagon = exports.PointDiamond = exports.PointCross = exports.PointBowtie = exports.PointHollowTriangleDown = exports.PointHollowTriangle = exports.PointHollowSquare = exports.PointHollow = exports.PointHollowHexagon = exports.PointHollowDiamond = exports.PointHollowBowtie = exports.Line3DShape = exports.LineTrail = exports.LineHVH = exports.LineVH = exports.LineHV = exports.LineSmooth = exports.LineShape = exports.CellHollow = exports.CellShape = exports.IntervalPyramid = exports.IntervalFunnel = exports.IntervalHollow = exports.IntervalShape = void 0;
|
|
4
|
+
exports.LiquidShape = exports.ShapeShape = exports.RectHollow = exports.RectShape = exports.RangeShape = exports.HeatmapShape = exports.DensityShape = exports.PathHollow = exports.PathShape = exports.LabelShape = exports.ConnectorShape = exports.LineXY = exports.BoxViolin = exports.BoxShape = void 0;
|
|
5
5
|
var rect_1 = require("./interval/rect");
|
|
6
6
|
Object.defineProperty(exports, "IntervalShape", { enumerable: true, get: function () { return rect_1.Rect; } });
|
|
7
7
|
var hollow_1 = require("./interval/hollow");
|
|
@@ -70,6 +70,8 @@ var sphere_1 = require("./point3D/sphere");
|
|
|
70
70
|
Object.defineProperty(exports, "Sphere", { enumerable: true, get: function () { return sphere_1.Sphere; } });
|
|
71
71
|
var cube_1 = require("./point3D/cube");
|
|
72
72
|
Object.defineProperty(exports, "Cube", { enumerable: true, get: function () { return cube_1.Cube; } });
|
|
73
|
+
var cube_2 = require("./interval3D/cube");
|
|
74
|
+
Object.defineProperty(exports, "IntervalCube", { enumerable: true, get: function () { return cube_2.Cube; } });
|
|
73
75
|
var vector_1 = require("./vector/vector");
|
|
74
76
|
Object.defineProperty(exports, "VectorShape", { enumerable: true, get: function () { return vector_1.Vector; } });
|
|
75
77
|
var text_1 = require("./text/text");
|
package/lib/shape/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["shape/index.ts"],"names":[],"mappings":";;;;AAAA,wCAAwD;AAA/C,qGAAA,IAAI,OAAiB;AAC9B,4CAA6D;AAApD,wGAAA,MAAM,OAAkB;AACjC,4CAA6D;AAApD,wGAAA,MAAM,OAAkB;AACjC,8CAAgE;AAAvD,0GAAA,OAAO,OAAmB;AACnC,wCAAoD;AAA3C,iGAAA,IAAI,OAAa;AAC1B,4CAAyD;AAAhD,oGAAA,MAAM,OAAc;AAC7B,oCAAgD;AAAvC,iGAAA,IAAI,OAAa;AAC1B,wCAAqD;AAA5C,oGAAA,MAAM,OAAc;AAC7B,gCAAyC;AAAhC,4FAAA,EAAE,OAAU;AACrB,gCAAyC;AAAhC,4FAAA,EAAE,OAAU;AACrB,kCAA4C;AAAnC,8FAAA,GAAG,OAAW;AACvB,sCAAkD;AAAzC,kGAAA,KAAK,OAAa;AAC3B,sCAAoD;AAA3C,mGAAA,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2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.Cube = void 0;
|
|
15
|
+
const g_plugin_3d_1 = require("@antv/g-plugin-3d");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
const selection_1 = require("../../utils/selection");
|
|
18
|
+
/**
|
|
19
|
+
* @see https://g.antv.antgroup.com/api/3d/geometry#cubegeometry
|
|
20
|
+
*/
|
|
21
|
+
const Cube = (options, context) => {
|
|
22
|
+
// Render border only when colorAttribute is stroke.
|
|
23
|
+
const style = __rest(options, []);
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
if (!context.cubeGeometry) {
|
|
26
|
+
const renderer = context.canvas.getConfig().renderer;
|
|
27
|
+
const plugin = renderer.getPlugin('device-renderer');
|
|
28
|
+
const device = plugin.getDevice();
|
|
29
|
+
// create a cube geometry
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
context.cubeGeometry = new g_plugin_3d_1.CubeGeometry(device, {
|
|
32
|
+
width: 1,
|
|
33
|
+
height: 1,
|
|
34
|
+
depth: 1,
|
|
35
|
+
});
|
|
36
|
+
// create a material with Lambert lighting model
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
context.cubeMaterial = new g_plugin_3d_1.MeshLambertMaterial(device);
|
|
39
|
+
}
|
|
40
|
+
return (_points, value, defaults) => {
|
|
41
|
+
const points = _points;
|
|
42
|
+
const { color: defaultColor } = defaults;
|
|
43
|
+
const { color = defaultColor, transform, opacity } = value;
|
|
44
|
+
const [cx, cy, cz] = (0, utils_1.getOrigin)(points);
|
|
45
|
+
const width = Math.abs(points[1][0] - points[0][0]);
|
|
46
|
+
const height = Math.abs(points[1][1] - points[0][1]);
|
|
47
|
+
const depth = Math.abs(points[1][2] - points[0][2]);
|
|
48
|
+
const cube = new g_plugin_3d_1.Mesh({
|
|
49
|
+
style: {
|
|
50
|
+
x: cx,
|
|
51
|
+
y: cy,
|
|
52
|
+
z: cz,
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
geometry: context.cubeGeometry,
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
material: context.cubeMaterial,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
cube.setOrigin(0, 0, 0);
|
|
60
|
+
cube.scale([width, height, depth]);
|
|
61
|
+
const selection = (0, selection_1.select)(cube)
|
|
62
|
+
.call(utils_1.applyStyle, defaults)
|
|
63
|
+
.style('fill', color)
|
|
64
|
+
.style('transform', transform)
|
|
65
|
+
.style((0, utils_1.toOpacityKey)(options), opacity)
|
|
66
|
+
.call(utils_1.applyStyle, style)
|
|
67
|
+
.node();
|
|
68
|
+
return selection;
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
exports.Cube = Cube;
|
|
72
|
+
exports.Cube.props = {
|
|
73
|
+
defaultMarker: 'cube',
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=cube.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cube.js","sourceRoot":"src/","sources":["shape/interval3D/cube.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mDAA4E;AAC5E,oCAA+D;AAE/D,qDAA+C;AAI/C;;GAEG;AACI,MAAM,IAAI,GAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE;IACxD,oDAAoD;IACpD,MAAW,KAAK,UAAK,OAAO,EAAt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,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpD,MAAM,IAAI,GAAG,IAAI,kBAAI,CAAC;YACpB,KAAK,EAAE;gBACL,CAAC,EAAE,EAAE;gBACL,CAAC,EAAE,EAAE;gBACL,CAAC,EAAE,EAAE;gBACL,aAAa;gBACb,QAAQ,EAAE,OAAO,CAAC,YAAY;gBAC9B,aAAa;gBACb,QAAQ,EAAE,OAAO,CAAC,YAAY;aAC/B;SACF,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAEnC,MAAM,SAAS,GAAG,IAAA,kBAAM,EAAC,IAAI,CAAC;aAC3B,IAAI,CAAC,kBAAU,EAAE,QAAQ,CAAC;aAC1B,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC;aACpB,KAAK,CAAC,WAAW,EAAE,SAAS,CAAC;aAC7B,KAAK,CAAC,IAAA,oBAAY,EAAC,OAAO,CAAC,EAAE,OAAO,CAAC;aACrC,IAAI,CAAC,kBAAU,EAAE,KAAK,CAAC;aACvB,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;AACJ,CAAC,CAAC;AAtDW,QAAA,IAAI,QAsDf;AAEF,YAAI,CAAC,KAAK,GAAG;IACX,aAAa,EAAE,MAAM;CACtB,CAAC"}
|
|
@@ -116,6 +116,7 @@ export type TooltipInteraction = {
|
|
|
116
116
|
position?: TooltipStyleProps['position'];
|
|
117
117
|
bounding?: BBox;
|
|
118
118
|
mount?: string | HTMLElement;
|
|
119
|
+
css?: Record<string, any>;
|
|
119
120
|
sort?: (d: TooltipItemValue) => any;
|
|
120
121
|
filter?: (d: TooltipItemValue) => any;
|
|
121
122
|
render?: (event: any, // @todo
|
package/package.json
CHANGED
package/src/api/runtime.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
optionsOf,
|
|
15
15
|
updateRoot,
|
|
16
16
|
createEmptyPromise,
|
|
17
|
+
REMOVE_FLAG,
|
|
17
18
|
} from './utils';
|
|
18
19
|
import { CompositionNode } from './composition';
|
|
19
20
|
import { Node } from './node';
|
|
@@ -155,7 +156,7 @@ export class Runtime<Spec extends G2Spec = G2Spec> extends CompositionNode {
|
|
|
155
156
|
this._unbindAutoFit();
|
|
156
157
|
this._reset();
|
|
157
158
|
destroy(options, this._context, true);
|
|
158
|
-
removeContainer(this._container);
|
|
159
|
+
if (this._container[REMOVE_FLAG]) removeContainer(this._container);
|
|
159
160
|
this.emit(ChartEvent.AFTER_DESTROY);
|
|
160
161
|
}
|
|
161
162
|
|
package/src/api/utils.ts
CHANGED
|
@@ -29,10 +29,16 @@ export const VIEW_KEYS = [
|
|
|
29
29
|
'title',
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
+
export const REMOVE_FLAG = '__remove__';
|
|
33
|
+
|
|
32
34
|
export function normalizeContainer(
|
|
33
35
|
container: string | HTMLElement,
|
|
34
36
|
): HTMLElement {
|
|
35
|
-
if (container === undefined)
|
|
37
|
+
if (container === undefined) {
|
|
38
|
+
const container = document.createElement('div');
|
|
39
|
+
container[REMOVE_FLAG] = true;
|
|
40
|
+
return container;
|
|
41
|
+
}
|
|
36
42
|
if (typeof container === 'string') {
|
|
37
43
|
const node = document.getElementById(container);
|
|
38
44
|
return node;
|
|
@@ -63,7 +63,16 @@ function createTooltip(
|
|
|
63
63
|
enterable,
|
|
64
64
|
bounding,
|
|
65
65
|
containerOffset,
|
|
66
|
+
css = {},
|
|
66
67
|
) {
|
|
68
|
+
const defaults = {
|
|
69
|
+
'.g2-tooltip': {},
|
|
70
|
+
'.g2-tooltip-title': {
|
|
71
|
+
overflow: 'hidden',
|
|
72
|
+
'white-space': 'nowrap',
|
|
73
|
+
'text-overflow': 'ellipsis',
|
|
74
|
+
},
|
|
75
|
+
};
|
|
67
76
|
const tooltipElement = new TooltipComponent({
|
|
68
77
|
className: 'tooltip',
|
|
69
78
|
style: {
|
|
@@ -79,14 +88,7 @@ function createTooltip(
|
|
|
79
88
|
template: {
|
|
80
89
|
prefixCls: 'g2-',
|
|
81
90
|
},
|
|
82
|
-
style:
|
|
83
|
-
'.g2-tooltip': {},
|
|
84
|
-
'.g2-tooltip-title': {
|
|
85
|
-
overflow: 'hidden',
|
|
86
|
-
'white-space': 'nowrap',
|
|
87
|
-
'text-overflow': 'ellipsis',
|
|
88
|
-
},
|
|
89
|
-
},
|
|
91
|
+
style: deepMix(defaults, css),
|
|
90
92
|
},
|
|
91
93
|
});
|
|
92
94
|
container.appendChild(tooltipElement.HTMLTooltipElement);
|
|
@@ -103,6 +105,7 @@ function showTooltip({
|
|
|
103
105
|
single,
|
|
104
106
|
position = 'right-bottom',
|
|
105
107
|
enterable = false,
|
|
108
|
+
css,
|
|
106
109
|
mount,
|
|
107
110
|
bounding,
|
|
108
111
|
}) {
|
|
@@ -123,6 +126,7 @@ function showTooltip({
|
|
|
123
126
|
enterable,
|
|
124
127
|
b,
|
|
125
128
|
containerOffset,
|
|
129
|
+
css,
|
|
126
130
|
),
|
|
127
131
|
} = parent as any;
|
|
128
132
|
const { items, title = '' } = data;
|
|
@@ -431,6 +435,7 @@ export function seriesTooltip(
|
|
|
431
435
|
disableNative = false,
|
|
432
436
|
marker = true,
|
|
433
437
|
style: _style = {},
|
|
438
|
+
css = {},
|
|
434
439
|
...rest
|
|
435
440
|
}: Record<string, any>,
|
|
436
441
|
) {
|
|
@@ -452,11 +457,14 @@ export function seriesTooltip(
|
|
|
452
457
|
const itemElements = [];
|
|
453
458
|
for (const element of elements) {
|
|
454
459
|
const { __data__: data } = element;
|
|
455
|
-
const { seriesX } = data;
|
|
460
|
+
const { seriesX, title, items } = data;
|
|
456
461
|
if (seriesX) seriesElements.push(element);
|
|
457
|
-
else itemElements.push(element);
|
|
462
|
+
else if (title || items) itemElements.push(element);
|
|
458
463
|
}
|
|
459
464
|
|
|
465
|
+
const isBandScale = !!(transposed ? scale.y : scale.x).getBandWidth;
|
|
466
|
+
const closest = isBandScale && itemElements.length > 0;
|
|
467
|
+
|
|
460
468
|
// Sorted elements from top to bottom visually,
|
|
461
469
|
// or from right to left in transpose coordinate.
|
|
462
470
|
seriesElements.sort((a, b) => {
|
|
@@ -465,6 +473,20 @@ export function seriesTooltip(
|
|
|
465
473
|
return transposed ? minY(b) - minY(a) : minY(a) - minY(b);
|
|
466
474
|
});
|
|
467
475
|
|
|
476
|
+
const extent = (d) => {
|
|
477
|
+
const index = transposed ? 1 : 0;
|
|
478
|
+
const { min, max } = d.getLocalBounds();
|
|
479
|
+
return sort([min[index], max[index]]);
|
|
480
|
+
};
|
|
481
|
+
// Sort itemElements by x or y.
|
|
482
|
+
itemElements.sort((a, b) => {
|
|
483
|
+
const [minA, maxA] = extent(a);
|
|
484
|
+
const [minB, maxB] = extent(b);
|
|
485
|
+
const midA = (minA + maxA) / 2;
|
|
486
|
+
const midB = (minB + maxB) / 2;
|
|
487
|
+
return transposed ? midB - midA : midA - midB;
|
|
488
|
+
});
|
|
489
|
+
|
|
468
490
|
// Get sortedIndex and X for each series elements
|
|
469
491
|
const elementSortedX = new Map(
|
|
470
492
|
seriesElements.map((element) => {
|
|
@@ -489,8 +511,9 @@ export function seriesTooltip(
|
|
|
489
511
|
const indexByFocus = (focus, I, X) => {
|
|
490
512
|
const finalX = abstractX(focus);
|
|
491
513
|
const [minX, maxX] = sort([X[0], X[X.length - 1]]);
|
|
492
|
-
//
|
|
493
|
-
|
|
514
|
+
// If closest is true, always find at least one element.
|
|
515
|
+
// Otherwise, skip element out of plot area.
|
|
516
|
+
if (!closest && (finalX < minX || finalX > maxX)) return null;
|
|
494
517
|
const search = bisector((i) => X[+i]).center;
|
|
495
518
|
const i = search(I, finalX);
|
|
496
519
|
return I[i];
|
|
@@ -499,14 +522,20 @@ export function seriesTooltip(
|
|
|
499
522
|
const elementsByFocus = (focus, elements) => {
|
|
500
523
|
const index = transposed ? 1 : 0;
|
|
501
524
|
const x = focus[index];
|
|
502
|
-
const
|
|
503
|
-
const { min, max } = d.getLocalBounds();
|
|
504
|
-
return sort([min[index], max[index]]);
|
|
505
|
-
};
|
|
506
|
-
return elements.filter((element) => {
|
|
525
|
+
const filtered = elements.filter((element) => {
|
|
507
526
|
const [min, max] = extent(element);
|
|
508
527
|
return x >= min && x <= max;
|
|
509
528
|
});
|
|
529
|
+
// If closet is true, always find at least one element.
|
|
530
|
+
if (!closest || filtered.length > 0) return filtered;
|
|
531
|
+
|
|
532
|
+
// Search the closet element to the focus.
|
|
533
|
+
const search = bisector((element) => {
|
|
534
|
+
const [min, max] = extent(element);
|
|
535
|
+
return (min + max) / 2;
|
|
536
|
+
}).center;
|
|
537
|
+
const i = search(elements, x);
|
|
538
|
+
return [elements[i]].filter(defined);
|
|
510
539
|
};
|
|
511
540
|
|
|
512
541
|
const seriesData = (element, index) => {
|
|
@@ -597,6 +626,7 @@ export function seriesTooltip(
|
|
|
597
626
|
enterable,
|
|
598
627
|
mount,
|
|
599
628
|
bounding,
|
|
629
|
+
css,
|
|
600
630
|
});
|
|
601
631
|
}
|
|
602
632
|
|
|
@@ -733,6 +763,7 @@ export function tooltip(
|
|
|
733
763
|
shared = false,
|
|
734
764
|
body = true,
|
|
735
765
|
disableNative = false,
|
|
766
|
+
css = {},
|
|
736
767
|
}: Record<string, any>,
|
|
737
768
|
) {
|
|
738
769
|
const elements = elementsof(root);
|
|
@@ -780,6 +811,7 @@ export function tooltip(
|
|
|
780
811
|
enterable,
|
|
781
812
|
mount,
|
|
782
813
|
bounding,
|
|
814
|
+
css,
|
|
783
815
|
});
|
|
784
816
|
}
|
|
785
817
|
|
package/src/lib/threed.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Cartesian3D } from '../coordinate';
|
|
2
2
|
import { AxisZ } from '../component';
|
|
3
|
-
import { Point3D, Line3D } from '../mark';
|
|
3
|
+
import { Point3D, Line3D, Interval3D } from '../mark';
|
|
4
4
|
|
|
5
5
|
export function threedlib() {
|
|
6
6
|
return {
|
|
@@ -8,5 +8,6 @@ export function threedlib() {
|
|
|
8
8
|
'component.axisZ': AxisZ,
|
|
9
9
|
'mark.point3D': Point3D,
|
|
10
10
|
'mark.line3D': Line3D,
|
|
11
|
+
'mark.interval3D': Interval3D,
|
|
11
12
|
} as const;
|
|
12
13
|
}
|
package/src/mark/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { Line } from './line';
|
|
|
4
4
|
export { Line3D } from './line3D';
|
|
5
5
|
export { Point } from './point';
|
|
6
6
|
export { Point3D } from './point3D';
|
|
7
|
+
export { Interval3D } from './interval3D';
|
|
7
8
|
export { Text } from './text';
|
|
8
9
|
export { Cell } from './cell';
|
|
9
10
|
export { Area } from './area';
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Coordinate3D } from '@antv/coord';
|
|
2
|
+
import { Band } from '@antv/scale';
|
|
3
|
+
import { MarkComponent as MC, Vector3 } from '../runtime';
|
|
4
|
+
import { PointMark } from '../spec';
|
|
5
|
+
import {
|
|
6
|
+
MaybeZeroX,
|
|
7
|
+
MaybeZeroY,
|
|
8
|
+
MaybeZeroZ,
|
|
9
|
+
MaybeSize,
|
|
10
|
+
MaybeZeroY1,
|
|
11
|
+
} from '../transform';
|
|
12
|
+
import { Sphere, IntervalCube } from '../shape';
|
|
13
|
+
import {
|
|
14
|
+
baseGeometryChannels,
|
|
15
|
+
basePostInference,
|
|
16
|
+
basePreInference,
|
|
17
|
+
tooltip3d,
|
|
18
|
+
} from './utils';
|
|
19
|
+
|
|
20
|
+
export type PointOptions = Omit<PointMark, 'type'>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Convert value for each channel to rect shapes.
|
|
24
|
+
* return two 3D points, which represents the bounding box of a rect.
|
|
25
|
+
*/
|
|
26
|
+
export const Interval3D: MC<PointOptions> = (options) => {
|
|
27
|
+
return (index, scale, value, coordinate) => {
|
|
28
|
+
const {
|
|
29
|
+
x: X,
|
|
30
|
+
y: Y,
|
|
31
|
+
y1: Y1,
|
|
32
|
+
z: Z,
|
|
33
|
+
size: SZ,
|
|
34
|
+
dx: DX,
|
|
35
|
+
dy: DY,
|
|
36
|
+
dz: DZ,
|
|
37
|
+
} = value;
|
|
38
|
+
|
|
39
|
+
// The scales for x and series channels must be band scale.
|
|
40
|
+
const x = scale.x as Band;
|
|
41
|
+
const z = scale.x as Band;
|
|
42
|
+
const [width, height, depth] = (
|
|
43
|
+
coordinate as unknown as Coordinate3D
|
|
44
|
+
).getSize();
|
|
45
|
+
const x1x2 = (x: number, w: number, i: number) => [x, x + w];
|
|
46
|
+
|
|
47
|
+
// Calc the points of bounding box for the interval.
|
|
48
|
+
// They are start from left-top corner in clock wise order.
|
|
49
|
+
// TODO: series support
|
|
50
|
+
const P = Array.from(index, (i) => {
|
|
51
|
+
const groupWidthX = bandWidth(x, X[i]);
|
|
52
|
+
const groupWidthZ = bandWidth(z, Z[i]);
|
|
53
|
+
const x0 = +X[i];
|
|
54
|
+
const z0 = +Z[i];
|
|
55
|
+
const [x1, x2] = x1x2(x0, groupWidthX, i);
|
|
56
|
+
const [z1, z2] = x1x2(z0, groupWidthZ, i);
|
|
57
|
+
const y1 = +Y[i];
|
|
58
|
+
const y2 = +Y1[i];
|
|
59
|
+
|
|
60
|
+
const p1 = [x1, y1, z1];
|
|
61
|
+
const p2 = [x2, y2, z2];
|
|
62
|
+
|
|
63
|
+
return [
|
|
64
|
+
(coordinate as unknown as Coordinate3D).map([...p1]),
|
|
65
|
+
(coordinate as unknown as Coordinate3D).map([...p2]),
|
|
66
|
+
];
|
|
67
|
+
});
|
|
68
|
+
return [index, P];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
function bandWidth(scale: Band, xz: any): number {
|
|
73
|
+
return scale.getBandWidth(scale.invert(xz));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const shape = {
|
|
77
|
+
cube: IntervalCube,
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
Interval3D.props = {
|
|
81
|
+
defaultShape: 'cube',
|
|
82
|
+
defaultLabelShape: 'label',
|
|
83
|
+
composite: false,
|
|
84
|
+
shape,
|
|
85
|
+
channels: [
|
|
86
|
+
...baseGeometryChannels({ shapes: Object.keys(shape) }),
|
|
87
|
+
{ name: 'x', scale: 'band', required: true },
|
|
88
|
+
{ name: 'z', scale: 'band', required: true },
|
|
89
|
+
{ name: 'y', required: true },
|
|
90
|
+
{ name: 'series', scale: 'band' },
|
|
91
|
+
{ name: 'size' },
|
|
92
|
+
],
|
|
93
|
+
preInference: [
|
|
94
|
+
...basePreInference(),
|
|
95
|
+
{ type: MaybeZeroX },
|
|
96
|
+
{ type: MaybeZeroY1 },
|
|
97
|
+
{ type: MaybeZeroZ },
|
|
98
|
+
],
|
|
99
|
+
postInference: [...basePostInference(), { type: MaybeSize }, ...tooltip3d()],
|
|
100
|
+
};
|
package/src/shape/index.ts
CHANGED
|
@@ -32,6 +32,7 @@ export { Triangle as PointTriangle } from './point/triangle';
|
|
|
32
32
|
export { TriangleDown as PointTriangleDown } from './point/triangleDown';
|
|
33
33
|
export { Sphere } from './point3D/sphere';
|
|
34
34
|
export { Cube } from './point3D/cube';
|
|
35
|
+
export { Cube as IntervalCube } from './interval3D/cube';
|
|
35
36
|
export { Vector as VectorShape } from './vector/vector';
|
|
36
37
|
export { Text as TextShape } from './text/text';
|
|
37
38
|
export { Badge as TextBadge } from './text/badge';
|
|
@@ -65,7 +66,7 @@ export { Liquid as LiquidShape } from './liquid/liquid';
|
|
|
65
66
|
export type { RectOptions as IntervalShapeOptions } from './interval/rect';
|
|
66
67
|
export type { HollowOptions as IntervalHollowOptions } from './interval/hollow';
|
|
67
68
|
export type { FunnelOptions as IntervalFunnelOptions } from './interval/funnel';
|
|
68
|
-
export type { PyramidOptions as
|
|
69
|
+
export type { PyramidOptions as IntervalPyline3DramidOptions } from './interval/pyramid';
|
|
69
70
|
export type { LineOptions as LineShapeOptions } from './line/line';
|
|
70
71
|
export type { SmoothOptions as LineSmoothOptions } from './line/smooth';
|
|
71
72
|
export type { HVOptions as LineHVOptions } from './line/hv';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { MeshLambertMaterial, CubeGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
|
+
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
|
+
import { ShapeComponent as SC, Vector3 } from '../../runtime';
|
|
4
|
+
import { select } from '../../utils/selection';
|
|
5
|
+
|
|
6
|
+
export type CubeOptions = Record<string, any>;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @see https://g.antv.antgroup.com/api/3d/geometry#cubegeometry
|
|
10
|
+
*/
|
|
11
|
+
export const Cube: SC<CubeOptions> = (options, context) => {
|
|
12
|
+
// Render border only when colorAttribute is stroke.
|
|
13
|
+
const { ...style } = options;
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
if (!context.cubeGeometry) {
|
|
17
|
+
const renderer = context.canvas.getConfig().renderer;
|
|
18
|
+
const plugin = renderer.getPlugin('device-renderer');
|
|
19
|
+
const device = plugin.getDevice();
|
|
20
|
+
// create a cube geometry
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
context.cubeGeometry = new CubeGeometry(device, {
|
|
23
|
+
width: 1,
|
|
24
|
+
height: 1,
|
|
25
|
+
depth: 1,
|
|
26
|
+
});
|
|
27
|
+
// create a material with Lambert lighting model
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
context.cubeMaterial = new MeshLambertMaterial(device);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (_points, value, defaults) => {
|
|
33
|
+
const points = _points as unknown as Vector3[];
|
|
34
|
+
const { color: defaultColor } = defaults;
|
|
35
|
+
const { color = defaultColor, transform, opacity } = value;
|
|
36
|
+
const [cx, cy, cz] = getOrigin(points);
|
|
37
|
+
|
|
38
|
+
const width = Math.abs(points[1][0] - points[0][0]);
|
|
39
|
+
const height = Math.abs(points[1][1] - points[0][1]);
|
|
40
|
+
const depth = Math.abs(points[1][2] - points[0][2]);
|
|
41
|
+
|
|
42
|
+
const cube = new Mesh({
|
|
43
|
+
style: {
|
|
44
|
+
x: cx,
|
|
45
|
+
y: cy,
|
|
46
|
+
z: cz,
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
geometry: context.cubeGeometry,
|
|
49
|
+
// @ts-ignore
|
|
50
|
+
material: context.cubeMaterial,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
cube.setOrigin(0, 0, 0);
|
|
54
|
+
cube.scale([width, height, depth]);
|
|
55
|
+
|
|
56
|
+
const selection = select(cube)
|
|
57
|
+
.call(applyStyle, defaults)
|
|
58
|
+
.style('fill', color)
|
|
59
|
+
.style('transform', transform)
|
|
60
|
+
.style(toOpacityKey(options), opacity)
|
|
61
|
+
.call(applyStyle, style)
|
|
62
|
+
.node();
|
|
63
|
+
return selection;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
Cube.props = {
|
|
68
|
+
defaultMarker: 'cube',
|
|
69
|
+
};
|
package/src/spec/interaction.ts
CHANGED
|
@@ -180,6 +180,7 @@ export type TooltipInteraction = {
|
|
|
180
180
|
position?: TooltipStyleProps['position'];
|
|
181
181
|
bounding?: BBox;
|
|
182
182
|
mount?: string | HTMLElement;
|
|
183
|
+
css?: Record<string, any>; // @todo
|
|
183
184
|
// enterable?: boolean;
|
|
184
185
|
sort?: (d: TooltipItemValue) => any;
|
|
185
186
|
filter?: (d: TooltipItemValue) => any;
|