@antv/g2 5.0.20 → 5.0.22
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 +32 -34
- package/README.zh-CN.md +99 -0
- package/dist/g2-lite.min.js +4 -4
- package/dist/g2.min.js +4 -4
- package/esm/api/runtime.js +2 -2
- package/esm/api/runtime.js.map +1 -1
- package/esm/api/utils.d.ts +5 -0
- package/esm/api/utils.js +3 -2
- package/esm/api/utils.js.map +1 -1
- package/esm/component/axis.d.ts +11 -1
- package/esm/component/axis.js +46 -11
- package/esm/component/axis.js.map +1 -1
- package/esm/component/axisX.js +7 -4
- package/esm/component/axisX.js.map +1 -1
- package/esm/component/axisY.js +6 -2
- package/esm/component/axisY.js.map +1 -1
- package/esm/component/axisZ.d.ts +8 -0
- package/esm/component/axisZ.js +14 -0
- package/esm/component/axisZ.js.map +1 -0
- package/esm/component/index.d.ts +1 -0
- package/esm/component/index.js +1 -0
- package/esm/component/index.js.map +1 -1
- package/esm/component/scrollbar.d.ts +2 -1
- package/esm/component/scrollbar.js +1 -1
- package/esm/component/scrollbar.js.map +1 -1
- package/esm/composition/mark.js +3 -1
- package/esm/composition/mark.js.map +1 -1
- package/esm/coordinate/cartesian3D.d.ts +7 -0
- package/esm/coordinate/cartesian3D.js +6 -0
- package/esm/coordinate/cartesian3D.js.map +1 -0
- package/esm/coordinate/index.d.ts +2 -0
- package/esm/coordinate/index.js +1 -0
- package/esm/coordinate/index.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interaction/event.js +20 -9
- package/esm/interaction/event.js.map +1 -1
- package/esm/lib/index.d.ts +1 -0
- package/esm/lib/index.js +1 -0
- package/esm/lib/index.js.map +1 -1
- package/esm/lib/threed.d.ts +5 -0
- package/esm/lib/threed.js +11 -0
- package/esm/lib/threed.js.map +1 -0
- 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/point3D.d.ts +9 -0
- package/esm/mark/point3D.js +76 -0
- package/esm/mark/point3D.js.map +1 -0
- package/esm/mark/utils.d.ts +7 -0
- package/esm/mark/utils.js +6 -0
- package/esm/mark/utils.js.map +1 -1
- package/esm/runtime/component.js +6 -3
- package/esm/runtime/component.js.map +1 -1
- package/esm/runtime/coordinate.js +9 -4
- package/esm/runtime/coordinate.js.map +1 -1
- package/esm/runtime/layout.d.ts +1 -0
- package/esm/runtime/layout.js +109 -29
- package/esm/runtime/layout.js.map +1 -1
- package/esm/runtime/plot.js +5 -3
- package/esm/runtime/plot.js.map +1 -1
- package/esm/runtime/render.js +12 -3
- package/esm/runtime/render.js.map +1 -1
- package/esm/runtime/types/common.d.ts +4 -0
- package/esm/runtime/types/component.d.ts +8 -2
- package/esm/runtime/types/options.d.ts +5 -1
- package/esm/shape/index.d.ts +2 -0
- package/esm/shape/index.js +2 -0
- package/esm/shape/index.js.map +1 -1
- package/esm/shape/point3D/cube.d.ts +6 -0
- package/esm/shape/point3D/cube.js +70 -0
- package/esm/shape/point3D/cube.js.map +1 -0
- package/esm/shape/point3D/sphere.d.ts +6 -0
- package/esm/shape/point3D/sphere.js +70 -0
- package/esm/shape/point3D/sphere.js.map +1 -0
- package/esm/shape/shape/shape.js +2 -2
- package/esm/shape/shape/shape.js.map +1 -1
- package/esm/shape/utils.d.ts +2 -2
- package/esm/shape/utils.js +2 -2
- package/esm/shape/utils.js.map +1 -1
- package/esm/spec/component.d.ts +1 -1
- package/esm/spec/composition.d.ts +2 -0
- package/esm/spec/coordinate.d.ts +5 -2
- package/esm/spec/index.d.ts +1 -0
- package/esm/spec/index.js.map +1 -1
- package/esm/spec/mark.d.ts +2 -2
- package/esm/transform/index.d.ts +1 -0
- package/esm/transform/index.js +1 -0
- package/esm/transform/index.js.map +1 -1
- package/esm/transform/maybeZeroZ.d.ts +6 -0
- package/esm/transform/maybeZeroZ.js +22 -0
- package/esm/transform/maybeZeroZ.js.map +1 -0
- package/esm/utils/size.d.ts +1 -0
- package/esm/utils/size.js +1 -0
- package/esm/utils/size.js.map +1 -1
- package/lib/api/runtime.js +2 -2
- package/lib/api/runtime.js.map +1 -1
- package/lib/api/utils.d.ts +5 -0
- package/lib/api/utils.js +3 -2
- package/lib/api/utils.js.map +1 -1
- package/lib/component/axis.d.ts +11 -1
- package/lib/component/axis.js +48 -12
- package/lib/component/axis.js.map +1 -1
- package/lib/component/axisX.js +6 -3
- package/lib/component/axisX.js.map +1 -1
- package/lib/component/axisY.js +5 -1
- package/lib/component/axisY.js.map +1 -1
- package/lib/component/axisZ.d.ts +8 -0
- package/lib/component/axisZ.js +19 -0
- package/lib/component/axisZ.js.map +1 -0
- package/lib/component/index.d.ts +1 -0
- package/lib/component/index.js +3 -1
- package/lib/component/index.js.map +1 -1
- package/lib/component/scrollbar.d.ts +2 -1
- package/lib/component/scrollbar.js +1 -1
- package/lib/component/scrollbar.js.map +1 -1
- package/lib/composition/mark.js +3 -1
- package/lib/composition/mark.js.map +1 -1
- package/lib/coordinate/cartesian3D.d.ts +7 -0
- package/lib/coordinate/cartesian3D.js +10 -0
- package/lib/coordinate/cartesian3D.js.map +1 -0
- package/lib/coordinate/index.d.ts +2 -0
- package/lib/coordinate/index.js +3 -1
- package/lib/coordinate/index.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/event.js +20 -9
- package/lib/interaction/event.js.map +1 -1
- package/lib/lib/index.d.ts +1 -0
- package/lib/lib/index.js +3 -1
- package/lib/lib/index.js.map +1 -1
- package/lib/lib/threed.d.ts +5 -0
- package/lib/lib/threed.js +15 -0
- package/lib/lib/threed.js.map +1 -0
- 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/point3D.d.ts +9 -0
- package/lib/mark/point3D.js +80 -0
- package/lib/mark/point3D.js.map +1 -0
- package/lib/mark/utils.d.ts +7 -0
- package/lib/mark/utils.js +8 -1
- package/lib/mark/utils.js.map +1 -1
- package/lib/runtime/component.js +6 -3
- package/lib/runtime/component.js.map +1 -1
- package/lib/runtime/coordinate.js +8 -3
- package/lib/runtime/coordinate.js.map +1 -1
- package/lib/runtime/layout.d.ts +1 -0
- package/lib/runtime/layout.js +112 -31
- package/lib/runtime/layout.js.map +1 -1
- package/lib/runtime/plot.js +4 -2
- package/lib/runtime/plot.js.map +1 -1
- package/lib/runtime/render.js +12 -3
- package/lib/runtime/render.js.map +1 -1
- package/lib/runtime/types/common.d.ts +4 -0
- package/lib/runtime/types/component.d.ts +8 -2
- package/lib/runtime/types/options.d.ts +5 -1
- package/lib/shape/index.d.ts +2 -0
- package/lib/shape/index.js +6 -2
- package/lib/shape/index.js.map +1 -1
- package/lib/shape/point3D/cube.d.ts +6 -0
- package/lib/shape/point3D/cube.js +74 -0
- package/lib/shape/point3D/cube.js.map +1 -0
- package/lib/shape/point3D/sphere.d.ts +6 -0
- package/lib/shape/point3D/sphere.js +74 -0
- package/lib/shape/point3D/sphere.js.map +1 -0
- package/lib/shape/shape/shape.js +2 -2
- package/lib/shape/shape/shape.js.map +1 -1
- package/lib/shape/utils.d.ts +2 -2
- package/lib/shape/utils.js +2 -2
- package/lib/shape/utils.js.map +1 -1
- package/lib/spec/component.d.ts +1 -1
- package/lib/spec/composition.d.ts +2 -0
- package/lib/spec/coordinate.d.ts +5 -2
- package/lib/spec/index.d.ts +1 -0
- package/lib/spec/index.js.map +1 -1
- package/lib/spec/mark.d.ts +2 -2
- package/lib/transform/index.d.ts +1 -0
- package/lib/transform/index.js +3 -1
- package/lib/transform/index.js.map +1 -1
- package/lib/transform/maybeZeroZ.d.ts +6 -0
- package/lib/transform/maybeZeroZ.js +26 -0
- package/lib/transform/maybeZeroZ.js.map +1 -0
- package/lib/utils/size.d.ts +1 -0
- package/lib/utils/size.js +1 -0
- package/lib/utils/size.js.map +1 -1
- package/package.json +11 -3
- package/src/api/runtime.ts +2 -2
- package/src/api/utils.ts +3 -2
- package/src/component/axis.ts +65 -9
- package/src/component/axisX.ts +8 -3
- package/src/component/axisY.ts +8 -3
- package/src/component/axisZ.ts +25 -0
- package/src/component/index.ts +1 -0
- package/src/component/scrollbar.ts +3 -2
- package/src/composition/mark.ts +4 -0
- package/src/coordinate/cartesian3D.ts +11 -0
- package/src/coordinate/index.ts +2 -0
- package/src/index.ts +1 -1
- package/src/interaction/event.ts +22 -9
- package/src/lib/index.ts +1 -0
- package/src/lib/threed.ts +11 -0
- package/src/mark/index.ts +1 -0
- package/src/mark/point3D.ts +90 -0
- package/src/mark/utils.ts +7 -0
- package/src/runtime/component.ts +6 -0
- package/src/runtime/coordinate.ts +18 -10
- package/src/runtime/layout.ts +178 -33
- package/src/runtime/plot.ts +11 -3
- package/src/runtime/render.ts +14 -3
- package/src/runtime/types/common.ts +4 -0
- package/src/runtime/types/component.ts +10 -1
- package/src/runtime/types/options.ts +5 -0
- package/src/shape/index.ts +2 -0
- package/src/shape/point3D/cube.ts +68 -0
- package/src/shape/point3D/sphere.ts +68 -0
- package/src/shape/shape/shape.ts +9 -6
- package/src/shape/utils.ts +4 -4
- package/src/spec/component.ts +1 -1
- package/src/spec/composition.ts +2 -0
- package/src/spec/coordinate.ts +6 -0
- package/src/spec/index.ts +1 -0
- package/src/spec/mark.ts +7 -1
- package/src/transform/index.ts +1 -0
- package/src/transform/maybeZeroZ.ts +25 -0
- package/src/utils/size.ts +2 -0
- package/README.en-US.md +0 -99
package/src/api/utils.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { Node } from './node';
|
|
|
8
8
|
export const VIEW_KEYS = [
|
|
9
9
|
'width',
|
|
10
10
|
'height',
|
|
11
|
+
'depth',
|
|
11
12
|
'padding',
|
|
12
13
|
'paddingLeft',
|
|
13
14
|
'paddingRight',
|
|
@@ -63,8 +64,8 @@ export function valueOf(node: Node): Record<string, any> {
|
|
|
63
64
|
export function sizeOf(options, container) {
|
|
64
65
|
const { autoFit } = options;
|
|
65
66
|
if (autoFit) return getContainerSize(container);
|
|
66
|
-
const { width = 640, height = 480 } = options;
|
|
67
|
-
return { width, height };
|
|
67
|
+
const { width = 640, height = 480, depth = 0 } = options;
|
|
68
|
+
return { width, height, depth };
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
export function optionsOf(node: Node): Record<string, any> {
|
package/src/component/axis.ts
CHANGED
|
@@ -11,7 +11,9 @@ import {
|
|
|
11
11
|
GuideComponentComponent as GCC,
|
|
12
12
|
GuideComponentOrientation as GCO,
|
|
13
13
|
GuideComponentPosition as GCP,
|
|
14
|
+
GuideComponentPlane,
|
|
14
15
|
Scale,
|
|
16
|
+
Vector3,
|
|
15
17
|
} from '../runtime';
|
|
16
18
|
import {
|
|
17
19
|
angleOf,
|
|
@@ -24,11 +26,11 @@ import {
|
|
|
24
26
|
radiusOf,
|
|
25
27
|
} from '../utils/coordinate';
|
|
26
28
|
import { capitalizeFirst } from '../utils/helper';
|
|
27
|
-
import { isOrdinalScale } from '../utils/scale';
|
|
28
29
|
import { adaptor, isVertical, titleContent } from './utils';
|
|
29
30
|
|
|
30
31
|
export type AxisOptions = {
|
|
31
32
|
position?: GCP;
|
|
33
|
+
plane?: GuideComponentPlane;
|
|
32
34
|
zIndex?: number;
|
|
33
35
|
title?: string | string[];
|
|
34
36
|
direction?: 'left' | 'center' | 'right';
|
|
@@ -50,13 +52,31 @@ export type AxisOptions = {
|
|
|
50
52
|
grid: any;
|
|
51
53
|
// options won't be overridden
|
|
52
54
|
important: Record<string, any>;
|
|
55
|
+
/**
|
|
56
|
+
* Rotation origin.
|
|
57
|
+
*/
|
|
58
|
+
origin?: Vector3;
|
|
59
|
+
/**
|
|
60
|
+
* EulerAngles of rotation.
|
|
61
|
+
*/
|
|
62
|
+
eulerAngles?: Vector3;
|
|
53
63
|
[key: string]: any;
|
|
54
64
|
};
|
|
55
65
|
|
|
56
|
-
function
|
|
66
|
+
export function rotateAxis(axis: DisplayObject, options: AxisOptions) {
|
|
67
|
+
const { eulerAngles, origin } = options;
|
|
68
|
+
if (origin) {
|
|
69
|
+
axis.setOrigin(origin);
|
|
70
|
+
}
|
|
71
|
+
if (eulerAngles) {
|
|
72
|
+
axis.rotate(eulerAngles[0], eulerAngles[1], eulerAngles[2]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function sizeOf(coordinate: Coordinate): [number, number, number] {
|
|
57
77
|
// @ts-ignore
|
|
58
|
-
const { innerWidth, innerHeight } = coordinate.getOptions();
|
|
59
|
-
return [innerWidth, innerHeight];
|
|
78
|
+
const { innerWidth, innerHeight, depth } = coordinate.getOptions();
|
|
79
|
+
return [innerWidth, innerHeight, depth];
|
|
60
80
|
}
|
|
61
81
|
|
|
62
82
|
function createFisheye(position, coordinate) {
|
|
@@ -193,10 +213,23 @@ function getData(
|
|
|
193
213
|
});
|
|
194
214
|
}
|
|
195
215
|
|
|
196
|
-
function inferGridLength(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
216
|
+
function inferGridLength(
|
|
217
|
+
position: GCP,
|
|
218
|
+
coordinate: Coordinate,
|
|
219
|
+
plane: GuideComponentPlane = 'xy',
|
|
220
|
+
) {
|
|
221
|
+
const [width, height, depth] = sizeOf(coordinate);
|
|
222
|
+
|
|
223
|
+
if (plane === 'xy') {
|
|
224
|
+
if (position.includes('bottom') || position.includes('top')) return height;
|
|
225
|
+
return width;
|
|
226
|
+
} else if (plane === 'xz') {
|
|
227
|
+
if (position.includes('bottom') || position.includes('top')) return depth;
|
|
228
|
+
return width;
|
|
229
|
+
} else {
|
|
230
|
+
if (position.includes('bottom') || position.includes('top')) return height;
|
|
231
|
+
return depth;
|
|
232
|
+
}
|
|
200
233
|
}
|
|
201
234
|
|
|
202
235
|
function inferLabelOverlap(transform = [], style: Record<string, any>) {
|
|
@@ -280,6 +313,20 @@ function inferGrid(value: boolean, coordinate: Coordinate, scale: Scale) {
|
|
|
280
313
|
return value === undefined ? !!scale.getTicks : value;
|
|
281
314
|
}
|
|
282
315
|
|
|
316
|
+
function infer3DAxisLinearOverrideStyle(coordinate: Coordinate) {
|
|
317
|
+
// @ts-ignore
|
|
318
|
+
const { depth } = coordinate.getOptions();
|
|
319
|
+
return depth
|
|
320
|
+
? {
|
|
321
|
+
tickIsBillboard: true,
|
|
322
|
+
lineIsBillboard: true,
|
|
323
|
+
labelIsBillboard: true,
|
|
324
|
+
titleIsBillboard: true,
|
|
325
|
+
gridIsBillboard: true,
|
|
326
|
+
}
|
|
327
|
+
: {};
|
|
328
|
+
}
|
|
329
|
+
|
|
283
330
|
function inferAxisLinearOverrideStyle(
|
|
284
331
|
position: GCP,
|
|
285
332
|
orientation: GCO,
|
|
@@ -492,6 +539,7 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
492
539
|
labelFormatter,
|
|
493
540
|
order,
|
|
494
541
|
orientation,
|
|
542
|
+
actualPosition,
|
|
495
543
|
position,
|
|
496
544
|
size,
|
|
497
545
|
style = {},
|
|
@@ -523,7 +571,12 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
523
571
|
...userDefinitions,
|
|
524
572
|
};
|
|
525
573
|
|
|
526
|
-
const gridLength = inferGridLength(
|
|
574
|
+
const gridLength = inferGridLength(
|
|
575
|
+
actualPosition || position,
|
|
576
|
+
coordinate,
|
|
577
|
+
options.plane,
|
|
578
|
+
);
|
|
579
|
+
|
|
527
580
|
const overrideStyle = inferAxisLinearOverrideStyle(
|
|
528
581
|
position,
|
|
529
582
|
orientation,
|
|
@@ -531,6 +584,8 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
531
584
|
coordinate,
|
|
532
585
|
);
|
|
533
586
|
|
|
587
|
+
const threeDOverrideStyle = infer3DAxisLinearOverrideStyle(coordinate);
|
|
588
|
+
|
|
534
589
|
const data = getData(
|
|
535
590
|
scale,
|
|
536
591
|
domain,
|
|
@@ -568,6 +623,7 @@ const LinearAxisComponent: GCC<AxisOptions> = (options) => {
|
|
|
568
623
|
indexBBox,
|
|
569
624
|
...(!internalAxisStyle.line ? { lineOpacity: 0 } : null),
|
|
570
625
|
...overrideStyle,
|
|
626
|
+
...threeDOverrideStyle,
|
|
571
627
|
...important,
|
|
572
628
|
};
|
|
573
629
|
|
package/src/component/axisX.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
-
import { LinearAxis,
|
|
2
|
+
import { AxisOptions, LinearAxis, rotateAxis } from './axis';
|
|
3
3
|
|
|
4
4
|
export type AxisXOptions = AxisOptions;
|
|
5
5
|
|
|
@@ -7,9 +7,14 @@ export type AxisXOptions = AxisOptions;
|
|
|
7
7
|
* LinearAxis component bind to x scale.
|
|
8
8
|
*/
|
|
9
9
|
export const AxisX: GCC<AxisXOptions> = (options) => {
|
|
10
|
-
return (...args) =>
|
|
10
|
+
return (...args) => {
|
|
11
11
|
// empirical value for crossPadding
|
|
12
|
-
LinearAxis(Object.assign({}, { crossPadding: 50 }, options))(
|
|
12
|
+
const axisX = LinearAxis(Object.assign({}, { crossPadding: 50 }, options))(
|
|
13
|
+
...args,
|
|
14
|
+
);
|
|
15
|
+
rotateAxis(axisX, options);
|
|
16
|
+
return axisX;
|
|
17
|
+
};
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
AxisX.props = {
|
package/src/component/axisY.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
2
|
-
import { AxisOptions, LinearAxis } from './axis';
|
|
2
|
+
import { AxisOptions, LinearAxis, rotateAxis } from './axis';
|
|
3
3
|
|
|
4
4
|
export type AxisYOptions = AxisOptions;
|
|
5
5
|
|
|
@@ -7,8 +7,13 @@ export type AxisYOptions = AxisOptions;
|
|
|
7
7
|
* LinearAxis component bind to y scale.
|
|
8
8
|
*/
|
|
9
9
|
export const AxisY: GCC<AxisYOptions> = (options) => {
|
|
10
|
-
return (...args) =>
|
|
11
|
-
LinearAxis(Object.assign({}, { crossPadding: 10 }, options))(
|
|
10
|
+
return (...args) => {
|
|
11
|
+
const axisY = LinearAxis(Object.assign({}, { crossPadding: 10 }, options))(
|
|
12
|
+
...args,
|
|
13
|
+
);
|
|
14
|
+
rotateAxis(axisY, options);
|
|
15
|
+
return axisY;
|
|
16
|
+
};
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
AxisY.props = {
|
|
@@ -0,0 +1,25 @@
|
|
|
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() {}
|
package/src/component/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { LinearAxis as AxisLinear, ArcAxis as AxisArc } from './axis';
|
|
2
2
|
export { AxisX } from './axisX';
|
|
3
3
|
export { AxisY } from './axisY';
|
|
4
|
+
export { AxisZ } from './axisZ';
|
|
4
5
|
export { AxisRadar } from './axisRadar';
|
|
5
6
|
export { LegendCategory } from './legendCategory';
|
|
6
7
|
export { LegendContinuous } from './legendContinuous';
|
|
@@ -2,7 +2,8 @@ import { Scrollbar as ScrollbarComponent } from '@antv/gui';
|
|
|
2
2
|
import { GuideComponentComponent as GCC } from '../runtime';
|
|
3
3
|
|
|
4
4
|
export type ScrollbarOptions = {
|
|
5
|
-
orientation
|
|
5
|
+
orientation?: 'horizontal' | 'vertical';
|
|
6
|
+
ratio?: number;
|
|
6
7
|
[key: string]: any;
|
|
7
8
|
};
|
|
8
9
|
|
|
@@ -28,9 +29,9 @@ export const Scrollbar: GCC<ScrollbarOptions> = (options) => {
|
|
|
28
29
|
x,
|
|
29
30
|
y,
|
|
30
31
|
trackLength: mainSize,
|
|
32
|
+
value: value1,
|
|
31
33
|
...rest,
|
|
32
34
|
orientation,
|
|
33
|
-
value: value1,
|
|
34
35
|
contentLength: actualSize,
|
|
35
36
|
viewportLength: mainSize,
|
|
36
37
|
}),
|
package/src/composition/mark.ts
CHANGED
|
@@ -11,6 +11,7 @@ export const Mark: CC<MarkOptions> = ({
|
|
|
11
11
|
const {
|
|
12
12
|
width,
|
|
13
13
|
height,
|
|
14
|
+
depth,
|
|
14
15
|
paddingLeft,
|
|
15
16
|
paddingRight,
|
|
16
17
|
paddingTop,
|
|
@@ -33,6 +34,7 @@ export const Mark: CC<MarkOptions> = ({
|
|
|
33
34
|
interaction,
|
|
34
35
|
x,
|
|
35
36
|
y,
|
|
37
|
+
z,
|
|
36
38
|
key,
|
|
37
39
|
frame,
|
|
38
40
|
labelTransform,
|
|
@@ -48,9 +50,11 @@ export const Mark: CC<MarkOptions> = ({
|
|
|
48
50
|
type: 'standardView',
|
|
49
51
|
x,
|
|
50
52
|
y,
|
|
53
|
+
z,
|
|
51
54
|
key,
|
|
52
55
|
width,
|
|
53
56
|
height,
|
|
57
|
+
depth,
|
|
54
58
|
padding,
|
|
55
59
|
paddingLeft,
|
|
56
60
|
paddingRight,
|
|
@@ -0,0 +1,11 @@
|
|
|
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/coordinate/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Cartesian } from './cartesian';
|
|
2
|
+
export { Cartesian3D } from './cartesian3D';
|
|
2
3
|
export { Polar, getPolarOptions } from './polar';
|
|
3
4
|
export { Helix } from './helix';
|
|
4
5
|
export { Transpose } from './transpose';
|
|
@@ -9,6 +10,7 @@ export { Fisheye } from './fisheye';
|
|
|
9
10
|
export { Radar } from './radar';
|
|
10
11
|
|
|
11
12
|
export type { CartesianOptions } from './cartesian';
|
|
13
|
+
export type { Cartesian3DOptions } from './cartesian3D';
|
|
12
14
|
export type { PolarOptions } from './polar';
|
|
13
15
|
export type { HelixOptions } from './helix';
|
|
14
16
|
export type { TransposeOptions } from './transpose';
|
package/src/index.ts
CHANGED
package/src/interaction/event.ts
CHANGED
|
@@ -14,14 +14,23 @@ export function dataOf(element, view) {
|
|
|
14
14
|
return selectedMark.data[index];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (node.className === 'element') return node;
|
|
17
|
+
function maybeRoot(node, rootOf) {
|
|
18
|
+
if (rootOf(node)) return node;
|
|
20
19
|
let root = node.parent;
|
|
21
|
-
while (root && root
|
|
20
|
+
while (root && !rootOf(root)) root = root.parent;
|
|
22
21
|
return root;
|
|
23
22
|
}
|
|
24
23
|
|
|
24
|
+
// For extended component
|
|
25
|
+
function maybeComponentRoot(node) {
|
|
26
|
+
return maybeRoot(node, (node) => node.className === 'component');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// For extended shape.
|
|
30
|
+
function maybeElementRoot(node) {
|
|
31
|
+
return maybeRoot(node, (node) => node.className === 'element');
|
|
32
|
+
}
|
|
33
|
+
|
|
25
34
|
function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
|
|
26
35
|
return (e) => {
|
|
27
36
|
if (!predicate(e)) return;
|
|
@@ -41,19 +50,23 @@ function bubblesEvent(eventType, view, emitter, predicate = (event) => true) {
|
|
|
41
50
|
|
|
42
51
|
// If target is element or child of element.
|
|
43
52
|
const elementRoot = maybeElementRoot(target);
|
|
44
|
-
|
|
45
|
-
const
|
|
53
|
+
// If target is component or child of component.
|
|
54
|
+
const componentRoot = maybeComponentRoot(target);
|
|
55
|
+
const root = elementRoot || componentRoot;
|
|
56
|
+
if (!root) return;
|
|
57
|
+
const { className: elementType, markType } = root;
|
|
46
58
|
if (elementType === 'element') {
|
|
47
59
|
const e1 = {
|
|
48
60
|
...e,
|
|
49
61
|
nativeEvent: true,
|
|
50
|
-
data: { data: dataOf(
|
|
62
|
+
data: { data: dataOf(root, view) },
|
|
51
63
|
};
|
|
52
64
|
emitter.emit(`element:${eventType}`, e1);
|
|
53
65
|
emitter.emit(`${markType}:${eventType}`, e1);
|
|
54
66
|
} else {
|
|
55
|
-
|
|
56
|
-
emitter.emit(
|
|
67
|
+
const e1 = { ...e, nativeEvent: true };
|
|
68
|
+
emitter.emit(`component:${eventType}`, e1);
|
|
69
|
+
emitter.emit(`${className}:${eventType}`, e1);
|
|
57
70
|
}
|
|
58
71
|
};
|
|
59
72
|
}
|
package/src/lib/index.ts
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Cartesian3D } from '../coordinate';
|
|
2
|
+
import { AxisZ } from '../component';
|
|
3
|
+
import { Point3D } from '../mark';
|
|
4
|
+
|
|
5
|
+
export function threedlib() {
|
|
6
|
+
return {
|
|
7
|
+
'coordinate.cartesian3D': Cartesian3D,
|
|
8
|
+
'component.axisZ': AxisZ,
|
|
9
|
+
'mark.point3D': Point3D,
|
|
10
|
+
} as const;
|
|
11
|
+
}
|
package/src/mark/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export { Interval } from './interval';
|
|
|
2
2
|
export { Rect } from './rect';
|
|
3
3
|
export { Line } from './line';
|
|
4
4
|
export { Point } from './point';
|
|
5
|
+
export { Point3D } from './point3D';
|
|
5
6
|
export { Text } from './text';
|
|
6
7
|
export { Cell } from './cell';
|
|
7
8
|
export { Area } from './area';
|
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
};
|
package/src/mark/utils.ts
CHANGED
|
@@ -30,6 +30,13 @@ export function baseGeometryChannels(options: ChannelOptions = {}): Channel[] {
|
|
|
30
30
|
return [...baseChannels(options), { name: 'title', scale: 'identity' }];
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export function tooltip3d() {
|
|
34
|
+
return [
|
|
35
|
+
{ type: MaybeTitle, channel: 'color' },
|
|
36
|
+
{ type: MaybeTooltip, channel: ['x', 'y', 'z'] },
|
|
37
|
+
];
|
|
38
|
+
}
|
|
39
|
+
|
|
33
40
|
export function tooltip2d() {
|
|
34
41
|
return [
|
|
35
42
|
{ type: MaybeTitle, channel: 'color' },
|
package/src/runtime/component.ts
CHANGED
|
@@ -102,6 +102,7 @@ export function inferComponent(
|
|
|
102
102
|
const { props } = createGuideComponent(type);
|
|
103
103
|
const {
|
|
104
104
|
defaultPosition,
|
|
105
|
+
defaultPlane = 'xy',
|
|
105
106
|
defaultOrientation,
|
|
106
107
|
defaultSize,
|
|
107
108
|
defaultOrder,
|
|
@@ -148,6 +149,7 @@ export function inferComponent(
|
|
|
148
149
|
defaultSize,
|
|
149
150
|
length,
|
|
150
151
|
position,
|
|
152
|
+
plane: defaultPlane,
|
|
151
153
|
orientation,
|
|
152
154
|
padding,
|
|
153
155
|
order,
|
|
@@ -363,6 +365,10 @@ function inferAxisComponentType(
|
|
|
363
365
|
if (isRadial(coordinates)) return ['axisArc', [scale]];
|
|
364
366
|
return [isTranspose(coordinates) ? 'axisX' : 'axisY', [scale]];
|
|
365
367
|
}
|
|
368
|
+
// Only support linear axis for z.
|
|
369
|
+
if (name.startsWith('z')) {
|
|
370
|
+
return ['axisZ', [scale]];
|
|
371
|
+
}
|
|
366
372
|
if (name.startsWith('position')) {
|
|
367
373
|
if (isRadar(coordinates)) return ['axisRadar', [scale]];
|
|
368
374
|
if (!isPolar(coordinates)) return ['axisY', [scale]];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Coordinate } from '@antv/coord';
|
|
1
|
+
import { Coordinate, Coordinate3D } from '@antv/coord';
|
|
2
2
|
import { G2View, G2CoordinateOptions, G2Library } from './types/options';
|
|
3
3
|
import { CoordinateComponent, CoordinateTransform } from './types/component';
|
|
4
4
|
import { useLibrary } from './library';
|
|
@@ -21,22 +21,27 @@ export function createCoordinate(
|
|
|
21
21
|
insetTop,
|
|
22
22
|
insetRight,
|
|
23
23
|
insetBottom,
|
|
24
|
-
marginLeft,
|
|
25
|
-
marginTop,
|
|
26
24
|
} = layout;
|
|
27
25
|
const { coordinates: partialTransform = [] } = partialOptions;
|
|
28
26
|
const transform = inferCoordinate(partialTransform);
|
|
29
|
-
|
|
27
|
+
|
|
28
|
+
const isCartesian3D = transform[0].type === 'cartesian3D';
|
|
29
|
+
const options = {
|
|
30
30
|
// @todo Find a better solution.
|
|
31
31
|
// Store more layout information for component.
|
|
32
32
|
...layout,
|
|
33
|
-
x: insetLeft
|
|
34
|
-
y: insetTop
|
|
33
|
+
x: insetLeft,
|
|
34
|
+
y: insetTop,
|
|
35
35
|
width: innerWidth - insetLeft - insetRight,
|
|
36
36
|
height: innerHeight - insetBottom - insetTop,
|
|
37
|
-
transformations: transform.
|
|
38
|
-
}
|
|
39
|
-
|
|
37
|
+
transformations: transform.flatMap(useCoordinate),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const coordinate = isCartesian3D
|
|
41
|
+
? // @ts-ignore
|
|
42
|
+
new Coordinate3D(options)
|
|
43
|
+
: new Coordinate(options);
|
|
44
|
+
return coordinate as Coordinate;
|
|
40
45
|
}
|
|
41
46
|
|
|
42
47
|
export function coordinate2Transform(node: G2View, library: G2Library): G2View {
|
|
@@ -112,6 +117,9 @@ export function isReflectY(coordinates: G2CoordinateOptions[]) {
|
|
|
112
117
|
function inferCoordinate(
|
|
113
118
|
coordinates: G2CoordinateOptions[],
|
|
114
119
|
): G2CoordinateOptions[] {
|
|
115
|
-
if (
|
|
120
|
+
if (
|
|
121
|
+
coordinates.find((d) => d.type === 'cartesian' || d.type === 'cartesian3D')
|
|
122
|
+
)
|
|
123
|
+
return coordinates;
|
|
116
124
|
return [...coordinates, { type: 'cartesian' }];
|
|
117
125
|
}
|