@antv/g2 5.0.0-beta.10 → 5.0.0-beta.12

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 (421) hide show
  1. package/dist/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +4 -4
  3. package/esm/api/chart.d.ts +2 -1
  4. package/esm/api/chart.js +2 -2
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition/base.d.ts +1 -1
  7. package/esm/api/composition/base.js +6 -17
  8. package/esm/api/composition/base.js.map +1 -1
  9. package/esm/api/composition/facetCircle.d.ts +2 -2
  10. package/esm/api/composition/facetCircle.js +2 -2
  11. package/esm/api/composition/facetCircle.js.map +1 -1
  12. package/esm/api/composition/facetRect.d.ts +2 -2
  13. package/esm/api/composition/facetRect.js +2 -2
  14. package/esm/api/composition/facetRect.js.map +1 -1
  15. package/esm/api/composition/geoPath.d.ts +2 -2
  16. package/esm/api/composition/geoPath.js +2 -2
  17. package/esm/api/composition/geoPath.js.map +1 -1
  18. package/esm/api/composition/geoView.d.ts +2 -2
  19. package/esm/api/composition/geoView.js +2 -2
  20. package/esm/api/composition/geoView.js.map +1 -1
  21. package/esm/api/composition/index.d.ts +2 -2
  22. package/esm/api/composition/index.js +2 -2
  23. package/esm/api/composition/index.js.map +1 -1
  24. package/esm/api/composition/repeatMatrix.d.ts +2 -2
  25. package/esm/api/composition/repeatMatrix.js +2 -2
  26. package/esm/api/composition/repeatMatrix.js.map +1 -1
  27. package/esm/api/composition/spaceFlex.d.ts +2 -2
  28. package/esm/api/composition/spaceFlex.js +2 -2
  29. package/esm/api/composition/spaceFlex.js.map +1 -1
  30. package/esm/api/composition/spaceLayer.d.ts +2 -2
  31. package/esm/api/composition/spaceLayer.js +2 -2
  32. package/esm/api/composition/spaceLayer.js.map +1 -1
  33. package/esm/api/composition/timingKeyframe.d.ts +2 -2
  34. package/esm/api/composition/timingKeyframe.js +2 -2
  35. package/esm/api/composition/timingKeyframe.js.map +1 -1
  36. package/esm/api/composition/view.d.ts +2 -2
  37. package/esm/api/composition/view.js +2 -2
  38. package/esm/api/composition/view.js.map +1 -1
  39. package/esm/api/index.d.ts +2 -0
  40. package/esm/api/index.js +2 -0
  41. package/esm/api/index.js.map +1 -1
  42. package/esm/api/mark/base.d.ts +1 -1
  43. package/esm/api/mark/base.js +7 -7
  44. package/esm/api/mark/base.js.map +1 -1
  45. package/esm/api/mark/index.d.ts +1 -0
  46. package/esm/api/mark/index.js +1 -0
  47. package/esm/api/mark/index.js.map +1 -1
  48. package/esm/api/mark/mark.d.ts +27 -27
  49. package/esm/api/mark/mark.js +28 -27
  50. package/esm/api/mark/mark.js.map +1 -1
  51. package/esm/api/mark/types.d.ts +1 -0
  52. package/esm/api/node.d.ts +1 -1
  53. package/esm/api/node.js +1 -1
  54. package/esm/api/node.js.map +1 -1
  55. package/esm/api/props.d.ts +1 -1
  56. package/esm/api/props.js +20 -0
  57. package/esm/api/props.js.map +1 -1
  58. package/esm/composition/timingKeyframe.js +13 -7
  59. package/esm/composition/timingKeyframe.js.map +1 -1
  60. package/esm/composition/view.js +2 -6
  61. package/esm/composition/view.js.map +1 -1
  62. package/esm/index.d.ts +1 -1
  63. package/esm/index.js +1 -1
  64. package/esm/index.js.map +1 -1
  65. package/esm/interaction/builtin/tooltip.d.ts +10 -2
  66. package/esm/interaction/index.d.ts +1 -0
  67. package/esm/interaction/index.js +1 -0
  68. package/esm/interaction/index.js.map +1 -1
  69. package/esm/interaction/native/event.d.ts +1 -0
  70. package/esm/interaction/native/event.js +42 -0
  71. package/esm/interaction/native/event.js.map +1 -0
  72. package/esm/interaction/native/tooltip.d.ts +2 -3
  73. package/esm/interaction/native/tooltip.js +78 -76
  74. package/esm/interaction/native/tooltip.js.map +1 -1
  75. package/esm/mark/area.js +1 -0
  76. package/esm/mark/area.js.map +1 -1
  77. package/esm/mark/box.js +1 -0
  78. package/esm/mark/box.js.map +1 -1
  79. package/esm/mark/boxplot.js +1 -3
  80. package/esm/mark/boxplot.js.map +1 -1
  81. package/esm/mark/cell.js +1 -0
  82. package/esm/mark/cell.js.map +1 -1
  83. package/esm/mark/connector.js +1 -0
  84. package/esm/mark/connector.js.map +1 -1
  85. package/esm/mark/forceGraph.js +1 -1
  86. package/esm/mark/forceGraph.js.map +1 -1
  87. package/esm/mark/image.js +1 -0
  88. package/esm/mark/image.js.map +1 -1
  89. package/esm/mark/interval.js +1 -0
  90. package/esm/mark/interval.js.map +1 -1
  91. package/esm/mark/line.js +1 -0
  92. package/esm/mark/line.js.map +1 -1
  93. package/esm/mark/lineX.js +1 -0
  94. package/esm/mark/lineX.js.map +1 -1
  95. package/esm/mark/lineY.js +1 -0
  96. package/esm/mark/lineY.js.map +1 -1
  97. package/esm/mark/link.js +1 -0
  98. package/esm/mark/link.js.map +1 -1
  99. package/esm/mark/pack.js +1 -1
  100. package/esm/mark/pack.js.map +1 -1
  101. package/esm/mark/path.js +1 -0
  102. package/esm/mark/path.js.map +1 -1
  103. package/esm/mark/point.js +1 -0
  104. package/esm/mark/point.js.map +1 -1
  105. package/esm/mark/polygon.js +1 -0
  106. package/esm/mark/polygon.js.map +1 -1
  107. package/esm/mark/range.js +1 -0
  108. package/esm/mark/range.js.map +1 -1
  109. package/esm/mark/rangeX.js +1 -0
  110. package/esm/mark/rangeX.js.map +1 -1
  111. package/esm/mark/rangeY.js +1 -0
  112. package/esm/mark/rangeY.js.map +1 -1
  113. package/esm/mark/rect.js +1 -0
  114. package/esm/mark/rect.js.map +1 -1
  115. package/esm/mark/sankey.js +1 -1
  116. package/esm/mark/sankey.js.map +1 -1
  117. package/esm/mark/shape.js +1 -0
  118. package/esm/mark/shape.js.map +1 -1
  119. package/esm/mark/text.js +1 -0
  120. package/esm/mark/text.js.map +1 -1
  121. package/esm/mark/tree.js +1 -1
  122. package/esm/mark/tree.js.map +1 -1
  123. package/esm/mark/treemap.js +1 -1
  124. package/esm/mark/treemap.js.map +1 -1
  125. package/esm/mark/utils.js +1 -5
  126. package/esm/mark/utils.js.map +1 -1
  127. package/esm/mark/vector.js +1 -0
  128. package/esm/mark/vector.js.map +1 -1
  129. package/esm/mark/wordCloud.js +1 -1
  130. package/esm/mark/wordCloud.js.map +1 -1
  131. package/esm/runtime/mark.js +12 -7
  132. package/esm/runtime/mark.js.map +1 -1
  133. package/esm/runtime/plot.js +81 -39
  134. package/esm/runtime/plot.js.map +1 -1
  135. package/esm/runtime/scale.js +2 -0
  136. package/esm/runtime/scale.js.map +1 -1
  137. package/esm/runtime/transform.d.ts +5 -0
  138. package/esm/runtime/transform.js +63 -6
  139. package/esm/runtime/transform.js.map +1 -1
  140. package/esm/runtime/types/common.d.ts +1 -0
  141. package/esm/runtime/types/component.d.ts +2 -1
  142. package/esm/runtime/types/mark.d.ts +3 -3
  143. package/esm/runtime/types/options.d.ts +8 -1
  144. package/esm/scale/constant.d.ts +4 -0
  145. package/esm/scale/constant.js +6 -0
  146. package/esm/scale/constant.js.map +1 -0
  147. package/esm/scale/index.d.ts +2 -0
  148. package/esm/scale/index.js +1 -0
  149. package/esm/scale/index.js.map +1 -1
  150. package/esm/shape/interval/color.js +6 -4
  151. package/esm/shape/interval/color.js.map +1 -1
  152. package/esm/spec/geometry.d.ts +33 -17
  153. package/esm/spec/interaction.d.ts +6 -1
  154. package/esm/spec/scale.d.ts +4 -3
  155. package/esm/stdlib/index.js +3 -3
  156. package/esm/stdlib/index.js.map +1 -1
  157. package/esm/transform/groupN.js +2 -2
  158. package/esm/transform/groupN.js.map +1 -1
  159. package/esm/transform/maybeTitle.js +13 -3
  160. package/esm/transform/maybeTitle.js.map +1 -1
  161. package/esm/transform/maybeTooltip.js +20 -20
  162. package/esm/transform/maybeTooltip.js.map +1 -1
  163. package/esm/transform/maybeZeroX.js +2 -2
  164. package/esm/transform/maybeZeroX.js.map +1 -1
  165. package/esm/transform/maybeZeroY.js +2 -2
  166. package/esm/transform/maybeZeroY.js.map +1 -1
  167. package/esm/transform/maybeZeroY1.js +2 -2
  168. package/esm/transform/maybeZeroY1.js.map +1 -1
  169. package/esm/transform/utils/helper.d.ts +12 -0
  170. package/esm/transform/utils/helper.js +8 -0
  171. package/esm/transform/utils/helper.js.map +1 -1
  172. package/esm/utils/helper.js +4 -1
  173. package/esm/utils/helper.js.map +1 -1
  174. package/lib/api/chart.d.ts +2 -1
  175. package/lib/api/chart.js +2 -2
  176. package/lib/api/chart.js.map +1 -1
  177. package/lib/api/composition/base.d.ts +1 -1
  178. package/lib/api/composition/base.js +8 -18
  179. package/lib/api/composition/base.js.map +1 -1
  180. package/lib/api/composition/facetCircle.d.ts +2 -2
  181. package/lib/api/composition/facetCircle.js +1 -1
  182. package/lib/api/composition/facetCircle.js.map +1 -1
  183. package/lib/api/composition/facetRect.d.ts +2 -2
  184. package/lib/api/composition/facetRect.js +1 -1
  185. package/lib/api/composition/facetRect.js.map +1 -1
  186. package/lib/api/composition/geoPath.d.ts +2 -2
  187. package/lib/api/composition/geoPath.js +1 -1
  188. package/lib/api/composition/geoPath.js.map +1 -1
  189. package/lib/api/composition/geoView.d.ts +2 -2
  190. package/lib/api/composition/geoView.js +1 -1
  191. package/lib/api/composition/geoView.js.map +1 -1
  192. package/lib/api/composition/index.d.ts +2 -2
  193. package/lib/api/composition/index.js +2 -2
  194. package/lib/api/composition/index.js.map +1 -1
  195. package/lib/api/composition/repeatMatrix.d.ts +2 -2
  196. package/lib/api/composition/repeatMatrix.js +1 -1
  197. package/lib/api/composition/repeatMatrix.js.map +1 -1
  198. package/lib/api/composition/spaceFlex.d.ts +2 -2
  199. package/lib/api/composition/spaceFlex.js +1 -1
  200. package/lib/api/composition/spaceFlex.js.map +1 -1
  201. package/lib/api/composition/spaceLayer.d.ts +2 -2
  202. package/lib/api/composition/spaceLayer.js +1 -1
  203. package/lib/api/composition/spaceLayer.js.map +1 -1
  204. package/lib/api/composition/timingKeyframe.d.ts +2 -2
  205. package/lib/api/composition/timingKeyframe.js +1 -1
  206. package/lib/api/composition/timingKeyframe.js.map +1 -1
  207. package/lib/api/composition/view.d.ts +2 -2
  208. package/lib/api/composition/view.js +1 -1
  209. package/lib/api/composition/view.js.map +1 -1
  210. package/lib/api/index.d.ts +2 -0
  211. package/lib/api/index.js +5 -1
  212. package/lib/api/index.js.map +1 -1
  213. package/lib/api/mark/base.d.ts +1 -1
  214. package/lib/api/mark/base.js +9 -9
  215. package/lib/api/mark/base.js.map +1 -1
  216. package/lib/api/mark/index.d.ts +1 -0
  217. package/lib/api/mark/index.js +3 -1
  218. package/lib/api/mark/index.js.map +1 -1
  219. package/lib/api/mark/mark.d.ts +27 -27
  220. package/lib/api/mark/mark.js +27 -26
  221. package/lib/api/mark/mark.js.map +1 -1
  222. package/lib/api/mark/types.d.ts +1 -0
  223. package/lib/api/node.d.ts +1 -1
  224. package/lib/api/node.js +1 -1
  225. package/lib/api/node.js.map +1 -1
  226. package/lib/api/props.d.ts +1 -1
  227. package/lib/api/props.js +20 -0
  228. package/lib/api/props.js.map +1 -1
  229. package/lib/composition/timingKeyframe.js +13 -7
  230. package/lib/composition/timingKeyframe.js.map +1 -1
  231. package/lib/composition/view.js +2 -6
  232. package/lib/composition/view.js.map +1 -1
  233. package/lib/index.d.ts +1 -1
  234. package/lib/index.js +3 -1
  235. package/lib/index.js.map +1 -1
  236. package/lib/interaction/builtin/tooltip.d.ts +10 -2
  237. package/lib/interaction/index.d.ts +1 -0
  238. package/lib/interaction/index.js +3 -1
  239. package/lib/interaction/index.js.map +1 -1
  240. package/lib/interaction/native/event.d.ts +1 -0
  241. package/lib/interaction/native/event.js +46 -0
  242. package/lib/interaction/native/event.js.map +1 -0
  243. package/lib/interaction/native/tooltip.d.ts +2 -3
  244. package/lib/interaction/native/tooltip.js +76 -74
  245. package/lib/interaction/native/tooltip.js.map +1 -1
  246. package/lib/mark/area.js +1 -0
  247. package/lib/mark/area.js.map +1 -1
  248. package/lib/mark/box.js +1 -0
  249. package/lib/mark/box.js.map +1 -1
  250. package/lib/mark/boxplot.js +1 -3
  251. package/lib/mark/boxplot.js.map +1 -1
  252. package/lib/mark/cell.js +1 -0
  253. package/lib/mark/cell.js.map +1 -1
  254. package/lib/mark/connector.js +1 -0
  255. package/lib/mark/connector.js.map +1 -1
  256. package/lib/mark/forceGraph.js +1 -1
  257. package/lib/mark/forceGraph.js.map +1 -1
  258. package/lib/mark/image.js +1 -0
  259. package/lib/mark/image.js.map +1 -1
  260. package/lib/mark/interval.js +1 -0
  261. package/lib/mark/interval.js.map +1 -1
  262. package/lib/mark/line.js +1 -0
  263. package/lib/mark/line.js.map +1 -1
  264. package/lib/mark/lineX.js +1 -0
  265. package/lib/mark/lineX.js.map +1 -1
  266. package/lib/mark/lineY.js +1 -0
  267. package/lib/mark/lineY.js.map +1 -1
  268. package/lib/mark/link.js +1 -0
  269. package/lib/mark/link.js.map +1 -1
  270. package/lib/mark/pack.js +1 -1
  271. package/lib/mark/pack.js.map +1 -1
  272. package/lib/mark/path.js +1 -0
  273. package/lib/mark/path.js.map +1 -1
  274. package/lib/mark/point.js +1 -0
  275. package/lib/mark/point.js.map +1 -1
  276. package/lib/mark/polygon.js +1 -0
  277. package/lib/mark/polygon.js.map +1 -1
  278. package/lib/mark/range.js +1 -0
  279. package/lib/mark/range.js.map +1 -1
  280. package/lib/mark/rangeX.js +1 -0
  281. package/lib/mark/rangeX.js.map +1 -1
  282. package/lib/mark/rangeY.js +1 -0
  283. package/lib/mark/rangeY.js.map +1 -1
  284. package/lib/mark/rect.js +1 -0
  285. package/lib/mark/rect.js.map +1 -1
  286. package/lib/mark/sankey.js +1 -1
  287. package/lib/mark/sankey.js.map +1 -1
  288. package/lib/mark/shape.js +1 -0
  289. package/lib/mark/shape.js.map +1 -1
  290. package/lib/mark/text.js +1 -0
  291. package/lib/mark/text.js.map +1 -1
  292. package/lib/mark/tree.js +1 -1
  293. package/lib/mark/tree.js.map +1 -1
  294. package/lib/mark/treemap.js +1 -1
  295. package/lib/mark/treemap.js.map +1 -1
  296. package/lib/mark/utils.js +1 -5
  297. package/lib/mark/utils.js.map +1 -1
  298. package/lib/mark/vector.js +1 -0
  299. package/lib/mark/vector.js.map +1 -1
  300. package/lib/mark/wordCloud.js +1 -1
  301. package/lib/mark/wordCloud.js.map +1 -1
  302. package/lib/runtime/mark.js +11 -6
  303. package/lib/runtime/mark.js.map +1 -1
  304. package/lib/runtime/plot.js +81 -39
  305. package/lib/runtime/plot.js.map +1 -1
  306. package/lib/runtime/scale.js +2 -0
  307. package/lib/runtime/scale.js.map +1 -1
  308. package/lib/runtime/transform.d.ts +5 -0
  309. package/lib/runtime/transform.js +65 -6
  310. package/lib/runtime/transform.js.map +1 -1
  311. package/lib/runtime/types/common.d.ts +1 -0
  312. package/lib/runtime/types/component.d.ts +2 -1
  313. package/lib/runtime/types/mark.d.ts +3 -3
  314. package/lib/runtime/types/options.d.ts +8 -1
  315. package/lib/scale/constant.d.ts +4 -0
  316. package/lib/scale/constant.js +10 -0
  317. package/lib/scale/constant.js.map +1 -0
  318. package/lib/scale/index.d.ts +2 -0
  319. package/lib/scale/index.js +3 -1
  320. package/lib/scale/index.js.map +1 -1
  321. package/lib/shape/interval/color.js +6 -4
  322. package/lib/shape/interval/color.js.map +1 -1
  323. package/lib/spec/geometry.d.ts +33 -17
  324. package/lib/spec/interaction.d.ts +6 -1
  325. package/lib/spec/scale.d.ts +4 -3
  326. package/lib/stdlib/index.js +1 -1
  327. package/lib/stdlib/index.js.map +1 -1
  328. package/lib/transform/groupN.js +1 -1
  329. package/lib/transform/groupN.js.map +1 -1
  330. package/lib/transform/maybeTitle.js +12 -2
  331. package/lib/transform/maybeTitle.js.map +1 -1
  332. package/lib/transform/maybeTooltip.js +20 -20
  333. package/lib/transform/maybeTooltip.js.map +1 -1
  334. package/lib/transform/maybeZeroX.js +1 -1
  335. package/lib/transform/maybeZeroX.js.map +1 -1
  336. package/lib/transform/maybeZeroY.js +1 -1
  337. package/lib/transform/maybeZeroY.js.map +1 -1
  338. package/lib/transform/maybeZeroY1.js +1 -1
  339. package/lib/transform/maybeZeroY1.js.map +1 -1
  340. package/lib/transform/utils/helper.d.ts +12 -0
  341. package/lib/transform/utils/helper.js +11 -1
  342. package/lib/transform/utils/helper.js.map +1 -1
  343. package/lib/utils/helper.js +4 -1
  344. package/lib/utils/helper.js.map +1 -1
  345. package/package.json +4 -4
  346. package/src/api/chart.ts +2 -2
  347. package/src/api/composition/base.ts +5 -7
  348. package/src/api/composition/facetCircle.ts +2 -2
  349. package/src/api/composition/facetRect.ts +2 -2
  350. package/src/api/composition/geoPath.ts +2 -2
  351. package/src/api/composition/geoView.ts +2 -2
  352. package/src/api/composition/index.ts +2 -2
  353. package/src/api/composition/repeatMatrix.ts +2 -2
  354. package/src/api/composition/spaceFlex.ts +2 -2
  355. package/src/api/composition/spaceLayer.ts +2 -2
  356. package/src/api/composition/timingKeyframe.ts +2 -2
  357. package/src/api/composition/view.ts +2 -2
  358. package/src/api/index.ts +2 -0
  359. package/src/api/mark/base.ts +7 -7
  360. package/src/api/mark/index.ts +2 -0
  361. package/src/api/mark/mark.ts +28 -27
  362. package/src/api/mark/types.ts +1 -0
  363. package/src/api/node.ts +1 -1
  364. package/src/api/props.ts +22 -1
  365. package/src/composition/timingKeyframe.ts +13 -7
  366. package/src/composition/view.ts +1 -9
  367. package/src/index.ts +1 -1
  368. package/src/interaction/index.ts +1 -0
  369. package/src/interaction/native/event.ts +44 -0
  370. package/src/interaction/native/tooltip.ts +78 -95
  371. package/src/mark/area.ts +1 -0
  372. package/src/mark/box.ts +1 -0
  373. package/src/mark/boxplot.ts +1 -3
  374. package/src/mark/cell.ts +1 -0
  375. package/src/mark/connector.ts +1 -0
  376. package/src/mark/forceGraph.ts +1 -1
  377. package/src/mark/image.ts +1 -0
  378. package/src/mark/interval.ts +1 -0
  379. package/src/mark/line.ts +1 -0
  380. package/src/mark/lineX.ts +1 -0
  381. package/src/mark/lineY.ts +1 -0
  382. package/src/mark/link.ts +1 -0
  383. package/src/mark/pack.ts +1 -1
  384. package/src/mark/path.ts +1 -0
  385. package/src/mark/point.ts +1 -0
  386. package/src/mark/polygon.ts +1 -0
  387. package/src/mark/range.ts +1 -0
  388. package/src/mark/rangeX.ts +1 -0
  389. package/src/mark/rangeY.ts +1 -0
  390. package/src/mark/rect.ts +1 -0
  391. package/src/mark/sankey.ts +1 -1
  392. package/src/mark/shape.ts +1 -0
  393. package/src/mark/text.ts +1 -0
  394. package/src/mark/tree.ts +1 -1
  395. package/src/mark/treemap.ts +1 -1
  396. package/src/mark/utils.ts +1 -5
  397. package/src/mark/vector.ts +1 -0
  398. package/src/mark/wordCloud.ts +1 -1
  399. package/src/runtime/mark.ts +13 -5
  400. package/src/runtime/plot.ts +117 -50
  401. package/src/runtime/scale.ts +2 -0
  402. package/src/runtime/transform.ts +72 -6
  403. package/src/runtime/types/common.ts +1 -0
  404. package/src/runtime/types/component.ts +2 -0
  405. package/src/runtime/types/mark.ts +3 -3
  406. package/src/runtime/types/options.ts +8 -1
  407. package/src/scale/constant.ts +11 -0
  408. package/src/scale/index.ts +2 -0
  409. package/src/shape/interval/color.ts +11 -7
  410. package/src/spec/geometry.ts +38 -30
  411. package/src/spec/interaction.ts +5 -1
  412. package/src/spec/scale.ts +6 -1
  413. package/src/stdlib/index.ts +4 -0
  414. package/src/transform/groupN.ts +2 -2
  415. package/src/transform/maybeTitle.ts +11 -3
  416. package/src/transform/maybeTooltip.ts +17 -21
  417. package/src/transform/maybeZeroX.ts +2 -2
  418. package/src/transform/maybeZeroY.ts +2 -2
  419. package/src/transform/maybeZeroY1.ts +2 -2
  420. package/src/transform/utils/helper.ts +10 -0
  421. package/src/utils/helper.ts +6 -1
@@ -7,7 +7,6 @@ import { mapObject } from '../utils/array';
7
7
  import { CHART_LIFE_CIRCLE } from '../utils/event';
8
8
  import {
9
9
  appendTransform,
10
- compose,
11
10
  copyAttributes,
12
11
  defined,
13
12
  error,
@@ -100,6 +99,12 @@ export async function plot<T extends G2ViewTree>(
100
99
  );
101
100
  const typeOf = (node: G2ViewTree) => {
102
101
  const { type } = node;
102
+ if (typeof type === 'function') {
103
+ // @ts-ignore
104
+ const { props = {} } = type;
105
+ const { composite = true } = props;
106
+ if (composite) return 'mark';
107
+ }
103
108
  return typeof type === 'string' && marks.has(type) ? 'mark' : type;
104
109
  };
105
110
  const isMark = (node: G2ViewTree) => typeOf(node) === 'mark';
@@ -226,7 +231,7 @@ export async function plot<T extends G2ViewTree>(
226
231
  // Apply interactions.
227
232
  for (const option of inferInteraction(options)) {
228
233
  const interaction = useInteraction(option);
229
- const destroy = interaction(target, enterViewInstances);
234
+ const destroy = interaction(target, enterViewInstances, context.emitter);
230
235
  nameInteraction.set(option.type, { destroy });
231
236
  }
232
237
  }
@@ -243,7 +248,7 @@ export async function plot<T extends G2ViewTree>(
243
248
 
244
249
  // Apply new interaction.
245
250
  const interaction = useInteraction(option);
246
- const destroy = interaction(target, updateViewInstances);
251
+ const destroy = interaction(target, updateViewInstances, context.emitter);
247
252
  nameInteraction.set(options.type, { destroy });
248
253
  }
249
254
  }
@@ -311,11 +316,80 @@ async function initializeView(
311
316
  options: G2View,
312
317
  library: G2Library,
313
318
  ): Promise<[G2ViewDescriptor, G2ViewTree[]]> {
314
- const transformedOptions = coordinate2Transform(options, library);
319
+ const flattenOptions = await transformMarks(options, library);
320
+
321
+ const mergedOptions = bubbleOptions(flattenOptions);
322
+ // @todo Remove this.
323
+ // !!! NOTE: Mute original view options.
324
+ // Update interaction and coordinate for this view.
325
+ options.interaction = mergedOptions.interaction;
326
+ options.coordinate = mergedOptions.coordinate;
327
+
328
+ const transformedOptions = coordinate2Transform(mergedOptions, library);
315
329
  const state = await initializeMarks(transformedOptions, library);
316
330
  return initializeState(state, transformedOptions, library);
317
331
  }
318
332
 
333
+ function bubbleOptions(options: G2View): G2View {
334
+ const {
335
+ coordinate: viewCoordinate = {},
336
+ interaction: viewInteraction = {},
337
+ marks,
338
+ ...rest
339
+ } = options;
340
+ const markCoordinates = marks.map((d) => d.coordinate || {});
341
+ const markInteractions = marks.map((d) => d.interaction || {});
342
+ const newCoordinate = [...markCoordinates, viewCoordinate].reduceRight(
343
+ (prev, cur) => deepMix(prev, cur),
344
+ {},
345
+ );
346
+ const newInteraction = [viewInteraction, ...markInteractions].reduce(
347
+ (prev, cur) => deepMix(prev, cur),
348
+ {},
349
+ );
350
+ return {
351
+ ...rest,
352
+ marks,
353
+ coordinate: newCoordinate,
354
+ interaction: newInteraction,
355
+ };
356
+ }
357
+
358
+ async function transformMarks(
359
+ options: G2View,
360
+ library: G2Library,
361
+ ): Promise<G2View> {
362
+ const [useMark, createMark] = useLibrary<G2MarkOptions, MarkComponent, Mark>(
363
+ 'mark',
364
+ library,
365
+ );
366
+
367
+ const { marks } = options;
368
+ const flattenMarks = [];
369
+ const discovered = [...marks];
370
+
371
+ // Pre order traversal.
372
+ while (discovered.length) {
373
+ const [node] = discovered.splice(0, 1);
374
+ // Apply data transform to get data.
375
+ const mark = (await applyTransform(node, library)) as G2Mark;
376
+ const { type = error('G2Mark type is required.'), key } = mark;
377
+ const { props = {} } = createMark(type);
378
+ const { composite = true } = props;
379
+ if (!composite) flattenMarks.push(mark);
380
+ else {
381
+ // Convert composite mark to marks.
382
+ const marks = await (
383
+ useMark as (options: G2MarkOptions) => CompositeMark
384
+ )(mark)(options);
385
+ const M = Array.isArray(marks) ? marks : [marks];
386
+ discovered.unshift(...M.map((d, i) => ({ ...d, key: `${key}-${i}` })));
387
+ }
388
+ }
389
+
390
+ return { ...options, marks: flattenMarks };
391
+ }
392
+
319
393
  async function initializeMarks(
320
394
  options: G2View,
321
395
  library: G2Library,
@@ -324,7 +398,7 @@ async function initializeMarks(
324
398
  'theme',
325
399
  library,
326
400
  );
327
- const [useMark, createMark] = useLibrary<G2MarkOptions, MarkComponent, Mark>(
401
+ const [, createMark] = useLibrary<G2MarkOptions, MarkComponent, Mark>(
328
402
  'mark',
329
403
  library,
330
404
  );
@@ -337,31 +411,10 @@ async function initializeMarks(
337
411
  const theme = useTheme(inferTheme(partialTheme));
338
412
  const markState = new Map<G2Mark, G2MarkState>();
339
413
 
340
- // Apply data transform to get data.
341
- const dataMarks = [];
342
- for (const mark of partialMarks) {
343
- const dataMark = await applyTransform(mark, library);
344
- dataMarks.push(dataMark);
345
- }
346
-
347
- // Convert composite mark to single mark.
348
- const flattenMarks = await Promise.all(
349
- dataMarks.map(async (mark) => {
350
- const { type = error('G2Mark type is required.'), key } = mark;
351
- const { props } = createMark(type);
352
- const { composite = false } = props;
353
- if (!composite) return mark;
354
- const marks = await (
355
- useMark as (options: G2MarkOptions) => CompositeMark
356
- )(mark)(options);
357
- return marks.map((d, i) => ({ key: `${key}-${i}`, ...d }));
358
- }),
359
- ).then((res) => res.flat());
360
-
361
414
  // Initialize channels for marks.
362
- for (const markOptions of flattenMarks) {
415
+ for (const markOptions of partialMarks) {
363
416
  const { type } = markOptions;
364
- const { props } = createMark(type);
417
+ const { props = {} } = createMark(type);
365
418
  const markAndState = await initializeMark(markOptions, props, library);
366
419
  if (markAndState) {
367
420
  const [initializedMark, state] = markAndState;
@@ -474,7 +527,7 @@ function initializeState(
474
527
  modifier,
475
528
  key: markKey,
476
529
  } = mark;
477
- const { index, channels } = state;
530
+ const { index, channels, tooltip } = state;
478
531
  const scale = Object.fromEntries(
479
532
  channels.map(({ name, scale }) => [name, scale]),
480
533
  );
@@ -495,6 +548,8 @@ function initializeState(
495
548
  );
496
549
  const count = dataDomain || I.length;
497
550
  const T = modifier ? modifier(P, count, layout) : [];
551
+ const titleOf = (i) => tooltip.title?.[i]?.value;
552
+ const itemsOf = (i) => tooltip.items.map((V) => V[i]);
498
553
  const visualData: Record<string, any>[] = I.map((d, i) => {
499
554
  const datum = {
500
555
  points: P[i],
@@ -502,12 +557,20 @@ function initializeState(
502
557
  index: d,
503
558
  markKey,
504
559
  viewKey: key,
560
+ ...(tooltip && {
561
+ title: titleOf(d),
562
+ items: itemsOf(d),
563
+ }),
505
564
  };
506
565
  for (const [k, V] of Object.entries(value)) {
507
566
  datum[k] = V[d];
508
567
  if (S) datum[`series${upperFirst(k)}`] = S[i].map((i) => V[i]);
509
568
  }
510
569
  if (S) datum['seriesIndex'] = S[i];
570
+ if (S && tooltip) {
571
+ datum['seriesItems'] = S[i].map((si) => itemsOf(si));
572
+ datum['seriesTitle'] = S[i].map((si) => titleOf(si));
573
+ }
511
574
  return datum;
512
575
  });
513
576
  state.data = visualData;
@@ -680,12 +743,14 @@ async function plotView(
680
743
  // Render marks with corresponding data.
681
744
  for (const [mark, state] of markState.entries()) {
682
745
  const { data } = state;
683
- const { key, class: cls } = mark;
746
+ const { key, class: cls, type } = mark;
684
747
  const shapeFunction = createMarkShapeFunction(mark, state, view, library);
685
748
  const enterFunction = createEnterFunction(mark, state, view, library);
686
749
  const updateFunction = createUpdateFunction(mark, state, view, library);
687
750
  const exitFunction = createExitFunction(mark, state, view, library);
688
751
  const facetElements = selectFacetElements(selection, cls, 'element');
752
+ const classNames = [ELEMENT_CLASS_NAME];
753
+ if (typeof type === 'string') classNames.push(type);
689
754
  const T = selection
690
755
  .select(`#${key}`)
691
756
  .selectAll(className(ELEMENT_CLASS_NAME))
@@ -699,7 +764,7 @@ async function plotView(
699
764
  (enter) =>
700
765
  enter
701
766
  .append(shapeFunction)
702
- .attr('className', ELEMENT_CLASS_NAME)
767
+ .attr('className', classNames.join(' '))
703
768
  .transition(function (data) {
704
769
  return enterFunction(data, [this]);
705
770
  }),
@@ -995,17 +1060,22 @@ function computeAnimationExtent(markState): [number, number] {
995
1060
  for (const [mark, state] of markState) {
996
1061
  const { animate = {} } = mark;
997
1062
  const { data } = state;
1063
+ const { enter = {}, update = {}, exit = {} } = animate;
1064
+ const {
1065
+ type: defaultUpdateType,
1066
+ duration: defaultUpdateDuration = 300,
1067
+ delay: defaultUpdateDelay = 0,
1068
+ } = update;
998
1069
  const {
999
- updateType: defaultUpdateType,
1000
- updateDuration: defaultUpdateDuration = 300,
1001
- updateDelay: defaultUpdateDelay = 0,
1002
- enterType: defaultEnterType,
1003
- enterDuration: defaultEnterDuration = 300,
1004
- enterDelay: defaultEnterDelay = 0,
1005
- exitType: defaultExitType,
1006
- exitDuration: defaultExitDuration = 300,
1007
- exitDelay: defaultExitDelay = 0,
1008
- } = animate;
1070
+ type: defaultEnterType,
1071
+ duration: defaultEnterDuration = 300,
1072
+ delay: defaultEnterDelay = 0,
1073
+ } = enter;
1074
+ const {
1075
+ type: defaultExitType,
1076
+ duration: defaultExitDuration = 300,
1077
+ delay: defaultExitDelay = 0,
1078
+ } = exit;
1009
1079
  for (const d of data) {
1010
1080
  const {
1011
1081
  updateType = defaultUpdateType,
@@ -1146,7 +1216,7 @@ function createAnimationFunction(
1146
1216
  shapeName(mark, defaultShape),
1147
1217
  ).props;
1148
1218
  const { [type]: defaultEffectTiming = {} } = theme;
1149
- const animate = subObject(mark.animate || {}, type);
1219
+ const animate = mark.animate?.[type] || {};
1150
1220
  return (data, from, to) => {
1151
1221
  const {
1152
1222
  [`${type}Type`]: animation,
@@ -1226,14 +1296,11 @@ function inferTheme(theme: G2ThemeOptions = { type: 'light' }): G2ThemeOptions {
1226
1296
  * @todo Infer builtin tooltips.
1227
1297
  */
1228
1298
  function inferInteraction(view: G2View): G2InteractionOptions[] {
1229
- const defaults = {};
1230
- const { interaction = {}, marks = [] } = view;
1231
- const markInteractions = marks.map((d) => d.interaction || {});
1232
- const all = [defaults, interaction, ...markInteractions].reduce(
1233
- (total, value) => deepMix(total, value),
1234
- {},
1235
- );
1236
- return Object.entries(all)
1299
+ const defaults = {
1300
+ event: true,
1301
+ };
1302
+ const { interaction = {} } = view;
1303
+ return Object.entries(deepMix(defaults, interaction))
1237
1304
  .filter((d) => !!d[1])
1238
1305
  .map(([key, value]) => ({
1239
1306
  type: key,
@@ -248,6 +248,8 @@ function inferScaleRange(
248
248
  }
249
249
  case 'sequential':
250
250
  return undefined;
251
+ case 'constant':
252
+ return [values[0][0]];
251
253
  default:
252
254
  return [];
253
255
  }
@@ -1,7 +1,7 @@
1
1
  import { Primitive } from 'd3-array';
2
2
  import { deepMix } from '@antv/util';
3
3
  import { indexOf, mapObject } from '../utils/array';
4
- import { composeAsync, defined } from '../utils/helper';
4
+ import { composeAsync, defined, isStrictObject } from '../utils/helper';
5
5
  import { useLibrary } from './library';
6
6
  import { createColumnOf } from './mark';
7
7
  import { Data, DataComponent } from './types/data';
@@ -77,7 +77,6 @@ export function inferChannelsType(
77
77
  return [I, { ...mark, encode: typedEncode }];
78
78
  }
79
79
 
80
- // @todo Move visual property to style instead of flagging visual.
81
80
  export function maybeVisualChannel(
82
81
  I: number[],
83
82
  mark: G2Mark,
@@ -88,7 +87,7 @@ export function maybeVisualChannel(
88
87
  const newEncode = mapObject(encode, (channel, name) => {
89
88
  const { type } = channel;
90
89
  if (type !== 'constant' || isPosition(name)) return channel;
91
- return { ...channel, visual: true };
90
+ return { ...channel, constant: true };
92
91
  });
93
92
  return [I, { ...mark, encode: newEncode }];
94
93
  }
@@ -106,6 +105,73 @@ export function extractColumns(
106
105
  return [I, { ...mark, encode: valuedEncode }];
107
106
  }
108
107
 
108
+ /**
109
+ * Normalize mark.tooltip to {title, items}.
110
+ */
111
+ export function normalizeTooltip(
112
+ I: number[],
113
+ mark: G2Mark,
114
+ context: TransformContext,
115
+ ): [number[], G2Mark] {
116
+ const { tooltip = {} } = mark;
117
+ const isFullTooltip = (tooltip) => {
118
+ if (Object.keys(tooltip).length === 0) return true;
119
+ const { title, items } = tooltip;
120
+ return title !== undefined || items !== undefined;
121
+ };
122
+ if (tooltip === null) return [I, mark];
123
+ if (Array.isArray(tooltip)) {
124
+ return [I, { ...mark, tooltip: { items: tooltip } }];
125
+ }
126
+ if (isStrictObject(tooltip) && isFullTooltip(tooltip)) {
127
+ return [I, { ...mark, tooltip }];
128
+ }
129
+ return [I, { ...mark, tooltip: { items: [tooltip] } }];
130
+ }
131
+
132
+ export function extractTooltip(
133
+ I: number[],
134
+ mark: G2Mark,
135
+ context: TransformContext,
136
+ ): [number[], G2Mark] {
137
+ const { data, encode, tooltip = {} } = mark;
138
+ if (tooltip === null) return [I, mark];
139
+ const valueOf = (item) => {
140
+ if (!item) return item;
141
+ if (typeof item === 'string') {
142
+ return I.map((i) => ({ name: item, value: data[i][item] }));
143
+ }
144
+ if (isStrictObject(item)) {
145
+ const { field, channel, color, name = field } = item;
146
+ const channelField = channel && encode[channel].field;
147
+ return I.map((i) => ({
148
+ name: name || channelField || channel,
149
+ color,
150
+ value: field
151
+ ? data[i][field]
152
+ : channel
153
+ ? encode[channel].value[i]
154
+ : null,
155
+ }));
156
+ }
157
+ if (typeof item === 'function') {
158
+ return I.map((i) => {
159
+ const v = item(data[i], i, data, encode);
160
+ if (isStrictObject(v)) return v;
161
+ return { value: v };
162
+ });
163
+ }
164
+ return item;
165
+ };
166
+ const { title, items = [], ...rest } = tooltip;
167
+ const newTooltip = {
168
+ title: valueOf(title),
169
+ items: items.map(valueOf),
170
+ ...rest,
171
+ };
172
+ return [I, { ...mark, tooltip: newTooltip }];
173
+ }
174
+
109
175
  export function maybeArrayField(
110
176
  I: number[],
111
177
  mark: G2Mark,
@@ -191,9 +257,9 @@ export function maybeNonAnimate(
191
257
  if (animate || animate === undefined) return [I, mark];
192
258
  deepMix(mark, {
193
259
  animate: {
194
- enterType: null,
195
- exitType: null,
196
- updateType: null,
260
+ enter: { type: null },
261
+ exit: { type: null },
262
+ update: { type: null },
197
263
  },
198
264
  });
199
265
  return [I, mark];
@@ -68,6 +68,7 @@ export type G2MarkState = {
68
68
  index?: number[];
69
69
  data?: Record<string, any>[];
70
70
  channels?: ChannelGroups[];
71
+ tooltip?: any; // @todo
71
72
  } & Omit<MarkProps, 'channels'>;
72
73
 
73
74
  export type MaybeArray<T> = T | T[];
@@ -1,5 +1,6 @@
1
1
  import { Coordinate, Transformation } from '@antv/coord';
2
2
  import { DisplayObject, IAnimation as GAnimation } from '@antv/g';
3
+ import EventEmitter from '@antv/event-emitter';
3
4
  import { G2ViewTree } from './options';
4
5
  import {
5
6
  G2Theme,
@@ -191,6 +192,7 @@ export type AnimationComponent<O = Record<string, unknown>> = G2BaseComponent<
191
192
  export type Interaction = (
192
193
  target: G2ViewInstance,
193
194
  viewInstances: G2ViewInstance[],
195
+ emitter?: EventEmitter,
194
196
  ) => void;
195
197
  export type InteractionComponent<O = Record<string, unknown>> = G2BaseComponent<
196
198
  Interaction,
@@ -10,13 +10,13 @@ export type MarkOptions = Record<string, any>;
10
10
 
11
11
  export type MarkComponent<O extends MarkOptions = MarkOptions> = {
12
12
  (options?: O): Mark;
13
- props: MarkProps;
13
+ props?: MarkProps;
14
14
  };
15
15
 
16
16
  export type MarkProps = {
17
- defaultShape: string;
17
+ defaultShape?: string;
18
18
  defaultLabelShape?: string;
19
- channels: Channel[];
19
+ channels?: Channel[];
20
20
  preInference?: TransformSpec[];
21
21
  postInference?: TransformSpec[];
22
22
  composite?: boolean;
@@ -83,6 +83,7 @@ export type G2View = {
83
83
  theme?: G2ThemeOptions;
84
84
  title?: G2TitleOptions;
85
85
  coordinates?: G2CoordinateOptions[];
86
+ coordinate?: Record<string, any>;
86
87
  component?: G2GuideComponentOptions[];
87
88
  interaction?: Record<string, any>;
88
89
  marks?: G2Mark[];
@@ -105,12 +106,17 @@ export type G2Mark = {
105
106
  scale?: Record<string, G2ScaleOptions>;
106
107
  encode?: Record<string, any | G2EncodeOptions>;
107
108
  type?: string | MarkComponent;
108
- animate?: Record<string, Primitive>;
109
+ animate?: {
110
+ enter?: Record<string, Primitive>;
111
+ update?: Record<string, Primitive>;
112
+ exit?: Record<string, Primitive>;
113
+ };
109
114
  facet?: boolean;
110
115
  axis?: boolean | Record<string, any>;
111
116
  legend?: boolean | Record<string, any>;
112
117
  slider?: Record<string, any>;
113
118
  scrollbar?: Record<string, any>;
119
+ tooltip?: any; // @todo
114
120
  filter?: (i: number) => boolean;
115
121
  children?: G2MarkChildrenCallback;
116
122
  dataDomain?: number;
@@ -119,6 +125,7 @@ export type G2Mark = {
119
125
  style?: Record<string, Primitive>;
120
126
  labels?: Record<string, any>[];
121
127
  interaction?: Record<string, any>;
128
+ coordinate?: Record<string, any>;
122
129
  };
123
130
 
124
131
  export type G2MarkChildrenCallback = (
@@ -0,0 +1,11 @@
1
+ import { Constant as ConstantScale } from '@antv/scale';
2
+ import { ConstantScale as ConstantScaleSpec } from '../spec';
3
+ import { ScaleComponent as SC } from '../runtime';
4
+
5
+ export type ConstantOptions = Omit<ConstantScaleSpec, 'type'>;
6
+
7
+ export const Constant: SC<ConstantOptions> = (options) => {
8
+ return new ConstantScale(options);
9
+ };
10
+
11
+ Constant.props = {};
@@ -11,6 +11,7 @@ export { Quantile } from './quantile';
11
11
  export { Quantize } from './quantize';
12
12
  export { Sqrt } from './sqrt';
13
13
  export { Sequential } from './sequential';
14
+ export { Constant } from './constant';
14
15
 
15
16
  export type { BandOptions } from './band';
16
17
  export type { LinearOptions } from './linear';
@@ -25,3 +26,4 @@ export type { QuantileOptions } from './quantile';
25
26
  export type { QuantizeOptions } from './quantize';
26
27
  export type { SqrtOptions } from './sqrt';
27
28
  export type { SequentialOptions } from './sequential';
29
+ export type { ConstantOptions } from './constant';
@@ -147,13 +147,17 @@ export const Color: SC<ColorOptions> = (options) => {
147
147
  insetTop,
148
148
  };
149
149
 
150
- return select(rect(points, value, coordinate, extendedStyle))
151
- .call(applyStyle, { ...defaults, ...rest })
152
- .style(toOpacityKey(options), opacity)
153
- .style(colorAttribute, color)
154
- .style('lineWidth', lineWidth)
155
- .style('stroke', stroke === undefined ? color : stroke)
156
- .node();
150
+ return (
151
+ select(rect(points, value, coordinate, extendedStyle))
152
+ .call(applyStyle, defaults)
153
+ .style(colorAttribute, color)
154
+ .style(toOpacityKey(options), opacity)
155
+ .style('lineWidth', lineWidth)
156
+ .style('stroke', stroke === undefined ? color : stroke)
157
+ // shape.style has higher priority.
158
+ .call(applyStyle, rest)
159
+ .node()
160
+ );
157
161
  };
158
162
  };
159
163
 
@@ -1,4 +1,4 @@
1
- import { MarkComponent } from '../runtime';
1
+ import { MarkComponent, Primitive } from '../runtime';
2
2
  import { Encode } from './encode';
3
3
  import { Transform } from './transform';
4
4
  import { Scale } from './scale';
@@ -93,8 +93,7 @@ export type ChannelTypes =
93
93
  | 'groupKey'
94
94
  | 'label'
95
95
  | 'position'
96
- | 'series'
97
- | `tooltip${number}`;
96
+ | 'series';
98
97
 
99
98
  export type BaseGeometry<
100
99
  T extends GeometryTypes,
@@ -149,36 +148,13 @@ export type BaseGeometry<
149
148
  frame?: boolean;
150
149
  labels?: Record<string, any>[];
151
150
  stack?: boolean;
151
+ tooltip?: Tooltip;
152
152
  animate?:
153
153
  | boolean
154
154
  | {
155
- enterType?: AnimationTypes;
156
- enterDuration?: number;
157
- enterDelay?: number;
158
- enterEasing?: string;
159
- enterFill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
160
- updateType?: AnimationTypes;
161
- updateDuration?: number;
162
- updateDelay?: number;
163
- updateEasing?: string;
164
- updateFill?:
165
- | 'forwards'
166
- | 'none'
167
- | 'backwards'
168
- | 'forwards'
169
- | 'both'
170
- | 'auto';
171
- exitType?: AnimationTypes;
172
- exitDuration?: number;
173
- exitDelay?: number;
174
- exitEasing?: string;
175
- exitFill?:
176
- | 'forwards'
177
- | 'none'
178
- | 'backwards'
179
- | 'forwards'
180
- | 'both'
181
- | 'auto';
155
+ enter?: Animation | null | boolean;
156
+ update?: Animation | null | boolean;
157
+ exit?: Animation | null | boolean;
182
158
  };
183
159
  cartesian?: boolean;
184
160
  layout?: Record<string, any>;
@@ -192,6 +168,14 @@ type StateOptions = {
192
168
  unselected?: Record<string, any>; // @todo
193
169
  };
194
170
 
171
+ export type Animation = {
172
+ type?: AnimationTypes;
173
+ duration?: number;
174
+ delay?: number;
175
+ easing?: string;
176
+ fill?: 'forwards' | 'none' | 'backwards' | 'both' | 'auto';
177
+ };
178
+
195
179
  export type Axis = {
196
180
  tickCount?: number;
197
181
  labelFormatter?: any;
@@ -325,3 +309,27 @@ export type WordCloudMark = BaseGeometry<
325
309
  };
326
310
 
327
311
  export type CustomComponent = BaseGeometry<MarkComponent>;
312
+
313
+ export type Tooltip =
314
+ | TooltipItem
315
+ | TooltipItem[]
316
+ | { title?: Encodeable<TooltipTitle>; items?: TooltipItem[] }
317
+ | null;
318
+
319
+ export type TooltipTitle = string | { field?: string; channel?: string };
320
+
321
+ export type TooltipItem =
322
+ | string
323
+ | { name?: string; color?: string; channel?: string; field?: string }
324
+ | Encodeable<Primitive>
325
+ | Encodeable<TooltipItemValue>;
326
+
327
+ export type TooltipItemValue = {
328
+ name?: string;
329
+ color?: string;
330
+ value?: Primitive;
331
+ };
332
+
333
+ export type Encodeable<T> =
334
+ | T
335
+ | ((d: any, index: number, data: any[], column: any) => T);
@@ -1,5 +1,5 @@
1
1
  import { InteractionComponent } from '../runtime';
2
- import { ChannelTypes } from './geometry';
2
+ import { ChannelTypes, TooltipItemValue } from './geometry';
3
3
  import { FisheyeCoordinate } from './coordinate';
4
4
 
5
5
  export type Interaction =
@@ -197,6 +197,10 @@ export type TooltipInteraction = {
197
197
  crosshairs?: boolean;
198
198
  // @todo
199
199
  item?: any;
200
+ render?: (
201
+ event, // @todo
202
+ options: { title: 'string'; items: TooltipItemValue[] },
203
+ ) => HTMLElement | string;
200
204
  };
201
205
 
202
206
  export type FisheyeInteraction = {
package/src/spec/scale.ts CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  QuantizeOptions,
13
13
  SqrtOptions,
14
14
  SequentialOptions,
15
+ ConstantOptions,
15
16
  } from '@antv/scale';
16
17
  import { ScaleComponent } from '../runtime';
17
18
  import { Palette } from './palette';
@@ -30,7 +31,8 @@ export type Scale =
30
31
  | QuantizeScale
31
32
  | QuantileScale
32
33
  | SequentialScale
33
- | CustomScale;
34
+ | CustomScale
35
+ | ConstantScale;
34
36
 
35
37
  export type ScaleTypes =
36
38
  | 'linear'
@@ -46,6 +48,7 @@ export type ScaleTypes =
46
48
  | 'quantize'
47
49
  | 'quantile'
48
50
  | 'sequential'
51
+ | 'constant'
49
52
  | ScaleComponent;
50
53
 
51
54
  export type BaseScale<T extends ScaleTypes, O> = {
@@ -88,4 +91,6 @@ export type QuantizeScale = BaseScale<'quantize', QuantizeOptions>;
88
91
 
89
92
  export type SequentialScale = BaseScale<'sequential', SequentialOptions>;
90
93
 
94
+ export type ConstantScale = BaseScale<'constant', ConstantOptions>;
95
+
91
96
  export type CustomScale = BaseScale<ScaleComponent, { [key: string]: any }>;