@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.
Files changed (302) 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/chart.d.ts +13 -855
  6. package/esm/api/chart.js.map +1 -1
  7. package/esm/api/extend.d.ts +2 -1
  8. package/esm/api/extend.js.map +1 -1
  9. package/esm/api/library.d.ts +1 -0
  10. package/esm/api/runtime.js +2 -2
  11. package/esm/api/runtime.js.map +1 -1
  12. package/esm/api/utils.d.ts +5 -0
  13. package/esm/api/utils.js +3 -2
  14. package/esm/api/utils.js.map +1 -1
  15. package/esm/component/axis.d.ts +11 -1
  16. package/esm/component/axis.js +46 -11
  17. package/esm/component/axis.js.map +1 -1
  18. package/esm/component/axisX.js +7 -4
  19. package/esm/component/axisX.js.map +1 -1
  20. package/esm/component/axisY.js +6 -2
  21. package/esm/component/axisY.js.map +1 -1
  22. package/esm/component/axisZ.d.ts +8 -0
  23. package/esm/component/axisZ.js +14 -0
  24. package/esm/component/axisZ.js.map +1 -0
  25. package/esm/component/index.d.ts +1 -0
  26. package/esm/component/index.js +1 -0
  27. package/esm/component/index.js.map +1 -1
  28. package/esm/component/scrollbar.d.ts +2 -1
  29. package/esm/component/scrollbar.js +1 -1
  30. package/esm/component/scrollbar.js.map +1 -1
  31. package/esm/composition/mark.js +3 -1
  32. package/esm/composition/mark.js.map +1 -1
  33. package/esm/coordinate/cartesian3D.d.ts +7 -0
  34. package/esm/coordinate/cartesian3D.js +6 -0
  35. package/esm/coordinate/cartesian3D.js.map +1 -0
  36. package/esm/coordinate/index.d.ts +2 -0
  37. package/esm/coordinate/index.js +1 -0
  38. package/esm/coordinate/index.js.map +1 -1
  39. package/esm/data/index.d.ts +2 -0
  40. package/esm/data/index.js +1 -0
  41. package/esm/data/index.js.map +1 -1
  42. package/esm/data/log.d.ts +7 -0
  43. package/esm/data/log.js +11 -0
  44. package/esm/data/log.js.map +1 -0
  45. package/esm/index.d.ts +1 -1
  46. package/esm/index.js +1 -1
  47. package/esm/index.js.map +1 -1
  48. package/esm/interaction/brushFilter.js +18 -16
  49. package/esm/interaction/brushFilter.js.map +1 -1
  50. package/esm/interaction/chartIndex.js +25 -22
  51. package/esm/interaction/chartIndex.js.map +1 -1
  52. package/esm/interaction/event.js +20 -9
  53. package/esm/interaction/event.js.map +1 -1
  54. package/esm/interaction/fisheye.js +17 -13
  55. package/esm/interaction/fisheye.js.map +1 -1
  56. package/esm/interaction/legendFilter.js +32 -26
  57. package/esm/interaction/legendFilter.js.map +1 -1
  58. package/esm/interaction/sliderFilter.js +8 -9
  59. package/esm/interaction/sliderFilter.js.map +1 -1
  60. package/esm/interaction/tooltip.d.ts +1 -1
  61. package/esm/interaction/tooltip.js +39 -4
  62. package/esm/interaction/tooltip.js.map +1 -1
  63. package/esm/lib/core.d.ts +1 -0
  64. package/esm/lib/core.js +2 -1
  65. package/esm/lib/core.js.map +1 -1
  66. package/esm/lib/index.d.ts +1 -0
  67. package/esm/lib/index.js +1 -0
  68. package/esm/lib/index.js.map +1 -1
  69. package/esm/lib/std.d.ts +1 -0
  70. package/esm/lib/threed.d.ts +5 -0
  71. package/esm/lib/threed.js +11 -0
  72. package/esm/lib/threed.js.map +1 -0
  73. package/esm/mark/index.d.ts +1 -0
  74. package/esm/mark/index.js +1 -0
  75. package/esm/mark/index.js.map +1 -1
  76. package/esm/mark/point3D.d.ts +9 -0
  77. package/esm/mark/point3D.js +76 -0
  78. package/esm/mark/point3D.js.map +1 -0
  79. package/esm/mark/utils.d.ts +7 -0
  80. package/esm/mark/utils.js +6 -0
  81. package/esm/mark/utils.js.map +1 -1
  82. package/esm/runtime/component.js +6 -3
  83. package/esm/runtime/component.js.map +1 -1
  84. package/esm/runtime/coordinate.js +9 -4
  85. package/esm/runtime/coordinate.js.map +1 -1
  86. package/esm/runtime/layout.d.ts +1 -0
  87. package/esm/runtime/layout.js +109 -29
  88. package/esm/runtime/layout.js.map +1 -1
  89. package/esm/runtime/plot.js +26 -9
  90. package/esm/runtime/plot.js.map +1 -1
  91. package/esm/runtime/render.js +12 -3
  92. package/esm/runtime/render.js.map +1 -1
  93. package/esm/runtime/types/common.d.ts +4 -0
  94. package/esm/runtime/types/component.d.ts +8 -2
  95. package/esm/runtime/types/options.d.ts +5 -1
  96. package/esm/shape/index.d.ts +2 -0
  97. package/esm/shape/index.js +2 -0
  98. package/esm/shape/index.js.map +1 -1
  99. package/esm/shape/point3D/cube.d.ts +6 -0
  100. package/esm/shape/point3D/cube.js +70 -0
  101. package/esm/shape/point3D/cube.js.map +1 -0
  102. package/esm/shape/point3D/sphere.d.ts +6 -0
  103. package/esm/shape/point3D/sphere.js +70 -0
  104. package/esm/shape/point3D/sphere.js.map +1 -0
  105. package/esm/shape/shape/shape.js +2 -2
  106. package/esm/shape/shape/shape.js.map +1 -1
  107. package/esm/shape/utils.d.ts +2 -2
  108. package/esm/shape/utils.js +2 -2
  109. package/esm/shape/utils.js.map +1 -1
  110. package/esm/spec/component.d.ts +1 -1
  111. package/esm/spec/composition.d.ts +2 -0
  112. package/esm/spec/coordinate.d.ts +5 -2
  113. package/esm/spec/dataTransform.d.ts +3 -2
  114. package/esm/spec/index.d.ts +1 -0
  115. package/esm/spec/index.js.map +1 -1
  116. package/esm/spec/interaction.d.ts +2 -1
  117. package/esm/spec/mark.d.ts +2 -2
  118. package/esm/transform/index.d.ts +1 -0
  119. package/esm/transform/index.js +1 -0
  120. package/esm/transform/index.js.map +1 -1
  121. package/esm/transform/maybeZeroZ.d.ts +6 -0
  122. package/esm/transform/maybeZeroZ.js +22 -0
  123. package/esm/transform/maybeZeroZ.js.map +1 -0
  124. package/esm/utils/size.d.ts +1 -0
  125. package/esm/utils/size.js +1 -0
  126. package/esm/utils/size.js.map +1 -1
  127. package/lib/api/chart.d.ts +13 -855
  128. package/lib/api/chart.js.map +1 -1
  129. package/lib/api/extend.d.ts +2 -1
  130. package/lib/api/extend.js.map +1 -1
  131. package/lib/api/library.d.ts +1 -0
  132. package/lib/api/runtime.js +2 -2
  133. package/lib/api/runtime.js.map +1 -1
  134. package/lib/api/utils.d.ts +5 -0
  135. package/lib/api/utils.js +3 -2
  136. package/lib/api/utils.js.map +1 -1
  137. package/lib/component/axis.d.ts +11 -1
  138. package/lib/component/axis.js +48 -12
  139. package/lib/component/axis.js.map +1 -1
  140. package/lib/component/axisX.js +6 -3
  141. package/lib/component/axisX.js.map +1 -1
  142. package/lib/component/axisY.js +5 -1
  143. package/lib/component/axisY.js.map +1 -1
  144. package/lib/component/axisZ.d.ts +8 -0
  145. package/lib/component/axisZ.js +19 -0
  146. package/lib/component/axisZ.js.map +1 -0
  147. package/lib/component/index.d.ts +1 -0
  148. package/lib/component/index.js +3 -1
  149. package/lib/component/index.js.map +1 -1
  150. package/lib/component/scrollbar.d.ts +2 -1
  151. package/lib/component/scrollbar.js +1 -1
  152. package/lib/component/scrollbar.js.map +1 -1
  153. package/lib/composition/mark.js +3 -1
  154. package/lib/composition/mark.js.map +1 -1
  155. package/lib/coordinate/cartesian3D.d.ts +7 -0
  156. package/lib/coordinate/cartesian3D.js +10 -0
  157. package/lib/coordinate/cartesian3D.js.map +1 -0
  158. package/lib/coordinate/index.d.ts +2 -0
  159. package/lib/coordinate/index.js +3 -1
  160. package/lib/coordinate/index.js.map +1 -1
  161. package/lib/data/index.d.ts +2 -0
  162. package/lib/data/index.js +3 -1
  163. package/lib/data/index.js.map +1 -1
  164. package/lib/data/log.d.ts +7 -0
  165. package/lib/data/log.js +15 -0
  166. package/lib/data/log.js.map +1 -0
  167. package/lib/index.d.ts +1 -1
  168. package/lib/index.js +2 -1
  169. package/lib/index.js.map +1 -1
  170. package/lib/interaction/brushFilter.js +18 -16
  171. package/lib/interaction/brushFilter.js.map +1 -1
  172. package/lib/interaction/chartIndex.js +25 -22
  173. package/lib/interaction/chartIndex.js.map +1 -1
  174. package/lib/interaction/event.js +20 -9
  175. package/lib/interaction/event.js.map +1 -1
  176. package/lib/interaction/fisheye.js +17 -13
  177. package/lib/interaction/fisheye.js.map +1 -1
  178. package/lib/interaction/legendFilter.js +32 -26
  179. package/lib/interaction/legendFilter.js.map +1 -1
  180. package/lib/interaction/sliderFilter.js +8 -9
  181. package/lib/interaction/sliderFilter.js.map +1 -1
  182. package/lib/interaction/tooltip.d.ts +1 -1
  183. package/lib/interaction/tooltip.js +38 -3
  184. package/lib/interaction/tooltip.js.map +1 -1
  185. package/lib/lib/core.d.ts +1 -0
  186. package/lib/lib/core.js +1 -0
  187. package/lib/lib/core.js.map +1 -1
  188. package/lib/lib/index.d.ts +1 -0
  189. package/lib/lib/index.js +3 -1
  190. package/lib/lib/index.js.map +1 -1
  191. package/lib/lib/std.d.ts +1 -0
  192. package/lib/lib/threed.d.ts +5 -0
  193. package/lib/lib/threed.js +15 -0
  194. package/lib/lib/threed.js.map +1 -0
  195. package/lib/mark/index.d.ts +1 -0
  196. package/lib/mark/index.js +3 -1
  197. package/lib/mark/index.js.map +1 -1
  198. package/lib/mark/point3D.d.ts +9 -0
  199. package/lib/mark/point3D.js +80 -0
  200. package/lib/mark/point3D.js.map +1 -0
  201. package/lib/mark/utils.d.ts +7 -0
  202. package/lib/mark/utils.js +8 -1
  203. package/lib/mark/utils.js.map +1 -1
  204. package/lib/runtime/component.js +6 -3
  205. package/lib/runtime/component.js.map +1 -1
  206. package/lib/runtime/coordinate.js +8 -3
  207. package/lib/runtime/coordinate.js.map +1 -1
  208. package/lib/runtime/layout.d.ts +1 -0
  209. package/lib/runtime/layout.js +112 -31
  210. package/lib/runtime/layout.js.map +1 -1
  211. package/lib/runtime/plot.js +25 -8
  212. package/lib/runtime/plot.js.map +1 -1
  213. package/lib/runtime/render.js +12 -3
  214. package/lib/runtime/render.js.map +1 -1
  215. package/lib/runtime/types/common.d.ts +4 -0
  216. package/lib/runtime/types/component.d.ts +8 -2
  217. package/lib/runtime/types/options.d.ts +5 -1
  218. package/lib/shape/index.d.ts +2 -0
  219. package/lib/shape/index.js +6 -2
  220. package/lib/shape/index.js.map +1 -1
  221. package/lib/shape/point3D/cube.d.ts +6 -0
  222. package/lib/shape/point3D/cube.js +74 -0
  223. package/lib/shape/point3D/cube.js.map +1 -0
  224. package/lib/shape/point3D/sphere.d.ts +6 -0
  225. package/lib/shape/point3D/sphere.js +74 -0
  226. package/lib/shape/point3D/sphere.js.map +1 -0
  227. package/lib/shape/shape/shape.js +2 -2
  228. package/lib/shape/shape/shape.js.map +1 -1
  229. package/lib/shape/utils.d.ts +2 -2
  230. package/lib/shape/utils.js +2 -2
  231. package/lib/shape/utils.js.map +1 -1
  232. package/lib/spec/component.d.ts +1 -1
  233. package/lib/spec/composition.d.ts +2 -0
  234. package/lib/spec/coordinate.d.ts +5 -2
  235. package/lib/spec/dataTransform.d.ts +3 -2
  236. package/lib/spec/index.d.ts +1 -0
  237. package/lib/spec/index.js.map +1 -1
  238. package/lib/spec/interaction.d.ts +2 -1
  239. package/lib/spec/mark.d.ts +2 -2
  240. package/lib/transform/index.d.ts +1 -0
  241. package/lib/transform/index.js +3 -1
  242. package/lib/transform/index.js.map +1 -1
  243. package/lib/transform/maybeZeroZ.d.ts +6 -0
  244. package/lib/transform/maybeZeroZ.js +26 -0
  245. package/lib/transform/maybeZeroZ.js.map +1 -0
  246. package/lib/utils/size.d.ts +1 -0
  247. package/lib/utils/size.js +1 -0
  248. package/lib/utils/size.js.map +1 -1
  249. package/package.json +10 -3
  250. package/src/api/chart.ts +3 -3
  251. package/src/api/extend.ts +5 -3
  252. package/src/api/runtime.ts +2 -2
  253. package/src/api/utils.ts +3 -2
  254. package/src/component/axis.ts +65 -9
  255. package/src/component/axisX.ts +8 -3
  256. package/src/component/axisY.ts +8 -3
  257. package/src/component/axisZ.ts +25 -0
  258. package/src/component/index.ts +1 -0
  259. package/src/component/scrollbar.ts +3 -2
  260. package/src/composition/mark.ts +4 -0
  261. package/src/coordinate/cartesian3D.ts +11 -0
  262. package/src/coordinate/index.ts +2 -0
  263. package/src/data/index.ts +2 -0
  264. package/src/data/log.ts +16 -0
  265. package/src/index.ts +1 -1
  266. package/src/interaction/brushFilter.ts +31 -28
  267. package/src/interaction/chartIndex.ts +26 -23
  268. package/src/interaction/event.ts +22 -9
  269. package/src/interaction/fisheye.ts +16 -12
  270. package/src/interaction/legendFilter.ts +45 -40
  271. package/src/interaction/sliderFilter.ts +15 -16
  272. package/src/interaction/tooltip.ts +47 -3
  273. package/src/lib/core.ts +2 -0
  274. package/src/lib/index.ts +1 -0
  275. package/src/lib/threed.ts +11 -0
  276. package/src/mark/index.ts +1 -0
  277. package/src/mark/point3D.ts +90 -0
  278. package/src/mark/utils.ts +7 -0
  279. package/src/runtime/component.ts +6 -0
  280. package/src/runtime/coordinate.ts +18 -10
  281. package/src/runtime/layout.ts +178 -33
  282. package/src/runtime/plot.ts +33 -10
  283. package/src/runtime/render.ts +14 -3
  284. package/src/runtime/types/common.ts +4 -0
  285. package/src/runtime/types/component.ts +10 -1
  286. package/src/runtime/types/options.ts +5 -0
  287. package/src/shape/index.ts +2 -0
  288. package/src/shape/point3D/cube.ts +68 -0
  289. package/src/shape/point3D/sphere.ts +68 -0
  290. package/src/shape/shape/shape.ts +9 -6
  291. package/src/shape/utils.ts +4 -4
  292. package/src/spec/component.ts +1 -1
  293. package/src/spec/composition.ts +2 -0
  294. package/src/spec/coordinate.ts +6 -0
  295. package/src/spec/dataTransform.ts +5 -0
  296. package/src/spec/index.ts +1 -0
  297. package/src/spec/interaction.ts +3 -1
  298. package/src/spec/mark.ts +7 -1
  299. package/src/transform/index.ts +1 -0
  300. package/src/transform/maybeZeroZ.ts +25 -0
  301. package/src/utils/size.ts +2 -0
  302. package/README.en-US.md +0 -99
@@ -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
+ };
@@ -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
- ...rest,
15
- x: x0,
16
- y: y0,
17
- });
13
+ return render(
14
+ {
15
+ ...rest,
16
+ x: x0,
17
+ y: y0,
18
+ },
19
+ context,
20
+ );
18
21
  };
19
22
  };
20
23
 
@@ -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
  }
@@ -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;
@@ -42,8 +42,10 @@ export type ViewComposition = {
42
42
  type?: 'view';
43
43
  x?: number;
44
44
  y?: number;
45
+ z?: number;
45
46
  width?: number;
46
47
  height?: number;
48
+ depth?: number;
47
49
  data?: Data;
48
50
  key?: string;
49
51
  class?: string;
@@ -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
@@ -5,6 +5,7 @@ import { Mark } from './mark';
5
5
  export type G2Spec = (Mark | Composition | AxisComponent | LegendComponent) & {
6
6
  width?: number;
7
7
  height?: number;
8
+ depth?: number;
8
9
  autoFit?: boolean;
9
10
  };
10
11
 
@@ -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 = '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).