@antv/g2 5.0.19 → 5.0.21
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/chart.d.ts +13 -855
- package/esm/api/chart.js.map +1 -1
- package/esm/api/extend.d.ts +2 -1
- package/esm/api/extend.js.map +1 -1
- package/esm/api/library.d.ts +1 -0
- 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/data/index.d.ts +2 -0
- package/esm/data/index.js +1 -0
- package/esm/data/index.js.map +1 -1
- package/esm/data/log.d.ts +7 -0
- package/esm/data/log.js +11 -0
- package/esm/data/log.js.map +1 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/interaction/brushFilter.js +18 -16
- package/esm/interaction/brushFilter.js.map +1 -1
- package/esm/interaction/chartIndex.js +25 -22
- package/esm/interaction/chartIndex.js.map +1 -1
- package/esm/interaction/event.js +20 -9
- package/esm/interaction/event.js.map +1 -1
- package/esm/interaction/fisheye.js +17 -13
- package/esm/interaction/fisheye.js.map +1 -1
- package/esm/interaction/legendFilter.js +32 -26
- package/esm/interaction/legendFilter.js.map +1 -1
- package/esm/interaction/sliderFilter.js +8 -9
- package/esm/interaction/sliderFilter.js.map +1 -1
- package/esm/interaction/tooltip.d.ts +1 -1
- package/esm/interaction/tooltip.js +39 -4
- package/esm/interaction/tooltip.js.map +1 -1
- package/esm/lib/core.d.ts +1 -0
- package/esm/lib/core.js +2 -1
- package/esm/lib/core.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/std.d.ts +1 -0
- 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 +26 -9
- 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/dataTransform.d.ts +3 -2
- package/esm/spec/index.d.ts +1 -0
- package/esm/spec/index.js.map +1 -1
- package/esm/spec/interaction.d.ts +2 -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/chart.d.ts +13 -855
- package/lib/api/chart.js.map +1 -1
- package/lib/api/extend.d.ts +2 -1
- package/lib/api/extend.js.map +1 -1
- package/lib/api/library.d.ts +1 -0
- 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/data/index.d.ts +2 -0
- package/lib/data/index.js +3 -1
- package/lib/data/index.js.map +1 -1
- package/lib/data/log.d.ts +7 -0
- package/lib/data/log.js +15 -0
- package/lib/data/log.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/interaction/brushFilter.js +18 -16
- package/lib/interaction/brushFilter.js.map +1 -1
- package/lib/interaction/chartIndex.js +25 -22
- package/lib/interaction/chartIndex.js.map +1 -1
- package/lib/interaction/event.js +20 -9
- package/lib/interaction/event.js.map +1 -1
- package/lib/interaction/fisheye.js +17 -13
- package/lib/interaction/fisheye.js.map +1 -1
- package/lib/interaction/legendFilter.js +32 -26
- package/lib/interaction/legendFilter.js.map +1 -1
- package/lib/interaction/sliderFilter.js +8 -9
- package/lib/interaction/sliderFilter.js.map +1 -1
- package/lib/interaction/tooltip.d.ts +1 -1
- package/lib/interaction/tooltip.js +38 -3
- package/lib/interaction/tooltip.js.map +1 -1
- package/lib/lib/core.d.ts +1 -0
- package/lib/lib/core.js +1 -0
- package/lib/lib/core.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/std.d.ts +1 -0
- 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 +25 -8
- 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/dataTransform.d.ts +3 -2
- package/lib/spec/index.d.ts +1 -0
- package/lib/spec/index.js.map +1 -1
- package/lib/spec/interaction.d.ts +2 -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 +10 -3
- package/src/api/chart.ts +3 -3
- package/src/api/extend.ts +5 -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/data/index.ts +2 -0
- package/src/data/log.ts +16 -0
- package/src/index.ts +1 -1
- package/src/interaction/brushFilter.ts +31 -28
- package/src/interaction/chartIndex.ts +26 -23
- package/src/interaction/event.ts +22 -9
- package/src/interaction/fisheye.ts +16 -12
- package/src/interaction/legendFilter.ts +45 -40
- package/src/interaction/sliderFilter.ts +15 -16
- package/src/interaction/tooltip.ts +47 -3
- package/src/lib/core.ts +2 -0
- 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 +33 -10
- 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/dataTransform.ts +5 -0
- package/src/spec/index.ts +1 -0
- package/src/spec/interaction.ts +3 -1
- 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/shape/index.ts
CHANGED
|
@@ -29,6 +29,8 @@ export { Square as PointSquare } from './point/square';
|
|
|
29
29
|
export { Tick as PointTick } from './point/tick';
|
|
30
30
|
export { Triangle as PointTriangle } from './point/triangle';
|
|
31
31
|
export { TriangleDown as PointTriangleDown } from './point/triangleDown';
|
|
32
|
+
export { Sphere } from './point3D/sphere';
|
|
33
|
+
export { Cube } from './point3D/cube';
|
|
32
34
|
export { Vector as VectorShape } from './vector/vector';
|
|
33
35
|
export { Text as TextShape } from './text/text';
|
|
34
36
|
export { Badge as TextBadge } from './text/badge';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MeshPhongMaterial, 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 MeshPhongMaterial(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
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { MeshPhongMaterial, 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 MeshPhongMaterial(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
|
+
};
|
package/src/shape/shape/shape.ts
CHANGED
|
@@ -6,15 +6,18 @@ export type ShapeOptions = Record<string, any>;
|
|
|
6
6
|
/**
|
|
7
7
|
* Draw a custom shape.
|
|
8
8
|
*/
|
|
9
|
-
export const Shape: SC<ShapeOptions> = (options) => {
|
|
9
|
+
export const Shape: SC<ShapeOptions> = (options, context) => {
|
|
10
10
|
const { render, ...rest } = options;
|
|
11
11
|
return (points) => {
|
|
12
12
|
const [[x0, y0]] = points;
|
|
13
|
-
return render(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
return render(
|
|
14
|
+
{
|
|
15
|
+
...rest,
|
|
16
|
+
x: x0,
|
|
17
|
+
y: y0,
|
|
18
|
+
},
|
|
19
|
+
context,
|
|
20
|
+
);
|
|
18
21
|
};
|
|
19
22
|
};
|
|
20
23
|
|
package/src/shape/utils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Linear } from '@antv/scale';
|
|
|
3
3
|
import { lowerFirst } from '@antv/util';
|
|
4
4
|
import { extent } from 'd3-array';
|
|
5
5
|
import { Path as D3Path } from 'd3-path';
|
|
6
|
-
import { G2Theme, Primitive, Vector2 } from '../runtime';
|
|
6
|
+
import { G2Theme, Primitive, Vector2, Vector3 } from '../runtime';
|
|
7
7
|
import { indexOf } from '../utils/array';
|
|
8
8
|
import { isPolar, isTranspose } from '../utils/coordinate';
|
|
9
9
|
import { Selection } from '../utils/selection';
|
|
@@ -212,8 +212,8 @@ export function getTransform(coordinate, value) {
|
|
|
212
212
|
return `translate(${center[0]}, ${center[1]}) ${suffix || ''}`;
|
|
213
213
|
}
|
|
214
214
|
|
|
215
|
-
export function getOrigin(points: Vector2[]) {
|
|
215
|
+
export function getOrigin(points: (Vector2 | Vector3)[]) {
|
|
216
216
|
if (points.length === 1) return points[0];
|
|
217
|
-
const [[x0, y0], [x2, y2]] = points;
|
|
218
|
-
return [(x0 + x2) / 2, (y0 + y2) / 2];
|
|
217
|
+
const [[x0, y0, z0 = 0], [x2, y2, z2 = 0]] = points;
|
|
218
|
+
return [(x0 + x2) / 2, (y0 + y2) / 2, (z0 + z2) / 2];
|
|
219
219
|
}
|
package/src/spec/component.ts
CHANGED
|
@@ -33,7 +33,7 @@ export type TitleComponent = {
|
|
|
33
33
|
} & UsePrefix<'title' | 'subtitle', Record<string, any>>;
|
|
34
34
|
|
|
35
35
|
export type AxisComponent = {
|
|
36
|
-
type?: 'axisX' | 'axisY';
|
|
36
|
+
type?: 'axisX' | 'axisY' | 'axisZ';
|
|
37
37
|
tickCount?: number;
|
|
38
38
|
labelFormatter?: any;
|
|
39
39
|
tickFilter?: any;
|
package/src/spec/composition.ts
CHANGED
package/src/spec/coordinate.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type Coordinate =
|
|
|
7
7
|
| ThetaCoordinate
|
|
8
8
|
| CustomCoordinate
|
|
9
9
|
| CartesianCoordinate
|
|
10
|
+
| Cartesian3DCoordinate
|
|
10
11
|
| ParallelCoordinate
|
|
11
12
|
| RadialCoordinate
|
|
12
13
|
| RadarCoordinate
|
|
@@ -18,6 +19,7 @@ export type CoordinateTypes =
|
|
|
18
19
|
| 'transpose'
|
|
19
20
|
| 'theta'
|
|
20
21
|
| 'cartesian'
|
|
22
|
+
| 'cartesian3D'
|
|
21
23
|
| 'parallel'
|
|
22
24
|
| 'fisheye'
|
|
23
25
|
| 'radial'
|
|
@@ -70,6 +72,10 @@ export type CartesianCoordinate = BaseCoordinate<{
|
|
|
70
72
|
type?: 'cartesian';
|
|
71
73
|
}>;
|
|
72
74
|
|
|
75
|
+
export type Cartesian3DCoordinate = BaseCoordinate<{
|
|
76
|
+
type?: 'cartesian3D';
|
|
77
|
+
}>;
|
|
78
|
+
|
|
73
79
|
export type ParallelCoordinate = BaseCoordinate<{
|
|
74
80
|
type?: 'parallel';
|
|
75
81
|
}>;
|
|
@@ -12,6 +12,7 @@ export type DataTransform =
|
|
|
12
12
|
| SliceTransform
|
|
13
13
|
| KDEDataTransform
|
|
14
14
|
| VennDataTransform
|
|
15
|
+
| LogDataTransform
|
|
15
16
|
| CustomTransform;
|
|
16
17
|
|
|
17
18
|
export type DataTransformTypes =
|
|
@@ -26,6 +27,7 @@ export type DataTransformTypes =
|
|
|
26
27
|
| 'slice'
|
|
27
28
|
| 'kde'
|
|
28
29
|
| 'venn'
|
|
30
|
+
| 'log'
|
|
29
31
|
| 'custom'
|
|
30
32
|
| DataComponent;
|
|
31
33
|
|
|
@@ -179,6 +181,9 @@ export type VennDataTransform = {
|
|
|
179
181
|
as?: [string, string];
|
|
180
182
|
};
|
|
181
183
|
|
|
184
|
+
// eslint-disable-next-line
|
|
185
|
+
export type LogDataTransform = {};
|
|
186
|
+
|
|
182
187
|
export type CustomTransform = {
|
|
183
188
|
type?: DataComponent;
|
|
184
189
|
[key: string]: any;
|
package/src/spec/index.ts
CHANGED
package/src/spec/interaction.ts
CHANGED
|
@@ -175,6 +175,7 @@ export type TooltipInteraction = {
|
|
|
175
175
|
facet?: boolean;
|
|
176
176
|
body?: boolean;
|
|
177
177
|
crosshairs?: boolean;
|
|
178
|
+
marker?: boolean;
|
|
178
179
|
groupName?: boolean;
|
|
179
180
|
position?: TooltipStyleProps['position'];
|
|
180
181
|
bounding?: BBox;
|
|
@@ -186,7 +187,8 @@ export type TooltipInteraction = {
|
|
|
186
187
|
event, // @todo
|
|
187
188
|
options: { title: 'string'; items: TooltipItemValue[] },
|
|
188
189
|
) => HTMLElement | string;
|
|
189
|
-
} & Record<`crosshairs${any}`, any
|
|
190
|
+
} & Record<`crosshairs${any}`, any> &
|
|
191
|
+
Record<`marker${any}`, any>;
|
|
190
192
|
|
|
191
193
|
export type FisheyeInteraction = {
|
|
192
194
|
type?: 'fisheye';
|
package/src/spec/mark.ts
CHANGED
|
@@ -89,6 +89,7 @@ export type MarkTypes =
|
|
|
89
89
|
export type ChannelTypes =
|
|
90
90
|
| 'x'
|
|
91
91
|
| 'y'
|
|
92
|
+
| 'z'
|
|
92
93
|
| 'x1'
|
|
93
94
|
| 'y1'
|
|
94
95
|
| 'series'
|
|
@@ -114,7 +115,12 @@ export type ChannelTypes =
|
|
|
114
115
|
| 'exitDelay'
|
|
115
116
|
| `position${number}`;
|
|
116
117
|
|
|
117
|
-
export type PositionChannelTypes =
|
|
118
|
+
export type PositionChannelTypes =
|
|
119
|
+
| 'x'
|
|
120
|
+
| 'y'
|
|
121
|
+
| 'z'
|
|
122
|
+
| 'position'
|
|
123
|
+
| `position${number}`;
|
|
118
124
|
|
|
119
125
|
export type AtheisticChanelTypes = 'size' | 'color' | 'shape' | 'opacity';
|
|
120
126
|
|
package/src/transform/index.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { MaybeStackY } from './maybeStackY';
|
|
|
3
3
|
export { MaybeTitle } from './maybeTitle';
|
|
4
4
|
export { MaybeZeroX } from './maybeZeroX';
|
|
5
5
|
export { MaybeZeroY } from './maybeZeroY';
|
|
6
|
+
export { MaybeZeroZ } from './maybeZeroZ';
|
|
6
7
|
export { MaybeSize } from './maybeSize';
|
|
7
8
|
export { MaybeKey } from './maybeKey';
|
|
8
9
|
export { MaybeSeries } from './maybeSeries';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { deepMix } from '@antv/util';
|
|
2
|
+
import { TransformComponent as TC } from '../runtime';
|
|
3
|
+
import { inferredColumn, constant } from './utils/helper';
|
|
4
|
+
|
|
5
|
+
export type MaybeZeroZOptions = Record<string, never>;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Add zero constant encode for z channel.
|
|
9
|
+
*/
|
|
10
|
+
export const MaybeZeroZ: TC<MaybeZeroZOptions> = () => {
|
|
11
|
+
return (I, mark) => {
|
|
12
|
+
const { encode } = mark;
|
|
13
|
+
const { z } = encode;
|
|
14
|
+
if (z !== undefined) return [I, mark];
|
|
15
|
+
return [
|
|
16
|
+
I,
|
|
17
|
+
deepMix({}, mark, {
|
|
18
|
+
encode: { z: inferredColumn(constant(I, 0)) },
|
|
19
|
+
scale: { z: { guide: null } },
|
|
20
|
+
}),
|
|
21
|
+
];
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
MaybeZeroZ.props = {};
|
package/src/utils/size.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { G2View } from '../runtime';
|
|
|
3
3
|
type Size = {
|
|
4
4
|
width: number;
|
|
5
5
|
height: number;
|
|
6
|
+
depth?: number;
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
const parseInt10 = (d: string) => (d ? parseInt(d) : 0);
|
|
@@ -28,6 +29,7 @@ export function getContainerSize(container: HTMLElement): Size {
|
|
|
28
29
|
return {
|
|
29
30
|
width: wrapperWidth - widthPadding,
|
|
30
31
|
height: wrapperHeight - heightPadding,
|
|
32
|
+
depth: wrapperWidth,
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
|
package/README.en-US.md
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
<img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> English | [简体中文](./README.md)
|
|
2
|
-
|
|
3
|
-
<h1 align="center">
|
|
4
|
-
<b>G2 5.0</b>
|
|
5
|
-
</h1>
|
|
6
|
-
|
|
7
|
-
<div align="center">
|
|
8
|
-
|
|
9
|
-
G2 is a visualization grammar for dashboard building, data exploration and storytelling.
|
|
10
|
-
|
|
11
|
-
[](https://github.com/antvis//actions)
|
|
12
|
-
[](https://coveralls.io/github/antvis/g2?branch=v5)
|
|
13
|
-
[](https://www.npmjs.com/package/@antv/g2)
|
|
14
|
-
[](https://www.npmjs.com/package/@antv/g2)
|
|
15
|
-
[](https://www.npmjs.com/package/@antv/g2)
|
|
16
|
-
|
|
17
|
-

|
|
18
|
-
|
|
19
|
-
</div>
|
|
20
|
-
|
|
21
|
-
> G2 5.0 is still work in progress, the stable release is on the [master](https://github.com/antvis/G2/tree/master) branch.
|
|
22
|
-
|
|
23
|
-
G2 is named after Leland Wilkinson’s book _The Grammar of Graphics_ and was profoundly inspired by it in the very beginning. Here are some resources you can begin with:
|
|
24
|
-
|
|
25
|
-
- [Introduction](http://g2-next.antv.vision/introduction) - a brief overview and G2's motivations
|
|
26
|
-
- [Examples](http://g2-next.antv.vision/examples) - a large number of demos to learn from and copy-paste
|
|
27
|
-
- [Tutorials](http://g2-next.antv.vision/tutorials) - interactive case-driven guides of G2's core concepts
|
|
28
|
-
- [API Reference](http://g2-next.antv.vision/basic) - complete documentation for all visualization components
|
|
29
|
-
|
|
30
|
-
## ✨ Features
|
|
31
|
-
|
|
32
|
-
- **Progressive Usage** - The main objective of G2 is to help you get meaningful visualizations quickly with concise declarations and it infers the rest. But you can configure much more for complex and advanced situations.
|
|
33
|
-
- **Declarative API** - We employs a functional declarative API to specify chart options in a programmatic fashion, which contributes to better logic reuse and more flexible code organization.
|
|
34
|
-
- **High Extensibility** - To satisfy specific needs, G2 provides a convenient and consistent mechanism to extend everything you can imagine, whether a scale, a transform, a mark, etc,. You can even customize a brand new visualization tool based on this mechanism.
|
|
35
|
-
- **Comprehensive Grammar** - G2 rejects a chart typology in favor of marks, transforms, scales, coordinates, and compositions. In addition to static visual representations, it's possible to declare data-driven animations and apply well-designed action-based interactions to plots as well.
|
|
36
|
-
- **Powerful Renderer** - There is a powerful renderer [G](https://github.com/antvis/G) under G2 to generate web-based visualizations using Canvas, SVG or WebGL. The plenty of plugins it has benefit G2 from rendering charts with novel styles such as hand-drawn and fully embrace the ecosystem of [D3](https://github.com/d3/d3).
|
|
37
|
-
|
|
38
|
-
## 🔨 Getting Started
|
|
39
|
-
|
|
40
|
-
G2 is usually installed via a package manager such as npm or Yarn.
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
$ npm install @antv/g2@next
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
$ yarn add @antv/g2@next
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The Chart object then can be imported from G2.
|
|
51
|
-
|
|
52
|
-
```html
|
|
53
|
-
<div id="chart"></div>
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
```js
|
|
57
|
-
import { Chart } from '@antv/g2';
|
|
58
|
-
|
|
59
|
-
// A tabular data to be visualized.
|
|
60
|
-
const data = [
|
|
61
|
-
{ genre: 'Sports', sold: 275 },
|
|
62
|
-
{ genre: 'Strategy', sold: 115 },
|
|
63
|
-
{ genre: 'Action', sold: 120 },
|
|
64
|
-
{ genre: 'Shooter', sold: 350 },
|
|
65
|
-
{ genre: 'Other', sold: 150 },
|
|
66
|
-
];
|
|
67
|
-
|
|
68
|
-
// Instantiate a new chart.
|
|
69
|
-
const chart = new Chart({
|
|
70
|
-
container: 'container',
|
|
71
|
-
theme: 'classic',
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
// Specify visualization.
|
|
75
|
-
chart
|
|
76
|
-
.interval() // Create an interval mark and add it to the chart.
|
|
77
|
-
.data(data) // Bind data for this mark.
|
|
78
|
-
.encode('x', 'genre') // Assign genre column to x position channel.
|
|
79
|
-
.encode('y', 'sold'); // Assign sold column to y position channel.
|
|
80
|
-
|
|
81
|
-
// Render visualization。
|
|
82
|
-
chart.render();
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
If all goes well, you can get the following lovely bar chart!
|
|
86
|
-
|
|
87
|
-
<img src="https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*K-7URYaij4kAAAAAAAAAAAAADmJ7AQ/original" width="640" height="480" alt="example">
|
|
88
|
-
|
|
89
|
-
## 📮 Contributing
|
|
90
|
-
|
|
91
|
-
- [Issues](https://github.com/antvis/g2/issues) - report bugs or request features
|
|
92
|
-
- [Contributing Guide](https://github.com/antvis/g2/blob/v5/CONTRIBUTING.en-US.md) - help build G2
|
|
93
|
-
- [Discussions](https://github.com/antvis/G2/discussions) - discuss on Github or in DingTalk group(30233731, 35686967, 44788198)
|
|
94
|
-
|
|
95
|
-
<img src="https://gw.alipayobjects.com/zos/antfincdn/hTzzaqgHgQ/Antv%252520G2%252520%26%252520G2Plot.png" width="200" height="266" alt="code"/>
|
|
96
|
-
|
|
97
|
-
## 📄 License
|
|
98
|
-
|
|
99
|
-
MIT@[AntV](https://github.com/antvis).
|