@antv/g2 5.0.18 → 5.0.20

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 (539) 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 +175 -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 +10 -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 +171 -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/data/index.d.ts +2 -0
  48. package/esm/data/index.js +1 -0
  49. package/esm/data/index.js.map +1 -1
  50. package/esm/data/log.d.ts +7 -0
  51. package/esm/data/log.js +11 -0
  52. package/esm/data/log.js.map +1 -0
  53. package/esm/index.d.ts +4 -3
  54. package/esm/index.js +3 -2
  55. package/esm/index.js.map +1 -1
  56. package/esm/interaction/brushFilter.js +18 -16
  57. package/esm/interaction/brushFilter.js.map +1 -1
  58. package/esm/interaction/chartIndex.js +25 -22
  59. package/esm/interaction/chartIndex.js.map +1 -1
  60. package/esm/interaction/fisheye.js +17 -13
  61. package/esm/interaction/fisheye.js.map +1 -1
  62. package/esm/interaction/legendFilter.js +32 -26
  63. package/esm/interaction/legendFilter.js.map +1 -1
  64. package/esm/interaction/sliderFilter.js +8 -9
  65. package/esm/interaction/sliderFilter.js.map +1 -1
  66. package/esm/interaction/tooltip.d.ts +1 -1
  67. package/esm/interaction/tooltip.js +39 -4
  68. package/esm/interaction/tooltip.js.map +1 -1
  69. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  70. package/esm/lib/core.d.ts +159 -0
  71. package/esm/lib/core.js +175 -0
  72. package/esm/lib/core.js.map +1 -0
  73. package/esm/lib/geo.d.ts +4 -0
  74. package/esm/lib/geo.js +9 -0
  75. package/esm/lib/geo.js.map +1 -0
  76. package/esm/lib/graph.d.ts +4 -0
  77. package/esm/lib/graph.js +8 -0
  78. package/esm/lib/graph.js.map +1 -0
  79. package/esm/lib/index.d.ts +6 -0
  80. package/esm/lib/index.js +7 -0
  81. package/esm/lib/index.js.map +1 -0
  82. package/esm/lib/lite.d.ts +64 -0
  83. package/esm/lib/lite.js +78 -0
  84. package/esm/lib/lite.js.map +1 -0
  85. package/esm/lib/plot.d.ts +11 -0
  86. package/esm/lib/plot.js +16 -0
  87. package/esm/lib/plot.js.map +1 -0
  88. package/esm/lib/std.d.ts +171 -0
  89. package/esm/lib/std.js +8 -0
  90. package/esm/lib/std.js.map +1 -0
  91. package/esm/mark/area.js +14 -5
  92. package/esm/mark/area.js.map +1 -1
  93. package/esm/mark/box.js +9 -2
  94. package/esm/mark/box.js.map +1 -1
  95. package/esm/mark/cell.js +11 -5
  96. package/esm/mark/cell.js.map +1 -1
  97. package/esm/mark/connector.js +6 -2
  98. package/esm/mark/connector.js.map +1 -1
  99. package/esm/mark/density.js +10 -7
  100. package/esm/mark/density.js.map +1 -1
  101. package/esm/mark/forceGraph.js +0 -3
  102. package/esm/mark/forceGraph.js.map +1 -1
  103. package/esm/mark/heatmap.js +9 -4
  104. package/esm/mark/heatmap.js.map +1 -1
  105. package/esm/mark/image.js +9 -4
  106. package/esm/mark/image.js.map +1 -1
  107. package/esm/mark/interval.js +13 -7
  108. package/esm/mark/interval.js.map +1 -1
  109. package/esm/mark/line.js +15 -4
  110. package/esm/mark/line.js.map +1 -1
  111. package/esm/mark/lineX.js +8 -3
  112. package/esm/mark/lineX.js.map +1 -1
  113. package/esm/mark/lineY.js +8 -3
  114. package/esm/mark/lineY.js.map +1 -1
  115. package/esm/mark/link.js +12 -4
  116. package/esm/mark/link.js.map +1 -1
  117. package/esm/mark/path.js +7 -2
  118. package/esm/mark/path.js.map +1 -1
  119. package/esm/mark/point.js +28 -29
  120. package/esm/mark/point.js.map +1 -1
  121. package/esm/mark/polygon.js +7 -2
  122. package/esm/mark/polygon.js.map +1 -1
  123. package/esm/mark/range.js +4 -2
  124. package/esm/mark/range.js.map +1 -1
  125. package/esm/mark/rangeX.js +6 -2
  126. package/esm/mark/rangeX.js.map +1 -1
  127. package/esm/mark/rangeY.js +6 -2
  128. package/esm/mark/rangeY.js.map +1 -1
  129. package/esm/mark/rect.js +9 -3
  130. package/esm/mark/rect.js.map +1 -1
  131. package/esm/mark/shape.js +9 -3
  132. package/esm/mark/shape.js.map +1 -1
  133. package/esm/mark/text.js +10 -4
  134. package/esm/mark/text.js.map +1 -1
  135. package/esm/mark/treemap.js.map +1 -1
  136. package/esm/mark/utils.d.ts +11 -8
  137. package/esm/mark/utils.js +8 -7
  138. package/esm/mark/utils.js.map +1 -1
  139. package/esm/mark/vector.js +6 -2
  140. package/esm/mark/vector.js.map +1 -1
  141. package/esm/runtime/index.d.ts +1 -1
  142. package/esm/runtime/index.js +1 -1
  143. package/esm/runtime/index.js.map +1 -1
  144. package/esm/runtime/plot.js +32 -13
  145. package/esm/runtime/plot.js.map +1 -1
  146. package/esm/runtime/render.js +3 -6
  147. package/esm/runtime/render.js.map +1 -1
  148. package/esm/runtime/types/component.d.ts +1 -1
  149. package/esm/runtime/types/mark.d.ts +4 -0
  150. package/esm/runtime/types/options.d.ts +4 -1
  151. package/esm/shape/index.d.ts +106 -101
  152. package/esm/shape/index.js +58 -53
  153. package/esm/shape/index.js.map +1 -1
  154. package/esm/shape/text/advance.js +3 -3
  155. package/esm/shape/text/advance.js.map +1 -1
  156. package/esm/spec/composition.d.ts +7 -0
  157. package/esm/spec/dataTransform.d.ts +3 -2
  158. package/esm/spec/index.d.ts +1 -0
  159. package/esm/spec/index.js.map +1 -1
  160. package/esm/spec/interaction.d.ts +4 -1
  161. package/esm/theme/academy.js +6 -6
  162. package/esm/theme/classic.js +6 -7
  163. package/esm/theme/classic.js.map +1 -1
  164. package/esm/theme/classicDark.js +6 -6
  165. package/esm/utils/coordinate.d.ts +2 -2
  166. package/esm/utils/scale.d.ts +1 -1
  167. package/esm/utils/scale.js +1 -1
  168. package/esm/utils/scale.js.map +1 -1
  169. package/lib/api/chart.d.ts +175 -85
  170. package/lib/api/chart.js +4 -263
  171. package/lib/api/chart.js.map +1 -1
  172. package/lib/api/composition.d.ts +37 -0
  173. package/lib/api/{composition/base.js → composition.js} +16 -5
  174. package/lib/api/composition.js.map +1 -0
  175. package/lib/api/define.d.ts +14 -0
  176. package/lib/api/define.js +97 -0
  177. package/lib/api/define.js.map +1 -0
  178. package/lib/api/extend.d.ts +10 -0
  179. package/lib/api/extend.js +13 -0
  180. package/lib/api/extend.js.map +1 -0
  181. package/lib/api/index.d.ts +2 -0
  182. package/lib/api/index.js +5 -1
  183. package/lib/api/index.js.map +1 -1
  184. package/lib/api/library.d.ts +171 -1
  185. package/lib/api/library.js +2 -2
  186. package/lib/api/library.js.map +1 -1
  187. package/lib/api/mark.d.ts +29 -0
  188. package/lib/api/{mark/base.js → mark.js} +15 -4
  189. package/lib/api/mark.js.map +1 -0
  190. package/lib/api/node.d.ts +2 -2
  191. package/lib/api/node.js.map +1 -1
  192. package/lib/api/props.d.ts +170 -12
  193. package/lib/api/props.js +22 -106
  194. package/lib/api/props.js.map +1 -1
  195. package/lib/api/runtime.d.ts +66 -0
  196. package/lib/api/runtime.js +301 -0
  197. package/lib/api/runtime.js.map +1 -0
  198. package/lib/api/types.d.ts +60 -5
  199. package/lib/api/utils.d.ts +1 -1
  200. package/lib/api/utils.js +14 -16
  201. package/lib/api/utils.js.map +1 -1
  202. package/lib/component/axis.js +7 -4
  203. package/lib/component/axis.js.map +1 -1
  204. package/lib/component/legendCategory.js +4 -5
  205. package/lib/component/legendCategory.js.map +1 -1
  206. package/lib/composition/d3Projection.js.map +1 -0
  207. package/lib/composition/geoPath.js.map +1 -0
  208. package/lib/{geo → composition}/geoView.js +1 -1
  209. package/lib/composition/geoView.js.map +1 -0
  210. package/lib/composition/index.d.ts +2 -0
  211. package/lib/composition/index.js +5 -1
  212. package/lib/composition/index.js.map +1 -1
  213. package/lib/data/index.d.ts +2 -0
  214. package/lib/data/index.js +3 -1
  215. package/lib/data/index.js.map +1 -1
  216. package/lib/data/log.d.ts +7 -0
  217. package/lib/data/log.js +15 -0
  218. package/lib/data/log.js.map +1 -0
  219. package/lib/index.d.ts +4 -3
  220. package/lib/index.js +8 -3
  221. package/lib/index.js.map +1 -1
  222. package/lib/interaction/brushFilter.js +18 -16
  223. package/lib/interaction/brushFilter.js.map +1 -1
  224. package/lib/interaction/chartIndex.js +25 -22
  225. package/lib/interaction/chartIndex.js.map +1 -1
  226. package/lib/interaction/fisheye.js +17 -13
  227. package/lib/interaction/fisheye.js.map +1 -1
  228. package/lib/interaction/legendFilter.js +32 -26
  229. package/lib/interaction/legendFilter.js.map +1 -1
  230. package/lib/interaction/sliderFilter.js +8 -9
  231. package/lib/interaction/sliderFilter.js.map +1 -1
  232. package/lib/interaction/tooltip.d.ts +1 -1
  233. package/lib/interaction/tooltip.js +38 -3
  234. package/lib/interaction/tooltip.js.map +1 -1
  235. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  236. package/lib/lib/core.d.ts +159 -0
  237. package/lib/lib/core.js +179 -0
  238. package/lib/lib/core.js.map +1 -0
  239. package/lib/lib/geo.d.ts +4 -0
  240. package/lib/lib/geo.js +13 -0
  241. package/lib/lib/geo.js.map +1 -0
  242. package/lib/lib/graph.d.ts +4 -0
  243. package/lib/lib/graph.js +12 -0
  244. package/lib/lib/graph.js.map +1 -0
  245. package/lib/lib/index.d.ts +6 -0
  246. package/lib/lib/index.js +16 -0
  247. package/lib/lib/index.js.map +1 -0
  248. package/lib/lib/lite.d.ts +64 -0
  249. package/lib/lib/lite.js +82 -0
  250. package/lib/lib/lite.js.map +1 -0
  251. package/lib/lib/plot.d.ts +11 -0
  252. package/lib/lib/plot.js +20 -0
  253. package/lib/lib/plot.js.map +1 -0
  254. package/lib/lib/std.d.ts +171 -0
  255. package/lib/lib/std.js +12 -0
  256. package/lib/lib/std.js.map +1 -0
  257. package/lib/mark/area.js +14 -5
  258. package/lib/mark/area.js.map +1 -1
  259. package/lib/mark/box.js +9 -2
  260. package/lib/mark/box.js.map +1 -1
  261. package/lib/mark/cell.js +11 -5
  262. package/lib/mark/cell.js.map +1 -1
  263. package/lib/mark/connector.js +6 -2
  264. package/lib/mark/connector.js.map +1 -1
  265. package/lib/mark/density.js +10 -7
  266. package/lib/mark/density.js.map +1 -1
  267. package/lib/mark/forceGraph.js +0 -3
  268. package/lib/mark/forceGraph.js.map +1 -1
  269. package/lib/mark/heatmap.js +9 -4
  270. package/lib/mark/heatmap.js.map +1 -1
  271. package/lib/mark/image.js +9 -4
  272. package/lib/mark/image.js.map +1 -1
  273. package/lib/mark/interval.js +13 -7
  274. package/lib/mark/interval.js.map +1 -1
  275. package/lib/mark/line.js +15 -4
  276. package/lib/mark/line.js.map +1 -1
  277. package/lib/mark/lineX.js +8 -3
  278. package/lib/mark/lineX.js.map +1 -1
  279. package/lib/mark/lineY.js +8 -3
  280. package/lib/mark/lineY.js.map +1 -1
  281. package/lib/mark/link.js +12 -4
  282. package/lib/mark/link.js.map +1 -1
  283. package/lib/mark/path.js +7 -2
  284. package/lib/mark/path.js.map +1 -1
  285. package/lib/mark/point.js +28 -29
  286. package/lib/mark/point.js.map +1 -1
  287. package/lib/mark/polygon.js +7 -2
  288. package/lib/mark/polygon.js.map +1 -1
  289. package/lib/mark/range.js +4 -2
  290. package/lib/mark/range.js.map +1 -1
  291. package/lib/mark/rangeX.js +6 -2
  292. package/lib/mark/rangeX.js.map +1 -1
  293. package/lib/mark/rangeY.js +6 -2
  294. package/lib/mark/rangeY.js.map +1 -1
  295. package/lib/mark/rect.js +9 -3
  296. package/lib/mark/rect.js.map +1 -1
  297. package/lib/mark/shape.js +9 -3
  298. package/lib/mark/shape.js.map +1 -1
  299. package/lib/mark/text.js +10 -4
  300. package/lib/mark/text.js.map +1 -1
  301. package/lib/mark/treemap.js.map +1 -1
  302. package/lib/mark/utils.d.ts +11 -8
  303. package/lib/mark/utils.js +8 -7
  304. package/lib/mark/utils.js.map +1 -1
  305. package/lib/mark/vector.js +6 -2
  306. package/lib/mark/vector.js.map +1 -1
  307. package/lib/runtime/index.d.ts +1 -1
  308. package/lib/runtime/index.js +4 -4
  309. package/lib/runtime/index.js.map +1 -1
  310. package/lib/runtime/plot.js +32 -13
  311. package/lib/runtime/plot.js.map +1 -1
  312. package/lib/runtime/render.js +3 -6
  313. package/lib/runtime/render.js.map +1 -1
  314. package/lib/runtime/types/component.d.ts +1 -1
  315. package/lib/runtime/types/mark.d.ts +4 -0
  316. package/lib/runtime/types/options.d.ts +4 -1
  317. package/lib/shape/index.d.ts +106 -101
  318. package/lib/shape/index.js +71 -61
  319. package/lib/shape/index.js.map +1 -1
  320. package/lib/shape/text/advance.js +3 -3
  321. package/lib/shape/text/advance.js.map +1 -1
  322. package/lib/spec/composition.d.ts +7 -0
  323. package/lib/spec/dataTransform.d.ts +3 -2
  324. package/lib/spec/index.d.ts +1 -0
  325. package/lib/spec/index.js.map +1 -1
  326. package/lib/spec/interaction.d.ts +4 -1
  327. package/lib/theme/academy.js +6 -6
  328. package/lib/theme/classic.js +6 -7
  329. package/lib/theme/classic.js.map +1 -1
  330. package/lib/theme/classicDark.js +6 -6
  331. package/lib/utils/coordinate.d.ts +2 -2
  332. package/lib/utils/scale.d.ts +1 -1
  333. package/lib/utils/scale.js +1 -1
  334. package/lib/utils/scale.js.map +1 -1
  335. package/package.json +8 -7
  336. package/src/api/chart.ts +5 -341
  337. package/src/api/{composition/base.ts → composition.ts} +16 -8
  338. package/src/api/define.ts +128 -0
  339. package/src/api/extend.ts +36 -0
  340. package/src/api/index.ts +2 -0
  341. package/src/api/library.ts +2 -2
  342. package/src/api/{mark/base.ts → mark.ts} +10 -7
  343. package/src/api/node.ts +3 -3
  344. package/src/api/props.ts +30 -114
  345. package/src/api/runtime.ts +366 -0
  346. package/src/api/types.ts +95 -17
  347. package/src/api/utils.ts +28 -11
  348. package/src/component/axis.ts +10 -5
  349. package/src/component/legendCategory.ts +4 -6
  350. package/src/{geo → composition}/geoView.ts +1 -1
  351. package/src/composition/index.ts +2 -0
  352. package/src/data/index.ts +2 -0
  353. package/src/data/log.ts +16 -0
  354. package/src/index.ts +12 -3
  355. package/src/interaction/brushFilter.ts +31 -28
  356. package/src/interaction/chartIndex.ts +26 -23
  357. package/src/interaction/fisheye.ts +16 -12
  358. package/src/interaction/legendFilter.ts +45 -40
  359. package/src/interaction/sliderFilter.ts +15 -16
  360. package/src/interaction/tooltip.ts +47 -3
  361. package/src/label-transform/overlapDodgeY.ts +0 -1
  362. package/src/{stdlib/index.ts → lib/core.ts} +76 -258
  363. package/src/lib/geo.ts +9 -0
  364. package/src/lib/graph.ts +8 -0
  365. package/src/lib/index.ts +6 -0
  366. package/src/lib/lite.ts +127 -0
  367. package/src/lib/plot.ts +16 -0
  368. package/src/lib/std.ts +13 -0
  369. package/src/mark/area.ts +15 -6
  370. package/src/mark/box.ts +10 -2
  371. package/src/mark/cell.ts +12 -6
  372. package/src/mark/connector.ts +7 -3
  373. package/src/mark/density.ts +11 -8
  374. package/src/mark/forceGraph.ts +0 -3
  375. package/src/mark/heatmap.ts +10 -5
  376. package/src/mark/image.ts +10 -5
  377. package/src/mark/interval.ts +22 -10
  378. package/src/mark/line.ts +23 -5
  379. package/src/mark/lineX.ts +9 -4
  380. package/src/mark/lineY.ts +9 -4
  381. package/src/mark/link.ts +13 -5
  382. package/src/mark/path.ts +8 -3
  383. package/src/mark/point.ts +49 -30
  384. package/src/mark/polygon.ts +8 -3
  385. package/src/mark/range.ts +5 -3
  386. package/src/mark/rangeX.ts +7 -3
  387. package/src/mark/rangeY.ts +7 -3
  388. package/src/mark/rect.ts +10 -4
  389. package/src/mark/shape.ts +14 -3
  390. package/src/mark/text.ts +11 -5
  391. package/src/mark/treemap.ts +0 -1
  392. package/src/mark/utils.ts +9 -8
  393. package/src/mark/vector.ts +7 -3
  394. package/src/runtime/index.ts +1 -1
  395. package/src/runtime/plot.ts +41 -17
  396. package/src/runtime/render.ts +3 -6
  397. package/src/runtime/types/component.ts +1 -2
  398. package/src/runtime/types/mark.ts +4 -0
  399. package/src/runtime/types/options.ts +4 -1
  400. package/src/shape/index.ts +106 -110
  401. package/src/shape/text/advance.ts +1 -2
  402. package/src/spec/composition.ts +7 -0
  403. package/src/spec/dataTransform.ts +5 -0
  404. package/src/spec/index.ts +1 -0
  405. package/src/spec/interaction.ts +5 -1
  406. package/src/theme/academy.ts +6 -6
  407. package/src/theme/classic.ts +6 -7
  408. package/src/theme/classicDark.ts +6 -6
  409. package/src/utils/scale.ts +1 -1
  410. package/esm/api/composition/base.d.ts +0 -28
  411. package/esm/api/composition/base.js.map +0 -1
  412. package/esm/api/composition/facetCircle.d.ts +0 -17
  413. package/esm/api/composition/facetCircle.js +0 -27
  414. package/esm/api/composition/facetCircle.js.map +0 -1
  415. package/esm/api/composition/facetRect.d.ts +0 -17
  416. package/esm/api/composition/facetRect.js +0 -27
  417. package/esm/api/composition/facetRect.js.map +0 -1
  418. package/esm/api/composition/geoPath.d.ts +0 -20
  419. package/esm/api/composition/geoPath.js +0 -30
  420. package/esm/api/composition/geoPath.js.map +0 -1
  421. package/esm/api/composition/geoView.d.ts +0 -19
  422. package/esm/api/composition/geoView.js +0 -28
  423. package/esm/api/composition/geoView.js.map +0 -1
  424. package/esm/api/composition/index.d.ts +0 -33
  425. package/esm/api/composition/index.js +0 -32
  426. package/esm/api/composition/index.js.map +0 -1
  427. package/esm/api/composition/repeatMatrix.d.ts +0 -17
  428. package/esm/api/composition/repeatMatrix.js +0 -27
  429. package/esm/api/composition/repeatMatrix.js.map +0 -1
  430. package/esm/api/composition/spaceFlex.d.ts +0 -12
  431. package/esm/api/composition/spaceFlex.js +0 -19
  432. package/esm/api/composition/spaceFlex.js.map +0 -1
  433. package/esm/api/composition/spaceLayer.d.ts +0 -12
  434. package/esm/api/composition/spaceLayer.js +0 -19
  435. package/esm/api/composition/spaceLayer.js.map +0 -1
  436. package/esm/api/composition/timingKeyframe.d.ts +0 -11
  437. package/esm/api/composition/timingKeyframe.js +0 -19
  438. package/esm/api/composition/timingKeyframe.js.map +0 -1
  439. package/esm/api/composition/view.d.ts +0 -19
  440. package/esm/api/composition/view.js +0 -29
  441. package/esm/api/composition/view.js.map +0 -1
  442. package/esm/api/mark/base.d.ts +0 -22
  443. package/esm/api/mark/base.js.map +0 -1
  444. package/esm/api/mark/index.d.ts +0 -75
  445. package/esm/api/mark/index.js +0 -39
  446. package/esm/api/mark/index.js.map +0 -1
  447. package/esm/api/mark/mark.d.ts +0 -212
  448. package/esm/api/mark/mark.js +0 -339
  449. package/esm/api/mark/mark.js.map +0 -1
  450. package/esm/api/mark/types.d.ts +0 -26
  451. package/esm/api/mark/types.js +0 -2
  452. package/esm/api/mark/types.js.map +0 -1
  453. package/esm/geo/d3Projection.js.map +0 -1
  454. package/esm/geo/geoPath.js.map +0 -1
  455. package/esm/geo/geoView.js.map +0 -1
  456. package/esm/geo/index.d.ts +0 -9
  457. package/esm/geo/index.js +0 -8
  458. package/esm/geo/index.js.map +0 -1
  459. package/esm/stdlib/index.d.ts +0 -2
  460. package/esm/stdlib/index.js +0 -21
  461. package/esm/stdlib/index.js.map +0 -1
  462. package/lib/api/composition/base.d.ts +0 -28
  463. package/lib/api/composition/base.js.map +0 -1
  464. package/lib/api/composition/facetCircle.d.ts +0 -17
  465. package/lib/api/composition/facetCircle.js +0 -30
  466. package/lib/api/composition/facetCircle.js.map +0 -1
  467. package/lib/api/composition/facetRect.d.ts +0 -17
  468. package/lib/api/composition/facetRect.js +0 -30
  469. package/lib/api/composition/facetRect.js.map +0 -1
  470. package/lib/api/composition/geoPath.d.ts +0 -20
  471. package/lib/api/composition/geoPath.js +0 -33
  472. package/lib/api/composition/geoPath.js.map +0 -1
  473. package/lib/api/composition/geoView.d.ts +0 -19
  474. package/lib/api/composition/geoView.js +0 -31
  475. package/lib/api/composition/geoView.js.map +0 -1
  476. package/lib/api/composition/index.d.ts +0 -33
  477. package/lib/api/composition/index.js +0 -44
  478. package/lib/api/composition/index.js.map +0 -1
  479. package/lib/api/composition/repeatMatrix.d.ts +0 -17
  480. package/lib/api/composition/repeatMatrix.js +0 -30
  481. package/lib/api/composition/repeatMatrix.js.map +0 -1
  482. package/lib/api/composition/spaceFlex.d.ts +0 -12
  483. package/lib/api/composition/spaceFlex.js +0 -22
  484. package/lib/api/composition/spaceFlex.js.map +0 -1
  485. package/lib/api/composition/spaceLayer.d.ts +0 -12
  486. package/lib/api/composition/spaceLayer.js +0 -22
  487. package/lib/api/composition/spaceLayer.js.map +0 -1
  488. package/lib/api/composition/timingKeyframe.d.ts +0 -11
  489. package/lib/api/composition/timingKeyframe.js +0 -22
  490. package/lib/api/composition/timingKeyframe.js.map +0 -1
  491. package/lib/api/composition/view.d.ts +0 -19
  492. package/lib/api/composition/view.js +0 -32
  493. package/lib/api/composition/view.js.map +0 -1
  494. package/lib/api/mark/base.d.ts +0 -22
  495. package/lib/api/mark/base.js.map +0 -1
  496. package/lib/api/mark/index.d.ts +0 -75
  497. package/lib/api/mark/index.js +0 -43
  498. package/lib/api/mark/index.js.map +0 -1
  499. package/lib/api/mark/mark.d.ts +0 -212
  500. package/lib/api/mark/mark.js +0 -342
  501. package/lib/api/mark/mark.js.map +0 -1
  502. package/lib/api/mark/types.d.ts +0 -26
  503. package/lib/api/mark/types.js +0 -3
  504. package/lib/api/mark/types.js.map +0 -1
  505. package/lib/geo/d3Projection.js.map +0 -1
  506. package/lib/geo/geoPath.js.map +0 -1
  507. package/lib/geo/geoView.js.map +0 -1
  508. package/lib/geo/index.d.ts +0 -9
  509. package/lib/geo/index.js +0 -12
  510. package/lib/geo/index.js.map +0 -1
  511. package/lib/stdlib/index.d.ts +0 -2
  512. package/lib/stdlib/index.js +0 -25
  513. package/lib/stdlib/index.js.map +0 -1
  514. package/src/api/composition/facetCircle.ts +0 -36
  515. package/src/api/composition/facetRect.ts +0 -36
  516. package/src/api/composition/geoPath.ts +0 -37
  517. package/src/api/composition/geoView.ts +0 -39
  518. package/src/api/composition/index.ts +0 -57
  519. package/src/api/composition/repeatMatrix.ts +0 -36
  520. package/src/api/composition/spaceFlex.ts +0 -18
  521. package/src/api/composition/spaceLayer.ts +0 -18
  522. package/src/api/composition/timingKeyframe.ts +0 -16
  523. package/src/api/composition/view.ts +0 -42
  524. package/src/api/mark/index.ts +0 -113
  525. package/src/api/mark/mark.ts +0 -439
  526. package/src/api/mark/types.ts +0 -31
  527. package/src/geo/index.ts +0 -12
  528. /package/esm/{geo → composition}/d3Projection.d.ts +0 -0
  529. /package/esm/{geo → composition}/d3Projection.js +0 -0
  530. /package/esm/{geo → composition}/geoPath.d.ts +0 -0
  531. /package/esm/{geo → composition}/geoPath.js +0 -0
  532. /package/esm/{geo → composition}/geoView.d.ts +0 -0
  533. /package/lib/{geo → composition}/d3Projection.d.ts +0 -0
  534. /package/lib/{geo → composition}/d3Projection.js +0 -0
  535. /package/lib/{geo → composition}/geoPath.d.ts +0 -0
  536. /package/lib/{geo → composition}/geoPath.js +0 -0
  537. /package/lib/{geo → composition}/geoView.d.ts +0 -0
  538. /package/src/{geo → composition}/d3Projection.ts +0 -0
  539. /package/src/{geo → composition}/geoPath.ts +0 -0
@@ -1,13 +1,171 @@
1
- export type NodePropertyDescriptor = {
2
- type: 'object' | 'value' | 'array' | 'node' | 'container' | 'mix';
3
- name: string;
4
- key?: string;
5
- ctor?: new (...args: any[]) => any;
1
+ export declare const commonProps: {
2
+ readonly encode: {
3
+ readonly type: "object";
4
+ };
5
+ readonly scale: {
6
+ readonly type: "object";
7
+ };
8
+ readonly data: {
9
+ readonly type: "value";
10
+ };
11
+ readonly transform: {
12
+ readonly type: "array";
13
+ };
14
+ readonly style: {
15
+ readonly type: "object";
16
+ };
17
+ readonly animate: {
18
+ readonly type: "object";
19
+ };
20
+ readonly coordinate: {
21
+ readonly type: "object";
22
+ };
23
+ readonly interaction: {
24
+ readonly type: "object";
25
+ };
26
+ readonly label: {
27
+ readonly type: "array";
28
+ readonly key: "labels";
29
+ };
30
+ readonly axis: {
31
+ readonly type: "object";
32
+ };
33
+ readonly legend: {
34
+ readonly type: "object";
35
+ };
36
+ readonly slider: {
37
+ readonly type: "object";
38
+ };
39
+ readonly scrollbar: {
40
+ readonly type: "object";
41
+ };
42
+ readonly state: {
43
+ readonly type: "object";
44
+ };
45
+ readonly layout: {
46
+ readonly type: "object";
47
+ };
48
+ readonly theme: {
49
+ readonly type: "object";
50
+ };
51
+ readonly title: {
52
+ readonly type: "value";
53
+ };
54
+ };
55
+ export declare const markProps: {
56
+ readonly tooltip: {
57
+ readonly type: "mix";
58
+ };
59
+ readonly viewStyle: {
60
+ readonly type: "object";
61
+ };
62
+ readonly encode: {
63
+ readonly type: "object";
64
+ };
65
+ readonly scale: {
66
+ readonly type: "object";
67
+ };
68
+ readonly data: {
69
+ readonly type: "value";
70
+ };
71
+ readonly transform: {
72
+ readonly type: "array";
73
+ };
74
+ readonly style: {
75
+ readonly type: "object";
76
+ };
77
+ readonly animate: {
78
+ readonly type: "object";
79
+ };
80
+ readonly coordinate: {
81
+ readonly type: "object";
82
+ };
83
+ readonly interaction: {
84
+ readonly type: "object";
85
+ };
86
+ readonly label: {
87
+ readonly type: "array";
88
+ readonly key: "labels";
89
+ };
90
+ readonly axis: {
91
+ readonly type: "object";
92
+ };
93
+ readonly legend: {
94
+ readonly type: "object";
95
+ };
96
+ readonly slider: {
97
+ readonly type: "object";
98
+ };
99
+ readonly scrollbar: {
100
+ readonly type: "object";
101
+ };
102
+ readonly state: {
103
+ readonly type: "object";
104
+ };
105
+ readonly layout: {
106
+ readonly type: "object";
107
+ };
108
+ readonly theme: {
109
+ readonly type: "object";
110
+ };
111
+ readonly title: {
112
+ readonly type: "value";
113
+ };
114
+ };
115
+ export declare const compositionProps: {
116
+ readonly labelTransform: {
117
+ readonly type: "array";
118
+ };
119
+ readonly encode: {
120
+ readonly type: "object";
121
+ };
122
+ readonly scale: {
123
+ readonly type: "object";
124
+ };
125
+ readonly data: {
126
+ readonly type: "value";
127
+ };
128
+ readonly transform: {
129
+ readonly type: "array";
130
+ };
131
+ readonly style: {
132
+ readonly type: "object";
133
+ };
134
+ readonly animate: {
135
+ readonly type: "object";
136
+ };
137
+ readonly coordinate: {
138
+ readonly type: "object";
139
+ };
140
+ readonly interaction: {
141
+ readonly type: "object";
142
+ };
143
+ readonly label: {
144
+ readonly type: "array";
145
+ readonly key: "labels";
146
+ };
147
+ readonly axis: {
148
+ readonly type: "object";
149
+ };
150
+ readonly legend: {
151
+ readonly type: "object";
152
+ };
153
+ readonly slider: {
154
+ readonly type: "object";
155
+ };
156
+ readonly scrollbar: {
157
+ readonly type: "object";
158
+ };
159
+ readonly state: {
160
+ readonly type: "object";
161
+ };
162
+ readonly layout: {
163
+ readonly type: "object";
164
+ };
165
+ readonly theme: {
166
+ readonly type: "object";
167
+ };
168
+ readonly title: {
169
+ readonly type: "value";
170
+ };
6
171
  };
7
- /**
8
- * A decorator to define different type of attribute setter or
9
- * getter for current node.
10
- */
11
- export declare function defineProps(descriptors: NodePropertyDescriptor[]): (Node: any) => any;
12
- export declare function nodeProps(node: Record<string, new (...args: any[]) => any>): NodePropertyDescriptor[];
13
- export declare function containerProps(node: Record<string, new (...args: any[]) => any>): NodePropertyDescriptor[];
package/esm/api/props.js CHANGED
@@ -1,103 +1,22 @@
1
- import { isStrictObject } from '../utils/helper';
2
- function defineValueProp(Node, { name, key = name }) {
3
- Node.prototype[name] = function (value) {
4
- if (arguments.length === 0)
5
- return this.attr(key);
6
- return this.attr(key, value);
7
- };
8
- }
9
- function defineArrayProp(Node, { name, key = name }) {
10
- Node.prototype[name] = function (value) {
11
- if (arguments.length === 0)
12
- return this.attr(key);
13
- if (Array.isArray(value))
14
- return this.attr(key, value);
15
- const array = [...(this.attr(key) || []), value];
16
- return this.attr(key, array);
17
- };
18
- }
19
- function defineObjectProp(Node, { name, key: k = name }) {
20
- Node.prototype[name] = function (key, value) {
21
- if (arguments.length === 0)
22
- return this.attr(k);
23
- if (arguments.length === 1 && typeof key !== 'string') {
24
- return this.attr(k, key);
25
- }
26
- const obj = this.attr(k) || {};
27
- obj[key] = arguments.length === 1 ? true : value;
28
- return this.attr(k, obj);
29
- };
30
- }
31
- function defineMixProp(Node, { name }) {
32
- Node.prototype[name] = function (key) {
33
- if (arguments.length === 0)
34
- return this.attr(name);
35
- if (Array.isArray(key))
36
- return this.attr(name, { items: key });
37
- if (isStrictObject(key) &&
38
- (key.title !== undefined || key.items !== undefined)) {
39
- return this.attr(name, key);
40
- }
41
- if (key === null || key === false)
42
- return this.attr(name, key);
43
- const obj = this.attr(name) || {};
44
- const { items = [] } = obj;
45
- items.push(key);
46
- obj.items = items;
47
- return this.attr(name, obj);
48
- };
49
- }
50
- function defineNodeProp(Node, { name, ctor }) {
51
- Node.prototype[name] = function (hocMark) {
52
- const node = this.append(ctor);
53
- if (name === 'mark') {
54
- node.type = hocMark;
55
- }
56
- return node;
57
- };
58
- }
59
- function defineContainerProp(Node, { name, ctor }) {
60
- Node.prototype[name] = function () {
61
- this.type = null;
62
- return this.append(ctor);
63
- };
64
- }
65
- /**
66
- * A decorator to define different type of attribute setter or
67
- * getter for current node.
68
- */
69
- export function defineProps(descriptors) {
70
- return (Node) => {
71
- for (const descriptor of descriptors) {
72
- const { type } = descriptor;
73
- if (type === 'value')
74
- defineValueProp(Node, descriptor);
75
- else if (type === 'array')
76
- defineArrayProp(Node, descriptor);
77
- else if (type === 'object')
78
- defineObjectProp(Node, descriptor);
79
- else if (type === 'node')
80
- defineNodeProp(Node, descriptor);
81
- else if (type === 'container')
82
- defineContainerProp(Node, descriptor);
83
- else if (type === 'mix')
84
- defineMixProp(Node, descriptor);
85
- }
86
- return Node;
87
- };
88
- }
89
- export function nodeProps(node) {
90
- return Object.entries(node).map(([name, ctor]) => ({
91
- type: 'node',
92
- name,
93
- ctor,
94
- }));
95
- }
96
- export function containerProps(node) {
97
- return Object.entries(node).map(([name, ctor]) => ({
98
- type: 'container',
99
- name,
100
- ctor,
101
- }));
102
- }
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
+ };
20
+ export const markProps = Object.assign(Object.assign({}, commonProps), { tooltip: { type: 'mix' }, viewStyle: { type: 'object' } });
21
+ export const compositionProps = Object.assign(Object.assign({}, commonProps), { labelTransform: { type: 'array' } });
103
22
  //# sourceMappingURL=props.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"props.js","sourceRoot":"src/","sources":["api/props.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AASjD,SAAS,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,EAA0B;IACzE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,KAAK;QACpC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,GAAG,GAAG,IAAI,EAA0B;IACzE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,UAAU,KAAK;QACpC,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC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EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IACvB,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;IAC5B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC3B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC9B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC/B,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE;IACvC,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACxB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC7B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IAC1B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;IACzB,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE;CAChB,CAAC;AAEX,MAAM,CAAC,MAAM,SAAS,GAAG,gCACpB,WAAW,KACd,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,EACxB,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,GACrB,CAAC;AAEX,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAC3B,WAAW,KACd,cAAc,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GACzB,CAAC"}
@@ -0,0 +1,66 @@
1
+ import { IRenderer, RendererPlugin, Canvas as GCanvas } from '@antv/g';
2
+ import { G2Context } from '../runtime';
3
+ import { G2Spec, ViewComposition } from '../spec';
4
+ import { G2Library } from '../runtime/types/options';
5
+ import { CompositionNode } from './composition';
6
+ export declare const G2_CHART_KEY = "G2_CHART_KEY";
7
+ export type RuntimeOptions = ViewComposition & {
8
+ container?: string | HTMLElement;
9
+ canvas?: GCanvas;
10
+ autoFit?: boolean;
11
+ renderer?: IRenderer;
12
+ plugins?: RendererPlugin[];
13
+ theme?: string;
14
+ lib?: G2Library;
15
+ };
16
+ export declare class Runtime<Spec extends G2Spec = G2Spec> extends CompositionNode {
17
+ private _container;
18
+ private _context;
19
+ private _emitter;
20
+ private _width;
21
+ private _height;
22
+ private _renderer;
23
+ private _plugins;
24
+ private _hasBindAutoFit;
25
+ private _rendering;
26
+ private _trailing;
27
+ private _trailingResolve;
28
+ private _trailingReject;
29
+ private _previousDefinedType;
30
+ private _marks;
31
+ private _compositions;
32
+ constructor(options: RuntimeOptions);
33
+ render(): Promise<Runtime<Spec>>;
34
+ /**
35
+ * @overload
36
+ * @returns {Spec}
37
+ */
38
+ options(): Spec;
39
+ /**
40
+ * @overload
41
+ * @param {G2ViewTree} options
42
+ * @returns {Runtime}
43
+ */
44
+ options(options: Spec): Runtime<Spec>;
45
+ getContainer(): HTMLElement;
46
+ getContext(): G2Context;
47
+ on(event: string, callback: (...args: any[]) => any, once?: boolean): this;
48
+ once(event: string, callback: (...args: any[]) => any): this;
49
+ emit(event: string, ...args: any[]): this;
50
+ off(event?: string, callback?: (...args: any[]) => any): this;
51
+ clear(): void;
52
+ destroy(): void;
53
+ forceFit(): Promise<Runtime<Spec>>;
54
+ changeSize(width: number, height: number): Promise<Runtime<Spec>>;
55
+ private _create;
56
+ private _reset;
57
+ private _renderTrailing;
58
+ private _createResolve;
59
+ private _createReject;
60
+ private _computedOptions;
61
+ private _createCanvas;
62
+ private _addToTrailing;
63
+ private _onResize;
64
+ private _bindAutoFit;
65
+ private _unbindAutoFit;
66
+ }
@@ -0,0 +1,294 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __rest = (this && this.__rest) || function (s, e) {
8
+ var t = {};
9
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
10
+ t[p] = s[p];
11
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
12
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
13
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
14
+ t[p[i]] = s[p[i]];
15
+ }
16
+ return t;
17
+ };
18
+ import { Canvas as GCanvas } from '@antv/g';
19
+ import { Renderer as CanvasRenderer } from '@antv/g-canvas';
20
+ import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
21
+ import { debounce } from '@antv/util';
22
+ import EventEmitter from '@antv/event-emitter';
23
+ import { render, destroy } from '../runtime';
24
+ import { ChartEvent } from '../utils/event';
25
+ import { normalizeContainer, removeContainer, sizeOf, optionsOf, updateRoot, createEmptyPromise, } from './utils';
26
+ import { CompositionNode } from './composition';
27
+ import { defineProps, nodeProps } from './define';
28
+ import { MarkNode } from './mark';
29
+ export const G2_CHART_KEY = 'G2_CHART_KEY';
30
+ export class Runtime extends CompositionNode {
31
+ constructor(options) {
32
+ const { container, canvas, renderer, plugins, lib } = options, rest = __rest(options, ["container", "canvas", "renderer", "plugins", "lib"]);
33
+ super(rest, 'view');
34
+ // Identifies whether bindAutoFit.
35
+ this._hasBindAutoFit = false;
36
+ this._rendering = false;
37
+ this._trailing = false;
38
+ this._trailingResolve = null;
39
+ this._trailingReject = null;
40
+ this._previousDefinedType = null;
41
+ this._onResize = debounce(() => {
42
+ this.forceFit();
43
+ }, 300);
44
+ this._renderer = renderer || new CanvasRenderer();
45
+ this._plugins = plugins || [];
46
+ this._container = normalizeContainer(container);
47
+ this._emitter = new EventEmitter();
48
+ this._context = { library: lib, emitter: this._emitter, canvas };
49
+ this._create();
50
+ }
51
+ render() {
52
+ if (this._rendering)
53
+ return this._addToTrailing();
54
+ if (!this._context.canvas)
55
+ this._createCanvas();
56
+ this._bindAutoFit();
57
+ this._rendering = true;
58
+ const finished = new Promise((resolve, reject) => render(this._computedOptions(), this._context, this._createResolve(resolve), this._createReject(reject)));
59
+ const [finished1, resolve, reject] = createEmptyPromise();
60
+ finished
61
+ .then(resolve)
62
+ .catch(reject)
63
+ .then(() => this._renderTrailing());
64
+ return finished1;
65
+ }
66
+ /**
67
+ * @overload
68
+ * @param {G2ViewTree} [options]
69
+ * @returns {Runtime|Spec}
70
+ */
71
+ options(options) {
72
+ if (arguments.length === 0)
73
+ return optionsOf(this);
74
+ const { type } = options;
75
+ if (type)
76
+ this._previousDefinedType = type;
77
+ updateRoot(this, options, this._previousDefinedType, this._marks, this._compositions);
78
+ return this;
79
+ }
80
+ getContainer() {
81
+ return this._container;
82
+ }
83
+ getContext() {
84
+ return this._context;
85
+ }
86
+ on(event, callback, once) {
87
+ this._emitter.on(event, callback, once);
88
+ return this;
89
+ }
90
+ once(event, callback) {
91
+ this._emitter.once(event, callback);
92
+ return this;
93
+ }
94
+ emit(event, ...args) {
95
+ this._emitter.emit(event, ...args);
96
+ return this;
97
+ }
98
+ off(event, callback) {
99
+ this._emitter.off(event, callback);
100
+ return this;
101
+ }
102
+ clear() {
103
+ const options = this.options();
104
+ this.emit(ChartEvent.BEFORE_CLEAR);
105
+ this._reset();
106
+ destroy(options, this._context, false);
107
+ this.emit(ChartEvent.AFTER_CLEAR);
108
+ }
109
+ destroy() {
110
+ const options = this.options();
111
+ this.emit(ChartEvent.BEFORE_DESTROY);
112
+ this._unbindAutoFit();
113
+ this._reset();
114
+ destroy(options, this._context, true);
115
+ removeContainer(this._container);
116
+ this.emit(ChartEvent.AFTER_DESTROY);
117
+ }
118
+ forceFit() {
119
+ // Don't fit if size do not change.
120
+ this.options['autoFit'] = true;
121
+ const { width, height } = sizeOf(this.options(), this._container);
122
+ if (width === this._width && height === this._height) {
123
+ return Promise.resolve(this);
124
+ }
125
+ // Don't call changeSize to prevent update width and height of options.
126
+ this.emit(ChartEvent.BEFORE_CHANGE_SIZE);
127
+ const finished = this.render();
128
+ finished.then(() => {
129
+ this.emit(ChartEvent.AFTER_CHANGE_SIZE);
130
+ });
131
+ return finished;
132
+ }
133
+ changeSize(width, height) {
134
+ if (width === this._width && height === this._height) {
135
+ return Promise.resolve(this);
136
+ }
137
+ this.emit(ChartEvent.BEFORE_CHANGE_SIZE);
138
+ this.attr('width', width);
139
+ this.attr('height', height);
140
+ const finished = this.render();
141
+ finished.then(() => {
142
+ this.emit(ChartEvent.AFTER_CHANGE_SIZE);
143
+ });
144
+ return finished;
145
+ }
146
+ _create() {
147
+ const { library } = this._context;
148
+ // @todo After refactor component as mark, remove this.
149
+ const isMark = (key) => key.startsWith('mark.') ||
150
+ key === 'component.axisX' ||
151
+ key === 'component.axisY' ||
152
+ key === 'component.legends';
153
+ const marks = [
154
+ 'mark.mark',
155
+ ...Object.keys(library).filter(isMark),
156
+ ];
157
+ // Create mark generators.
158
+ this._marks = {};
159
+ for (const key of marks) {
160
+ const name = key.split('.').pop();
161
+ class Mark extends MarkNode {
162
+ constructor() {
163
+ super({}, name);
164
+ }
165
+ }
166
+ this._marks[name] = Mark;
167
+ this[name] = function (composite) {
168
+ const node = this.append(Mark);
169
+ if (name === 'mark')
170
+ node.type = composite;
171
+ return node;
172
+ };
173
+ }
174
+ // Create composition generators.
175
+ const compositions = Object.keys(library).filter((key) => key.startsWith('composition.') && key !== 'composition.mark');
176
+ this._compositions = Object.fromEntries(compositions.map((key) => {
177
+ const name = key.split('.').pop();
178
+ let Composition = class Composition extends CompositionNode {
179
+ constructor() {
180
+ super({}, name);
181
+ }
182
+ };
183
+ Composition = __decorate([
184
+ defineProps(nodeProps(this._marks))
185
+ ], Composition);
186
+ return [name, Composition];
187
+ }));
188
+ for (const Ctor of Object.values(this._compositions)) {
189
+ defineProps(nodeProps(this._compositions))(Ctor);
190
+ }
191
+ for (const key of compositions) {
192
+ const name = key.split('.').pop();
193
+ this[name] = function () {
194
+ const Composition = this._compositions[name];
195
+ this.type = null;
196
+ return this.append(Composition);
197
+ };
198
+ }
199
+ }
200
+ _reset() {
201
+ const KEYS = ['theme', 'type', 'width', 'height', 'autoFit'];
202
+ this.type = 'view';
203
+ this.value = Object.fromEntries(Object.entries(this.value).filter(([key]) => key.startsWith('margin') ||
204
+ key.startsWith('padding') ||
205
+ key.startsWith('inset') ||
206
+ KEYS.includes(key)));
207
+ this.children = [];
208
+ }
209
+ _renderTrailing() {
210
+ if (!this._trailing)
211
+ return;
212
+ this._trailing = false;
213
+ this.render()
214
+ .then(() => {
215
+ const trailingResolve = this._trailingResolve.bind(this);
216
+ this._trailingResolve = null;
217
+ trailingResolve(this);
218
+ })
219
+ .catch((error) => {
220
+ const trailingReject = this._trailingReject.bind(this);
221
+ this._trailingReject = null;
222
+ trailingReject(error);
223
+ });
224
+ }
225
+ _createResolve(resolve) {
226
+ return () => {
227
+ this._rendering = false;
228
+ resolve(this);
229
+ };
230
+ }
231
+ _createReject(reject) {
232
+ return (error) => {
233
+ this._rendering = false;
234
+ reject(error);
235
+ };
236
+ }
237
+ // Update actual size and key.
238
+ _computedOptions() {
239
+ const options = this.options();
240
+ const { key = G2_CHART_KEY } = options;
241
+ const { width, height } = sizeOf(options, this._container);
242
+ this._width = width;
243
+ this._height = height;
244
+ this._key = key;
245
+ return Object.assign(Object.assign({ key: this._key }, options), { width, height });
246
+ }
247
+ // Create canvas if it does not exist.
248
+ // DragAndDropPlugin is for interaction.
249
+ // It is OK to register more than one time, G will handle this.
250
+ _createCanvas() {
251
+ const { width, height } = sizeOf(this.options(), this._container);
252
+ this._plugins.push(new DragAndDropPlugin());
253
+ this._plugins.forEach((d) => this._renderer.registerPlugin(d));
254
+ this._context.canvas = new GCanvas({
255
+ container: this._container,
256
+ width,
257
+ height,
258
+ renderer: this._renderer,
259
+ });
260
+ }
261
+ _addToTrailing() {
262
+ var _a;
263
+ // Resolve previous promise, and give up this task.
264
+ (_a = this._trailingResolve) === null || _a === void 0 ? void 0 : _a.call(this, this);
265
+ // Create new task.
266
+ this._trailing = true;
267
+ const promise = new Promise((resolve, reject) => {
268
+ this._trailingResolve = resolve;
269
+ this._trailingReject = reject;
270
+ });
271
+ return promise;
272
+ }
273
+ _bindAutoFit() {
274
+ const options = this.options();
275
+ const { autoFit } = options;
276
+ if (this._hasBindAutoFit) {
277
+ // If it was bind before, unbind it now.
278
+ if (!autoFit)
279
+ this._unbindAutoFit();
280
+ return;
281
+ }
282
+ if (autoFit) {
283
+ this._hasBindAutoFit = true;
284
+ window.addEventListener('resize', this._onResize);
285
+ }
286
+ }
287
+ _unbindAutoFit() {
288
+ if (this._hasBindAutoFit) {
289
+ this._hasBindAutoFit = false;
290
+ window.removeEventListener('resize', this._onResize);
291
+ }
292
+ }
293
+ }
294
+ //# sourceMappingURL=runtime.js.map