@antv/g2 5.1.6 → 5.1.8-beta.1
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/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/component/axis.js +1 -5
- package/esm/component/axis.js.map +1 -1
- package/esm/component/index.d.ts +0 -1
- package/esm/component/index.js +0 -1
- package/esm/component/index.js.map +1 -1
- package/esm/component/legendContinuous.js +1 -1
- package/esm/component/legendContinuous.js.map +1 -1
- package/esm/coordinate/index.d.ts +0 -2
- package/esm/coordinate/index.js +0 -1
- package/esm/coordinate/index.js.map +1 -1
- package/esm/exports.d.ts +6 -1
- package/esm/exports.js +4 -0
- package/esm/exports.js.map +1 -1
- package/esm/index.d.ts +114 -114
- package/esm/index.js +2 -2
- package/esm/index.js.map +1 -1
- package/esm/lib/builtinlib.d.ts +7 -7
- package/esm/lib/core.d.ts +32 -32
- package/esm/lib/index.d.ts +0 -2
- package/esm/lib/index.js +0 -2
- package/esm/lib/index.js.map +1 -1
- package/esm/lib/lite.d.ts +18 -18
- package/esm/lib/std.d.ts +56 -56
- package/esm/mark/index.d.ts +0 -4
- package/esm/mark/index.js +0 -4
- package/esm/mark/index.js.map +1 -1
- package/esm/mark/liquid.js +2 -1
- package/esm/mark/liquid.js.map +1 -1
- package/esm/runtime/component.js +1 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/types/component.d.ts +1 -6
- package/esm/shape/index.d.ts +0 -4
- package/esm/shape/index.js +0 -4
- package/esm/shape/index.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/spec/coordinate.d.ts +1 -4
- package/esm/spec/mark.d.ts +1 -3
- package/esm/theme/create.d.ts +1 -0
- package/esm/theme/create.js +1 -0
- package/esm/theme/create.js.map +1 -1
- package/esm/transform/filter.js +3 -1
- package/esm/transform/filter.js.map +1 -1
- package/esm/transform/maybeTitle.js +6 -1
- package/esm/transform/maybeTitle.js.map +1 -1
- package/esm/utils/dateFormat.d.ts +1 -0
- package/esm/utils/dateFormat.js +18 -0
- package/esm/utils/dateFormat.js.map +1 -0
- package/esm/utils/number.d.ts +4 -0
- package/esm/utils/number.js +8 -0
- package/esm/utils/number.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/component/axis.js +3 -7
- package/lib/component/axis.js.map +1 -1
- package/lib/component/index.d.ts +0 -1
- package/lib/component/index.js +1 -3
- package/lib/component/index.js.map +1 -1
- package/lib/component/legendContinuous.js +1 -1
- package/lib/component/legendContinuous.js.map +1 -1
- package/lib/coordinate/index.d.ts +0 -2
- package/lib/coordinate/index.js +1 -3
- package/lib/coordinate/index.js.map +1 -1
- package/lib/exports.d.ts +6 -1
- package/lib/exports.js +13 -1
- package/lib/exports.js.map +1 -1
- package/lib/index.d.ts +114 -114
- package/lib/index.js +1 -2
- package/lib/index.js.map +1 -1
- package/lib/lib/builtinlib.d.ts +7 -7
- package/lib/lib/core.d.ts +32 -32
- package/lib/lib/index.d.ts +0 -2
- package/lib/lib/index.js +1 -5
- package/lib/lib/index.js.map +1 -1
- package/lib/lib/lite.d.ts +18 -18
- package/lib/lib/std.d.ts +56 -56
- package/lib/mark/index.d.ts +0 -4
- package/lib/mark/index.js +1 -9
- package/lib/mark/index.js.map +1 -1
- package/lib/mark/liquid.js +2 -1
- package/lib/mark/liquid.js.map +1 -1
- package/lib/runtime/component.js +2 -4
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/types/component.d.ts +1 -6
- package/lib/shape/index.d.ts +0 -4
- package/lib/shape/index.js +6 -14
- package/lib/shape/index.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/spec/coordinate.d.ts +1 -4
- package/lib/spec/mark.d.ts +1 -3
- package/lib/theme/create.d.ts +1 -0
- package/lib/theme/create.js +1 -0
- package/lib/theme/create.js.map +1 -1
- package/lib/transform/filter.js +3 -1
- package/lib/transform/filter.js.map +1 -1
- package/lib/transform/maybeTitle.js +6 -1
- package/lib/transform/maybeTitle.js.map +1 -1
- package/lib/utils/dateFormat.d.ts +1 -0
- package/lib/utils/dateFormat.js +22 -0
- package/lib/utils/dateFormat.js.map +1 -0
- package/lib/utils/number.d.ts +4 -0
- package/lib/utils/number.js +10 -1
- package/lib/utils/number.js.map +1 -1
- package/package.json +10 -17
- 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/component/axis.ts +1 -5
- package/src/component/index.ts +0 -1
- package/src/component/legendContinuous.ts +1 -1
- package/src/coordinate/index.ts +0 -2
- package/src/exports.ts +18 -2
- package/src/index.ts +2 -2
- package/src/lib/index.ts +0 -2
- package/src/mark/index.ts +0 -4
- package/src/mark/liquid.ts +2 -1
- package/src/runtime/component.ts +1 -4
- package/src/runtime/types/component.ts +2 -9
- package/src/shape/index.ts +0 -4
- 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/spec/coordinate.ts +0 -5
- package/src/spec/mark.ts +0 -3
- package/src/theme/create.ts +1 -0
- package/src/transform/filter.ts +3 -1
- package/src/transform/maybeTitle.ts +8 -1
- package/src/utils/dateFormat.ts +22 -0
- package/src/utils/number.ts +8 -0
- package/CHANGELOG.md +0 -417
- package/esm/component/axisZ.d.ts +0 -8
- package/esm/component/axisZ.js +0 -14
- package/esm/component/axisZ.js.map +0 -1
- package/esm/coordinate/cartesian3D.d.ts +0 -7
- package/esm/coordinate/cartesian3D.js +0 -6
- package/esm/coordinate/cartesian3D.js.map +0 -1
- 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/lib/threed.d.ts +0 -7
- package/esm/lib/threed.js +0 -13
- package/esm/lib/threed.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/esm/mark/interval3D.d.ts +0 -8
- package/esm/mark/interval3D.js +0 -65
- package/esm/mark/interval3D.js.map +0 -1
- package/esm/mark/line3D.d.ts +0 -7
- package/esm/mark/line3D.js +0 -65
- package/esm/mark/line3D.js.map +0 -1
- package/esm/mark/point3D.d.ts +0 -9
- package/esm/mark/point3D.js +0 -76
- package/esm/mark/point3D.js.map +0 -1
- package/esm/shape/interval3D/cube.d.ts +0 -6
- package/esm/shape/interval3D/cube.js +0 -71
- package/esm/shape/interval3D/cube.js.map +0 -1
- package/esm/shape/line3D/line.d.ts +0 -3
- package/esm/shape/line3D/line.js +0 -30
- package/esm/shape/line3D/line.js.map +0 -1
- package/esm/shape/point3D/cube.d.ts +0 -6
- package/esm/shape/point3D/cube.js +0 -70
- package/esm/shape/point3D/cube.js.map +0 -1
- package/esm/shape/point3D/sphere.d.ts +0 -6
- package/esm/shape/point3D/sphere.js +0 -70
- package/esm/shape/point3D/sphere.js.map +0 -1
- package/lib/component/axisZ.d.ts +0 -8
- package/lib/component/axisZ.js +0 -19
- package/lib/component/axisZ.js.map +0 -1
- package/lib/coordinate/cartesian3D.d.ts +0 -7
- package/lib/coordinate/cartesian3D.js +0 -10
- package/lib/coordinate/cartesian3D.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/lib/threed.d.ts +0 -7
- package/lib/lib/threed.js +0 -17
- package/lib/lib/threed.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/lib/mark/interval3D.d.ts +0 -8
- package/lib/mark/interval3D.js +0 -69
- package/lib/mark/interval3D.js.map +0 -1
- package/lib/mark/line3D.d.ts +0 -7
- package/lib/mark/line3D.js +0 -69
- package/lib/mark/line3D.js.map +0 -1
- package/lib/mark/point3D.d.ts +0 -9
- package/lib/mark/point3D.js +0 -80
- package/lib/mark/point3D.js.map +0 -1
- package/lib/shape/interval3D/cube.d.ts +0 -6
- package/lib/shape/interval3D/cube.js +0 -75
- package/lib/shape/interval3D/cube.js.map +0 -1
- package/lib/shape/line3D/line.d.ts +0 -3
- package/lib/shape/line3D/line.js +0 -34
- package/lib/shape/line3D/line.js.map +0 -1
- package/lib/shape/point3D/cube.d.ts +0 -6
- package/lib/shape/point3D/cube.js +0 -74
- package/lib/shape/point3D/cube.js.map +0 -1
- package/lib/shape/point3D/sphere.d.ts +0 -6
- package/lib/shape/point3D/sphere.js +0 -74
- package/lib/shape/point3D/sphere.js.map +0 -1
- package/src/component/axisZ.ts +0 -25
- package/src/coordinate/cartesian3D.ts +0 -11
- package/src/lib/auto.ts +0 -7
- package/src/lib/threed.ts +0 -13
- package/src/mark/auto.ts +0 -22
- package/src/mark/interval3D.ts +0 -100
- package/src/mark/line3D.ts +0 -81
- package/src/mark/point3D.ts +0 -90
- package/src/shape/interval3D/cube.ts +0 -69
- package/src/shape/line3D/line.ts +0 -29
- package/src/shape/point3D/cube.ts +0 -68
- package/src/shape/point3D/sphere.ts +0 -68
package/src/component/axisZ.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
-
import { LinearAxis, AxisOptions, rotateAxis } from './axis';
|
|
3
|
-
|
|
4
|
-
export type AxisXOptions = AxisOptions;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* LinearAxis component bind to z scale.
|
|
8
|
-
*/
|
|
9
|
-
export const AxisZ: GCC<AxisXOptions> = (options) => {
|
|
10
|
-
return (...args) => {
|
|
11
|
-
const axisZ = LinearAxis(Object.assign({}, { crossPadding: 10 }, options))(
|
|
12
|
-
...args,
|
|
13
|
-
);
|
|
14
|
-
rotateAxis(axisZ, options);
|
|
15
|
-
return axisZ;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
AxisZ.props = {
|
|
20
|
-
...LinearAxis.props,
|
|
21
|
-
defaultPosition: 'bottom',
|
|
22
|
-
defaultPlane: 'yz',
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export function axisZConfig() {}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Coordinate3DComponent as CC } from '../runtime';
|
|
2
|
-
import { Cartesian3DCoordinate } from '../spec';
|
|
3
|
-
|
|
4
|
-
export type Cartesian3DOptions = Cartesian3DCoordinate;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Default coordinate3D transformation for all charts.
|
|
8
|
-
*/
|
|
9
|
-
export const Cartesian3D: CC<Cartesian3DCoordinate> = () => [['cartesian3D']];
|
|
10
|
-
|
|
11
|
-
Cartesian3D.props = {};
|
package/src/lib/auto.ts
DELETED
package/src/lib/threed.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Cartesian3D } from '../coordinate';
|
|
2
|
-
import { AxisZ } from '../component';
|
|
3
|
-
import { Point3D, Line3D, Interval3D } from '../mark';
|
|
4
|
-
|
|
5
|
-
export function threedlib() {
|
|
6
|
-
return {
|
|
7
|
-
'coordinate.cartesian3D': Cartesian3D,
|
|
8
|
-
'component.axisZ': AxisZ,
|
|
9
|
-
'mark.point3D': Point3D,
|
|
10
|
-
'mark.line3D': Line3D,
|
|
11
|
-
'mark.interval3D': Interval3D,
|
|
12
|
-
} as const;
|
|
13
|
-
}
|
package/src/mark/auto.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { Advisor } from '@antv/ava';
|
|
2
|
-
import { deepMix } from '@antv/util';
|
|
3
|
-
|
|
4
|
-
export const Auto = (options) => {
|
|
5
|
-
const chartAdvisor = new Advisor();
|
|
6
|
-
const {
|
|
7
|
-
data,
|
|
8
|
-
dataProps,
|
|
9
|
-
fields,
|
|
10
|
-
options: o,
|
|
11
|
-
colorOptions,
|
|
12
|
-
...rest
|
|
13
|
-
} = options;
|
|
14
|
-
const results = chartAdvisor.advise({
|
|
15
|
-
data,
|
|
16
|
-
dataProps,
|
|
17
|
-
fields,
|
|
18
|
-
options: o,
|
|
19
|
-
colorOptions,
|
|
20
|
-
});
|
|
21
|
-
return deepMix({}, rest, results?.[0].spec);
|
|
22
|
-
};
|
package/src/mark/interval3D.ts
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
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/mark/line3D.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { group } from 'd3-array';
|
|
2
|
-
import { Mark, MarkComponent as MC, SingleMark, Vector3 } from '../runtime';
|
|
3
|
-
import { LineMark } from '../spec';
|
|
4
|
-
import { Line3DShape } from '../shape';
|
|
5
|
-
import { MaybeSeries } from '../transform';
|
|
6
|
-
import {
|
|
7
|
-
baseGeometryChannels,
|
|
8
|
-
basePostInference,
|
|
9
|
-
basePreInference,
|
|
10
|
-
tooltip3d,
|
|
11
|
-
} from './utils';
|
|
12
|
-
|
|
13
|
-
const shape = {
|
|
14
|
-
line: Line3DShape,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type LineOptions = Omit<LineMark, 'type'>;
|
|
18
|
-
|
|
19
|
-
const line: Mark = (index, scale, value, coordinate) => {
|
|
20
|
-
const { series: S, x: X, y: Y, z: Z } = value;
|
|
21
|
-
const { x, y, z } = scale;
|
|
22
|
-
|
|
23
|
-
// Because x and y channel is not strictly required in Line.props,
|
|
24
|
-
// it should throw error with empty x, y or z channels.
|
|
25
|
-
if (X === undefined || Y === undefined || Z === undefined) {
|
|
26
|
-
throw new Error('Missing encode for x, y or z channel.');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Group data into series.
|
|
30
|
-
// There is only one series without specified series encode.
|
|
31
|
-
const series = S ? Array.from(group(index, (i) => S[i]).values()) : [index];
|
|
32
|
-
const I = series.map((group) => group[0]).filter((i) => i !== undefined);
|
|
33
|
-
|
|
34
|
-
// A group of data corresponds to one line.
|
|
35
|
-
const xoffset = (x?.getBandWidth?.() || 0) / 2;
|
|
36
|
-
const yoffset = (y?.getBandWidth?.() || 0) / 2;
|
|
37
|
-
const zoffset = (z?.getBandWidth?.() || 0) / 2;
|
|
38
|
-
const P = Array.from(series, (I) => {
|
|
39
|
-
return I.map((i) =>
|
|
40
|
-
coordinate.map([
|
|
41
|
-
(+X[i] || 0) + xoffset,
|
|
42
|
-
(+Y[i] || 0) + yoffset,
|
|
43
|
-
(+Z[i] || 0) + zoffset,
|
|
44
|
-
]),
|
|
45
|
-
) as Vector3[];
|
|
46
|
-
});
|
|
47
|
-
return [I, P, series];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Convert value for each channel to line shapes.
|
|
52
|
-
*/
|
|
53
|
-
export const Line3D: MC<LineOptions> = () => {
|
|
54
|
-
return (index, scale, value, coordinate) => {
|
|
55
|
-
const mark = line;
|
|
56
|
-
return (mark as SingleMark)(index, scale, value, coordinate);
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
Line3D.props = {
|
|
61
|
-
defaultShape: 'line',
|
|
62
|
-
defaultLabelShape: 'label',
|
|
63
|
-
composite: false,
|
|
64
|
-
shape,
|
|
65
|
-
channels: [
|
|
66
|
-
...baseGeometryChannels({ shapes: Object.keys(shape) }),
|
|
67
|
-
{ name: 'x' },
|
|
68
|
-
{ name: 'y' },
|
|
69
|
-
{ name: 'z' },
|
|
70
|
-
{ name: 'position', independent: true },
|
|
71
|
-
{ name: 'size' },
|
|
72
|
-
{ name: 'series', scale: 'identity' },
|
|
73
|
-
],
|
|
74
|
-
preInference: [...basePreInference(), { type: MaybeSeries }],
|
|
75
|
-
postInference: [...basePostInference(), ...tooltip3d()],
|
|
76
|
-
interaction: {
|
|
77
|
-
shareTooltip: false,
|
|
78
|
-
seriesTooltip: false,
|
|
79
|
-
crosshairs: false,
|
|
80
|
-
},
|
|
81
|
-
};
|
package/src/mark/point3D.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Coordinate3D } from '@antv/coord';
|
|
2
|
-
import { MarkComponent as MC, Vector3 } from '../runtime';
|
|
3
|
-
import { PointMark } from '../spec';
|
|
4
|
-
import { MaybeZeroX, MaybeZeroY, MaybeZeroZ, MaybeSize } from '../transform';
|
|
5
|
-
import { Sphere, Cube } from '../shape';
|
|
6
|
-
import {
|
|
7
|
-
baseGeometryChannels,
|
|
8
|
-
basePostInference,
|
|
9
|
-
basePreInference,
|
|
10
|
-
tooltip3d,
|
|
11
|
-
} from './utils';
|
|
12
|
-
|
|
13
|
-
export type PointOptions = Omit<PointMark, 'type'>;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Convert value for each channel to point shapes.
|
|
17
|
-
* Calc the bbox of each point based on x, y and r.
|
|
18
|
-
* This is for allowing their radius can be affected by coordinate(e.g. fisheye).
|
|
19
|
-
*/
|
|
20
|
-
export const Point3D: MC<PointOptions> = (options) => {
|
|
21
|
-
return (index, _, value, coordinate) => {
|
|
22
|
-
const { x: X, y: Y, z: Z, size: S, dx: DX, dy: DY, dz: DZ } = value;
|
|
23
|
-
const [width, height, depth] = (
|
|
24
|
-
coordinate as unknown as Coordinate3D
|
|
25
|
-
).getSize();
|
|
26
|
-
const xyz: (i: number) => Vector3 = (i) => {
|
|
27
|
-
const dx = +(DX?.[i] || 0);
|
|
28
|
-
const dy = +(DY?.[i] || 0);
|
|
29
|
-
const dz = +(DZ?.[i] || 0);
|
|
30
|
-
const x = +X[i];
|
|
31
|
-
const y = +Y[i];
|
|
32
|
-
const z = +Z[i];
|
|
33
|
-
const cx = x + dx;
|
|
34
|
-
const cy = y + dy;
|
|
35
|
-
const cz = z + dz;
|
|
36
|
-
return [cx, cy, cz];
|
|
37
|
-
};
|
|
38
|
-
const P = S
|
|
39
|
-
? Array.from(index, (i) => {
|
|
40
|
-
const [cx, cy, cz] = xyz(i);
|
|
41
|
-
const r = +S[i];
|
|
42
|
-
const a = r / width;
|
|
43
|
-
const b = r / height;
|
|
44
|
-
const c = r / depth;
|
|
45
|
-
const p1: Vector3 = [cx - a, cy - b, cz - c];
|
|
46
|
-
const p2: Vector3 = [cx + a, cy + b, cz + c];
|
|
47
|
-
return [
|
|
48
|
-
(coordinate as unknown as Coordinate3D).map([...p1, cz]),
|
|
49
|
-
(coordinate as unknown as Coordinate3D).map([...p2, cz]),
|
|
50
|
-
] as Vector3[];
|
|
51
|
-
})
|
|
52
|
-
: Array.from(index, (i) => {
|
|
53
|
-
const [cx, cy, cz] = xyz(i);
|
|
54
|
-
return [
|
|
55
|
-
(coordinate as unknown as Coordinate3D).map([cx, cy, cz]),
|
|
56
|
-
] as Vector3[];
|
|
57
|
-
});
|
|
58
|
-
return [index, P];
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const shape = {
|
|
63
|
-
sphere: Sphere,
|
|
64
|
-
cube: Cube,
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
Point3D.props = {
|
|
68
|
-
defaultShape: 'cube',
|
|
69
|
-
defaultLabelShape: 'label',
|
|
70
|
-
composite: false,
|
|
71
|
-
shape,
|
|
72
|
-
channels: [
|
|
73
|
-
...baseGeometryChannels({ shapes: Object.keys(shape) }),
|
|
74
|
-
{ name: 'x', required: true },
|
|
75
|
-
{ name: 'y', required: true },
|
|
76
|
-
{ name: 'z', required: true },
|
|
77
|
-
{ name: 'series', scale: 'band' },
|
|
78
|
-
{ name: 'size', quantitative: 'sqrt' },
|
|
79
|
-
{ name: 'dx', scale: 'identity' },
|
|
80
|
-
{ name: 'dy', scale: 'identity' },
|
|
81
|
-
{ name: 'dz', scale: 'identity' },
|
|
82
|
-
],
|
|
83
|
-
preInference: [
|
|
84
|
-
...basePreInference(),
|
|
85
|
-
{ type: MaybeZeroX },
|
|
86
|
-
{ type: MaybeZeroY },
|
|
87
|
-
{ type: MaybeZeroZ },
|
|
88
|
-
],
|
|
89
|
-
postInference: [...basePostInference(), { type: MaybeSize }, ...tooltip3d()],
|
|
90
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
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/shape/line3D/line.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Polyline } from '@antv/g';
|
|
2
|
-
import { applyStyle } from '../utils';
|
|
3
|
-
import { ShapeComponent as SC } from '../../runtime';
|
|
4
|
-
import { select } from '../../utils/selection';
|
|
5
|
-
|
|
6
|
-
export type LineOptions = Record<string, any>;
|
|
7
|
-
|
|
8
|
-
export const Line: SC<LineOptions> = (options, context) => {
|
|
9
|
-
return (P, value, defaults) => {
|
|
10
|
-
const { color: defaultColor, lineWidth: defaultSize, ...rest } = defaults;
|
|
11
|
-
const { color = defaultColor, size = defaultSize } = value;
|
|
12
|
-
const stroke = color;
|
|
13
|
-
const finalStyle = {
|
|
14
|
-
isBillboard: true,
|
|
15
|
-
...rest,
|
|
16
|
-
...(stroke && { stroke }),
|
|
17
|
-
...(size && { lineWidth: size }),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return select(new Polyline())
|
|
21
|
-
.style('points', P)
|
|
22
|
-
.call(applyStyle, finalStyle)
|
|
23
|
-
.node();
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
Line.props = {
|
|
28
|
-
defaultMarker: 'line',
|
|
29
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { MeshLambertMaterial, CubeGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
|
-
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
|
-
import { ShapeComponent as SC } from '../../runtime';
|
|
4
|
-
import { select } from '../../utils/selection';
|
|
5
|
-
|
|
6
|
-
const GEOMETRY_SIZE = 5;
|
|
7
|
-
|
|
8
|
-
export type CubeOptions = Record<string, any>;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @see https://g.antv.antgroup.com/api/3d/geometry#cubegeometry
|
|
12
|
-
*/
|
|
13
|
-
export const Cube: SC<CubeOptions> = (options, context) => {
|
|
14
|
-
// Render border only when colorAttribute is stroke.
|
|
15
|
-
const { ...style } = options;
|
|
16
|
-
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
if (!context.cubeGeometry) {
|
|
19
|
-
const renderer = context.canvas.getConfig().renderer;
|
|
20
|
-
const plugin = renderer.getPlugin('device-renderer');
|
|
21
|
-
const device = plugin.getDevice();
|
|
22
|
-
// create a sphere geometry
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
context.cubeGeometry = new CubeGeometry(device, {
|
|
25
|
-
width: GEOMETRY_SIZE * 2,
|
|
26
|
-
height: GEOMETRY_SIZE * 2,
|
|
27
|
-
depth: GEOMETRY_SIZE * 2,
|
|
28
|
-
});
|
|
29
|
-
// create a material with Phong lighting model
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
context.cubeMaterial = new MeshLambertMaterial(device);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (points, value, defaults) => {
|
|
35
|
-
const { color: defaultColor } = defaults;
|
|
36
|
-
const { color = defaultColor, transform, opacity } = value;
|
|
37
|
-
const [cx, cy, cz] = getOrigin(points);
|
|
38
|
-
const r = value.size;
|
|
39
|
-
const finalRadius = r || style.r || defaults.r;
|
|
40
|
-
|
|
41
|
-
const cube = new Mesh({
|
|
42
|
-
style: {
|
|
43
|
-
x: cx,
|
|
44
|
-
y: cy,
|
|
45
|
-
z: cz,
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
geometry: context.cubeGeometry,
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
material: context.cubeMaterial,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
cube.setOrigin(0, 0, 0);
|
|
53
|
-
const scaling = finalRadius / GEOMETRY_SIZE;
|
|
54
|
-
cube.scale(scaling);
|
|
55
|
-
|
|
56
|
-
return 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
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Cube.props = {
|
|
67
|
-
defaultMarker: 'cube',
|
|
68
|
-
};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { MeshLambertMaterial, SphereGeometry, Mesh } from '@antv/g-plugin-3d';
|
|
2
|
-
import { applyStyle, getOrigin, toOpacityKey } from '../utils';
|
|
3
|
-
import { ShapeComponent as SC } from '../../runtime';
|
|
4
|
-
import { select } from '../../utils/selection';
|
|
5
|
-
|
|
6
|
-
export type SphereOptions = Record<string, any>;
|
|
7
|
-
|
|
8
|
-
const GEOMETRY_SIZE = 5;
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* @see https://g.antv.antgroup.com/api/3d/geometry#spheregeometry
|
|
12
|
-
*/
|
|
13
|
-
export const Sphere: SC<SphereOptions> = (options, context) => {
|
|
14
|
-
// Render border only when colorAttribute is stroke.
|
|
15
|
-
const { ...style } = options;
|
|
16
|
-
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
if (!context.sphereGeometry) {
|
|
19
|
-
const renderer = context.canvas.getConfig().renderer;
|
|
20
|
-
const plugin = renderer.getPlugin('device-renderer');
|
|
21
|
-
const device = plugin.getDevice();
|
|
22
|
-
// create a sphere geometry
|
|
23
|
-
// @ts-ignore
|
|
24
|
-
context.sphereGeometry = new SphereGeometry(device, {
|
|
25
|
-
radius: GEOMETRY_SIZE,
|
|
26
|
-
latitudeBands: 32,
|
|
27
|
-
longitudeBands: 32,
|
|
28
|
-
});
|
|
29
|
-
// create a material with Phong lighting model
|
|
30
|
-
// @ts-ignore
|
|
31
|
-
context.sphereMaterial = new MeshLambertMaterial(device);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return (points, value, defaults) => {
|
|
35
|
-
const { color: defaultColor } = defaults;
|
|
36
|
-
const { color = defaultColor, transform, opacity } = value;
|
|
37
|
-
const [cx, cy, cz] = getOrigin(points);
|
|
38
|
-
const r = value.size;
|
|
39
|
-
const finalRadius = r || style.r || defaults.r;
|
|
40
|
-
|
|
41
|
-
const sphere = new Mesh({
|
|
42
|
-
style: {
|
|
43
|
-
x: cx,
|
|
44
|
-
y: cy,
|
|
45
|
-
z: cz,
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
geometry: context.sphereGeometry,
|
|
48
|
-
// @ts-ignore
|
|
49
|
-
material: context.sphereMaterial,
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
sphere.setOrigin(0, 0, 0);
|
|
53
|
-
const scaling = finalRadius / GEOMETRY_SIZE;
|
|
54
|
-
sphere.scale(scaling);
|
|
55
|
-
|
|
56
|
-
return select(sphere)
|
|
57
|
-
.call(applyStyle, defaults)
|
|
58
|
-
.style('fill', color)
|
|
59
|
-
.style('transform', transform)
|
|
60
|
-
.style(toOpacityKey(options), opacity)
|
|
61
|
-
.call(applyStyle, style)
|
|
62
|
-
.node();
|
|
63
|
-
};
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
Sphere.props = {
|
|
67
|
-
defaultMarker: 'sphere',
|
|
68
|
-
};
|