@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.
Files changed (229) hide show
  1. package/README.md +32 -34
  2. package/README.zh-CN.md +99 -0
  3. package/dist/g2-lite.min.js +4 -4
  4. package/dist/g2.min.js +4 -4
  5. package/esm/api/runtime.js +2 -2
  6. package/esm/api/runtime.js.map +1 -1
  7. package/esm/api/utils.d.ts +5 -0
  8. package/esm/api/utils.js +3 -2
  9. package/esm/api/utils.js.map +1 -1
  10. package/esm/component/axis.d.ts +11 -1
  11. package/esm/component/axis.js +46 -11
  12. package/esm/component/axis.js.map +1 -1
  13. package/esm/component/axisX.js +7 -4
  14. package/esm/component/axisX.js.map +1 -1
  15. package/esm/component/axisY.js +6 -2
  16. package/esm/component/axisY.js.map +1 -1
  17. package/esm/component/axisZ.d.ts +8 -0
  18. package/esm/component/axisZ.js +14 -0
  19. package/esm/component/axisZ.js.map +1 -0
  20. package/esm/component/index.d.ts +1 -0
  21. package/esm/component/index.js +1 -0
  22. package/esm/component/index.js.map +1 -1
  23. package/esm/component/scrollbar.d.ts +2 -1
  24. package/esm/component/scrollbar.js +1 -1
  25. package/esm/component/scrollbar.js.map +1 -1
  26. package/esm/composition/mark.js +3 -1
  27. package/esm/composition/mark.js.map +1 -1
  28. package/esm/coordinate/cartesian3D.d.ts +7 -0
  29. package/esm/coordinate/cartesian3D.js +6 -0
  30. package/esm/coordinate/cartesian3D.js.map +1 -0
  31. package/esm/coordinate/index.d.ts +2 -0
  32. package/esm/coordinate/index.js +1 -0
  33. package/esm/coordinate/index.js.map +1 -1
  34. package/esm/index.d.ts +1 -1
  35. package/esm/index.js +1 -1
  36. package/esm/index.js.map +1 -1
  37. package/esm/interaction/event.js +20 -9
  38. package/esm/interaction/event.js.map +1 -1
  39. package/esm/lib/index.d.ts +1 -0
  40. package/esm/lib/index.js +1 -0
  41. package/esm/lib/index.js.map +1 -1
  42. package/esm/lib/threed.d.ts +5 -0
  43. package/esm/lib/threed.js +11 -0
  44. package/esm/lib/threed.js.map +1 -0
  45. package/esm/mark/index.d.ts +1 -0
  46. package/esm/mark/index.js +1 -0
  47. package/esm/mark/index.js.map +1 -1
  48. package/esm/mark/point3D.d.ts +9 -0
  49. package/esm/mark/point3D.js +76 -0
  50. package/esm/mark/point3D.js.map +1 -0
  51. package/esm/mark/utils.d.ts +7 -0
  52. package/esm/mark/utils.js +6 -0
  53. package/esm/mark/utils.js.map +1 -1
  54. package/esm/runtime/component.js +6 -3
  55. package/esm/runtime/component.js.map +1 -1
  56. package/esm/runtime/coordinate.js +9 -4
  57. package/esm/runtime/coordinate.js.map +1 -1
  58. package/esm/runtime/layout.d.ts +1 -0
  59. package/esm/runtime/layout.js +109 -29
  60. package/esm/runtime/layout.js.map +1 -1
  61. package/esm/runtime/plot.js +5 -3
  62. package/esm/runtime/plot.js.map +1 -1
  63. package/esm/runtime/render.js +12 -3
  64. package/esm/runtime/render.js.map +1 -1
  65. package/esm/runtime/types/common.d.ts +4 -0
  66. package/esm/runtime/types/component.d.ts +8 -2
  67. package/esm/runtime/types/options.d.ts +5 -1
  68. package/esm/shape/index.d.ts +2 -0
  69. package/esm/shape/index.js +2 -0
  70. package/esm/shape/index.js.map +1 -1
  71. package/esm/shape/point3D/cube.d.ts +6 -0
  72. package/esm/shape/point3D/cube.js +70 -0
  73. package/esm/shape/point3D/cube.js.map +1 -0
  74. package/esm/shape/point3D/sphere.d.ts +6 -0
  75. package/esm/shape/point3D/sphere.js +70 -0
  76. package/esm/shape/point3D/sphere.js.map +1 -0
  77. package/esm/shape/shape/shape.js +2 -2
  78. package/esm/shape/shape/shape.js.map +1 -1
  79. package/esm/shape/utils.d.ts +2 -2
  80. package/esm/shape/utils.js +2 -2
  81. package/esm/shape/utils.js.map +1 -1
  82. package/esm/spec/component.d.ts +1 -1
  83. package/esm/spec/composition.d.ts +2 -0
  84. package/esm/spec/coordinate.d.ts +5 -2
  85. package/esm/spec/index.d.ts +1 -0
  86. package/esm/spec/index.js.map +1 -1
  87. package/esm/spec/mark.d.ts +2 -2
  88. package/esm/transform/index.d.ts +1 -0
  89. package/esm/transform/index.js +1 -0
  90. package/esm/transform/index.js.map +1 -1
  91. package/esm/transform/maybeZeroZ.d.ts +6 -0
  92. package/esm/transform/maybeZeroZ.js +22 -0
  93. package/esm/transform/maybeZeroZ.js.map +1 -0
  94. package/esm/utils/size.d.ts +1 -0
  95. package/esm/utils/size.js +1 -0
  96. package/esm/utils/size.js.map +1 -1
  97. package/lib/api/runtime.js +2 -2
  98. package/lib/api/runtime.js.map +1 -1
  99. package/lib/api/utils.d.ts +5 -0
  100. package/lib/api/utils.js +3 -2
  101. package/lib/api/utils.js.map +1 -1
  102. package/lib/component/axis.d.ts +11 -1
  103. package/lib/component/axis.js +48 -12
  104. package/lib/component/axis.js.map +1 -1
  105. package/lib/component/axisX.js +6 -3
  106. package/lib/component/axisX.js.map +1 -1
  107. package/lib/component/axisY.js +5 -1
  108. package/lib/component/axisY.js.map +1 -1
  109. package/lib/component/axisZ.d.ts +8 -0
  110. package/lib/component/axisZ.js +19 -0
  111. package/lib/component/axisZ.js.map +1 -0
  112. package/lib/component/index.d.ts +1 -0
  113. package/lib/component/index.js +3 -1
  114. package/lib/component/index.js.map +1 -1
  115. package/lib/component/scrollbar.d.ts +2 -1
  116. package/lib/component/scrollbar.js +1 -1
  117. package/lib/component/scrollbar.js.map +1 -1
  118. package/lib/composition/mark.js +3 -1
  119. package/lib/composition/mark.js.map +1 -1
  120. package/lib/coordinate/cartesian3D.d.ts +7 -0
  121. package/lib/coordinate/cartesian3D.js +10 -0
  122. package/lib/coordinate/cartesian3D.js.map +1 -0
  123. package/lib/coordinate/index.d.ts +2 -0
  124. package/lib/coordinate/index.js +3 -1
  125. package/lib/coordinate/index.js.map +1 -1
  126. package/lib/index.d.ts +1 -1
  127. package/lib/index.js +2 -1
  128. package/lib/index.js.map +1 -1
  129. package/lib/interaction/event.js +20 -9
  130. package/lib/interaction/event.js.map +1 -1
  131. package/lib/lib/index.d.ts +1 -0
  132. package/lib/lib/index.js +3 -1
  133. package/lib/lib/index.js.map +1 -1
  134. package/lib/lib/threed.d.ts +5 -0
  135. package/lib/lib/threed.js +15 -0
  136. package/lib/lib/threed.js.map +1 -0
  137. package/lib/mark/index.d.ts +1 -0
  138. package/lib/mark/index.js +3 -1
  139. package/lib/mark/index.js.map +1 -1
  140. package/lib/mark/point3D.d.ts +9 -0
  141. package/lib/mark/point3D.js +80 -0
  142. package/lib/mark/point3D.js.map +1 -0
  143. package/lib/mark/utils.d.ts +7 -0
  144. package/lib/mark/utils.js +8 -1
  145. package/lib/mark/utils.js.map +1 -1
  146. package/lib/runtime/component.js +6 -3
  147. package/lib/runtime/component.js.map +1 -1
  148. package/lib/runtime/coordinate.js +8 -3
  149. package/lib/runtime/coordinate.js.map +1 -1
  150. package/lib/runtime/layout.d.ts +1 -0
  151. package/lib/runtime/layout.js +112 -31
  152. package/lib/runtime/layout.js.map +1 -1
  153. package/lib/runtime/plot.js +4 -2
  154. package/lib/runtime/plot.js.map +1 -1
  155. package/lib/runtime/render.js +12 -3
  156. package/lib/runtime/render.js.map +1 -1
  157. package/lib/runtime/types/common.d.ts +4 -0
  158. package/lib/runtime/types/component.d.ts +8 -2
  159. package/lib/runtime/types/options.d.ts +5 -1
  160. package/lib/shape/index.d.ts +2 -0
  161. package/lib/shape/index.js +6 -2
  162. package/lib/shape/index.js.map +1 -1
  163. package/lib/shape/point3D/cube.d.ts +6 -0
  164. package/lib/shape/point3D/cube.js +74 -0
  165. package/lib/shape/point3D/cube.js.map +1 -0
  166. package/lib/shape/point3D/sphere.d.ts +6 -0
  167. package/lib/shape/point3D/sphere.js +74 -0
  168. package/lib/shape/point3D/sphere.js.map +1 -0
  169. package/lib/shape/shape/shape.js +2 -2
  170. package/lib/shape/shape/shape.js.map +1 -1
  171. package/lib/shape/utils.d.ts +2 -2
  172. package/lib/shape/utils.js +2 -2
  173. package/lib/shape/utils.js.map +1 -1
  174. package/lib/spec/component.d.ts +1 -1
  175. package/lib/spec/composition.d.ts +2 -0
  176. package/lib/spec/coordinate.d.ts +5 -2
  177. package/lib/spec/index.d.ts +1 -0
  178. package/lib/spec/index.js.map +1 -1
  179. package/lib/spec/mark.d.ts +2 -2
  180. package/lib/transform/index.d.ts +1 -0
  181. package/lib/transform/index.js +3 -1
  182. package/lib/transform/index.js.map +1 -1
  183. package/lib/transform/maybeZeroZ.d.ts +6 -0
  184. package/lib/transform/maybeZeroZ.js +26 -0
  185. package/lib/transform/maybeZeroZ.js.map +1 -0
  186. package/lib/utils/size.d.ts +1 -0
  187. package/lib/utils/size.js +1 -0
  188. package/lib/utils/size.js.map +1 -1
  189. package/package.json +11 -3
  190. package/src/api/runtime.ts +2 -2
  191. package/src/api/utils.ts +3 -2
  192. package/src/component/axis.ts +65 -9
  193. package/src/component/axisX.ts +8 -3
  194. package/src/component/axisY.ts +8 -3
  195. package/src/component/axisZ.ts +25 -0
  196. package/src/component/index.ts +1 -0
  197. package/src/component/scrollbar.ts +3 -2
  198. package/src/composition/mark.ts +4 -0
  199. package/src/coordinate/cartesian3D.ts +11 -0
  200. package/src/coordinate/index.ts +2 -0
  201. package/src/index.ts +1 -1
  202. package/src/interaction/event.ts +22 -9
  203. package/src/lib/index.ts +1 -0
  204. package/src/lib/threed.ts +11 -0
  205. package/src/mark/index.ts +1 -0
  206. package/src/mark/point3D.ts +90 -0
  207. package/src/mark/utils.ts +7 -0
  208. package/src/runtime/component.ts +6 -0
  209. package/src/runtime/coordinate.ts +18 -10
  210. package/src/runtime/layout.ts +178 -33
  211. package/src/runtime/plot.ts +11 -3
  212. package/src/runtime/render.ts +14 -3
  213. package/src/runtime/types/common.ts +4 -0
  214. package/src/runtime/types/component.ts +10 -1
  215. package/src/runtime/types/options.ts +5 -0
  216. package/src/shape/index.ts +2 -0
  217. package/src/shape/point3D/cube.ts +68 -0
  218. package/src/shape/point3D/sphere.ts +68 -0
  219. package/src/shape/shape/shape.ts +9 -6
  220. package/src/shape/utils.ts +4 -4
  221. package/src/spec/component.ts +1 -1
  222. package/src/spec/composition.ts +2 -0
  223. package/src/spec/coordinate.ts +6 -0
  224. package/src/spec/index.ts +1 -0
  225. package/src/spec/mark.ts +7 -1
  226. package/src/transform/index.ts +1 -0
  227. package/src/transform/maybeZeroZ.ts +25 -0
  228. package/src/utils/size.ts +2 -0
  229. 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 = 'x' | 'y' | 'position' | `position${number}`;
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
 
@@ -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
- [![Build Status](https://github.com/antvis/g2/workflows/build/badge.svg?branch=v5)](https://github.com/antvis//actions)
12
- [![Coverage Status](https://img.shields.io/coveralls/github/antvis/g2/v5.svg)](https://coveralls.io/github/antvis/g2?branch=v5)
13
- [![npm Version](https://img.shields.io/npm/v/@antv/g2.svg)](https://www.npmjs.com/package/@antv/g2)
14
- [![npm Download](https://img.shields.io/npm/dm/@antv/g2.svg)](https://www.npmjs.com/package/@antv/g2)
15
- [![npm License](https://img.shields.io/npm/l/@antv/g2.svg)](https://www.npmjs.com/package/@antv/g2)
16
-
17
- ![examples](https://gw.alipayobjects.com/mdn/rms_dfc253/afts/img/A*o4YET5i12oMAAAAAAAAAAAAAARQnAQ)
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).