@antv/g2 5.0.0-beta.7 → 5.0.0-beta.9

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 (473) hide show
  1. package/dist/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +4 -4
  3. package/esm/animation/morphing.js +22 -2
  4. package/esm/animation/morphing.js.map +1 -1
  5. package/esm/api/chart.d.ts +8 -3
  6. package/esm/api/chart.js +35 -16
  7. package/esm/api/chart.js.map +1 -1
  8. package/esm/api/composition/base.d.ts +18 -1
  9. package/esm/api/composition/base.js +44 -1
  10. package/esm/api/composition/base.js.map +1 -1
  11. package/esm/api/mark/base.d.ts +22 -0
  12. package/esm/api/mark/base.js +54 -0
  13. package/esm/api/mark/base.js.map +1 -0
  14. package/esm/api/mark/mark.d.ts +1 -7
  15. package/esm/api/mark/mark.js +1 -13
  16. package/esm/api/mark/mark.js.map +1 -1
  17. package/esm/api/props.js +0 -20
  18. package/esm/api/props.js.map +1 -1
  19. package/esm/component/axis.d.ts +5 -7
  20. package/esm/component/axis.js +126 -94
  21. package/esm/component/axis.js.map +1 -1
  22. package/esm/component/axisArc.d.ts +7 -0
  23. package/esm/component/axisArc.js +9 -0
  24. package/esm/component/axisArc.js.map +1 -0
  25. package/esm/component/axisRadar.d.ts +9 -0
  26. package/esm/component/axisRadar.js +46 -0
  27. package/esm/component/axisRadar.js.map +1 -0
  28. package/esm/component/axisX.d.ts +2 -1
  29. package/esm/component/axisX.js +5 -4
  30. package/esm/component/axisX.js.map +1 -1
  31. package/esm/component/axisY.d.ts +1 -1
  32. package/esm/component/axisY.js +4 -4
  33. package/esm/component/axisY.js.map +1 -1
  34. package/esm/component/index.d.ts +8 -0
  35. package/esm/component/index.js +5 -0
  36. package/esm/component/index.js.map +1 -1
  37. package/esm/component/legendCategory.d.ts +5 -3
  38. package/esm/component/legendCategory.js +80 -36
  39. package/esm/component/legendCategory.js.map +1 -1
  40. package/esm/component/legendContinuous.d.ts +4 -2
  41. package/esm/component/legendContinuous.js +76 -24
  42. package/esm/component/legendContinuous.js.map +1 -1
  43. package/esm/component/legendContinuousBlock.d.ts +4 -0
  44. package/esm/component/legendContinuousBlock.js +6 -0
  45. package/esm/component/legendContinuousBlock.js.map +1 -0
  46. package/esm/component/legendContinuousBlockSize.d.ts +4 -0
  47. package/esm/component/legendContinuousBlockSize.js +6 -0
  48. package/esm/component/legendContinuousBlockSize.js.map +1 -0
  49. package/esm/component/legendContinuousSize.d.ts +4 -0
  50. package/esm/component/legendContinuousSize.js +10 -0
  51. package/esm/component/legendContinuousSize.js.map +1 -0
  52. package/esm/component/scrollbar.js +1 -1
  53. package/esm/component/scrollbar.js.map +1 -1
  54. package/esm/component/slider.js +1 -1
  55. package/esm/component/slider.js.map +1 -1
  56. package/esm/component/title.js +1 -1
  57. package/esm/component/title.js.map +1 -1
  58. package/esm/component/utils.d.ts +12 -0
  59. package/esm/component/utils.js +35 -0
  60. package/esm/component/utils.js.map +1 -1
  61. package/esm/composition/facetCircle.js +1 -1
  62. package/esm/composition/facetCircle.js.map +1 -1
  63. package/esm/coordinate/index.d.ts +3 -3
  64. package/esm/coordinate/index.js +3 -3
  65. package/esm/coordinate/index.js.map +1 -1
  66. package/esm/coordinate/polar.d.ts +6 -0
  67. package/esm/coordinate/polar.js +18 -6
  68. package/esm/coordinate/polar.js.map +1 -1
  69. package/esm/coordinate/radial.d.ts +6 -0
  70. package/esm/coordinate/radial.js +17 -5
  71. package/esm/coordinate/radial.js.map +1 -1
  72. package/esm/coordinate/theta.d.ts +7 -0
  73. package/esm/coordinate/theta.js +16 -4
  74. package/esm/coordinate/theta.js.map +1 -1
  75. package/esm/interaction/builtin/elementHighlight.d.ts +2 -0
  76. package/esm/interaction/builtin/elementHighlightByColor.d.ts +2 -0
  77. package/esm/interaction/builtin/elementHighlightByX.d.ts +2 -0
  78. package/esm/interaction/index.d.ts +2 -0
  79. package/esm/interaction/index.js +2 -0
  80. package/esm/interaction/index.js.map +1 -1
  81. package/esm/interaction/native/brushAxisHighlight.js +6 -1
  82. package/esm/interaction/native/brushAxisHighlight.js.map +1 -1
  83. package/esm/interaction/native/brushFilter.js +1 -1
  84. package/esm/interaction/native/brushFilter.js.map +1 -1
  85. package/esm/interaction/native/elementHighlight.d.ts +7 -2
  86. package/esm/interaction/native/elementHighlight.js +72 -19
  87. package/esm/interaction/native/elementHighlight.js.map +1 -1
  88. package/esm/interaction/native/elementHighlightByColor.d.ts +4 -1
  89. package/esm/interaction/native/elementHighlightByColor.js +19 -3
  90. package/esm/interaction/native/elementHighlightByColor.js.map +1 -1
  91. package/esm/interaction/native/elementHighlightByX.d.ts +3 -3
  92. package/esm/interaction/native/elementHighlightByX.js +19 -3
  93. package/esm/interaction/native/elementHighlightByX.js.map +1 -1
  94. package/esm/interaction/native/elementSelect.d.ts +1 -1
  95. package/esm/interaction/native/elementSelect.js +42 -21
  96. package/esm/interaction/native/elementSelect.js.map +1 -1
  97. package/esm/interaction/native/elementSelectByColor.js +3 -2
  98. package/esm/interaction/native/elementSelectByColor.js.map +1 -1
  99. package/esm/interaction/native/elementSelectByX.js +3 -2
  100. package/esm/interaction/native/elementSelectByX.js.map +1 -1
  101. package/esm/interaction/native/legendFilter.d.ts +6 -0
  102. package/esm/interaction/native/legendFilter.js +26 -7
  103. package/esm/interaction/native/legendFilter.js.map +1 -1
  104. package/esm/interaction/native/legendHighlight.d.ts +4 -0
  105. package/esm/interaction/native/legendHighlight.js +93 -0
  106. package/esm/interaction/native/legendHighlight.js.map +1 -0
  107. package/esm/interaction/native/poptip.d.ts +5 -0
  108. package/esm/interaction/native/poptip.js +91 -0
  109. package/esm/interaction/native/poptip.js.map +1 -0
  110. package/esm/interaction/native/utils.d.ts +13 -2
  111. package/esm/interaction/native/utils.js +151 -26
  112. package/esm/interaction/native/utils.js.map +1 -1
  113. package/esm/label-transform/overlapDodgeY.js +0 -8
  114. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  115. package/esm/mark/area.js +1 -1
  116. package/esm/mark/area.js.map +1 -1
  117. package/esm/mark/pack.js +0 -1
  118. package/esm/mark/pack.js.map +1 -1
  119. package/esm/mark/treemap.js +0 -1
  120. package/esm/mark/treemap.js.map +1 -1
  121. package/esm/runtime/component.d.ts +3 -0
  122. package/esm/runtime/component.js +246 -103
  123. package/esm/runtime/component.js.map +1 -1
  124. package/esm/runtime/coordinate.d.ts +11 -0
  125. package/esm/runtime/coordinate.js +23 -16
  126. package/esm/runtime/coordinate.js.map +1 -1
  127. package/esm/runtime/layout.d.ts +1 -1
  128. package/esm/runtime/layout.js +145 -76
  129. package/esm/runtime/layout.js.map +1 -1
  130. package/esm/runtime/plot.js +5 -4
  131. package/esm/runtime/plot.js.map +1 -1
  132. package/esm/runtime/render.js +18 -13
  133. package/esm/runtime/render.js.map +1 -1
  134. package/esm/runtime/scale.d.ts +2 -1
  135. package/esm/runtime/scale.js +35 -0
  136. package/esm/runtime/scale.js.map +1 -1
  137. package/esm/runtime/transform.js +1 -1
  138. package/esm/runtime/transform.js.map +1 -1
  139. package/esm/runtime/types/common.d.ts +11 -2
  140. package/esm/runtime/types/component.d.ts +9 -7
  141. package/esm/runtime/types/options.d.ts +8 -6
  142. package/esm/runtime/types/scale.d.ts +18 -0
  143. package/esm/runtime/types/scale.js +19 -0
  144. package/esm/runtime/types/scale.js.map +1 -0
  145. package/esm/runtime/types/theme.d.ts +2 -1
  146. package/esm/shape/area/hv.d.ts +3 -0
  147. package/esm/shape/area/hv.js +9 -0
  148. package/esm/shape/area/hv.js.map +1 -0
  149. package/esm/shape/area/hvh.d.ts +3 -0
  150. package/esm/shape/area/{step.js → hvh.js} +3 -3
  151. package/esm/shape/area/hvh.js.map +1 -0
  152. package/esm/shape/area/vh.d.ts +3 -0
  153. package/esm/shape/area/vh.js +9 -0
  154. package/esm/shape/area/vh.js.map +1 -0
  155. package/esm/shape/connector/connector.js +1 -1
  156. package/esm/shape/index.d.ts +6 -2
  157. package/esm/shape/index.js +3 -1
  158. package/esm/shape/index.js.map +1 -1
  159. package/esm/shape/interval/color.d.ts +1 -0
  160. package/esm/shape/interval/color.js +65 -53
  161. package/esm/shape/interval/color.js.map +1 -1
  162. package/esm/shape/utils.js.map +1 -1
  163. package/esm/spec/composition.d.ts +0 -3
  164. package/esm/spec/geometry.d.ts +1 -1
  165. package/esm/spec/interaction.d.ts +33 -15
  166. package/esm/spec/transform.d.ts +13 -3
  167. package/esm/stdlib/index.js +4 -9
  168. package/esm/stdlib/index.js.map +1 -1
  169. package/esm/theme/academy.js +10 -4
  170. package/esm/theme/academy.js.map +1 -1
  171. package/esm/theme/dark.js +10 -4
  172. package/esm/theme/dark.js.map +1 -1
  173. package/esm/theme/light.js +12 -4
  174. package/esm/theme/light.js.map +1 -1
  175. package/esm/transform/sample.js +42 -26
  176. package/esm/transform/sample.js.map +1 -1
  177. package/esm/transform/utils/lttb.d.ts +5 -0
  178. package/esm/transform/utils/lttb.js +56 -0
  179. package/esm/transform/utils/lttb.js.map +1 -0
  180. package/esm/utils/angle.d.ts +2 -0
  181. package/esm/utils/angle.js +7 -0
  182. package/esm/utils/angle.js.map +1 -0
  183. package/esm/utils/array.d.ts +8 -0
  184. package/esm/utils/array.js +35 -0
  185. package/esm/utils/array.js.map +1 -1
  186. package/esm/utils/coordinate.d.ts +4 -0
  187. package/esm/utils/coordinate.js +19 -0
  188. package/esm/utils/coordinate.js.map +1 -1
  189. package/esm/utils/event.d.ts +0 -2
  190. package/esm/utils/event.js +0 -18
  191. package/esm/utils/event.js.map +1 -1
  192. package/esm/utils/scale.d.ts +1 -0
  193. package/esm/utils/scale.js +3 -3
  194. package/esm/utils/scale.js.map +1 -1
  195. package/esm/utils/vector.d.ts +1 -1
  196. package/esm/utils/vector.js +1 -1
  197. package/lib/animation/morphing.js +22 -2
  198. package/lib/animation/morphing.js.map +1 -1
  199. package/lib/api/chart.d.ts +8 -3
  200. package/lib/api/chart.js +37 -15
  201. package/lib/api/chart.js.map +1 -1
  202. package/lib/api/composition/base.d.ts +18 -1
  203. package/lib/api/composition/base.js +44 -1
  204. package/lib/api/composition/base.js.map +1 -1
  205. package/lib/api/mark/base.d.ts +22 -0
  206. package/lib/api/mark/base.js +58 -0
  207. package/lib/api/mark/base.js.map +1 -0
  208. package/lib/api/mark/mark.d.ts +1 -7
  209. package/lib/api/mark/mark.js +28 -41
  210. package/lib/api/mark/mark.js.map +1 -1
  211. package/lib/api/props.js +0 -20
  212. package/lib/api/props.js.map +1 -1
  213. package/lib/component/axis.d.ts +5 -7
  214. package/lib/component/axis.js +127 -96
  215. package/lib/component/axis.js.map +1 -1
  216. package/lib/component/axisArc.d.ts +7 -0
  217. package/lib/component/axisArc.js +13 -0
  218. package/lib/component/axisArc.js.map +1 -0
  219. package/lib/component/axisRadar.d.ts +9 -0
  220. package/lib/component/axisRadar.js +50 -0
  221. package/lib/component/axisRadar.js.map +1 -0
  222. package/lib/component/axisX.d.ts +2 -1
  223. package/lib/component/axisX.js +6 -4
  224. package/lib/component/axisX.js.map +1 -1
  225. package/lib/component/axisY.d.ts +1 -1
  226. package/lib/component/axisY.js +3 -3
  227. package/lib/component/axisY.js.map +1 -1
  228. package/lib/component/index.d.ts +8 -0
  229. package/lib/component/index.js +12 -1
  230. package/lib/component/index.js.map +1 -1
  231. package/lib/component/legendCategory.d.ts +5 -3
  232. package/lib/component/legendCategory.js +79 -35
  233. package/lib/component/legendCategory.js.map +1 -1
  234. package/lib/component/legendContinuous.d.ts +4 -2
  235. package/lib/component/legendContinuous.js +75 -23
  236. package/lib/component/legendContinuous.js.map +1 -1
  237. package/lib/component/legendContinuousBlock.d.ts +4 -0
  238. package/lib/component/legendContinuousBlock.js +10 -0
  239. package/lib/component/legendContinuousBlock.js.map +1 -0
  240. package/lib/component/legendContinuousBlockSize.d.ts +4 -0
  241. package/lib/component/legendContinuousBlockSize.js +10 -0
  242. package/lib/component/legendContinuousBlockSize.js.map +1 -0
  243. package/lib/component/legendContinuousSize.d.ts +4 -0
  244. package/lib/component/legendContinuousSize.js +14 -0
  245. package/lib/component/legendContinuousSize.js.map +1 -0
  246. package/lib/component/scrollbar.js +1 -1
  247. package/lib/component/scrollbar.js.map +1 -1
  248. package/lib/component/slider.js +1 -1
  249. package/lib/component/slider.js.map +1 -1
  250. package/lib/component/title.js +1 -1
  251. package/lib/component/title.js.map +1 -1
  252. package/lib/component/utils.d.ts +12 -0
  253. package/lib/component/utils.js +39 -1
  254. package/lib/component/utils.js.map +1 -1
  255. package/lib/composition/facetCircle.js +1 -1
  256. package/lib/composition/facetCircle.js.map +1 -1
  257. package/lib/coordinate/index.d.ts +3 -3
  258. package/lib/coordinate/index.js +4 -1
  259. package/lib/coordinate/index.js.map +1 -1
  260. package/lib/coordinate/polar.d.ts +6 -0
  261. package/lib/coordinate/polar.js +20 -7
  262. package/lib/coordinate/polar.js.map +1 -1
  263. package/lib/coordinate/radial.d.ts +6 -0
  264. package/lib/coordinate/radial.js +19 -6
  265. package/lib/coordinate/radial.js.map +1 -1
  266. package/lib/coordinate/theta.d.ts +7 -0
  267. package/lib/coordinate/theta.js +18 -5
  268. package/lib/coordinate/theta.js.map +1 -1
  269. package/lib/interaction/builtin/elementHighlight.d.ts +2 -0
  270. package/lib/interaction/builtin/elementHighlightByColor.d.ts +2 -0
  271. package/lib/interaction/builtin/elementHighlightByX.d.ts +2 -0
  272. package/lib/interaction/index.d.ts +2 -0
  273. package/lib/interaction/index.js +5 -1
  274. package/lib/interaction/index.js.map +1 -1
  275. package/lib/interaction/native/brushAxisHighlight.js +6 -1
  276. package/lib/interaction/native/brushAxisHighlight.js.map +1 -1
  277. package/lib/interaction/native/brushFilter.js +1 -1
  278. package/lib/interaction/native/brushFilter.js.map +1 -1
  279. package/lib/interaction/native/elementHighlight.d.ts +7 -2
  280. package/lib/interaction/native/elementHighlight.js +71 -18
  281. package/lib/interaction/native/elementHighlight.js.map +1 -1
  282. package/lib/interaction/native/elementHighlightByColor.d.ts +4 -1
  283. package/lib/interaction/native/elementHighlightByColor.js +18 -2
  284. package/lib/interaction/native/elementHighlightByColor.js.map +1 -1
  285. package/lib/interaction/native/elementHighlightByX.d.ts +3 -3
  286. package/lib/interaction/native/elementHighlightByX.js +18 -2
  287. package/lib/interaction/native/elementHighlightByX.js.map +1 -1
  288. package/lib/interaction/native/elementSelect.d.ts +1 -1
  289. package/lib/interaction/native/elementSelect.js +41 -20
  290. package/lib/interaction/native/elementSelect.js.map +1 -1
  291. package/lib/interaction/native/elementSelectByColor.js +2 -1
  292. package/lib/interaction/native/elementSelectByColor.js.map +1 -1
  293. package/lib/interaction/native/elementSelectByX.js +2 -1
  294. package/lib/interaction/native/elementSelectByX.js.map +1 -1
  295. package/lib/interaction/native/legendFilter.d.ts +6 -0
  296. package/lib/interaction/native/legendFilter.js +31 -6
  297. package/lib/interaction/native/legendFilter.js.map +1 -1
  298. package/lib/interaction/native/legendHighlight.d.ts +4 -0
  299. package/lib/interaction/native/legendHighlight.js +97 -0
  300. package/lib/interaction/native/legendHighlight.js.map +1 -0
  301. package/lib/interaction/native/poptip.d.ts +5 -0
  302. package/lib/interaction/native/poptip.js +95 -0
  303. package/lib/interaction/native/poptip.js.map +1 -0
  304. package/lib/interaction/native/utils.d.ts +13 -2
  305. package/lib/interaction/native/utils.js +154 -27
  306. package/lib/interaction/native/utils.js.map +1 -1
  307. package/lib/label-transform/overlapDodgeY.js +0 -8
  308. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  309. package/lib/mark/area.js +1 -1
  310. package/lib/mark/area.js.map +1 -1
  311. package/lib/mark/pack.js +0 -1
  312. package/lib/mark/pack.js.map +1 -1
  313. package/lib/mark/treemap.js +0 -1
  314. package/lib/mark/treemap.js.map +1 -1
  315. package/lib/runtime/component.d.ts +3 -0
  316. package/lib/runtime/component.js +250 -107
  317. package/lib/runtime/component.js.map +1 -1
  318. package/lib/runtime/coordinate.d.ts +11 -0
  319. package/lib/runtime/coordinate.js +26 -17
  320. package/lib/runtime/coordinate.js.map +1 -1
  321. package/lib/runtime/layout.d.ts +1 -1
  322. package/lib/runtime/layout.js +146 -77
  323. package/lib/runtime/layout.js.map +1 -1
  324. package/lib/runtime/plot.js +4 -3
  325. package/lib/runtime/plot.js.map +1 -1
  326. package/lib/runtime/render.js +20 -12
  327. package/lib/runtime/render.js.map +1 -1
  328. package/lib/runtime/scale.d.ts +2 -1
  329. package/lib/runtime/scale.js +37 -1
  330. package/lib/runtime/scale.js.map +1 -1
  331. package/lib/runtime/transform.js +1 -1
  332. package/lib/runtime/transform.js.map +1 -1
  333. package/lib/runtime/types/common.d.ts +11 -2
  334. package/lib/runtime/types/component.d.ts +9 -7
  335. package/lib/runtime/types/options.d.ts +8 -6
  336. package/lib/runtime/types/scale.d.ts +18 -0
  337. package/lib/runtime/types/scale.js +22 -0
  338. package/lib/runtime/types/scale.js.map +1 -0
  339. package/lib/runtime/types/theme.d.ts +2 -1
  340. package/lib/shape/area/hv.d.ts +3 -0
  341. package/lib/shape/area/hv.js +13 -0
  342. package/lib/shape/area/hv.js.map +1 -0
  343. package/lib/shape/area/hvh.d.ts +3 -0
  344. package/lib/shape/area/{step.js → hvh.js} +5 -5
  345. package/lib/shape/area/hvh.js.map +1 -0
  346. package/lib/shape/area/vh.d.ts +3 -0
  347. package/lib/shape/area/vh.js +13 -0
  348. package/lib/shape/area/vh.js.map +1 -0
  349. package/lib/shape/connector/connector.js +1 -1
  350. package/lib/shape/index.d.ts +6 -2
  351. package/lib/shape/index.js +7 -3
  352. package/lib/shape/index.js.map +1 -1
  353. package/lib/shape/interval/color.d.ts +1 -0
  354. package/lib/shape/interval/color.js +67 -54
  355. package/lib/shape/interval/color.js.map +1 -1
  356. package/lib/shape/utils.js.map +1 -1
  357. package/lib/spec/composition.d.ts +0 -3
  358. package/lib/spec/geometry.d.ts +1 -1
  359. package/lib/spec/interaction.d.ts +33 -15
  360. package/lib/spec/transform.d.ts +13 -3
  361. package/lib/stdlib/index.js +1 -1
  362. package/lib/stdlib/index.js.map +1 -1
  363. package/lib/theme/academy.js +10 -4
  364. package/lib/theme/academy.js.map +1 -1
  365. package/lib/theme/dark.js +10 -4
  366. package/lib/theme/dark.js.map +1 -1
  367. package/lib/theme/light.js +12 -4
  368. package/lib/theme/light.js.map +1 -1
  369. package/lib/transform/sample.js +42 -26
  370. package/lib/transform/sample.js.map +1 -1
  371. package/lib/transform/utils/lttb.d.ts +5 -0
  372. package/lib/transform/utils/lttb.js +60 -0
  373. package/lib/transform/utils/lttb.js.map +1 -0
  374. package/lib/utils/angle.d.ts +2 -0
  375. package/lib/utils/angle.js +12 -0
  376. package/lib/utils/angle.js.map +1 -0
  377. package/lib/utils/array.d.ts +8 -0
  378. package/lib/utils/array.js +38 -1
  379. package/lib/utils/array.js.map +1 -1
  380. package/lib/utils/coordinate.d.ts +4 -0
  381. package/lib/utils/coordinate.js +24 -1
  382. package/lib/utils/coordinate.js.map +1 -1
  383. package/lib/utils/event.d.ts +0 -2
  384. package/lib/utils/event.js +1 -21
  385. package/lib/utils/event.js.map +1 -1
  386. package/lib/utils/scale.d.ts +1 -0
  387. package/lib/utils/scale.js +5 -4
  388. package/lib/utils/scale.js.map +1 -1
  389. package/lib/utils/vector.d.ts +1 -1
  390. package/lib/utils/vector.js +1 -1
  391. package/package.json +7 -7
  392. package/src/animation/morphing.ts +23 -2
  393. package/src/api/chart.ts +43 -20
  394. package/src/api/composition/base.ts +46 -1
  395. package/src/api/mark/base.ts +58 -0
  396. package/src/api/mark/mark.ts +1 -20
  397. package/src/api/props.ts +0 -23
  398. package/src/component/axis.ts +199 -118
  399. package/src/component/axisArc.ts +16 -0
  400. package/src/component/axisRadar.ts +73 -0
  401. package/src/component/axisX.ts +7 -4
  402. package/src/component/axisY.ts +4 -4
  403. package/src/component/index.ts +8 -0
  404. package/src/component/legendCategory.ts +156 -35
  405. package/src/component/legendContinuous.ts +133 -32
  406. package/src/component/legendContinuousBlock.ts +17 -0
  407. package/src/component/legendContinuousBlockSize.ts +22 -0
  408. package/src/component/legendContinuousSize.ts +27 -0
  409. package/src/component/scrollbar.ts +1 -1
  410. package/src/component/slider.ts +1 -1
  411. package/src/component/title.ts +1 -1
  412. package/src/component/utils.ts +46 -0
  413. package/src/composition/facetCircle.ts +1 -1
  414. package/src/coordinate/index.ts +3 -3
  415. package/src/coordinate/polar.ts +19 -11
  416. package/src/coordinate/radial.ts +19 -10
  417. package/src/coordinate/theta.ts +18 -9
  418. package/src/interaction/index.ts +2 -0
  419. package/src/interaction/native/brushAxisHighlight.ts +9 -1
  420. package/src/interaction/native/brushFilter.ts +1 -1
  421. package/src/interaction/native/elementHighlight.ts +78 -12
  422. package/src/interaction/native/elementHighlightByColor.ts +9 -4
  423. package/src/interaction/native/elementHighlightByX.ts +9 -5
  424. package/src/interaction/native/elementSelect.ts +58 -15
  425. package/src/interaction/native/elementSelectByColor.ts +4 -1
  426. package/src/interaction/native/elementSelectByX.ts +4 -1
  427. package/src/interaction/native/legendFilter.ts +29 -7
  428. package/src/interaction/native/legendHighlight.ts +86 -0
  429. package/src/interaction/native/poptip.ts +87 -0
  430. package/src/interaction/native/utils.ts +183 -26
  431. package/src/label-transform/overlapDodgeY.ts +0 -7
  432. package/src/mark/area.ts +1 -1
  433. package/src/mark/pack.ts +0 -1
  434. package/src/mark/treemap.ts +0 -1
  435. package/src/runtime/component.ts +335 -124
  436. package/src/runtime/coordinate.ts +29 -16
  437. package/src/runtime/layout.ts +206 -97
  438. package/src/runtime/plot.ts +5 -4
  439. package/src/runtime/render.ts +26 -13
  440. package/src/runtime/scale.ts +41 -0
  441. package/src/runtime/transform.ts +3 -0
  442. package/src/runtime/types/common.ts +23 -10
  443. package/src/runtime/types/component.ts +19 -10
  444. package/src/runtime/types/options.ts +24 -16
  445. package/src/runtime/types/scale.ts +20 -0
  446. package/src/runtime/types/theme.ts +2 -1
  447. package/src/shape/area/hv.ts +20 -0
  448. package/src/shape/area/{step.ts → hvh.ts} +3 -3
  449. package/src/shape/area/vh.ts +20 -0
  450. package/src/shape/connector/connector.ts +1 -1
  451. package/src/shape/index.ts +7 -2
  452. package/src/shape/interval/color.ts +86 -54
  453. package/src/shape/utils.ts +2 -0
  454. package/src/spec/composition.ts +0 -1
  455. package/src/spec/geometry.ts +3 -1
  456. package/src/spec/interaction.ts +51 -19
  457. package/src/spec/transform.ts +27 -2
  458. package/src/stdlib/index.ts +22 -6
  459. package/src/theme/academy.ts +10 -4
  460. package/src/theme/dark.ts +10 -4
  461. package/src/theme/light.ts +12 -4
  462. package/src/transform/sample.ts +54 -18
  463. package/src/transform/utils/lttb.ts +73 -0
  464. package/src/utils/angle.ts +7 -0
  465. package/src/utils/array.ts +39 -0
  466. package/src/utils/coordinate.ts +29 -0
  467. package/src/utils/event.ts +0 -26
  468. package/src/utils/scale.ts +4 -4
  469. package/src/utils/vector.ts +1 -1
  470. package/esm/shape/area/step.d.ts +0 -3
  471. package/esm/shape/area/step.js.map +0 -1
  472. package/lib/shape/area/step.d.ts +0 -3
  473. package/lib/shape/area/step.js.map +0 -1
@@ -1,13 +1,16 @@
1
1
  import { Coordinate } from '@antv/coord';
2
- import { group, ascending } from 'd3-array';
2
+ import { ascending, group } from 'd3-array';
3
+ import { isParallel, isPolar, isRadar, radiusOf } from '../utils/coordinate';
3
4
  import { capitalizeFirst } from '../utils/helper';
5
+ import { divide } from '../utils/array';
4
6
  import {
5
- GuideComponentPosition,
6
- Section,
7
+ GuideComponentPosition as GCP,
8
+ GuideComponentOrientation as GCO,
7
9
  Layout,
10
+ Section,
8
11
  SectionArea,
9
12
  } from './types/common';
10
- import { G2View, G2GuideComponentOptions } from './types/options';
13
+ import { G2GuideComponentOptions, G2View } from './types/options';
11
14
 
12
15
  export function computeLayout(
13
16
  components: G2GuideComponentOptions[],
@@ -31,6 +34,7 @@ export function computeLayout(
31
34
  marginTop = margin,
32
35
  marginRight = margin,
33
36
  } = options;
37
+
34
38
  return {
35
39
  ...padding,
36
40
  width,
@@ -57,11 +61,15 @@ function computePadding(
57
61
  components: G2GuideComponentOptions[],
58
62
  options: G2View,
59
63
  ) {
60
- const positions: GuideComponentPosition[] = [
64
+ const positions: GCP[] = [
61
65
  'left',
62
66
  'right',
63
67
  'top',
64
68
  'bottom',
69
+ 'top-left',
70
+ 'top-right',
71
+ 'bottom-left',
72
+ 'bottom-right',
65
73
  ];
66
74
  const positionComponents = group(components, (d) => d.position);
67
75
  const {
@@ -119,40 +127,179 @@ export function placeComponents(
119
127
  const pb = paddingBottom + marginBottom;
120
128
 
121
129
  const section: Section = {
122
- top: [pl, 0, innerWidth, pt, 0, true, ascending],
123
- right: [width - pr, pt, pr, innerHeight, 1, false, ascending],
124
- bottom: [pl, height - pb, innerWidth, pb, 0, false, ascending],
125
- left: [0, pt, pl, innerHeight, 1, true, ascending],
126
- centerVertical: [pl, pt, innerWidth, innerHeight, -1, null, null],
127
- centerHorizontal: [pl, pt, innerWidth, innerHeight, -1, null, null],
128
- arc: [pl, pt, innerWidth, innerHeight, -1, null, null],
129
- arcY: [pl, pt, innerWidth, innerHeight, -1, null, null],
130
- arcInner: [pl, pt, innerWidth, innerHeight, -1, null, null],
131
- center: [pl, pt, innerWidth, innerHeight, -1, null, null],
132
- arcCenter: [pl, pt, innerWidth, innerHeight, -1, null, null],
130
+ top: [pl, 0, innerWidth, pt, 'vertical', true, ascending],
131
+ right: [width - pr, pt, pr, innerHeight, 'horizontal', false, ascending],
132
+ bottom: [pl, height - pb, innerWidth, pb, 'vertical', false, ascending],
133
+ left: [0, pt, pl, innerHeight, 'horizontal', true, ascending],
134
+ 'top-left': [pl, 0, innerWidth, pt, 'vertical', true, ascending],
135
+ 'top-right': [pl, 0, innerWidth, pt, 'vertical', true, ascending],
136
+ 'bottom-left': [
137
+ pl,
138
+ height - pb,
139
+ innerWidth,
140
+ pb,
141
+ 'vertical',
142
+ false,
143
+ ascending,
144
+ ],
145
+ 'bottom-right': [
146
+ pl,
147
+ height - pb,
148
+ innerWidth,
149
+ pb,
150
+ 'vertical',
151
+ false,
152
+ ascending,
153
+ ],
154
+ center: [pl, pt, innerWidth, innerHeight, 'center', null, null],
155
+ inner: [pl, pt, innerWidth, innerHeight, 'center', null, null],
156
+ outer: [pl, pt, innerWidth, innerHeight, 'center', null, null],
133
157
  };
158
+ for (const [position, components] of positionComponents.entries()) {
159
+ const area = section[position];
160
+
161
+ /**
162
+ * @description non-entity components: axis in the center, inner, outer, component in the center
163
+ * @description entity components: other components
164
+ * @description no volumn components take up no extra space
165
+ */
166
+
167
+ const [nonEntityComponents, entityComponents] = divide(
168
+ components,
169
+ (component) => {
170
+ if (typeof component.type !== 'string') return false;
171
+ if (position === 'center') return true;
172
+ if (
173
+ component.type.startsWith('axis') &&
174
+ ['inner', 'outer'].includes(position)
175
+ ) {
176
+ return true;
177
+ }
178
+ return false;
179
+ },
180
+ );
134
181
 
135
- for (const [key, components] of positionComponents.entries()) {
136
- const area = section[key];
137
- if (key === 'centerVertical') {
138
- placeCenterVertical(components, coordinate, area);
139
- } else if (key === 'centerHorizontal') {
140
- placeCenterHorizontal(components, coordinate, area);
141
- } else if (key === 'arc') {
142
- placeArc(components, coordinate, area);
143
- } else if (key === 'arcY') {
144
- placeArcY(components, coordinate, area);
145
- } else if (key === 'arcInner') {
146
- placeArcInner(components, coordinate, area);
147
- } else if (key === 'arcCenter') {
148
- placeArcCenter(components, coordinate, area);
149
- } else {
182
+ if (nonEntityComponents.length) {
183
+ placeNonEntityComponents(nonEntityComponents, coordinate, area, position);
184
+ }
185
+ if (entityComponents.length) {
150
186
  placePaddingArea(components, coordinate, area);
151
187
  }
152
188
  }
153
189
  }
154
190
 
155
- function placeCenterVertical(
191
+ function placeNonEntityComponents(
192
+ components: G2GuideComponentOptions[],
193
+ coordinate: Coordinate,
194
+ area: SectionArea,
195
+ position: GCP,
196
+ ) {
197
+ const [axisComponents, nonAxisComponents] = divide(
198
+ components,
199
+ (component) => {
200
+ if (
201
+ typeof component.type === 'string' &&
202
+ component.type.startsWith('axis')
203
+ ) {
204
+ return true;
205
+ }
206
+ return false;
207
+ },
208
+ );
209
+
210
+ placeNonEntityAxis(axisComponents, coordinate, area, position);
211
+ // in current stage, only legend component which located in the center can be placed
212
+ placeCenter(nonAxisComponents, coordinate, area);
213
+ }
214
+
215
+ function placeNonEntityAxis(
216
+ components: G2GuideComponentOptions[],
217
+ coordinate: Coordinate,
218
+ area: SectionArea,
219
+ position: GCP,
220
+ ) {
221
+ if (position === 'center') {
222
+ if (isRadar(coordinate)) {
223
+ placeAxisRadar(components, coordinate, area, position);
224
+ } else if (isPolar(coordinate)) {
225
+ placeArcLinear(components, coordinate, area);
226
+ } else if (isParallel(coordinate)) {
227
+ placeAxisParallel(
228
+ components,
229
+ coordinate,
230
+ area,
231
+ components[0].orientation, // assume that all components have the same orientation
232
+ );
233
+ }
234
+ } else if (position === 'inner') {
235
+ placeAxisArcInner(components, coordinate, area);
236
+ } else if (position === 'outer') {
237
+ placeAxisArcOuter(components, coordinate, area);
238
+ }
239
+ }
240
+
241
+ function placeAxisArcInner(
242
+ components: G2GuideComponentOptions[],
243
+ coordinate: Coordinate,
244
+ area: SectionArea,
245
+ ) {
246
+ const [x, y, , height] = area;
247
+ const [cx, cy] = coordinate.getCenter();
248
+ const [innerRadius] = radiusOf(coordinate);
249
+ const r = height / 2;
250
+ const size = innerRadius * r;
251
+ const x0 = cx - size;
252
+ const y0 = cy - size;
253
+ for (let i = 0; i < components.length; i++) {
254
+ const component = components[i];
255
+ component.bbox = {
256
+ x: x + x0,
257
+ y: y + y0,
258
+ width: size * 2,
259
+ height: size * 2,
260
+ };
261
+ }
262
+ }
263
+
264
+ function placeAxisArcOuter(
265
+ components: G2GuideComponentOptions[],
266
+ coordinate: Coordinate,
267
+ area: SectionArea,
268
+ ) {
269
+ const [x, y, width, height] = area;
270
+ for (const component of components) {
271
+ component.bbox = { x, y, width, height };
272
+ }
273
+ }
274
+
275
+ /**
276
+ * @example arcX, arcY, axisLinear with angle
277
+ */
278
+ function placeArcLinear(
279
+ components: G2GuideComponentOptions[],
280
+ coordinate: Coordinate,
281
+ area: SectionArea,
282
+ ) {
283
+ const [x, y, width, height] = area;
284
+ for (const component of components) {
285
+ component.bbox = { x: x, y, width, height };
286
+ }
287
+ }
288
+
289
+ function placeAxisParallel(
290
+ components: G2GuideComponentOptions[],
291
+ coordinate: Coordinate,
292
+ area: SectionArea,
293
+ orientation: GCO,
294
+ ) {
295
+ if (orientation === 'horizontal') {
296
+ placeAxisParallelHorizontal(components, coordinate, area);
297
+ } else if (orientation === 'vertical') {
298
+ placeAxisParallelVertical(components, coordinate, area);
299
+ }
300
+ }
301
+
302
+ function placeAxisParallelVertical(
156
303
  components: G2GuideComponentOptions[],
157
304
  coordinate: Coordinate,
158
305
  area: SectionArea,
@@ -177,7 +324,7 @@ function placeCenterVertical(
177
324
  }
178
325
  }
179
326
 
180
- function placeCenterHorizontal(
327
+ function placeAxisParallelHorizontal(
181
328
  components: G2GuideComponentOptions[],
182
329
  coordinate: Coordinate,
183
330
  area: SectionArea,
@@ -200,13 +347,31 @@ function placeCenterHorizontal(
200
347
  const height = Y[i + 1] - y;
201
348
  component.bbox = { x, y, width, height };
202
349
  }
350
+
351
+ // override style
352
+ }
353
+
354
+ function placeAxisRadar(
355
+ components: G2GuideComponentOptions[],
356
+ coordinate: Coordinate,
357
+ area: SectionArea,
358
+ position: GCP,
359
+ ) {
360
+ const [x, y, width, height] = area;
361
+ for (const component of components) {
362
+ component.bbox = { x, y, width, height };
363
+ component.radar = {
364
+ index: components.indexOf(component),
365
+ count: components.length,
366
+ };
367
+ }
203
368
  }
204
369
 
205
370
  function placePaddingArea(
206
371
  components: G2GuideComponentOptions[],
207
372
  coordinate: Coordinate,
208
373
  area: SectionArea,
209
- ): void {
374
+ ) {
210
375
  const [x, y, width, height, direction, reverse, comparator] = area;
211
376
  const [
212
377
  mainStartKey,
@@ -218,13 +383,13 @@ function placePaddingArea(
218
383
  crossSizeKey,
219
384
  crossSizeValue,
220
385
  ] =
221
- direction === 0
386
+ direction === 'vertical'
222
387
  ? ['y', y, 'x', x, 'height', height, 'width', width]
223
388
  : ['x', x, 'y', y, 'width', width, 'height', height];
224
389
 
225
390
  // Sort components by order.
226
391
  // The smaller the order, the closer to center.
227
- components.sort((a, b) => comparator(a.order, b.order));
392
+ components.sort((a, b) => comparator?.(a.order, b.order));
228
393
 
229
394
  const startValue = reverse ? mainStartValue + mainSizeValue : mainStartValue;
230
395
  for (let i = 0, start = startValue; i < components.length; i++) {
@@ -240,40 +405,15 @@ function placePaddingArea(
240
405
  }
241
406
  }
242
407
 
243
- function placeArc(
244
- components: G2GuideComponentOptions[],
245
- coordinate: Coordinate,
246
- area: SectionArea,
247
- ) {
248
- const [x, y, width, height] = area;
249
- for (let i = 0; i < components.length; i++) {
250
- const component = components[i];
251
- component.bbox = { x, y, width, height };
252
- }
253
- }
254
-
255
- function placeArcY(
256
- components: G2GuideComponentOptions[],
257
- coordinate: Coordinate,
258
- area: SectionArea,
259
- ) {
260
- const [x, y, , height] = area;
261
- const [cx, cy] = coordinate.getCenter();
262
- const [innerRadius, outerRadius] = radiusOf(coordinate);
263
- const r = height / 2;
264
- const y0 = cy - outerRadius * r;
265
- const h = (outerRadius - innerRadius) * r;
266
- for (let i = 0; i < components.length; i++) {
267
- const component = components[i];
268
- component.bbox = { x: cx + x, y: y0 + y, width: 0, height: h };
269
- }
270
- }
271
-
272
- function placeArcCenter(
408
+ /**
409
+ * @example legend in the center of radial or polar system
410
+ */
411
+ function placeCenter(
273
412
  components: G2GuideComponentOptions[],
274
413
  coordinate: Coordinate,
275
414
  area: SectionArea,
276
415
  ) {
416
+ if (components.length === 0) return;
277
417
  const [x, y, width, height] = area;
278
418
  const [innerRadius] = radiusOf(coordinate);
279
419
  const r = ((height / 2) * innerRadius) / Math.sqrt(2);
@@ -284,34 +424,3 @@ function placeArcCenter(
284
424
  component.bbox = { x: cx - r, y: cy - r, width: r * 2, height: r * 2 };
285
425
  }
286
426
  }
287
-
288
- function placeArcInner(
289
- components: G2GuideComponentOptions[],
290
- coordinate: Coordinate,
291
- area: SectionArea,
292
- ) {
293
- const [x, y, , height] = area;
294
- const [cx, cy] = coordinate.getCenter();
295
- const [innerRadius] = radiusOf(coordinate);
296
- const r = height / 2;
297
- const size = innerRadius * r;
298
- const x0 = cx - size;
299
- const y0 = cy - size;
300
- for (let i = 0; i < components.length; i++) {
301
- const component = components[i];
302
- component.bbox = {
303
- x: x + x0,
304
- y: y + y0,
305
- width: size * 2,
306
- height: size * 2,
307
- };
308
- }
309
- }
310
-
311
- function radiusOf(coordinate: Coordinate): [number, number] {
312
- const { transformations } = coordinate.getOptions();
313
- const [, , , innerRadius, outerRadius] = transformations.find(
314
- (d) => d[0] === 'polar',
315
- );
316
- return [innerRadius as number, outerRadius as number];
317
- }
@@ -4,7 +4,7 @@ import { deepMix, upperFirst } from '@antv/util';
4
4
  import { group } from 'd3-array';
5
5
  import { format } from 'd3-format';
6
6
  import { mapObject } from '../utils/array';
7
- import { CHART_LIFE_CIRCLE, emitEvent } from '../utils/event';
7
+ import { CHART_LIFE_CIRCLE } from '../utils/event';
8
8
  import {
9
9
  appendTransform,
10
10
  compose,
@@ -165,8 +165,7 @@ export async function plot<T extends G2ViewTree>(
165
165
  }
166
166
  }
167
167
 
168
- const { on } = options;
169
- emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_PAINT);
168
+ context.emitter.emit(CHART_LIFE_CIRCLE.BEFORE_PAINT);
170
169
 
171
170
  // Plot chart.
172
171
  const enterContainer = new Map<G2ViewDescriptor, DisplayObject>();
@@ -266,9 +265,10 @@ export async function plot<T extends G2ViewTree>(
266
265
  keyframes.push(keyframe);
267
266
  }
268
267
 
268
+ context.views = views;
269
269
  context.animations = transitions;
270
270
 
271
- emitEvent(on, CHART_LIFE_CIRCLE.AFTER_PAINT);
271
+ context.emitter.emit(CHART_LIFE_CIRCLE.AFTER_PAINT);
272
272
 
273
273
  // Note!!!
274
274
  // The returned promise will never resolved if one of nodeGenerator
@@ -632,6 +632,7 @@ async function plotView(
632
632
  enter
633
633
  // Make this layer interactive, such as click and mousemove events.
634
634
  .append('rect')
635
+ // todo zIndex
635
636
  .style('fill', 'transparent')
636
637
  .attr('className', PLOT_CLASS_NAME)
637
638
  .call(updateBBox)
@@ -2,9 +2,10 @@ import { Canvas as GCanvas, DisplayObject, Group } from '@antv/g';
2
2
  import { Renderer as CanvasRenderer } from '@antv/g-canvas';
3
3
  import { Plugin as DragAndDropPlugin } from '@antv/g-plugin-dragndrop';
4
4
  import { deepMix } from '@antv/util';
5
+ import EventEmitter from '@antv/event-emitter';
5
6
  import { createLibrary } from '../stdlib';
6
7
  import { select } from '../utils/selection';
7
- import { emitEvent, CHART_LIFE_CIRCLE, offEvent } from '../utils/event';
8
+ import { CHART_LIFE_CIRCLE } from '../utils/event';
8
9
  import { G2Context, G2ViewTree } from './types/options';
9
10
  import { plot } from './plot';
10
11
 
@@ -65,12 +66,17 @@ export function render<T extends G2ViewTree = G2ViewTree>(
65
66
  // Initialize the context if it is not provided.
66
67
  const { width = 640, height = 480, on } = options;
67
68
  const keyed = inferKeys(options);
68
- const { canvas = Canvas(width, height), library = createLibrary() } = context;
69
+ const {
70
+ canvas = Canvas(width, height),
71
+ library = createLibrary(),
72
+ emitter = new EventEmitter(),
73
+ } = context;
69
74
  context.canvas = canvas;
70
75
  context.library = library;
76
+ context.emitter = emitter;
71
77
  canvas.resize(width, height);
72
78
 
73
- emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_RENDER);
79
+ emitter.emit(CHART_LIFE_CIRCLE.BEFORE_RENDER);
74
80
 
75
81
  // Plot the chart and mutate context.
76
82
  // Make sure that plot chart after container is ready for every time.
@@ -79,8 +85,10 @@ export function render<T extends G2ViewTree = G2ViewTree>(
79
85
  .then(() =>
80
86
  plot<T>({ ...keyed, width, height }, selection, library, context),
81
87
  )
82
- .then(callback)
83
- .then(() => emitEvent(on, CHART_LIFE_CIRCLE.AFTER_RENDER));
88
+ .then(() => {
89
+ emitter.emit(CHART_LIFE_CIRCLE.AFTER_RENDER);
90
+ callback?.();
91
+ });
84
92
 
85
93
  // Return the container HTML element wraps the canvas or svg element.
86
94
  return normalizeContainer(canvas.getConfig().container);
@@ -94,7 +102,11 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
94
102
  // Initialize the context if it is not provided.
95
103
  const { width = 640, height = 480, on } = options;
96
104
  const keyed = inferKeys(options);
97
- const { library = createLibrary(), group = new Group() } = context;
105
+ const {
106
+ library = createLibrary(),
107
+ group = new Group(),
108
+ emitter = new EventEmitter(),
109
+ } = context;
98
110
 
99
111
  if (!group?.parentElement) {
100
112
  throw new Error(
@@ -105,13 +117,15 @@ export function renderToMountedElement<T extends G2ViewTree = G2ViewTree>(
105
117
  const selection = select(group);
106
118
  context.group = group;
107
119
  context.library = library;
120
+ context.emitter = emitter;
108
121
 
109
- emitEvent(on, CHART_LIFE_CIRCLE.BEFORE_RENDER);
122
+ emitter.emit(CHART_LIFE_CIRCLE.BEFORE_RENDER);
110
123
  // Plot the chart and mutate context.
111
124
  // Make sure that plot chart after container is ready for every time.
112
- plot<T>({ ...keyed, width, height }, selection, library, context)
113
- .then(callback)
114
- .then(() => emitEvent(on, CHART_LIFE_CIRCLE.AFTER_RENDER));
125
+ plot<T>({ ...keyed, width, height }, selection, library, context).then(() => {
126
+ emitter.emit(CHART_LIFE_CIRCLE.AFTER_RENDER);
127
+ callback?.();
128
+ });
115
129
 
116
130
  // Return the Group wraps the canvas or svg element.
117
131
  return group;
@@ -121,12 +135,11 @@ export function destroy<T extends G2ViewTree = G2ViewTree>(
121
135
  options: T,
122
136
  context: G2Context = {},
123
137
  ) {
124
- const { on } = options;
125
- const { canvas } = context;
138
+ const { canvas, emitter } = context;
126
139
  if (canvas) {
127
140
  canvas.destroy();
128
141
  }
129
- offEvent(on);
142
+ emitter.off();
130
143
  }
131
144
 
132
145
  function normalizeContainer(container: HTMLElement | string): HTMLElement {
@@ -234,6 +234,7 @@ function inferScaleRange(
234
234
  case 'linear':
235
235
  case 'time':
236
236
  case 'log':
237
+ case 'pow':
237
238
  case 'sqrt': {
238
239
  const colors = categoricalColors(values, options, domain, theme, library);
239
240
  const [r0, r1] = inferRangeQ(name, colors);
@@ -498,3 +499,43 @@ export function isPosition(name: string): boolean {
498
499
  name === 'exitDuration'
499
500
  );
500
501
  }
502
+
503
+ export function isValidScale(scale: G2ScaleOptions) {
504
+ if (!scale || !scale.type) return false;
505
+ if (typeof scale.type === 'function') return true;
506
+ const { type, domain, range, interpolator } = scale;
507
+ const isValidDomain = domain && domain.length > 0;
508
+ const isValidRange = range && range.length > 0;
509
+
510
+ if (
511
+ [
512
+ 'linear',
513
+ 'sqrt',
514
+ 'log',
515
+ 'time',
516
+ 'pow',
517
+ 'threshold',
518
+ 'quantize',
519
+ 'quantile',
520
+ 'ordinal',
521
+ 'band',
522
+ 'point',
523
+ ].includes(type) &&
524
+ isValidDomain &&
525
+ isValidRange
526
+ ) {
527
+ return true;
528
+ }
529
+
530
+ if (
531
+ ['sequential'].includes(type) &&
532
+ isValidDomain &&
533
+ (isValidRange || interpolator)
534
+ ) {
535
+ return true;
536
+ }
537
+
538
+ if (['constant', 'identity'].includes(type) && isValidRange) return true;
539
+
540
+ return false;
541
+ }
@@ -174,6 +174,9 @@ export function addGuideToScale(
174
174
  ),
175
175
  color: { guide: normalize(legend, 'color') },
176
176
  size: { guide: normalize(legend, 'size') },
177
+ shape: { guide: normalize(legend, 'shape') },
178
+ // fixme: opacity is conflict with DisplayObject.opacity
179
+ // opacity: { guide: normalize(legend, 'opacity') },
177
180
  },
178
181
  });
179
182
  return [I, mark];
@@ -127,18 +127,24 @@ export type BBox = {
127
127
  height?: number;
128
128
  };
129
129
 
130
- export type GuideComponentPosition =
130
+ export type GuidePrimitivePosition =
131
131
  | 'top'
132
- | 'left'
133
132
  | 'bottom'
133
+ | 'left'
134
134
  | 'right'
135
- | 'centerVertical'
136
- | 'centerHorizontal'
137
135
  | 'center'
138
- | 'arc'
139
- | 'arcY'
140
- | 'arcInner'
141
- | 'arcCenter';
136
+ | 'inner'
137
+ | 'outer';
138
+ export type GuideCompositePosition =
139
+ | 'top-left'
140
+ | 'top-right'
141
+ | 'bottom-left'
142
+ | 'bottom-right';
143
+ export type GuideComponentPosition =
144
+ | GuidePrimitivePosition
145
+ | GuideCompositePosition;
146
+
147
+ export type GuideComponentOrientation = 'horizontal' | 'vertical' | number;
142
148
 
143
149
  export type Layout = {
144
150
  paddingLeft?: number;
@@ -162,13 +168,20 @@ export type Layout = {
162
168
  y?: number;
163
169
  };
164
170
 
165
- // @todo Using emus.
171
+ export type Direction = 'horizontal' | 'vertical' | 'center';
172
+
173
+ export type FlexLayout = {
174
+ flexDirection?: 'row' | 'column';
175
+ justifyContent?: 'flex-start' | 'flex-end' | 'center';
176
+ alignItems?: 'flex-start' | 'flex-end' | 'center';
177
+ };
178
+
166
179
  export type SectionArea = [
167
180
  x: number,
168
181
  y: number,
169
182
  width: number,
170
183
  height: number,
171
- direction: 0 | 1 | -1, // horizontal: 1, vertical: 0, center: -1
184
+ direction: Direction,
172
185
  reverse: boolean,
173
186
  comparator: (a: Primitive, b: Primitive) => number,
174
187
  ];
@@ -1,18 +1,25 @@
1
+ import { Coordinate, Transformation } from '@antv/coord';
1
2
  import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
2
- import { Transformation, Coordinate } from '@antv/coord';
3
3
  import {
4
- IndexedValue,
4
+ G2View,
5
+ G2GuideComponentOptions,
6
+ G2CoordinateOptions,
7
+ G2ScaleOptions,
8
+ G2ViewTree,
9
+ } from './options';
10
+ import {
5
11
  G2Theme,
6
- Vector2,
12
+ G2ViewInstance,
7
13
  GuideComponentPosition,
14
+ GuideComponentOrientation,
15
+ IndexedValue,
8
16
  Layout,
9
- G2ViewInstance,
17
+ Vector2,
10
18
  } from './common';
11
- import { G2ViewTree } from './options';
12
- import { EncodeComponent, Encode } from './encode';
13
- import { MarkComponent, Mark } from './mark';
14
- import { TransformComponent, Transform } from './transform';
15
19
  import { DataComponent } from './data';
20
+ import { Encode, EncodeComponent } from './encode';
21
+ import { Mark, MarkComponent } from './mark';
22
+ import { Transform, TransformComponent } from './transform';
16
23
 
17
24
  export type G2ComponentNamespaces =
18
25
  | 'coordinate'
@@ -156,15 +163,17 @@ export type ThemeComponent<O = Record<string, unknown>> = G2BaseComponent<
156
163
  >;
157
164
 
158
165
  export type GuideComponent = (
159
- scale: Scale,
166
+ scales: Scale[],
160
167
  style: Record<string, any>,
161
168
  coordinate: Coordinate,
162
169
  theme: G2Theme,
163
170
  ) => DisplayObject;
164
171
  export type GuideComponentProps = {
165
- defaultPosition: GuideComponentPosition;
172
+ defaultPosition?: GuideComponentPosition;
173
+ defaultOrientation?: GuideComponentOrientation;
166
174
  defaultSize: number;
167
175
  defaultOrder: number;
176
+ [key: string]: any;
168
177
  };
169
178
  export type GuideComponentComponent<O = Record<string, unknown>> =
170
179
  G2BaseComponent<GuideComponent, O, GuideComponentProps>;