@antv/g2 5.0.0-beta.6 → 5.0.0-beta.8

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 (387) hide show
  1. package/dist/g2-lite.min.js +3 -3
  2. package/dist/g2.min.js +3 -3
  3. package/esm/api/chart.d.ts +8 -4
  4. package/esm/api/chart.js +33 -17
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition/base.d.ts +21 -0
  7. package/esm/api/composition/base.js +59 -0
  8. package/esm/api/composition/base.js.map +1 -0
  9. package/esm/api/composition/facetCircle.d.ts +2 -3
  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 -3
  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 -3
  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 -3
  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 -1
  22. package/esm/api/composition/index.js +2 -1
  23. package/esm/api/composition/index.js.map +1 -1
  24. package/esm/api/composition/repeatMatrix.d.ts +2 -3
  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 -3
  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 -3
  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 -3
  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 +3 -3
  37. package/esm/api/composition/view.js +4 -4
  38. package/esm/api/composition/view.js.map +1 -1
  39. package/esm/api/mark/base.d.ts +22 -0
  40. package/esm/api/mark/base.js +54 -0
  41. package/esm/api/mark/base.js.map +1 -0
  42. package/esm/api/mark/mark.d.ts +29 -29
  43. package/esm/api/mark/mark.js +27 -27
  44. package/esm/api/mark/mark.js.map +1 -1
  45. package/esm/api/node.d.ts +2 -1
  46. package/esm/api/node.js +8 -9
  47. package/esm/api/node.js.map +1 -1
  48. package/esm/api/props.js +0 -20
  49. package/esm/api/props.js.map +1 -1
  50. package/esm/component/axis.js +4 -0
  51. package/esm/component/axis.js.map +1 -1
  52. package/esm/component/legendContinuous.d.ts +1 -0
  53. package/esm/component/legendContinuous.js +14 -16
  54. package/esm/component/legendContinuous.js.map +1 -1
  55. package/esm/component/slider.js +3 -13
  56. package/esm/component/slider.js.map +1 -1
  57. package/esm/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  58. package/esm/geo/{d3-projection.js → d3Projection.js} +1 -1
  59. package/esm/geo/d3Projection.js.map +1 -0
  60. package/esm/geo/geoView.js +1 -1
  61. package/esm/geo/geoView.js.map +1 -1
  62. package/esm/interaction/builtin/elementHighlight.d.ts +2 -0
  63. package/esm/interaction/builtin/elementHighlightByColor.d.ts +2 -0
  64. package/esm/interaction/builtin/elementHighlightByX.d.ts +2 -0
  65. package/esm/interaction/index.d.ts +2 -0
  66. package/esm/interaction/index.js +2 -0
  67. package/esm/interaction/index.js.map +1 -1
  68. package/esm/interaction/native/brushFilter.d.ts +3 -1
  69. package/esm/interaction/native/brushFilter.js +7 -32
  70. package/esm/interaction/native/brushFilter.js.map +1 -1
  71. package/esm/interaction/native/brushXFilter.js +1 -1
  72. package/esm/interaction/native/brushXFilter.js.map +1 -1
  73. package/esm/interaction/native/brushYFilter.js +1 -1
  74. package/esm/interaction/native/brushYFilter.js.map +1 -1
  75. package/esm/interaction/native/elementHighlight.d.ts +7 -2
  76. package/esm/interaction/native/elementHighlight.js +72 -18
  77. package/esm/interaction/native/elementHighlight.js.map +1 -1
  78. package/esm/interaction/native/elementHighlightByColor.d.ts +4 -1
  79. package/esm/interaction/native/elementHighlightByColor.js +19 -3
  80. package/esm/interaction/native/elementHighlightByColor.js.map +1 -1
  81. package/esm/interaction/native/elementHighlightByX.d.ts +3 -3
  82. package/esm/interaction/native/elementHighlightByX.js +19 -3
  83. package/esm/interaction/native/elementHighlightByX.js.map +1 -1
  84. package/esm/interaction/native/elementSelect.d.ts +1 -1
  85. package/esm/interaction/native/elementSelect.js +42 -20
  86. package/esm/interaction/native/elementSelect.js.map +1 -1
  87. package/esm/interaction/native/elementSelectByColor.js +3 -2
  88. package/esm/interaction/native/elementSelectByColor.js.map +1 -1
  89. package/esm/interaction/native/elementSelectByX.js +3 -2
  90. package/esm/interaction/native/elementSelectByX.js.map +1 -1
  91. package/esm/interaction/native/legendFilter.d.ts +4 -0
  92. package/esm/interaction/native/legendFilter.js +7 -4
  93. package/esm/interaction/native/legendFilter.js.map +1 -1
  94. package/esm/interaction/native/legendHighlight.d.ts +4 -0
  95. package/esm/interaction/native/legendHighlight.js +94 -0
  96. package/esm/interaction/native/legendHighlight.js.map +1 -0
  97. package/esm/interaction/native/sliderFilter.d.ts +5 -0
  98. package/esm/interaction/native/sliderFilter.js +87 -0
  99. package/esm/interaction/native/sliderFilter.js.map +1 -0
  100. package/esm/interaction/native/tooltip.js +11 -0
  101. package/esm/interaction/native/tooltip.js.map +1 -1
  102. package/esm/interaction/native/utils.d.ts +13 -2
  103. package/esm/interaction/native/utils.js +151 -26
  104. package/esm/interaction/native/utils.js.map +1 -1
  105. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  106. package/esm/mark/area.js +1 -1
  107. package/esm/mark/area.js.map +1 -1
  108. package/esm/runtime/component.d.ts +1 -1
  109. package/esm/runtime/component.js +5 -3
  110. package/esm/runtime/component.js.map +1 -1
  111. package/esm/runtime/plot.d.ts +1 -1
  112. package/esm/runtime/plot.js +68 -29
  113. package/esm/runtime/plot.js.map +1 -1
  114. package/esm/runtime/render.js +18 -13
  115. package/esm/runtime/render.js.map +1 -1
  116. package/esm/runtime/scale.d.ts +2 -1
  117. package/esm/runtime/scale.js +7 -0
  118. package/esm/runtime/scale.js.map +1 -1
  119. package/esm/runtime/types/options.d.ts +4 -2
  120. package/esm/shape/area/hv.d.ts +3 -0
  121. package/esm/shape/area/hv.js +9 -0
  122. package/esm/shape/area/hv.js.map +1 -0
  123. package/esm/shape/area/hvh.d.ts +3 -0
  124. package/esm/shape/area/{step.js → hvh.js} +3 -3
  125. package/esm/shape/area/hvh.js.map +1 -0
  126. package/esm/shape/area/vh.d.ts +3 -0
  127. package/esm/shape/area/vh.js +9 -0
  128. package/esm/shape/area/vh.js.map +1 -0
  129. package/esm/shape/index.d.ts +6 -2
  130. package/esm/shape/index.js +3 -1
  131. package/esm/shape/index.js.map +1 -1
  132. package/esm/shape/interval/color.d.ts +1 -0
  133. package/esm/shape/interval/color.js +65 -53
  134. package/esm/shape/interval/color.js.map +1 -1
  135. package/esm/spec/composition.d.ts +0 -3
  136. package/esm/spec/geometry.d.ts +1 -0
  137. package/esm/spec/interaction.d.ts +30 -11
  138. package/esm/spec/transform.d.ts +15 -5
  139. package/esm/stdlib/index.js +3 -8
  140. package/esm/stdlib/index.js.map +1 -1
  141. package/esm/transform/sample.js +42 -26
  142. package/esm/transform/sample.js.map +1 -1
  143. package/esm/transform/select.js +1 -13
  144. package/esm/transform/select.js.map +1 -1
  145. package/esm/transform/selectX.js +1 -1
  146. package/esm/transform/selectX.js.map +1 -1
  147. package/esm/transform/selectY.js +1 -1
  148. package/esm/transform/selectY.js.map +1 -1
  149. package/esm/transform/utils/lttb.d.ts +5 -0
  150. package/esm/transform/utils/lttb.js +56 -0
  151. package/esm/transform/utils/lttb.js.map +1 -0
  152. package/esm/utils/event.d.ts +0 -2
  153. package/esm/utils/event.js +0 -18
  154. package/esm/utils/event.js.map +1 -1
  155. package/esm/utils/scale.d.ts +3 -0
  156. package/esm/utils/scale.js +30 -0
  157. package/esm/utils/scale.js.map +1 -0
  158. package/esm/utils/vector.d.ts +1 -1
  159. package/esm/utils/vector.js +1 -1
  160. package/lib/api/chart.d.ts +8 -4
  161. package/lib/api/chart.js +34 -15
  162. package/lib/api/chart.js.map +1 -1
  163. package/lib/api/composition/base.d.ts +21 -0
  164. package/lib/api/composition/base.js +62 -0
  165. package/lib/api/composition/base.js.map +1 -0
  166. package/lib/api/composition/facetCircle.d.ts +2 -3
  167. package/lib/api/composition/facetCircle.js +2 -2
  168. package/lib/api/composition/facetCircle.js.map +1 -1
  169. package/lib/api/composition/facetRect.d.ts +2 -3
  170. package/lib/api/composition/facetRect.js +2 -2
  171. package/lib/api/composition/facetRect.js.map +1 -1
  172. package/lib/api/composition/geoPath.d.ts +2 -3
  173. package/lib/api/composition/geoPath.js +2 -2
  174. package/lib/api/composition/geoPath.js.map +1 -1
  175. package/lib/api/composition/geoView.d.ts +2 -3
  176. package/lib/api/composition/geoView.js +2 -2
  177. package/lib/api/composition/geoView.js.map +1 -1
  178. package/lib/api/composition/index.d.ts +2 -1
  179. package/lib/api/composition/index.js +3 -1
  180. package/lib/api/composition/index.js.map +1 -1
  181. package/lib/api/composition/repeatMatrix.d.ts +2 -3
  182. package/lib/api/composition/repeatMatrix.js +2 -2
  183. package/lib/api/composition/repeatMatrix.js.map +1 -1
  184. package/lib/api/composition/spaceFlex.d.ts +2 -3
  185. package/lib/api/composition/spaceFlex.js +2 -2
  186. package/lib/api/composition/spaceFlex.js.map +1 -1
  187. package/lib/api/composition/spaceLayer.d.ts +2 -3
  188. package/lib/api/composition/spaceLayer.js +2 -2
  189. package/lib/api/composition/spaceLayer.js.map +1 -1
  190. package/lib/api/composition/timingKeyframe.d.ts +2 -3
  191. package/lib/api/composition/timingKeyframe.js +2 -2
  192. package/lib/api/composition/timingKeyframe.js.map +1 -1
  193. package/lib/api/composition/view.d.ts +3 -3
  194. package/lib/api/composition/view.js +4 -4
  195. package/lib/api/composition/view.js.map +1 -1
  196. package/lib/api/mark/base.d.ts +22 -0
  197. package/lib/api/mark/base.js +58 -0
  198. package/lib/api/mark/base.js.map +1 -0
  199. package/lib/api/mark/mark.d.ts +29 -29
  200. package/lib/api/mark/mark.js +27 -27
  201. package/lib/api/mark/mark.js.map +1 -1
  202. package/lib/api/node.d.ts +2 -1
  203. package/lib/api/node.js +8 -9
  204. package/lib/api/node.js.map +1 -1
  205. package/lib/api/props.js +0 -20
  206. package/lib/api/props.js.map +1 -1
  207. package/lib/component/axis.js +4 -0
  208. package/lib/component/axis.js.map +1 -1
  209. package/lib/component/legendContinuous.d.ts +1 -0
  210. package/lib/component/legendContinuous.js +14 -16
  211. package/lib/component/legendContinuous.js.map +1 -1
  212. package/lib/component/slider.js +3 -13
  213. package/lib/component/slider.js.map +1 -1
  214. package/lib/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  215. package/lib/geo/{d3-projection.js → d3Projection.js} +1 -1
  216. package/lib/geo/d3Projection.js.map +1 -0
  217. package/lib/geo/geoView.js +1 -1
  218. package/lib/geo/geoView.js.map +1 -1
  219. package/lib/interaction/builtin/elementHighlight.d.ts +2 -0
  220. package/lib/interaction/builtin/elementHighlightByColor.d.ts +2 -0
  221. package/lib/interaction/builtin/elementHighlightByX.d.ts +2 -0
  222. package/lib/interaction/index.d.ts +2 -0
  223. package/lib/interaction/index.js +5 -1
  224. package/lib/interaction/index.js.map +1 -1
  225. package/lib/interaction/native/brushFilter.d.ts +3 -1
  226. package/lib/interaction/native/brushFilter.js +10 -35
  227. package/lib/interaction/native/brushFilter.js.map +1 -1
  228. package/lib/interaction/native/brushXFilter.js +1 -1
  229. package/lib/interaction/native/brushXFilter.js.map +1 -1
  230. package/lib/interaction/native/brushYFilter.js +1 -1
  231. package/lib/interaction/native/brushYFilter.js.map +1 -1
  232. package/lib/interaction/native/elementHighlight.d.ts +7 -2
  233. package/lib/interaction/native/elementHighlight.js +71 -17
  234. package/lib/interaction/native/elementHighlight.js.map +1 -1
  235. package/lib/interaction/native/elementHighlightByColor.d.ts +4 -1
  236. package/lib/interaction/native/elementHighlightByColor.js +18 -2
  237. package/lib/interaction/native/elementHighlightByColor.js.map +1 -1
  238. package/lib/interaction/native/elementHighlightByX.d.ts +3 -3
  239. package/lib/interaction/native/elementHighlightByX.js +18 -2
  240. package/lib/interaction/native/elementHighlightByX.js.map +1 -1
  241. package/lib/interaction/native/elementSelect.d.ts +1 -1
  242. package/lib/interaction/native/elementSelect.js +41 -19
  243. package/lib/interaction/native/elementSelect.js.map +1 -1
  244. package/lib/interaction/native/elementSelectByColor.js +2 -1
  245. package/lib/interaction/native/elementSelectByColor.js.map +1 -1
  246. package/lib/interaction/native/elementSelectByX.js +2 -1
  247. package/lib/interaction/native/elementSelectByX.js.map +1 -1
  248. package/lib/interaction/native/legendFilter.d.ts +4 -0
  249. package/lib/interaction/native/legendFilter.js +10 -3
  250. package/lib/interaction/native/legendFilter.js.map +1 -1
  251. package/lib/interaction/native/legendHighlight.d.ts +4 -0
  252. package/lib/interaction/native/legendHighlight.js +98 -0
  253. package/lib/interaction/native/legendHighlight.js.map +1 -0
  254. package/lib/interaction/native/sliderFilter.d.ts +5 -0
  255. package/lib/interaction/native/sliderFilter.js +91 -0
  256. package/lib/interaction/native/sliderFilter.js.map +1 -0
  257. package/lib/interaction/native/tooltip.js +11 -0
  258. package/lib/interaction/native/tooltip.js.map +1 -1
  259. package/lib/interaction/native/utils.d.ts +13 -2
  260. package/lib/interaction/native/utils.js +154 -27
  261. package/lib/interaction/native/utils.js.map +1 -1
  262. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  263. package/lib/mark/area.js +1 -1
  264. package/lib/mark/area.js.map +1 -1
  265. package/lib/runtime/component.d.ts +1 -1
  266. package/lib/runtime/component.js +4 -2
  267. package/lib/runtime/component.js.map +1 -1
  268. package/lib/runtime/plot.d.ts +1 -1
  269. package/lib/runtime/plot.js +65 -26
  270. package/lib/runtime/plot.js.map +1 -1
  271. package/lib/runtime/render.js +20 -12
  272. package/lib/runtime/render.js.map +1 -1
  273. package/lib/runtime/scale.d.ts +2 -1
  274. package/lib/runtime/scale.js +9 -1
  275. package/lib/runtime/scale.js.map +1 -1
  276. package/lib/runtime/types/options.d.ts +4 -2
  277. package/lib/shape/area/hv.d.ts +3 -0
  278. package/lib/shape/area/hv.js +13 -0
  279. package/lib/shape/area/hv.js.map +1 -0
  280. package/lib/shape/area/hvh.d.ts +3 -0
  281. package/lib/shape/area/{step.js → hvh.js} +5 -5
  282. package/lib/shape/area/hvh.js.map +1 -0
  283. package/lib/shape/area/vh.d.ts +3 -0
  284. package/lib/shape/area/vh.js +13 -0
  285. package/lib/shape/area/vh.js.map +1 -0
  286. package/lib/shape/index.d.ts +6 -2
  287. package/lib/shape/index.js +7 -3
  288. package/lib/shape/index.js.map +1 -1
  289. package/lib/shape/interval/color.d.ts +1 -0
  290. package/lib/shape/interval/color.js +67 -54
  291. package/lib/shape/interval/color.js.map +1 -1
  292. package/lib/spec/composition.d.ts +0 -3
  293. package/lib/spec/geometry.d.ts +1 -0
  294. package/lib/spec/interaction.d.ts +30 -11
  295. package/lib/spec/transform.d.ts +15 -5
  296. package/lib/stdlib/index.js +1 -1
  297. package/lib/stdlib/index.js.map +1 -1
  298. package/lib/transform/sample.js +42 -26
  299. package/lib/transform/sample.js.map +1 -1
  300. package/lib/transform/select.js +1 -13
  301. package/lib/transform/select.js.map +1 -1
  302. package/lib/transform/selectX.js +1 -1
  303. package/lib/transform/selectX.js.map +1 -1
  304. package/lib/transform/selectY.js +1 -1
  305. package/lib/transform/selectY.js.map +1 -1
  306. package/lib/transform/utils/lttb.d.ts +5 -0
  307. package/lib/transform/utils/lttb.js +60 -0
  308. package/lib/transform/utils/lttb.js.map +1 -0
  309. package/lib/utils/event.d.ts +0 -2
  310. package/lib/utils/event.js +1 -21
  311. package/lib/utils/event.js.map +1 -1
  312. package/lib/utils/scale.d.ts +3 -0
  313. package/lib/utils/scale.js +36 -0
  314. package/lib/utils/scale.js.map +1 -0
  315. package/lib/utils/vector.d.ts +1 -1
  316. package/lib/utils/vector.js +1 -1
  317. package/package.json +4 -3
  318. package/src/.DS_Store +0 -0
  319. package/src/api/chart.ts +39 -18
  320. package/src/api/composition/base.ts +56 -0
  321. package/src/api/composition/facetCircle.ts +2 -3
  322. package/src/api/composition/facetRect.ts +2 -3
  323. package/src/api/composition/geoPath.ts +2 -3
  324. package/src/api/composition/geoView.ts +2 -3
  325. package/src/api/composition/index.ts +2 -0
  326. package/src/api/composition/repeatMatrix.ts +2 -3
  327. package/src/api/composition/spaceFlex.ts +2 -3
  328. package/src/api/composition/spaceLayer.ts +2 -3
  329. package/src/api/composition/timingKeyframe.ts +2 -3
  330. package/src/api/composition/view.ts +6 -4
  331. package/src/api/mark/base.ts +58 -0
  332. package/src/api/mark/mark.ts +29 -28
  333. package/src/api/node.ts +9 -11
  334. package/src/api/props.ts +0 -23
  335. package/src/component/axis.ts +7 -0
  336. package/src/component/legendContinuous.ts +15 -5
  337. package/src/component/slider.ts +3 -12
  338. package/src/data/.DS_Store +0 -0
  339. package/src/geo/{d3-projection.ts → d3Projection.ts} +0 -0
  340. package/src/geo/geoView.ts +1 -1
  341. package/src/interaction/index.ts +2 -0
  342. package/src/interaction/native/brushFilter.ts +18 -38
  343. package/src/interaction/native/brushXFilter.ts +1 -0
  344. package/src/interaction/native/brushYFilter.ts +1 -0
  345. package/src/interaction/native/elementHighlight.ts +78 -11
  346. package/src/interaction/native/elementHighlightByColor.ts +9 -4
  347. package/src/interaction/native/elementHighlightByX.ts +9 -5
  348. package/src/interaction/native/elementSelect.ts +58 -14
  349. package/src/interaction/native/elementSelectByColor.ts +4 -1
  350. package/src/interaction/native/elementSelectByX.ts +4 -1
  351. package/src/interaction/native/legendFilter.ts +8 -4
  352. package/src/interaction/native/legendHighlight.ts +87 -0
  353. package/src/interaction/native/sliderFilter.ts +112 -0
  354. package/src/interaction/native/tooltip.ts +11 -0
  355. package/src/interaction/native/utils.ts +183 -26
  356. package/src/label-transform/overlapDodgeY.ts +1 -1
  357. package/src/mark/area.ts +1 -1
  358. package/src/runtime/component.ts +18 -25
  359. package/src/runtime/plot.ts +123 -75
  360. package/src/runtime/render.ts +26 -13
  361. package/src/runtime/scale.ts +14 -0
  362. package/src/runtime/types/options.ts +10 -2
  363. package/src/shape/.DS_Store +0 -0
  364. package/src/shape/area/hv.ts +20 -0
  365. package/src/shape/area/{step.ts → hvh.ts} +3 -3
  366. package/src/shape/area/vh.ts +20 -0
  367. package/src/shape/index.ts +7 -2
  368. package/src/shape/interval/color.ts +86 -54
  369. package/src/spec/composition.ts +0 -1
  370. package/src/spec/geometry.ts +1 -0
  371. package/src/spec/interaction.ts +45 -12
  372. package/src/spec/transform.ts +30 -3
  373. package/src/stdlib/index.ts +10 -6
  374. package/src/transform/sample.ts +54 -18
  375. package/src/transform/select.ts +1 -2
  376. package/src/transform/selectX.ts +1 -1
  377. package/src/transform/selectY.ts +1 -1
  378. package/src/transform/utils/lttb.ts +73 -0
  379. package/src/utils/event.ts +0 -26
  380. package/src/utils/scale.ts +31 -0
  381. package/src/utils/vector.ts +1 -1
  382. package/esm/geo/d3-projection.js.map +0 -1
  383. package/esm/shape/area/step.d.ts +0 -3
  384. package/esm/shape/area/step.js.map +0 -1
  385. package/lib/geo/d3-projection.js.map +0 -1
  386. package/lib/shape/area/step.d.ts +0 -3
  387. package/lib/shape/area/step.js.map +0 -1
@@ -3,21 +3,26 @@ import {
3
3
  createDatumof,
4
4
  selectG2Elements,
5
5
  createColorKey,
6
+ selectPlotArea,
6
7
  } from './utils';
7
8
  import { elementHighlight } from './elementHighlight';
8
9
 
9
10
  /**
10
11
  * @todo Bind abstract data or data index.
11
12
  */
12
- export function ElementHighlightByColor(options) {
13
+ export function ElementHighlightByColor({ delay, ...rest }) {
13
14
  return (context) => {
14
15
  const { container, view } = context;
15
- return elementHighlight(container, {
16
- ...options,
17
- ...applyDefaultsHighlightedStyle(options),
16
+ const { scale, coordinate } = view;
17
+ const plotArea = selectPlotArea(container);
18
+ return elementHighlight(plotArea, {
19
+ ...applyDefaultsHighlightedStyle(rest),
18
20
  elements: selectG2Elements,
19
21
  datum: createDatumof(view),
20
22
  groupKey: createColorKey(view),
23
+ scale,
24
+ coordinate,
25
+ delay,
21
26
  });
22
27
  };
23
28
  }
@@ -3,6 +3,7 @@ import {
3
3
  createDatumof,
4
4
  selectG2Elements,
5
5
  createXKey,
6
+ selectPlotArea,
6
7
  } from './utils';
7
8
  import { elementHighlight } from './elementHighlight';
8
9
 
@@ -10,16 +11,19 @@ import { elementHighlight } from './elementHighlight';
10
11
  *
11
12
  * @todo Bind abstract data or data index.
12
13
  */
13
- export function ElementHighlightByX(
14
- options = { selectedLineWidth: 1, selectedColor: 'black' },
15
- ) {
14
+ export function ElementHighlightByX({ delay, ...rest }) {
16
15
  return (context) => {
17
16
  const { container, view } = context;
18
- return elementHighlight(container, {
19
- ...applyDefaultsHighlightedStyle(options),
17
+ const { scale, coordinate } = view;
18
+ const plotArea = selectPlotArea(container);
19
+ return elementHighlight(plotArea, {
20
+ ...applyDefaultsHighlightedStyle(rest),
20
21
  elements: selectG2Elements,
21
22
  datum: createDatumof(view),
22
23
  groupKey: createXKey(view),
24
+ scale,
25
+ coordinate,
26
+ delay,
23
27
  });
24
28
  };
25
29
  }
@@ -8,6 +8,9 @@ import {
8
8
  useState,
9
9
  renderLink,
10
10
  applyDefaultsHighlightedStyle,
11
+ renderBackground,
12
+ selectPlotArea,
13
+ offsetTransform,
11
14
  } from './utils';
12
15
 
13
16
  /**
@@ -21,6 +24,10 @@ export function elementSelect(
21
24
  groupKey = (d) => d, // group elements by specified key
22
25
  link = false, // draw link or not
23
26
  single = false, // single select or not
27
+ coordinate,
28
+ background = false,
29
+ offset = 0,
30
+ scale,
24
31
  ...rest
25
32
  }: Record<string, any>,
26
33
  ) {
@@ -28,15 +35,39 @@ export function elementSelect(
28
35
  const elementSet = new Set(elements);
29
36
  const keyGroup = group(elements, groupKey);
30
37
  const valueof = createValueof(elements, datum);
31
- const [appendLink, removeLink] = renderLink(root, {
38
+ const [appendLink, removeLink] = renderLink({
39
+ link,
32
40
  elements,
33
41
  valueof,
42
+ coordinate,
34
43
  ...subObject(rest, 'link'),
35
44
  });
36
- const { setState, removeState, hasState } = useState(rest, valueof);
45
+
46
+ const [appendBackground, removeBackground] = renderBackground({
47
+ background,
48
+ coordinate,
49
+ scale,
50
+ valueof,
51
+ ...subObject(rest, 'background'),
52
+ });
53
+
54
+ const elementStyle = {
55
+ ...(offset !== 0 && {
56
+ // Apply translate to mock slice out.
57
+ selectedTransform: (_, i) => {
58
+ return offsetTransform(elements[i], offset, coordinate);
59
+ },
60
+ }),
61
+ ...rest,
62
+ };
63
+ const { setState, removeState, hasState } = useState(elementStyle, valueof);
64
+
37
65
  const clear = () => {
38
- for (const e of elements) removeState(e, 'selected', 'unselected');
39
- if (link) removeLink();
66
+ for (const e of elements) {
67
+ removeState(e, 'selected', 'unselected');
68
+ removeLink(e);
69
+ removeBackground(e);
70
+ }
40
71
  return;
41
72
  };
42
73
 
@@ -49,13 +80,14 @@ export function elementSelect(
49
80
  const groupSet = new Set(group);
50
81
  for (const e of elements) {
51
82
  if (groupSet.has(e)) setState(e, 'selected');
52
- else setState(e, 'unselected');
53
- }
54
- // Remove all links and append link for this group.
55
- if (link) {
56
- removeLink();
57
- appendLink(group);
83
+ else {
84
+ setState(e, 'unselected');
85
+ removeLink(e);
86
+ }
87
+ if (e !== element) removeBackground(e);
58
88
  }
89
+ appendLink(group);
90
+ appendBackground(element);
59
91
  }
60
92
  };
61
93
 
@@ -70,7 +102,8 @@ export function elementSelect(
70
102
  else if (!hasState(e, 'selected')) setState(e, 'unselected');
71
103
  }
72
104
  // Append link for each group only once.
73
- if (!hasSelectedGroup && link) appendLink(group, k);
105
+ if (!hasSelectedGroup && link) appendLink(group);
106
+ appendBackground(element);
74
107
  } else {
75
108
  // If there is no selected elements after resetting this group,
76
109
  // clear the states.
@@ -80,8 +113,11 @@ export function elementSelect(
80
113
  if (!hasSelected) return clear();
81
114
  // If there are still some selected elements after resetting this group,
82
115
  // only remove the link.
83
- for (const e of group) setState(e, 'unselected');
84
- if (link) removeLink(k);
116
+ for (const e of group) {
117
+ setState(e, 'unselected');
118
+ removeLink(e);
119
+ removeBackground(e);
120
+ }
85
121
  }
86
122
  };
87
123
 
@@ -98,16 +134,24 @@ export function elementSelect(
98
134
 
99
135
  return () => {
100
136
  root.removeEventListener('click', click);
137
+ for (const e of elements) {
138
+ removeLink(e);
139
+ }
101
140
  };
102
141
  }
103
142
 
104
143
  export function ElementSelect(options) {
105
144
  return (context) => {
106
145
  const { container, view } = context;
107
- return elementSelect(container, {
146
+ const { coordinate, scale } = view;
147
+ const plotArea = selectPlotArea(container);
148
+ return elementSelect(plotArea, {
149
+ ...options,
108
150
  ...applyDefaultsHighlightedStyle(options),
109
151
  elements: selectG2Elements,
110
152
  datum: createDatumof(view),
153
+ coordinate,
154
+ scale,
111
155
  });
112
156
  };
113
157
  }
@@ -3,13 +3,16 @@ import {
3
3
  selectG2Elements,
4
4
  applyDefaultsHighlightedStyle,
5
5
  createColorKey,
6
+ selectPlotArea,
6
7
  } from './utils';
7
8
  import { elementSelect } from './elementSelect';
8
9
 
9
10
  export function ElementSelectByColor(options) {
10
11
  return (context) => {
11
12
  const { container, view } = context;
12
- return elementSelect(container, {
13
+ const plot = selectPlotArea(container);
14
+ return elementSelect(plot, {
15
+ ...options,
13
16
  ...applyDefaultsHighlightedStyle(options),
14
17
  elements: selectG2Elements,
15
18
  datum: createDatumof(view),
@@ -3,13 +3,16 @@ import {
3
3
  selectG2Elements,
4
4
  applyDefaultsHighlightedStyle,
5
5
  createXKey,
6
+ selectPlotArea,
6
7
  } from './utils';
7
8
  import { elementSelect } from './elementSelect';
8
9
 
9
10
  export function ElementSelectByX(options) {
10
11
  return (context) => {
11
12
  const { container, view } = context;
12
- return elementSelect(container, {
13
+ const plot = selectPlotArea(container);
14
+ return elementSelect(plot, {
15
+ ...options,
13
16
  ...applyDefaultsHighlightedStyle(options),
14
17
  elements: selectG2Elements,
15
18
  datum: createDatumof(view),
@@ -11,18 +11,22 @@ export const LEGEND_MAKER_CLASS_NAME = 'legend-category-item-marker';
11
11
 
12
12
  export const LEGEND_LABEL_CLASS_NAME = 'legend-category-item-label';
13
13
 
14
- function markerOf(item) {
14
+ export function markerOf(item) {
15
15
  return item.getElementsByClassName(LEGEND_MAKER_CLASS_NAME)[0];
16
16
  }
17
17
 
18
- function labelOf(item) {
18
+ export function labelOf(item) {
19
19
  return item.getElementsByClassName(LEGEND_LABEL_CLASS_NAME)[0];
20
20
  }
21
21
 
22
- function legendsOf(root) {
22
+ export function itemsOf(root) {
23
23
  return root.getElementsByClassName(LEGEND_ITEMS_CLASS_NAME);
24
24
  }
25
25
 
26
+ export function legendsOf(root) {
27
+ return root.getElementsByClassName(CATEGORY_LEGEND_CLASS_NAME);
28
+ }
29
+
26
30
  function builtInAccessors(selectedLegend) {
27
31
  // Get the value and scale type from legend.
28
32
  const { data } = selectedLegend.attributes;
@@ -31,7 +35,7 @@ function builtInAccessors(selectedLegend) {
31
35
  return [
32
36
  channel,
33
37
  {
34
- legends: legendsOf,
38
+ legends: itemsOf,
35
39
  marker: markerOf,
36
40
  label: labelOf,
37
41
  datum: (d) => {
@@ -0,0 +1,87 @@
1
+ import { group } from 'd3-array';
2
+ import { subObject } from '../../utils/helper';
3
+ import { selectG2Elements, useState } from './utils';
4
+ import { markerOf, labelOf, itemsOf, legendsOf } from './legendFilter';
5
+
6
+ export function LegendHighlight({ channel, ...rest }) {
7
+ return (context) => {
8
+ const { container, view } = context;
9
+ const legends = legendsOf(container);
10
+ const elements = selectG2Elements(container);
11
+ const channelOf = (legend) => {
12
+ const { __data__ } = legend.parentNode;
13
+ return __data__.scale.name;
14
+ };
15
+ const scaleOf = (channel) => {
16
+ const {
17
+ scale: { [channel]: scale },
18
+ } = view;
19
+ return scale;
20
+ };
21
+ for (const legend of legends) {
22
+ const datumOf = (item) => {
23
+ const { data } = legend.attributes;
24
+ const { __data__: datum } = item;
25
+ const { index } = datum;
26
+ return data[index].label;
27
+ };
28
+ const channel = channelOf(legend);
29
+ const items = itemsOf(legend);
30
+ const scale = scaleOf(channel);
31
+ const elementGroup = group<any, any>(elements, (d) =>
32
+ scale.invert(d.__data__[channel]),
33
+ );
34
+ const { setState, removeState } = useState(rest);
35
+ const markerStyle = subObject(rest, 'marker');
36
+ const labelStyle = subObject(rest, 'label');
37
+ const { setState: setM, removeState: removeM } = useState(markerStyle);
38
+ const { setState: setL, removeState: removeL } = useState(labelStyle);
39
+ const updateLegendState = (highlight) => {
40
+ for (const item of items) {
41
+ const marker = markerOf(item);
42
+ const label = labelOf(item);
43
+ if (item === highlight || highlight === null) {
44
+ removeM(marker, 'unhighlighted');
45
+ removeL(label, 'unhighlighted');
46
+ } else {
47
+ setM(marker, 'unhighlighted');
48
+ setL(label, 'unhighlighted');
49
+ }
50
+ }
51
+ };
52
+
53
+ const itemPointerover = new Map();
54
+
55
+ // Add listener for the legend items.
56
+ for (const item of items) {
57
+ const pointerover = () => {
58
+ const value = datumOf(item);
59
+ const elementSet = new Set(elementGroup.get(value));
60
+ for (const e of elements) {
61
+ if (elementSet.has(e)) setState(e, 'highlighted');
62
+ else setState(e, 'unhighlighted');
63
+ }
64
+ updateLegendState(item);
65
+ };
66
+ item.addEventListener('pointerover', pointerover);
67
+ itemPointerover.set(item, pointerover);
68
+ }
69
+
70
+ // Add listener for the legend group.
71
+ const pointerleave = () => {
72
+ for (const e of elements) {
73
+ removeState(e, 'unhighlighted', 'highlighted');
74
+ }
75
+ updateLegendState(null);
76
+ };
77
+ legend.addEventListener('pointerleave', pointerleave);
78
+
79
+ return () => {
80
+ legend.removeEventListener(pointerleave);
81
+ for (const [item, pointerover] of itemPointerover) {
82
+ item.removeEventListener(pointerover);
83
+ }
84
+ };
85
+ }
86
+ };
87
+ }
@@ -0,0 +1,112 @@
1
+ import { deepMix, throttle } from '@antv/util';
2
+ import { invert, domainOf } from '../../utils/scale';
3
+
4
+ export const SLIDER_CLASS_NAME = 'slider';
5
+
6
+ function filterDataByDomain(options, scaleOptions) {
7
+ const { marks } = options;
8
+ const newMarks = marks.map((mark) =>
9
+ deepMix(
10
+ {
11
+ // Hide label to keep smooth transition.
12
+ axis: {
13
+ x: { labelTransforms: [{ type: 'hide' }] },
14
+ y: { labelTransforms: [{ type: 'hide' }] },
15
+ },
16
+ },
17
+ mark,
18
+ {
19
+ scale: scaleOptions,
20
+ // Don't rerender sliders.
21
+ slider: {
22
+ ...(mark.slider.x && { x: { preserve: true } }),
23
+ ...(mark.slider.y && { y: { preserve: true } }),
24
+ },
25
+ animate: false,
26
+ },
27
+ ),
28
+ );
29
+
30
+ // Rerender and update view.
31
+ return {
32
+ ...options,
33
+ marks: newMarks,
34
+ clip: true, // Clip shapes out of plot area.
35
+ animate: false,
36
+ };
37
+ }
38
+
39
+ function abstractValue(values, scale) {
40
+ const [x, x1] = values;
41
+ const d0 = invert(scale, x, true);
42
+ const d1 = invert(scale, x1, false);
43
+ return domainOf(scale, [d0, d1]);
44
+ }
45
+
46
+ /**
47
+ * @todo Support click to reset after fix click and dragend conflict.
48
+ */
49
+ export function SliderFilter({
50
+ wait = 50,
51
+ leading = true,
52
+ trailing = false,
53
+ }: any) {
54
+ return (context) => {
55
+ const { container, view, options, update } = context;
56
+ const sliders = container.getElementsByClassName(SLIDER_CLASS_NAME);
57
+ if (!sliders.length) return;
58
+
59
+ let filtering = false;
60
+ const { scale } = view;
61
+ const { x: scaleX, y: scaleY } = scale;
62
+
63
+ const sliderHandler = new Map();
64
+
65
+ // Store current domain of x and y scale.
66
+ const channelDomain = {
67
+ x: scaleX.getOptions().domain,
68
+ y: scaleY.getOptions().domain,
69
+ };
70
+
71
+ for (const slider of sliders) {
72
+ const { orient } = slider.attributes;
73
+
74
+ const onValueChange = throttle(
75
+ async (event) => {
76
+ const { value: values } = event.detail;
77
+ if (filtering) return;
78
+ filtering = true;
79
+
80
+ // Update domain of the current channel.
81
+ const channel0 = orient === 'vertical' ? 'y' : 'x';
82
+ const scale0 = scale[channel0];
83
+ const domain0 = abstractValue(values, scale0);
84
+ channelDomain[channel0] = domain0;
85
+
86
+ // Get domain of the other channel.
87
+ const channel1 = orient === 'vertical' ? 'x' : 'y';
88
+ const domain1 = channelDomain[channel1];
89
+
90
+ // Filter data.
91
+ const newOptions = filterDataByDomain(options, {
92
+ [channel0]: { domain: domain0 },
93
+ [channel1]: { domain: domain1 },
94
+ });
95
+ await update(newOptions);
96
+ filtering = false;
97
+ },
98
+ wait,
99
+ { leading, trailing },
100
+ );
101
+
102
+ slider.addEventListener('valuechange', onValueChange);
103
+ sliderHandler.set(slider, onValueChange);
104
+ }
105
+
106
+ return () => {
107
+ for (const [slider, handler] of sliderHandler) {
108
+ slider.removeEventListener('valuechange', handler);
109
+ }
110
+ };
111
+ };
112
+ }
@@ -72,6 +72,14 @@ function hideTooltip(root) {
72
72
  if (tooltipElement) tooltipElement.hide();
73
73
  }
74
74
 
75
+ function destroyTooltip(root) {
76
+ const { tooltipElement } = root;
77
+ if (tooltipElement) {
78
+ tooltipElement.destroy();
79
+ root.tooltipElement = undefined;
80
+ }
81
+ }
82
+
75
83
  function filterDefined(obj) {
76
84
  return Object.fromEntries(
77
85
  Object.entries(obj).filter(([, value]) => defined(value)),
@@ -384,6 +392,8 @@ export function seriesTooltip(
384
392
  root.removeEventListener('pointerover', update);
385
393
  root.removeEventListener('pointerout', update);
386
394
  root.removeEventListener('pointerleave', hide);
395
+ destroyTooltip(root);
396
+ if (crosshairs) hideRuleY(root);
387
397
  };
388
398
  }
389
399
 
@@ -437,6 +447,7 @@ export function tooltip(
437
447
  root.removeEventListener('pointerover', pointerover);
438
448
  root.removeEventListener('pointermove', pointerover);
439
449
  root.removeEventListener('pointerout', pointerout);
450
+ destroyTooltip(root);
440
451
  };
441
452
  }
442
453