@antv/g2 5.0.20 → 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/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 +10 -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/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).
|