@antv/g2 5.0.18 → 5.0.19

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 (490) hide show
  1. package/dist/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +3 -3
  3. package/esm/api/chart.d.ts +1017 -85
  4. package/esm/api/chart.js +3 -259
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition.d.ts +37 -0
  7. package/esm/api/{composition/base.js → composition.js} +17 -5
  8. package/esm/api/composition.js.map +1 -0
  9. package/esm/api/define.d.ts +14 -0
  10. package/esm/api/define.js +92 -0
  11. package/esm/api/define.js.map +1 -0
  12. package/esm/api/extend.d.ts +9 -0
  13. package/esm/api/extend.js +9 -0
  14. package/esm/api/extend.js.map +1 -0
  15. package/esm/api/index.d.ts +2 -0
  16. package/esm/api/index.js +2 -0
  17. package/esm/api/index.js.map +1 -1
  18. package/esm/api/library.d.ts +170 -1
  19. package/esm/api/library.js +2 -2
  20. package/esm/api/library.js.map +1 -1
  21. package/esm/api/mark.d.ts +29 -0
  22. package/esm/api/{mark/base.js → mark.js} +16 -4
  23. package/esm/api/mark.js.map +1 -0
  24. package/esm/api/node.d.ts +2 -2
  25. package/esm/api/node.js.map +1 -1
  26. package/esm/api/props.d.ts +170 -12
  27. package/esm/api/props.js +21 -102
  28. package/esm/api/props.js.map +1 -1
  29. package/esm/api/runtime.d.ts +66 -0
  30. package/esm/api/runtime.js +294 -0
  31. package/esm/api/runtime.js.map +1 -0
  32. package/esm/api/types.d.ts +60 -5
  33. package/esm/api/utils.d.ts +1 -1
  34. package/esm/api/utils.js +11 -13
  35. package/esm/api/utils.js.map +1 -1
  36. package/esm/component/axis.js +7 -4
  37. package/esm/component/axis.js.map +1 -1
  38. package/esm/component/legendCategory.js +4 -5
  39. package/esm/component/legendCategory.js.map +1 -1
  40. package/esm/composition/d3Projection.js.map +1 -0
  41. package/esm/composition/geoPath.js.map +1 -0
  42. package/esm/{geo → composition}/geoView.js +1 -1
  43. package/esm/composition/geoView.js.map +1 -0
  44. package/esm/composition/index.d.ts +2 -0
  45. package/esm/composition/index.js +2 -0
  46. package/esm/composition/index.js.map +1 -1
  47. package/esm/index.d.ts +4 -3
  48. package/esm/index.js +3 -2
  49. package/esm/index.js.map +1 -1
  50. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  51. package/esm/lib/core.d.ts +158 -0
  52. package/esm/lib/core.js +174 -0
  53. package/esm/lib/core.js.map +1 -0
  54. package/esm/lib/geo.d.ts +4 -0
  55. package/esm/lib/geo.js +9 -0
  56. package/esm/lib/geo.js.map +1 -0
  57. package/esm/lib/graph.d.ts +4 -0
  58. package/esm/lib/graph.js +8 -0
  59. package/esm/lib/graph.js.map +1 -0
  60. package/esm/lib/index.d.ts +6 -0
  61. package/esm/lib/index.js +7 -0
  62. package/esm/lib/index.js.map +1 -0
  63. package/esm/lib/lite.d.ts +64 -0
  64. package/esm/lib/lite.js +78 -0
  65. package/esm/lib/lite.js.map +1 -0
  66. package/esm/lib/plot.d.ts +11 -0
  67. package/esm/lib/plot.js +16 -0
  68. package/esm/lib/plot.js.map +1 -0
  69. package/esm/lib/std.d.ts +170 -0
  70. package/esm/lib/std.js +8 -0
  71. package/esm/lib/std.js.map +1 -0
  72. package/esm/mark/area.js +14 -5
  73. package/esm/mark/area.js.map +1 -1
  74. package/esm/mark/box.js +9 -2
  75. package/esm/mark/box.js.map +1 -1
  76. package/esm/mark/cell.js +11 -5
  77. package/esm/mark/cell.js.map +1 -1
  78. package/esm/mark/connector.js +6 -2
  79. package/esm/mark/connector.js.map +1 -1
  80. package/esm/mark/density.js +10 -7
  81. package/esm/mark/density.js.map +1 -1
  82. package/esm/mark/forceGraph.js +0 -3
  83. package/esm/mark/forceGraph.js.map +1 -1
  84. package/esm/mark/heatmap.js +9 -4
  85. package/esm/mark/heatmap.js.map +1 -1
  86. package/esm/mark/image.js +9 -4
  87. package/esm/mark/image.js.map +1 -1
  88. package/esm/mark/interval.js +13 -7
  89. package/esm/mark/interval.js.map +1 -1
  90. package/esm/mark/line.js +15 -4
  91. package/esm/mark/line.js.map +1 -1
  92. package/esm/mark/lineX.js +8 -3
  93. package/esm/mark/lineX.js.map +1 -1
  94. package/esm/mark/lineY.js +8 -3
  95. package/esm/mark/lineY.js.map +1 -1
  96. package/esm/mark/link.js +12 -4
  97. package/esm/mark/link.js.map +1 -1
  98. package/esm/mark/path.js +7 -2
  99. package/esm/mark/path.js.map +1 -1
  100. package/esm/mark/point.js +28 -29
  101. package/esm/mark/point.js.map +1 -1
  102. package/esm/mark/polygon.js +7 -2
  103. package/esm/mark/polygon.js.map +1 -1
  104. package/esm/mark/range.js +4 -2
  105. package/esm/mark/range.js.map +1 -1
  106. package/esm/mark/rangeX.js +6 -2
  107. package/esm/mark/rangeX.js.map +1 -1
  108. package/esm/mark/rangeY.js +6 -2
  109. package/esm/mark/rangeY.js.map +1 -1
  110. package/esm/mark/rect.js +9 -3
  111. package/esm/mark/rect.js.map +1 -1
  112. package/esm/mark/shape.js +9 -3
  113. package/esm/mark/shape.js.map +1 -1
  114. package/esm/mark/text.js +10 -4
  115. package/esm/mark/text.js.map +1 -1
  116. package/esm/mark/treemap.js.map +1 -1
  117. package/esm/mark/utils.d.ts +11 -8
  118. package/esm/mark/utils.js +8 -7
  119. package/esm/mark/utils.js.map +1 -1
  120. package/esm/mark/vector.js +6 -2
  121. package/esm/mark/vector.js.map +1 -1
  122. package/esm/runtime/index.d.ts +1 -1
  123. package/esm/runtime/index.js +1 -1
  124. package/esm/runtime/index.js.map +1 -1
  125. package/esm/runtime/plot.js +11 -7
  126. package/esm/runtime/plot.js.map +1 -1
  127. package/esm/runtime/render.js +3 -6
  128. package/esm/runtime/render.js.map +1 -1
  129. package/esm/runtime/types/component.d.ts +1 -1
  130. package/esm/runtime/types/mark.d.ts +4 -0
  131. package/esm/runtime/types/options.d.ts +4 -1
  132. package/esm/shape/index.d.ts +106 -101
  133. package/esm/shape/index.js +58 -53
  134. package/esm/shape/index.js.map +1 -1
  135. package/esm/shape/text/advance.js +3 -3
  136. package/esm/shape/text/advance.js.map +1 -1
  137. package/esm/spec/composition.d.ts +7 -0
  138. package/esm/spec/index.d.ts +1 -0
  139. package/esm/spec/index.js.map +1 -1
  140. package/esm/spec/interaction.d.ts +2 -0
  141. package/esm/theme/academy.js +6 -6
  142. package/esm/theme/classic.js +6 -7
  143. package/esm/theme/classic.js.map +1 -1
  144. package/esm/theme/classicDark.js +6 -6
  145. package/esm/utils/coordinate.d.ts +2 -2
  146. package/esm/utils/scale.d.ts +1 -1
  147. package/esm/utils/scale.js +1 -1
  148. package/esm/utils/scale.js.map +1 -1
  149. package/lib/api/chart.d.ts +1017 -85
  150. package/lib/api/chart.js +4 -263
  151. package/lib/api/chart.js.map +1 -1
  152. package/lib/api/composition.d.ts +37 -0
  153. package/lib/api/{composition/base.js → composition.js} +16 -5
  154. package/lib/api/composition.js.map +1 -0
  155. package/lib/api/define.d.ts +14 -0
  156. package/lib/api/define.js +97 -0
  157. package/lib/api/define.js.map +1 -0
  158. package/lib/api/extend.d.ts +9 -0
  159. package/lib/api/extend.js +13 -0
  160. package/lib/api/extend.js.map +1 -0
  161. package/lib/api/index.d.ts +2 -0
  162. package/lib/api/index.js +5 -1
  163. package/lib/api/index.js.map +1 -1
  164. package/lib/api/library.d.ts +170 -1
  165. package/lib/api/library.js +2 -2
  166. package/lib/api/library.js.map +1 -1
  167. package/lib/api/mark.d.ts +29 -0
  168. package/lib/api/{mark/base.js → mark.js} +15 -4
  169. package/lib/api/mark.js.map +1 -0
  170. package/lib/api/node.d.ts +2 -2
  171. package/lib/api/node.js.map +1 -1
  172. package/lib/api/props.d.ts +170 -12
  173. package/lib/api/props.js +22 -106
  174. package/lib/api/props.js.map +1 -1
  175. package/lib/api/runtime.d.ts +66 -0
  176. package/lib/api/runtime.js +301 -0
  177. package/lib/api/runtime.js.map +1 -0
  178. package/lib/api/types.d.ts +60 -5
  179. package/lib/api/utils.d.ts +1 -1
  180. package/lib/api/utils.js +14 -16
  181. package/lib/api/utils.js.map +1 -1
  182. package/lib/component/axis.js +7 -4
  183. package/lib/component/axis.js.map +1 -1
  184. package/lib/component/legendCategory.js +4 -5
  185. package/lib/component/legendCategory.js.map +1 -1
  186. package/lib/composition/d3Projection.js.map +1 -0
  187. package/lib/composition/geoPath.js.map +1 -0
  188. package/lib/{geo → composition}/geoView.js +1 -1
  189. package/lib/composition/geoView.js.map +1 -0
  190. package/lib/composition/index.d.ts +2 -0
  191. package/lib/composition/index.js +5 -1
  192. package/lib/composition/index.js.map +1 -1
  193. package/lib/index.d.ts +4 -3
  194. package/lib/index.js +8 -3
  195. package/lib/index.js.map +1 -1
  196. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  197. package/lib/lib/core.d.ts +158 -0
  198. package/lib/lib/core.js +178 -0
  199. package/lib/lib/core.js.map +1 -0
  200. package/lib/lib/geo.d.ts +4 -0
  201. package/lib/lib/geo.js +13 -0
  202. package/lib/lib/geo.js.map +1 -0
  203. package/lib/lib/graph.d.ts +4 -0
  204. package/lib/lib/graph.js +12 -0
  205. package/lib/lib/graph.js.map +1 -0
  206. package/lib/lib/index.d.ts +6 -0
  207. package/lib/lib/index.js +16 -0
  208. package/lib/lib/index.js.map +1 -0
  209. package/lib/lib/lite.d.ts +64 -0
  210. package/lib/lib/lite.js +82 -0
  211. package/lib/lib/lite.js.map +1 -0
  212. package/lib/lib/plot.d.ts +11 -0
  213. package/lib/lib/plot.js +20 -0
  214. package/lib/lib/plot.js.map +1 -0
  215. package/lib/lib/std.d.ts +170 -0
  216. package/lib/lib/std.js +12 -0
  217. package/lib/lib/std.js.map +1 -0
  218. package/lib/mark/area.js +14 -5
  219. package/lib/mark/area.js.map +1 -1
  220. package/lib/mark/box.js +9 -2
  221. package/lib/mark/box.js.map +1 -1
  222. package/lib/mark/cell.js +11 -5
  223. package/lib/mark/cell.js.map +1 -1
  224. package/lib/mark/connector.js +6 -2
  225. package/lib/mark/connector.js.map +1 -1
  226. package/lib/mark/density.js +10 -7
  227. package/lib/mark/density.js.map +1 -1
  228. package/lib/mark/forceGraph.js +0 -3
  229. package/lib/mark/forceGraph.js.map +1 -1
  230. package/lib/mark/heatmap.js +9 -4
  231. package/lib/mark/heatmap.js.map +1 -1
  232. package/lib/mark/image.js +9 -4
  233. package/lib/mark/image.js.map +1 -1
  234. package/lib/mark/interval.js +13 -7
  235. package/lib/mark/interval.js.map +1 -1
  236. package/lib/mark/line.js +15 -4
  237. package/lib/mark/line.js.map +1 -1
  238. package/lib/mark/lineX.js +8 -3
  239. package/lib/mark/lineX.js.map +1 -1
  240. package/lib/mark/lineY.js +8 -3
  241. package/lib/mark/lineY.js.map +1 -1
  242. package/lib/mark/link.js +12 -4
  243. package/lib/mark/link.js.map +1 -1
  244. package/lib/mark/path.js +7 -2
  245. package/lib/mark/path.js.map +1 -1
  246. package/lib/mark/point.js +28 -29
  247. package/lib/mark/point.js.map +1 -1
  248. package/lib/mark/polygon.js +7 -2
  249. package/lib/mark/polygon.js.map +1 -1
  250. package/lib/mark/range.js +4 -2
  251. package/lib/mark/range.js.map +1 -1
  252. package/lib/mark/rangeX.js +6 -2
  253. package/lib/mark/rangeX.js.map +1 -1
  254. package/lib/mark/rangeY.js +6 -2
  255. package/lib/mark/rangeY.js.map +1 -1
  256. package/lib/mark/rect.js +9 -3
  257. package/lib/mark/rect.js.map +1 -1
  258. package/lib/mark/shape.js +9 -3
  259. package/lib/mark/shape.js.map +1 -1
  260. package/lib/mark/text.js +10 -4
  261. package/lib/mark/text.js.map +1 -1
  262. package/lib/mark/treemap.js.map +1 -1
  263. package/lib/mark/utils.d.ts +11 -8
  264. package/lib/mark/utils.js +8 -7
  265. package/lib/mark/utils.js.map +1 -1
  266. package/lib/mark/vector.js +6 -2
  267. package/lib/mark/vector.js.map +1 -1
  268. package/lib/runtime/index.d.ts +1 -1
  269. package/lib/runtime/index.js +4 -4
  270. package/lib/runtime/index.js.map +1 -1
  271. package/lib/runtime/plot.js +11 -7
  272. package/lib/runtime/plot.js.map +1 -1
  273. package/lib/runtime/render.js +3 -6
  274. package/lib/runtime/render.js.map +1 -1
  275. package/lib/runtime/types/component.d.ts +1 -1
  276. package/lib/runtime/types/mark.d.ts +4 -0
  277. package/lib/runtime/types/options.d.ts +4 -1
  278. package/lib/shape/index.d.ts +106 -101
  279. package/lib/shape/index.js +71 -61
  280. package/lib/shape/index.js.map +1 -1
  281. package/lib/shape/text/advance.js +3 -3
  282. package/lib/shape/text/advance.js.map +1 -1
  283. package/lib/spec/composition.d.ts +7 -0
  284. package/lib/spec/index.d.ts +1 -0
  285. package/lib/spec/index.js.map +1 -1
  286. package/lib/spec/interaction.d.ts +2 -0
  287. package/lib/theme/academy.js +6 -6
  288. package/lib/theme/classic.js +6 -7
  289. package/lib/theme/classic.js.map +1 -1
  290. package/lib/theme/classicDark.js +6 -6
  291. package/lib/utils/coordinate.d.ts +2 -2
  292. package/lib/utils/scale.d.ts +1 -1
  293. package/lib/utils/scale.js +1 -1
  294. package/lib/utils/scale.js.map +1 -1
  295. package/package.json +8 -7
  296. package/src/api/chart.ts +5 -341
  297. package/src/api/{composition/base.ts → composition.ts} +16 -8
  298. package/src/api/define.ts +128 -0
  299. package/src/api/extend.ts +34 -0
  300. package/src/api/index.ts +2 -0
  301. package/src/api/library.ts +2 -2
  302. package/src/api/{mark/base.ts → mark.ts} +10 -7
  303. package/src/api/node.ts +3 -3
  304. package/src/api/props.ts +30 -114
  305. package/src/api/runtime.ts +366 -0
  306. package/src/api/types.ts +95 -17
  307. package/src/api/utils.ts +28 -11
  308. package/src/component/axis.ts +10 -5
  309. package/src/component/legendCategory.ts +4 -6
  310. package/src/{geo → composition}/geoView.ts +1 -1
  311. package/src/composition/index.ts +2 -0
  312. package/src/index.ts +12 -3
  313. package/src/label-transform/overlapDodgeY.ts +0 -1
  314. package/src/{stdlib/index.ts → lib/core.ts} +74 -258
  315. package/src/lib/geo.ts +9 -0
  316. package/src/lib/graph.ts +8 -0
  317. package/src/lib/index.ts +6 -0
  318. package/src/lib/lite.ts +127 -0
  319. package/src/lib/plot.ts +16 -0
  320. package/src/lib/std.ts +13 -0
  321. package/src/mark/area.ts +15 -6
  322. package/src/mark/box.ts +10 -2
  323. package/src/mark/cell.ts +12 -6
  324. package/src/mark/connector.ts +7 -3
  325. package/src/mark/density.ts +11 -8
  326. package/src/mark/forceGraph.ts +0 -3
  327. package/src/mark/heatmap.ts +10 -5
  328. package/src/mark/image.ts +10 -5
  329. package/src/mark/interval.ts +22 -10
  330. package/src/mark/line.ts +23 -5
  331. package/src/mark/lineX.ts +9 -4
  332. package/src/mark/lineY.ts +9 -4
  333. package/src/mark/link.ts +13 -5
  334. package/src/mark/path.ts +8 -3
  335. package/src/mark/point.ts +49 -30
  336. package/src/mark/polygon.ts +8 -3
  337. package/src/mark/range.ts +5 -3
  338. package/src/mark/rangeX.ts +7 -3
  339. package/src/mark/rangeY.ts +7 -3
  340. package/src/mark/rect.ts +10 -4
  341. package/src/mark/shape.ts +14 -3
  342. package/src/mark/text.ts +11 -5
  343. package/src/mark/treemap.ts +0 -1
  344. package/src/mark/utils.ts +9 -8
  345. package/src/mark/vector.ts +7 -3
  346. package/src/runtime/index.ts +1 -1
  347. package/src/runtime/plot.ts +19 -10
  348. package/src/runtime/render.ts +3 -6
  349. package/src/runtime/types/component.ts +1 -2
  350. package/src/runtime/types/mark.ts +4 -0
  351. package/src/runtime/types/options.ts +4 -1
  352. package/src/shape/index.ts +106 -110
  353. package/src/shape/text/advance.ts +1 -2
  354. package/src/spec/composition.ts +7 -0
  355. package/src/spec/index.ts +1 -0
  356. package/src/spec/interaction.ts +2 -0
  357. package/src/theme/academy.ts +6 -6
  358. package/src/theme/classic.ts +6 -7
  359. package/src/theme/classicDark.ts +6 -6
  360. package/src/utils/scale.ts +1 -1
  361. package/esm/api/composition/base.d.ts +0 -28
  362. package/esm/api/composition/base.js.map +0 -1
  363. package/esm/api/composition/facetCircle.d.ts +0 -17
  364. package/esm/api/composition/facetCircle.js +0 -27
  365. package/esm/api/composition/facetCircle.js.map +0 -1
  366. package/esm/api/composition/facetRect.d.ts +0 -17
  367. package/esm/api/composition/facetRect.js +0 -27
  368. package/esm/api/composition/facetRect.js.map +0 -1
  369. package/esm/api/composition/geoPath.d.ts +0 -20
  370. package/esm/api/composition/geoPath.js +0 -30
  371. package/esm/api/composition/geoPath.js.map +0 -1
  372. package/esm/api/composition/geoView.d.ts +0 -19
  373. package/esm/api/composition/geoView.js +0 -28
  374. package/esm/api/composition/geoView.js.map +0 -1
  375. package/esm/api/composition/index.d.ts +0 -33
  376. package/esm/api/composition/index.js +0 -32
  377. package/esm/api/composition/index.js.map +0 -1
  378. package/esm/api/composition/repeatMatrix.d.ts +0 -17
  379. package/esm/api/composition/repeatMatrix.js +0 -27
  380. package/esm/api/composition/repeatMatrix.js.map +0 -1
  381. package/esm/api/composition/spaceFlex.d.ts +0 -12
  382. package/esm/api/composition/spaceFlex.js +0 -19
  383. package/esm/api/composition/spaceFlex.js.map +0 -1
  384. package/esm/api/composition/spaceLayer.d.ts +0 -12
  385. package/esm/api/composition/spaceLayer.js +0 -19
  386. package/esm/api/composition/spaceLayer.js.map +0 -1
  387. package/esm/api/composition/timingKeyframe.d.ts +0 -11
  388. package/esm/api/composition/timingKeyframe.js +0 -19
  389. package/esm/api/composition/timingKeyframe.js.map +0 -1
  390. package/esm/api/composition/view.d.ts +0 -19
  391. package/esm/api/composition/view.js +0 -29
  392. package/esm/api/composition/view.js.map +0 -1
  393. package/esm/api/mark/base.d.ts +0 -22
  394. package/esm/api/mark/base.js.map +0 -1
  395. package/esm/api/mark/index.d.ts +0 -75
  396. package/esm/api/mark/index.js +0 -39
  397. package/esm/api/mark/index.js.map +0 -1
  398. package/esm/api/mark/mark.d.ts +0 -212
  399. package/esm/api/mark/mark.js +0 -339
  400. package/esm/api/mark/mark.js.map +0 -1
  401. package/esm/api/mark/types.d.ts +0 -26
  402. package/esm/api/mark/types.js +0 -2
  403. package/esm/api/mark/types.js.map +0 -1
  404. package/esm/geo/d3Projection.js.map +0 -1
  405. package/esm/geo/geoPath.js.map +0 -1
  406. package/esm/geo/geoView.js.map +0 -1
  407. package/esm/geo/index.d.ts +0 -9
  408. package/esm/geo/index.js +0 -8
  409. package/esm/geo/index.js.map +0 -1
  410. package/esm/stdlib/index.d.ts +0 -2
  411. package/esm/stdlib/index.js +0 -21
  412. package/esm/stdlib/index.js.map +0 -1
  413. package/lib/api/composition/base.d.ts +0 -28
  414. package/lib/api/composition/base.js.map +0 -1
  415. package/lib/api/composition/facetCircle.d.ts +0 -17
  416. package/lib/api/composition/facetCircle.js +0 -30
  417. package/lib/api/composition/facetCircle.js.map +0 -1
  418. package/lib/api/composition/facetRect.d.ts +0 -17
  419. package/lib/api/composition/facetRect.js +0 -30
  420. package/lib/api/composition/facetRect.js.map +0 -1
  421. package/lib/api/composition/geoPath.d.ts +0 -20
  422. package/lib/api/composition/geoPath.js +0 -33
  423. package/lib/api/composition/geoPath.js.map +0 -1
  424. package/lib/api/composition/geoView.d.ts +0 -19
  425. package/lib/api/composition/geoView.js +0 -31
  426. package/lib/api/composition/geoView.js.map +0 -1
  427. package/lib/api/composition/index.d.ts +0 -33
  428. package/lib/api/composition/index.js +0 -44
  429. package/lib/api/composition/index.js.map +0 -1
  430. package/lib/api/composition/repeatMatrix.d.ts +0 -17
  431. package/lib/api/composition/repeatMatrix.js +0 -30
  432. package/lib/api/composition/repeatMatrix.js.map +0 -1
  433. package/lib/api/composition/spaceFlex.d.ts +0 -12
  434. package/lib/api/composition/spaceFlex.js +0 -22
  435. package/lib/api/composition/spaceFlex.js.map +0 -1
  436. package/lib/api/composition/spaceLayer.d.ts +0 -12
  437. package/lib/api/composition/spaceLayer.js +0 -22
  438. package/lib/api/composition/spaceLayer.js.map +0 -1
  439. package/lib/api/composition/timingKeyframe.d.ts +0 -11
  440. package/lib/api/composition/timingKeyframe.js +0 -22
  441. package/lib/api/composition/timingKeyframe.js.map +0 -1
  442. package/lib/api/composition/view.d.ts +0 -19
  443. package/lib/api/composition/view.js +0 -32
  444. package/lib/api/composition/view.js.map +0 -1
  445. package/lib/api/mark/base.d.ts +0 -22
  446. package/lib/api/mark/base.js.map +0 -1
  447. package/lib/api/mark/index.d.ts +0 -75
  448. package/lib/api/mark/index.js +0 -43
  449. package/lib/api/mark/index.js.map +0 -1
  450. package/lib/api/mark/mark.d.ts +0 -212
  451. package/lib/api/mark/mark.js +0 -342
  452. package/lib/api/mark/mark.js.map +0 -1
  453. package/lib/api/mark/types.d.ts +0 -26
  454. package/lib/api/mark/types.js +0 -3
  455. package/lib/api/mark/types.js.map +0 -1
  456. package/lib/geo/d3Projection.js.map +0 -1
  457. package/lib/geo/geoPath.js.map +0 -1
  458. package/lib/geo/geoView.js.map +0 -1
  459. package/lib/geo/index.d.ts +0 -9
  460. package/lib/geo/index.js +0 -12
  461. package/lib/geo/index.js.map +0 -1
  462. package/lib/stdlib/index.d.ts +0 -2
  463. package/lib/stdlib/index.js +0 -25
  464. package/lib/stdlib/index.js.map +0 -1
  465. package/src/api/composition/facetCircle.ts +0 -36
  466. package/src/api/composition/facetRect.ts +0 -36
  467. package/src/api/composition/geoPath.ts +0 -37
  468. package/src/api/composition/geoView.ts +0 -39
  469. package/src/api/composition/index.ts +0 -57
  470. package/src/api/composition/repeatMatrix.ts +0 -36
  471. package/src/api/composition/spaceFlex.ts +0 -18
  472. package/src/api/composition/spaceLayer.ts +0 -18
  473. package/src/api/composition/timingKeyframe.ts +0 -16
  474. package/src/api/composition/view.ts +0 -42
  475. package/src/api/mark/index.ts +0 -113
  476. package/src/api/mark/mark.ts +0 -439
  477. package/src/api/mark/types.ts +0 -31
  478. package/src/geo/index.ts +0 -12
  479. /package/esm/{geo → composition}/d3Projection.d.ts +0 -0
  480. /package/esm/{geo → composition}/d3Projection.js +0 -0
  481. /package/esm/{geo → composition}/geoPath.d.ts +0 -0
  482. /package/esm/{geo → composition}/geoPath.js +0 -0
  483. /package/esm/{geo → composition}/geoView.d.ts +0 -0
  484. /package/lib/{geo → composition}/d3Projection.d.ts +0 -0
  485. /package/lib/{geo → composition}/d3Projection.js +0 -0
  486. /package/lib/{geo → composition}/geoPath.d.ts +0 -0
  487. /package/lib/{geo → composition}/geoPath.js +0 -0
  488. /package/lib/{geo → composition}/geoView.d.ts +0 -0
  489. /package/src/{geo → composition}/d3Projection.ts +0 -0
  490. /package/src/{geo → composition}/geoPath.ts +0 -0
@@ -1,14 +1,22 @@
1
1
  import { Coordinate } from '@antv/coord';
2
2
  import { DisplayObject } from '@antv/g';
3
- import { Scale, G2Theme, G2ViewDescriptor } from '../../runtime';
4
- import { hide, show } from '../../utils/style';
5
- import { Node } from '../node';
3
+ import { Scale, G2Theme, G2ViewDescriptor } from '../runtime';
4
+ import { hide, show } from '../utils/style';
5
+ import { Composition as Spec } from '../spec';
6
+ import { Node } from './node';
7
+ import { defineProps } from './define';
8
+ import { compositionProps } from './props';
9
+ import { PropsOf } from './types';
6
10
 
7
- export class CompositionNode<
8
- Value extends Record<string, any> = Record<string, any>,
9
- ParentValue extends Record<string, any> = Record<string, any>,
10
- ChildValue extends Record<string, any> = Record<string, any>,
11
- > extends Node<Value, ParentValue, ChildValue> {
11
+ export interface CompositionNode<T = any>
12
+ extends PropsOf<
13
+ typeof compositionProps,
14
+ any, // todo Remove this when update types of Spec.
15
+ CompositionNode & T
16
+ > {}
17
+
18
+ @defineProps(compositionProps)
19
+ export class CompositionNode extends Node<Spec & { [key: string]: any }> {
12
20
  protected _key: string;
13
21
 
14
22
  /**
@@ -0,0 +1,128 @@
1
+ import { isStrictObject } from '../utils/helper';
2
+ import { Node } from './node';
3
+
4
+ export type NodePropertyDescriptor = {
5
+ type: 'object' | 'value' | 'array' | 'node' | 'container' | 'mix';
6
+ key?: string;
7
+ ctor?: new (...args: any[]) => any;
8
+ };
9
+
10
+ type NodeClass = new (props: any, type?: string) => Node;
11
+
12
+ function defineValueProp(
13
+ Node: NodeClass,
14
+ name: string,
15
+ { key = name }: NodePropertyDescriptor,
16
+ ) {
17
+ Node.prototype[name] = function (value) {
18
+ if (arguments.length === 0) return this.attr(key);
19
+ return this.attr(key, value);
20
+ };
21
+ }
22
+
23
+ function defineArrayProp(
24
+ Node: NodeClass,
25
+ name: string,
26
+ { key = name }: NodePropertyDescriptor,
27
+ ) {
28
+ Node.prototype[name] = function (value) {
29
+ if (arguments.length === 0) return this.attr(key);
30
+ if (Array.isArray(value)) return this.attr(key, value);
31
+ const array = [...(this.attr(key) || []), value];
32
+ return this.attr(key, array);
33
+ };
34
+ }
35
+
36
+ function defineObjectProp(
37
+ Node: NodeClass,
38
+ name: string,
39
+ { key: k = name }: NodePropertyDescriptor,
40
+ ) {
41
+ Node.prototype[name] = function (key, value) {
42
+ if (arguments.length === 0) return this.attr(k);
43
+ if (arguments.length === 1 && typeof key !== 'string') {
44
+ return this.attr(k, key);
45
+ }
46
+ const obj = this.attr(k) || {};
47
+ obj[key] = arguments.length === 1 ? true : value;
48
+ return this.attr(k, obj);
49
+ };
50
+ }
51
+
52
+ function defineMixProp(
53
+ Node: NodeClass,
54
+ name: string,
55
+ descriptor: NodePropertyDescriptor,
56
+ ) {
57
+ Node.prototype[name] = function (key) {
58
+ if (arguments.length === 0) return this.attr(name);
59
+ if (Array.isArray(key)) return this.attr(name, { items: key });
60
+ if (
61
+ isStrictObject(key) &&
62
+ (key.title !== undefined || key.items !== undefined)
63
+ ) {
64
+ return this.attr(name, key);
65
+ }
66
+ if (key === null || key === false) return this.attr(name, key);
67
+ const obj = this.attr(name) || {};
68
+ const { items = [] } = obj;
69
+ items.push(key);
70
+ obj.items = items;
71
+ return this.attr(name, obj);
72
+ };
73
+ }
74
+
75
+ function defineNodeProp(
76
+ Node: NodeClass,
77
+ name: string,
78
+ { ctor }: NodePropertyDescriptor,
79
+ ) {
80
+ Node.prototype[name] = function (hocMark?) {
81
+ const node = this.append(ctor);
82
+ if (name === 'mark') {
83
+ node.type = hocMark;
84
+ }
85
+ return node;
86
+ };
87
+ }
88
+
89
+ function defineContainerProp(
90
+ Node: NodeClass,
91
+ name: string,
92
+ { ctor }: NodePropertyDescriptor,
93
+ ) {
94
+ Node.prototype[name] = function () {
95
+ this.type = null;
96
+ return this.append(ctor);
97
+ };
98
+ }
99
+
100
+ /**
101
+ * A decorator to define different type of attribute setter or
102
+ * getter for current node.
103
+ */
104
+ export function defineProps(
105
+ descriptors: Record<string, NodePropertyDescriptor>,
106
+ ) {
107
+ return (Node: NodeClass) => {
108
+ for (const [name, descriptor] of Object.entries(descriptors)) {
109
+ const { type } = descriptor;
110
+ if (type === 'value') defineValueProp(Node, name, descriptor);
111
+ else if (type === 'array') defineArrayProp(Node, name, descriptor);
112
+ else if (type === 'object') defineObjectProp(Node, name, descriptor);
113
+ else if (type === 'node') defineNodeProp(Node, name, descriptor);
114
+ else if (type === 'container')
115
+ defineContainerProp(Node, name, descriptor);
116
+ else if (type === 'mix') defineMixProp(Node, name, descriptor);
117
+ }
118
+ return Node as any;
119
+ };
120
+ }
121
+
122
+ export function nodeProps(
123
+ node: Record<string, new (...args: any[]) => any>,
124
+ ): Record<string, NodePropertyDescriptor> {
125
+ return Object.fromEntries(
126
+ Object.entries(node).map(([name, ctor]) => [name, { type: 'node', ctor }]),
127
+ );
128
+ }
@@ -0,0 +1,34 @@
1
+ import { G2Spec } from '../spec';
2
+ import { G2Library } from '../runtime';
3
+ import { Runtime, RuntimeOptions } from './runtime';
4
+ import { MarkOf, CompositionOf as Of } from './types';
5
+ import { MarkNode } from './mark';
6
+ import { CompositionNode } from './composition';
7
+
8
+ type CompositionOf<Library> = Of<
9
+ Library,
10
+ (
11
+ composite?,
12
+ ) => CompositionNode<
13
+ CompositionOf<Library> & MarkOf<Library, (composite?) => MarkNode>
14
+ > &
15
+ MarkOf<Library, (composite?) => MarkNode> &
16
+ CompositionOf<Library>
17
+ >;
18
+
19
+ export function extend<
20
+ Spec extends G2Spec = G2Spec,
21
+ Library extends G2Library = G2Library,
22
+ >(
23
+ Runtime: new (options: RuntimeOptions) => Runtime<Spec>,
24
+ library: Library,
25
+ ): new (options?: RuntimeOptions) => Runtime<Spec> &
26
+ MarkOf<Library, (composite?) => MarkNode> &
27
+ CompositionOf<Library> {
28
+ class Chart extends Runtime {
29
+ constructor(options: Omit<RuntimeOptions, 'lib'>) {
30
+ super({ ...options, lib: library });
31
+ }
32
+ }
33
+ return Chart as any;
34
+ }
package/src/api/index.ts CHANGED
@@ -2,3 +2,5 @@ export { Chart } from './chart';
2
2
  export { MarkNode } from './mark';
3
3
  export { CompositionNode } from './composition';
4
4
  export { register } from './library';
5
+ export { Runtime } from './runtime';
6
+ export { extend } from './extend';
@@ -1,7 +1,7 @@
1
- import { createLibrary } from '../stdlib';
1
+ import { stdlib } from '../lib/std';
2
2
  import { G2ComponentNamespaces, G2Component } from '../runtime';
3
3
 
4
- export const library = createLibrary();
4
+ export const library = stdlib();
5
5
 
6
6
  // @todo Warn if override existing key.
7
7
  export function register(
@@ -1,12 +1,15 @@
1
1
  import { DisplayObject } from '@antv/g';
2
- import { Node } from '../node';
3
- import { G2MarkState, Scale } from '../../runtime';
2
+ import { G2MarkState, Scale } from '../runtime';
3
+ import { Mark as Spec } from '../spec';
4
+ import { Node } from './node';
5
+ import { defineProps } from './define';
6
+ import { markProps } from './props';
7
+ import { PropsOf } from './types';
4
8
 
5
- export class MarkNode<
6
- Value extends Record<string, any> = Record<string, any>,
7
- ParentValue extends Record<string, any> = Record<string, any>,
8
- ChildValue extends Record<string, any> = Record<string, any>,
9
- > extends Node<Value, ParentValue, ChildValue> {
9
+ export interface MarkNode extends PropsOf<typeof markProps, Spec, MarkNode> {}
10
+
11
+ @defineProps(markProps)
12
+ export class MarkNode extends Node<Spec & { [key: string]: any }> {
10
13
  changeData(data: any) {
11
14
  const chart = this.getRoot();
12
15
  if (!chart) return;
package/src/api/node.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Chart } from './chart';
1
+ import { Runtime } from './runtime';
2
2
 
3
3
  /**
4
4
  * BFS nodes and execute callback.
@@ -140,12 +140,12 @@ export class Node<
140
140
  return this;
141
141
  }
142
142
 
143
- getRoot(): Chart {
143
+ getRoot(): Runtime {
144
144
  // Find the root chart and render.
145
145
  let root: Node = this;
146
146
  while (root && root.parentNode) {
147
147
  root = root.parentNode;
148
148
  }
149
- return root as Chart;
149
+ return root as Runtime;
150
150
  }
151
151
  }
package/src/api/props.ts CHANGED
@@ -1,114 +1,30 @@
1
- import { isStrictObject } from '../utils/helper';
2
-
3
- export type NodePropertyDescriptor = {
4
- type: 'object' | 'value' | 'array' | 'node' | 'container' | 'mix';
5
- name: string;
6
- key?: string;
7
- ctor?: new (...args: any[]) => any;
8
- };
9
-
10
- function defineValueProp(Node, { name, key = name }: NodePropertyDescriptor) {
11
- Node.prototype[name] = function (value) {
12
- if (arguments.length === 0) return this.attr(key);
13
- return this.attr(key, value);
14
- };
15
- }
16
-
17
- function defineArrayProp(Node, { name, key = name }: NodePropertyDescriptor) {
18
- Node.prototype[name] = function (value) {
19
- if (arguments.length === 0) return this.attr(key);
20
- if (Array.isArray(value)) return this.attr(key, value);
21
- const array = [...(this.attr(key) || []), value];
22
- return this.attr(key, array);
23
- };
24
- }
25
-
26
- function defineObjectProp(
27
- Node,
28
- { name, key: k = name }: NodePropertyDescriptor,
29
- ) {
30
- Node.prototype[name] = function (key, value) {
31
- if (arguments.length === 0) return this.attr(k);
32
- if (arguments.length === 1 && typeof key !== 'string') {
33
- return this.attr(k, key);
34
- }
35
- const obj = this.attr(k) || {};
36
- obj[key] = arguments.length === 1 ? true : value;
37
- return this.attr(k, obj);
38
- };
39
- }
40
-
41
- function defineMixProp(Node, { name }: NodePropertyDescriptor) {
42
- Node.prototype[name] = function (key) {
43
- if (arguments.length === 0) return this.attr(name);
44
- if (Array.isArray(key)) return this.attr(name, { items: key });
45
- if (
46
- isStrictObject(key) &&
47
- (key.title !== undefined || key.items !== undefined)
48
- ) {
49
- return this.attr(name, key);
50
- }
51
- if (key === null || key === false) return this.attr(name, key);
52
- const obj = this.attr(name) || {};
53
- const { items = [] } = obj;
54
- items.push(key);
55
- obj.items = items;
56
- return this.attr(name, obj);
57
- };
58
- }
59
-
60
- function defineNodeProp(Node, { name, ctor }: NodePropertyDescriptor) {
61
- Node.prototype[name] = function (hocMark?) {
62
- const node = this.append(ctor);
63
- if (name === 'mark') {
64
- node.type = hocMark;
65
- }
66
- return node;
67
- };
68
- }
69
-
70
- function defineContainerProp(Node, { name, ctor }: NodePropertyDescriptor) {
71
- Node.prototype[name] = function () {
72
- this.type = null;
73
- return this.append(ctor);
74
- };
75
- }
76
-
77
- /**
78
- * A decorator to define different type of attribute setter or
79
- * getter for current node.
80
- */
81
- export function defineProps(descriptors: NodePropertyDescriptor[]) {
82
- return (Node) => {
83
- for (const descriptor of descriptors) {
84
- const { type } = descriptor;
85
- if (type === 'value') defineValueProp(Node, descriptor);
86
- else if (type === 'array') defineArrayProp(Node, descriptor);
87
- else if (type === 'object') defineObjectProp(Node, descriptor);
88
- else if (type === 'node') defineNodeProp(Node, descriptor);
89
- else if (type === 'container') defineContainerProp(Node, descriptor);
90
- else if (type === 'mix') defineMixProp(Node, descriptor);
91
- }
92
- return Node;
93
- };
94
- }
95
-
96
- export function nodeProps(
97
- node: Record<string, new (...args: any[]) => any>,
98
- ): NodePropertyDescriptor[] {
99
- return Object.entries(node).map(([name, ctor]) => ({
100
- type: 'node',
101
- name,
102
- ctor,
103
- }));
104
- }
105
-
106
- export function containerProps(
107
- node: Record<string, new (...args: any[]) => any>,
108
- ): NodePropertyDescriptor[] {
109
- return Object.entries(node).map(([name, ctor]) => ({
110
- type: 'container',
111
- name,
112
- ctor,
113
- }));
114
- }
1
+ export const commonProps = {
2
+ encode: { type: 'object' },
3
+ scale: { type: 'object' },
4
+ data: { type: 'value' },
5
+ transform: { type: 'array' },
6
+ style: { type: 'object' },
7
+ animate: { type: 'object' },
8
+ coordinate: { type: 'object' },
9
+ interaction: { type: 'object' },
10
+ label: { type: 'array', key: 'labels' },
11
+ axis: { type: 'object' },
12
+ legend: { type: 'object' },
13
+ slider: { type: 'object' },
14
+ scrollbar: { type: 'object' },
15
+ state: { type: 'object' },
16
+ layout: { type: 'object' },
17
+ theme: { type: 'object' },
18
+ title: { type: 'value' },
19
+ } as const;
20
+
21
+ export const markProps = {
22
+ ...commonProps,
23
+ tooltip: { type: 'mix' },
24
+ viewStyle: { type: 'object' },
25
+ } as const;
26
+
27
+ export const compositionProps = {
28
+ ...commonProps,
29
+ labelTransform: { type: 'array' },
30
+ } as const;