@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
@@ -2,7 +2,7 @@ import { DisplayObject, IElement, Line } from '@antv/g';
2
2
  import { sort, group, mean, range, bisector } from 'd3-array';
3
3
  import { lowerFirst, throttle } from '@antv/util';
4
4
  import { Tooltip as TooltipComponent } from '@antv/gui';
5
- import { Identity } from '@antv/scale';
5
+ import { Constant, Identity } from '@antv/scale';
6
6
  import { defined, subObject, isStrictObject } from '../../utils/helper';
7
7
  import {
8
8
  selectG2Elements,
@@ -55,7 +55,7 @@ function createTooltip(root, x0, y0) {
55
55
  return tooltipElement;
56
56
  }
57
57
 
58
- function showTooltip(root, data, x, y) {
58
+ function showTooltip(root, data, x, y, render, event) {
59
59
  const { tooltipElement = createTooltip(root, x, y) } = root;
60
60
  const { items, title } = data;
61
61
  tooltipElement.show();
@@ -63,6 +63,9 @@ function showTooltip(root, data, x, y) {
63
63
  tooltipElement.update({
64
64
  items,
65
65
  title,
66
+ ...(render !== undefined && {
67
+ customContent: render(event, { items, title }),
68
+ }),
66
69
  });
67
70
  root.tooltipElement = tooltipElement;
68
71
  }
@@ -80,39 +83,16 @@ function destroyTooltip(root) {
80
83
  }
81
84
  }
82
85
 
83
- function filterDefined(obj) {
84
- return Object.fromEntries(
85
- Object.entries(obj).filter(([, value]) => defined(value)),
86
- );
87
- }
88
-
89
- function singleItem(element, item, scale) {
86
+ function singleItem(element) {
90
87
  const { __data__: datum } = element;
91
- const { title, ...rest } = datum;
92
- const defaultColor = itemColorOf(element);
93
- const items = Object.entries(rest)
94
- .filter(([key]) => key.startsWith('tooltip'))
95
- .map(([key, d]: any) => {
96
- const { field: f, title = f } = scale[key].getOptions();
97
- const {
98
- field = undefined,
99
- color = defaultColor,
100
- name = field || title,
101
- value,
102
- ...rest
103
- } = normalizeTooltip(d);
104
- return {
105
- ...rest,
106
- color,
107
- name,
108
- value,
109
- ...filterDefined(item({ channel: key, value })),
110
- };
111
- })
112
- .filter(({ value }) => value !== undefined);
88
+ const { title, items = [] } = datum;
89
+ const newItems = items.map(({ color = itemColorOf(element), ...item }) => ({
90
+ ...item,
91
+ color,
92
+ }));
113
93
  return {
114
94
  ...(title && { title }),
115
- items,
95
+ items: newItems,
116
96
  };
117
97
  }
118
98
 
@@ -120,7 +100,12 @@ function groupNameOf(scale, datum) {
120
100
  const { color: scaleColor, series: scaleSeries } = scale;
121
101
  const { color, series } = datum;
122
102
  const invertAble = (scale) => {
123
- return scale && scale.invert && !(scale instanceof Identity);
103
+ return (
104
+ scale &&
105
+ scale.invert &&
106
+ !(scale instanceof Identity) &&
107
+ !(scale instanceof Constant)
108
+ );
124
109
  };
125
110
  if (invertAble(scaleColor)) return scaleColor.invert(color);
126
111
  if (invertAble(scaleSeries)) return scaleSeries.invert(series);
@@ -136,7 +121,11 @@ function itemColorOf(element) {
136
121
  }
137
122
 
138
123
  function normalizeTooltip(d) {
139
- return isStrictObject(d) ? d : { value: d === undefined ? d : `${d}` };
124
+ return isStrictObject(d)
125
+ ? d
126
+ : d === null || d === undefined
127
+ ? { value: d }
128
+ : { value: `${d}` };
140
129
  }
141
130
 
142
131
  function uniqueTitles(titles) {
@@ -148,39 +137,22 @@ function uniqueTitles(titles) {
148
137
 
149
138
  function groupItems(
150
139
  elements,
151
- item,
152
140
  scale,
153
141
  data = elements.map((d) => d['__data__']),
154
142
  ) {
155
143
  const T = uniqueTitles(data.map((d) => d.title)).filter(defined);
156
- const items = data.flatMap((datum, i) => {
144
+ const newItems = data.flatMap((datum, i) => {
157
145
  const element = elements[i];
158
- const { title, ...rest } = datum;
159
- const defaultColor = itemColorOf(element);
160
- return Object.entries(rest)
161
- .filter(([key]) => key.startsWith('tooltip'))
162
- .map(([key, d]: any) => {
163
- const { field: f, title = f } = scale[key].getOptions();
164
- const {
165
- field = undefined,
166
- color = defaultColor,
167
- name = groupNameOf(scale, datum) || field || title,
168
- value,
169
- ...rest
170
- } = normalizeTooltip(d);
171
- return {
172
- ...rest,
173
- name,
174
- color,
175
- value,
176
- ...filterDefined(item({ channel: key, value })),
177
- };
178
- })
179
- .filter(({ value }) => value !== undefined);
146
+ const { items = [], title } = datum;
147
+ return items.map(({ color = itemColorOf(element), name, ...item }) => ({
148
+ ...item,
149
+ color,
150
+ name: groupNameOf(scale, datum) || name || title,
151
+ }));
180
152
  });
181
153
  return {
182
154
  ...(T.length > 0 && { title: T.join(',') }),
183
- items,
155
+ items: newItems,
184
156
  };
185
157
  }
186
158
 
@@ -256,6 +228,7 @@ export function seriesTooltip(
256
228
  coordinate,
257
229
  crosshairs,
258
230
  item,
231
+ render,
259
232
  startX = 0,
260
233
  startY = 0,
261
234
  ...rest
@@ -274,6 +247,12 @@ export function seriesTooltip(
274
247
  else itemElements.push(element);
275
248
  }
276
249
 
250
+ // Sorted elements from top to bottom visually.
251
+ seriesElements.sort((a, b) => {
252
+ const minY = (d) => d.getBounds().min[1];
253
+ return minY(a) - minY(b);
254
+ });
255
+
277
256
  // Get sortedIndex and X for each series elements
278
257
  const elementSortedX = new Map(
279
258
  seriesElements.map((element) => {
@@ -301,32 +280,32 @@ export function seriesTooltip(
301
280
 
302
281
  const indexByFocus = (focus, I, X) => {
303
282
  const [normalizedX] = coordinate.invert(focus);
283
+ const finalX = normalizedX - offsetX;
284
+ const [minX, maxX] = sort([X[0], X[X.length - 1]]);
285
+ // Skip x out of range.
286
+ if (finalX < minX || finalX > maxX) return null;
304
287
  const search = bisector((i) => X[+i]).center;
305
- const i = search(I, normalizedX - offsetX);
288
+ const i = search(I, finalX);
306
289
  return I[i];
307
290
  };
308
291
 
309
- const indicesByFocus = (focus, I, X) => {
310
- const len = I.length;
311
- if (len === 0) return [];
312
- const [normalizedX] = coordinate.invert(focus);
313
- const x = normalizedX - offsetX;
314
- const search = bisector((i) => X[+i]).center;
315
- const center = search(I, x);
316
-
317
- // Find the least index and greatest index of X[center]
318
- let left = center;
319
- let right = center;
320
- while (left - 1 > 0 && X[I[left - 1]] == X[I[center]]) left--;
321
- while (right + 1 < len && X[I[right + 1]] === X[I[center]]) right++;
322
- return range(left, right + 1).map((i) => I[i]);
292
+ const elementsByFocus = (focus, elements) => {
293
+ const x = focus[0];
294
+ const extent = (d) => {
295
+ const { min, max } = d.getLocalBounds();
296
+ return sort([min[0], max[0]]);
297
+ };
298
+ return elements.filter((element) => {
299
+ const [min, max] = extent(element);
300
+ return x >= min && x <= max;
301
+ });
323
302
  };
324
303
 
325
304
  const seriesData = (element, index) => {
326
305
  const { __data__: data } = element;
327
306
  return Object.fromEntries(
328
307
  Object.entries(data)
329
- .filter(([key]) => key.startsWith('series'))
308
+ .filter(([key]) => key.startsWith('series') && key !== 'series')
330
309
  .map(([key, V]) => {
331
310
  const d = V[index];
332
311
  return [lowerFirst(key.replace('series', '')), d];
@@ -344,32 +323,38 @@ export function seriesTooltip(
344
323
  const focus = [mouse[0] - startX, mouse[1] - startY];
345
324
  if (!focus) return;
346
325
  // Get selected item element.
347
- const selectedItemIndices = indicesByFocus(focus, itemSortedIndex, itemX);
348
- const selectedItems = selectedItemIndices.map((i) => itemElements[i]);
326
+ const selectedItems = elementsByFocus(focus, itemElements);
349
327
 
350
328
  // Get selected data item from both series element and item element.
351
- const selectedSeriesData = seriesElements.map((element) => {
329
+ const selectedSeriesElements = [];
330
+ const selectedSeriesData = [];
331
+ for (const element of seriesElements) {
352
332
  const [sortedIndex, X] = elementSortedX.get(element);
353
333
  const index = indexByFocus(focus, sortedIndex, X);
354
- const d = seriesData(element, index);
355
- const { x, y } = d;
356
- return [d, coordinate.map([x + offsetX, y])] as const;
357
- });
334
+ if (index !== null) {
335
+ selectedSeriesElements.push(element);
336
+ const d = seriesData(element, index);
337
+ const { x, y } = d;
338
+ const p = coordinate.map([x + offsetX, y]);
339
+ selectedSeriesData.push([d, p] as const);
340
+ }
341
+ }
358
342
  const selectedData = [
359
343
  ...selectedSeriesData.map((d) => d[0]),
360
344
  ...selectedItems.map((d) => d.__data__),
361
345
  ];
362
346
 
363
347
  // Get the displayed tooltip data.
364
- const selectedElements = [...seriesElements, ...selectedItems];
365
- const tooltipData = groupItems(
366
- selectedElements,
367
- item,
368
- scale,
369
- selectedData,
370
- );
348
+ const selectedElements = [...selectedSeriesElements, ...selectedItems];
349
+ const tooltipData = groupItems(selectedElements, scale, selectedData);
371
350
 
372
- showTooltip(root, tooltipData, mouse[0] + x, mouse[1] + y);
351
+ // Hide tooltip with no selected tooltip.
352
+ if (selectedElements.length === 0) {
353
+ hide();
354
+ return;
355
+ }
356
+
357
+ showTooltip(root, tooltipData, mouse[0] + x, mouse[1] + y, render, event);
373
358
  if (crosshairs) {
374
359
  const points = selectedSeriesData.map((d) => d[1]);
375
360
  updateRuleY(root, points, { ...ruleStyle, height, startX, startY });
@@ -405,11 +390,11 @@ export function tooltip(
405
390
  {
406
391
  elements: elementsof,
407
392
  scale,
393
+ render,
408
394
  wait = 50,
409
395
  leading = true,
410
396
  trailing = false,
411
397
  groupKey = (d) => d, // group elements by specified key
412
- item,
413
398
  }: Record<string, any>,
414
399
  ) {
415
400
  const elements = elementsof(root);
@@ -423,11 +408,9 @@ export function tooltip(
423
408
  const k = groupKey(element);
424
409
  const group = keyGroup.get(k);
425
410
  const data =
426
- group.length === 1
427
- ? singleItem(group[0], item, scale)
428
- : groupItems(group, item, scale);
411
+ group.length === 1 ? singleItem(group[0]) : groupItems(group, scale);
429
412
  const { offsetX, offsetY } = event;
430
- showTooltip(root, data, offsetX, offsetY);
413
+ showTooltip(root, data, offsetX, offsetY, render, event);
431
414
  },
432
415
  wait,
433
416
  { leading, trailing },
package/src/mark/area.ts CHANGED
@@ -67,6 +67,7 @@ const shapes = ['area', 'smooth', 'hvh', 'hv', 'vh'];
67
67
  Area.props = {
68
68
  defaultShape: 'area',
69
69
  defaultLabelShape: 'label',
70
+ composite: false,
70
71
  channels: [
71
72
  ...baseGeometryChannels({ shapes }),
72
73
  { name: 'x', required: true },
package/src/mark/box.ts CHANGED
@@ -90,6 +90,7 @@ export const Box: MC<BoxOptions> = () => {
90
90
  Box.props = {
91
91
  defaultShape: 'box',
92
92
  defaultLabelShape: 'label',
93
+ composite: false,
93
94
  channels: [
94
95
  ...baseGeometryChannels({ shapes: ['box'] }),
95
96
  { name: 'x', scale: 'band', required: true },
@@ -116,6 +116,4 @@ export const Boxplot: CC<BoxPlotOptions> = (options) => {
116
116
  };
117
117
  };
118
118
 
119
- Boxplot.props = {
120
- composite: true,
121
- };
119
+ Boxplot.props = {};
package/src/mark/cell.ts CHANGED
@@ -40,6 +40,7 @@ const shapes = ['cell', 'hollow'];
40
40
  Cell.props = {
41
41
  defaultShape: 'cell',
42
42
  defaultLabelShape: 'label',
43
+ composite: false,
43
44
  channels: [
44
45
  ...baseGeometryChannels({ shapes }),
45
46
  { name: 'x', required: true, scale: 'band' },
@@ -18,6 +18,7 @@ const shapes = ['connector'];
18
18
  Connector.props = {
19
19
  defaultShape: 'connector',
20
20
  defaultLabelShape: 'label',
21
+ composite: false,
21
22
  channels: [
22
23
  ...baseAnnotationChannels({ shapes }),
23
24
  { name: 'x', required: true },
@@ -130,4 +130,4 @@ export const ForceGraph: CC<ForceGraphOptions> = (options) => {
130
130
  };
131
131
  };
132
132
 
133
- ForceGraph.props = { composite: true };
133
+ ForceGraph.props = {};
package/src/mark/image.ts CHANGED
@@ -30,6 +30,7 @@ const shapes = ['image'];
30
30
  Image.props = {
31
31
  defaultShape: 'image',
32
32
  defaultLabelShape: 'label',
33
+ composite: false,
33
34
  channels: [
34
35
  ...baseGeometryChannels({ shapes }),
35
36
  { name: 'x', required: true },
@@ -65,6 +65,7 @@ const shapes = ['rect', 'hollow', 'funnel', 'pyramid'];
65
65
  Interval.props = {
66
66
  defaultShape: 'rect',
67
67
  defaultLabelShape: 'label',
68
+ composite: false,
68
69
  channels: [
69
70
  ...baseGeometryChannels({ shapes }),
70
71
  { name: 'x', scale: 'band', required: true },
package/src/mark/line.ts CHANGED
@@ -84,6 +84,7 @@ const shapes = ['line', 'smooth'];
84
84
  Line.props = {
85
85
  defaultShape: 'line',
86
86
  defaultLabelShape: 'label',
87
+ composite: false,
87
88
  channels: [
88
89
  ...baseGeometryChannels({ shapes }),
89
90
  { name: 'x' },
package/src/mark/lineX.ts CHANGED
@@ -26,6 +26,7 @@ const shapes = ['line'];
26
26
  LineX.props = {
27
27
  defaultShape: 'line',
28
28
  defaultLabelShape: 'label',
29
+ composite: false,
29
30
  channels: [
30
31
  ...baseAnnotationChannels({ shapes }),
31
32
  { name: 'x', required: true },
package/src/mark/lineY.ts CHANGED
@@ -26,6 +26,7 @@ const shapes = ['line'];
26
26
  LineY.props = {
27
27
  defaultShape: 'line',
28
28
  defaultLabelShape: 'label',
29
+ composite: false,
29
30
  channels: [
30
31
  ...baseAnnotationChannels({ shapes }),
31
32
  { name: 'y', required: true },
package/src/mark/link.ts CHANGED
@@ -30,6 +30,7 @@ const shapes = ['link', 'arc', 'vhv', 'smooth'];
30
30
  Link.props = {
31
31
  defaultShape: 'link',
32
32
  defaultLabelShape: 'label',
33
+ composite: false,
33
34
  channels: [
34
35
  ...baseGeometryChannels({ shapes }),
35
36
  { name: 'x', required: true },
package/src/mark/pack.ts CHANGED
@@ -101,4 +101,4 @@ export const Pack: CC<PackOptions> = (markOptions) => {
101
101
  };
102
102
  };
103
103
 
104
- Pack.props = { composite: true };
104
+ Pack.props = {};
package/src/mark/path.ts CHANGED
@@ -25,6 +25,7 @@ const shapes = ['path', 'hollow'];
25
25
  Path.props = {
26
26
  defaultShape: 'path',
27
27
  defaultLabelShape: 'label',
28
+ composite: false,
28
29
  channels: [
29
30
  ...baseGeometryChannels({ shapes }),
30
31
  { name: 'd', scale: 'identity' },
package/src/mark/point.ts CHANGED
@@ -75,6 +75,7 @@ const shapes = [
75
75
  Point.props = {
76
76
  defaultShape: 'hollow',
77
77
  defaultLabelShape: 'label',
78
+ composite: false,
78
79
  channels: [
79
80
  ...baseGeometryChannels({ shapes }),
80
81
  { name: 'x', required: true },
@@ -42,6 +42,7 @@ const shapes = ['polygon', 'ribbon'];
42
42
  Polygon.props = {
43
43
  defaultShape: 'polygon',
44
44
  defaultLabelShape: 'label',
45
+ composite: false,
45
46
  channels: [
46
47
  ...baseGeometryChannels({ shapes }),
47
48
  { name: 'x', required: true },
package/src/mark/range.ts CHANGED
@@ -47,6 +47,7 @@ const shapes = ['range'];
47
47
  Range.props = {
48
48
  defaultShape: 'range',
49
49
  defaultLabelShape: 'label',
50
+ composite: false,
50
51
  channels: [
51
52
  ...baseAnnotationChannels({ shapes }),
52
53
  { name: 'x', required: true },
@@ -18,6 +18,7 @@ const shapes = ['range'];
18
18
  RangeX.props = {
19
19
  defaultShape: 'range',
20
20
  defaultLabelShape: 'label',
21
+ composite: false,
21
22
  channels: [
22
23
  ...baseAnnotationChannels({ shapes }),
23
24
  { name: 'x', required: true },
@@ -18,6 +18,7 @@ const shapes = ['range'];
18
18
  RangeY.props = {
19
19
  defaultShape: 'range',
20
20
  defaultLabelShape: 'label',
21
+ composite: false,
21
22
  channels: [
22
23
  ...baseAnnotationChannels({ shapes }),
23
24
  { name: 'y', required: true },
package/src/mark/rect.ts CHANGED
@@ -31,6 +31,7 @@ const shapes = ['rect', 'hollow'];
31
31
  Rect.props = {
32
32
  defaultShape: 'rect',
33
33
  defaultLabelShape: 'label',
34
+ composite: false,
34
35
  channels: [
35
36
  ...baseGeometryChannels({ shapes }),
36
37
  { name: 'x', required: true },
@@ -125,4 +125,4 @@ export const Sankey: CC<SankeyOptions> = (options) => {
125
125
  };
126
126
  };
127
127
 
128
- Sankey.props = { composite: true };
128
+ Sankey.props = {};
package/src/mark/shape.ts CHANGED
@@ -24,6 +24,7 @@ export const Shape: MC<ShapeOptions> = (options) => {
24
24
  Shape.props = {
25
25
  defaultShape: 'shape',
26
26
  defaultLabelShape: 'label',
27
+ composite: false,
27
28
  channels: [
28
29
  { name: 'x', required: true },
29
30
  { name: 'y', required: true },
package/src/mark/text.ts CHANGED
@@ -31,6 +31,7 @@ const shapes = ['text', 'badge'];
31
31
  Text.props = {
32
32
  defaultShape: 'text',
33
33
  defaultLabelShape: 'label',
34
+ composite: false,
34
35
  channels: [
35
36
  ...baseGeometryChannels({ shapes }),
36
37
  { name: 'x', required: true },
package/src/mark/tree.ts CHANGED
@@ -83,4 +83,4 @@ export const Tree: CC<TreeOptions> = (options) => {
83
83
  };
84
84
  };
85
85
 
86
- Tree.props = { composite: true };
86
+ Tree.props = {};
@@ -185,4 +185,4 @@ export const Treemap: CC<TreemapOptions> = (options) => {
185
185
  };
186
186
  };
187
187
 
188
- Treemap.props = { composite: true };
188
+ Treemap.props = {};
package/src/mark/utils.ts CHANGED
@@ -26,11 +26,7 @@ export function baseChannels(options: ChannelOptions = {}): Channel[] {
26
26
  }
27
27
 
28
28
  export function baseGeometryChannels(options: ChannelOptions = {}): Channel[] {
29
- return [
30
- ...baseChannels(options),
31
- { name: 'title', scale: 'identity' },
32
- { name: 'tooltip', scale: 'identity', independent: true },
33
- ];
29
+ return [...baseChannels(options), { name: 'title', scale: 'identity' }];
34
30
  }
35
31
 
36
32
  export function tooltip2d() {
@@ -42,6 +42,7 @@ const shapes = ['vector'];
42
42
  Vector.props = {
43
43
  defaultShape: 'vector',
44
44
  defaultLabelShape: 'label',
45
+ composite: false,
45
46
  channels: [
46
47
  ...baseGeometryChannels({ shapes }),
47
48
  { name: 'x', required: true },
@@ -71,4 +71,4 @@ export const WordCloud: CC<WordCloudOptions> = (options) => {
71
71
  };
72
72
  };
73
73
 
74
- WordCloud.props = { composite: true };
74
+ WordCloud.props = {};
@@ -26,6 +26,8 @@ import {
26
26
  maybeVisualChannel,
27
27
  addGuideToScale,
28
28
  maybeNonAnimate,
29
+ normalizeTooltip,
30
+ extractTooltip,
29
31
  } from './transform';
30
32
 
31
33
  export async function initializeMark(
@@ -41,7 +43,7 @@ export async function initializeMark(
41
43
  context,
42
44
  );
43
45
 
44
- const { encode, scale, data } = transformedMark;
46
+ const { encode, scale, data, tooltip } = transformedMark;
45
47
 
46
48
  // Skip mark with non-tabular data. Do not skip empty
47
49
  // data, they are useful for facet to display axes.
@@ -82,30 +84,34 @@ export async function initializeMark(
82
84
  );
83
85
  return valuesArray.map(([channel, values], i) => {
84
86
  const visual = values.some((d) => d.visual);
87
+ const constant = values.some((d) => d.constant);
85
88
  const {
86
89
  independent = false,
87
90
  // Use channel name as default scale key.
88
91
  key = scaleKey || channel,
89
92
  // Visual channel use identity scale.
90
- type = visual ? 'identity' : scaleType,
93
+ type = constant ? 'constant' : visual ? 'identity' : scaleType,
91
94
  ...scaleOptions
92
95
  } = scale[channel] || {};
96
+ // For constant scale, infer range from data.
97
+ const isConstant = type === 'constant';
98
+ const finalRange = isConstant ? undefined : range;
93
99
  return {
94
100
  name: channel,
95
101
  values,
96
102
  // Generate a unique key for independent channel,
97
103
  // which will not group with any other channels.
98
- scaleKey: independent ? Symbol('independent') : key,
104
+ scaleKey: independent || isConstant ? Symbol('independent') : key,
99
105
  scale: {
100
106
  type,
101
- range,
107
+ range: finalRange,
102
108
  ...scaleOptions,
103
109
  },
104
110
  };
105
111
  });
106
112
  });
107
113
 
108
- return [transformedMark, { ...partialProps, index: I, channels }];
114
+ return [transformedMark, { ...partialProps, index: I, channels, tooltip }];
109
115
  }
110
116
 
111
117
  export function createColumnOf(library: G2Library): ColumnOf {
@@ -148,9 +154,11 @@ async function applyMarkTransform(
148
154
  maybeArrayField,
149
155
  maybeNonAnimate,
150
156
  addGuideToScale,
157
+ normalizeTooltip,
151
158
  ...preInference.map(useTransform),
152
159
  ...transform.map(useTransform),
153
160
  ...postInference.map(useTransform),
161
+ extractTooltip,
154
162
  ];
155
163
  let index = [];
156
164
  let transformedMark = mark;