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

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 (522) hide show
  1. package/dist/g2-lite.min.js +4 -4
  2. package/dist/g2.min.js +4 -4
  3. package/esm/api/chart.d.ts +6 -2
  4. package/esm/api/chart.js +28 -7
  5. package/esm/api/chart.js.map +1 -1
  6. package/esm/api/composition/base.d.ts +4 -0
  7. package/esm/api/composition/base.js +16 -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/mark.d.ts +34 -28
  40. package/esm/api/mark/mark.js +39 -26
  41. package/esm/api/mark/mark.js.map +1 -1
  42. package/esm/api/mark/types.d.ts +1 -0
  43. package/esm/api/node.d.ts +2 -1
  44. package/esm/api/node.js +8 -9
  45. package/esm/api/node.js.map +1 -1
  46. package/esm/component/axis.js +18 -5
  47. package/esm/component/axis.js.map +1 -1
  48. package/esm/component/index.d.ts +2 -0
  49. package/esm/component/index.js +2 -0
  50. package/esm/component/index.js.map +1 -1
  51. package/esm/component/scrollbar.d.ts +9 -0
  52. package/esm/component/scrollbar.js +36 -0
  53. package/esm/component/scrollbar.js.map +1 -0
  54. package/esm/component/scrollbarX.d.ts +7 -0
  55. package/esm/component/scrollbarX.js +9 -0
  56. package/esm/component/scrollbarX.js.map +1 -0
  57. package/esm/component/scrollbarY.d.ts +7 -0
  58. package/esm/component/scrollbarY.js +9 -0
  59. package/esm/component/scrollbarY.js.map +1 -0
  60. package/esm/component/slider.js +3 -13
  61. package/esm/component/slider.js.map +1 -1
  62. package/esm/component/title.js +46 -22
  63. package/esm/component/title.js.map +1 -1
  64. package/esm/data/fold.js +4 -10
  65. package/esm/data/fold.js.map +1 -1
  66. package/esm/data/index.d.ts +2 -2
  67. package/esm/data/index.js +1 -1
  68. package/esm/data/index.js.map +1 -1
  69. package/esm/data/pick.js +10 -2
  70. package/esm/data/pick.js.map +1 -1
  71. package/esm/data/slice.d.ts +8 -0
  72. package/esm/data/slice.js +10 -0
  73. package/esm/data/slice.js.map +1 -0
  74. package/esm/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  75. package/esm/geo/{d3-projection.js → d3Projection.js} +1 -1
  76. package/esm/geo/d3Projection.js.map +1 -0
  77. package/esm/geo/geoView.js +1 -1
  78. package/esm/geo/geoView.js.map +1 -1
  79. package/esm/interaction/index.d.ts +6 -0
  80. package/esm/interaction/index.js +5 -30
  81. package/esm/interaction/index.js.map +1 -1
  82. package/esm/interaction/native/brushAxisHighlight.d.ts +26 -0
  83. package/esm/interaction/native/brushAxisHighlight.js +159 -0
  84. package/esm/interaction/native/brushAxisHighlight.js.map +1 -0
  85. package/esm/interaction/native/brushFilter.d.ts +14 -0
  86. package/esm/interaction/native/brushFilter.js +122 -0
  87. package/esm/interaction/native/brushFilter.js.map +1 -0
  88. package/esm/interaction/native/brushHighlight.d.ts +30 -5
  89. package/esm/interaction/native/brushHighlight.js +92 -34
  90. package/esm/interaction/native/brushHighlight.js.map +1 -1
  91. package/esm/interaction/native/brushXFilter.d.ts +1 -0
  92. package/esm/interaction/native/brushXFilter.js +6 -0
  93. package/esm/interaction/native/brushXFilter.js.map +1 -0
  94. package/esm/interaction/native/brushXHighlight.d.ts +6 -1
  95. package/esm/interaction/native/brushXHighlight.js +5 -4
  96. package/esm/interaction/native/brushXHighlight.js.map +1 -1
  97. package/esm/interaction/native/brushYFilter.d.ts +1 -0
  98. package/esm/interaction/native/brushYFilter.js +6 -0
  99. package/esm/interaction/native/brushYFilter.js.map +1 -0
  100. package/esm/interaction/native/brushYHighlight.d.ts +6 -1
  101. package/esm/interaction/native/brushYHighlight.js +5 -4
  102. package/esm/interaction/native/brushYHighlight.js.map +1 -1
  103. package/esm/interaction/native/elementHighlight.js +1 -0
  104. package/esm/interaction/native/elementHighlight.js.map +1 -1
  105. package/esm/interaction/native/elementSelect.js +1 -0
  106. package/esm/interaction/native/elementSelect.js.map +1 -1
  107. package/esm/interaction/native/sliderFilter.d.ts +5 -0
  108. package/esm/interaction/native/sliderFilter.js +87 -0
  109. package/esm/interaction/native/sliderFilter.js.map +1 -0
  110. package/esm/interaction/native/tooltip.js +16 -4
  111. package/esm/interaction/native/tooltip.js.map +1 -1
  112. package/esm/interaction/native/utils.d.ts +5 -1
  113. package/esm/interaction/native/utils.js +11 -3
  114. package/esm/interaction/native/utils.js.map +1 -1
  115. package/esm/label-transform/overlapDodgeY.js +8 -0
  116. package/esm/label-transform/overlapDodgeY.js.map +1 -1
  117. package/esm/mark/area.js +1 -1
  118. package/esm/mark/area.js.map +1 -1
  119. package/esm/mark/boxplot.js +5 -18
  120. package/esm/mark/boxplot.js.map +1 -1
  121. package/esm/runtime/component.d.ts +1 -1
  122. package/esm/runtime/component.js +38 -41
  123. package/esm/runtime/component.js.map +1 -1
  124. package/esm/runtime/layout.js +7 -7
  125. package/esm/runtime/layout.js.map +1 -1
  126. package/esm/runtime/plot.d.ts +1 -1
  127. package/esm/runtime/plot.js +70 -27
  128. package/esm/runtime/plot.js.map +1 -1
  129. package/esm/runtime/render.d.ts +0 -1
  130. package/esm/runtime/render.js +4 -34
  131. package/esm/runtime/render.js.map +1 -1
  132. package/esm/runtime/scale.d.ts +2 -1
  133. package/esm/runtime/scale.js +7 -0
  134. package/esm/runtime/scale.js.map +1 -1
  135. package/esm/runtime/transform.js +6 -2
  136. package/esm/runtime/transform.js.map +1 -1
  137. package/esm/runtime/types/common.d.ts +26 -9
  138. package/esm/runtime/types/options.d.ts +2 -5
  139. package/esm/runtime/types/theme.d.ts +2 -5
  140. package/esm/shape/area/curve.js +15 -8
  141. package/esm/shape/area/curve.js.map +1 -1
  142. package/esm/shape/box/box.js +1 -1
  143. package/esm/shape/box/box.js.map +1 -1
  144. package/esm/shape/connector/connector.js +2 -2
  145. package/esm/shape/connector/connector.js.map +1 -1
  146. package/esm/shape/image/image.js +2 -2
  147. package/esm/shape/image/image.js.map +1 -1
  148. package/esm/shape/interval/color.js +3 -1
  149. package/esm/shape/interval/color.js.map +1 -1
  150. package/esm/shape/label/position/default.d.ts +5 -7
  151. package/esm/shape/label/position/default.js +14 -40
  152. package/esm/shape/label/position/default.js.map +1 -1
  153. package/esm/shape/label/position/outside.d.ts +18 -1
  154. package/esm/shape/label/position/outside.js +66 -1
  155. package/esm/shape/label/position/outside.js.map +1 -1
  156. package/esm/shape/label/position/spider.d.ts +1 -1
  157. package/esm/shape/label/position/spider.js +12 -18
  158. package/esm/shape/label/position/spider.js.map +1 -1
  159. package/esm/shape/label/position/surround.d.ts +1 -1
  160. package/esm/shape/label/position/surround.js +12 -14
  161. package/esm/shape/label/position/surround.js.map +1 -1
  162. package/esm/shape/line/curve.js +1 -1
  163. package/esm/shape/line/curve.js.map +1 -1
  164. package/esm/shape/lineXY/line.js +2 -2
  165. package/esm/shape/lineXY/line.js.map +1 -1
  166. package/esm/shape/link/arc.js +2 -2
  167. package/esm/shape/link/arc.js.map +1 -1
  168. package/esm/shape/link/link.js +2 -2
  169. package/esm/shape/link/link.js.map +1 -1
  170. package/esm/shape/link/smooth.js +2 -2
  171. package/esm/shape/link/smooth.js.map +1 -1
  172. package/esm/shape/link/vhv.js +2 -2
  173. package/esm/shape/link/vhv.js.map +1 -1
  174. package/esm/shape/point/color.js +1 -1
  175. package/esm/shape/point/color.js.map +1 -1
  176. package/esm/shape/polygon/polygon.js +3 -3
  177. package/esm/shape/polygon/polygon.js.map +1 -1
  178. package/esm/shape/polygon/ribbon.js +3 -3
  179. package/esm/shape/polygon/ribbon.js.map +1 -1
  180. package/esm/shape/text/advance.js +1 -1
  181. package/esm/shape/text/advance.js.map +1 -1
  182. package/esm/shape/text/badge.js +3 -3
  183. package/esm/shape/text/badge.js.map +1 -1
  184. package/esm/shape/text/text.js +1 -1
  185. package/esm/shape/text/text.js.map +1 -1
  186. package/esm/shape/utils.d.ts +4 -0
  187. package/esm/shape/utils.js +6 -1
  188. package/esm/shape/utils.js.map +1 -1
  189. package/esm/shape/vector/vector.js +3 -3
  190. package/esm/shape/vector/vector.js.map +1 -1
  191. package/esm/spec/data.d.ts +24 -9
  192. package/esm/spec/geometry.d.ts +2 -0
  193. package/esm/spec/interaction.d.ts +28 -3
  194. package/esm/spec/transform.d.ts +2 -2
  195. package/esm/stdlib/index.js +5 -5
  196. package/esm/stdlib/index.js.map +1 -1
  197. package/esm/theme/academy.js +11 -15
  198. package/esm/theme/academy.js.map +1 -1
  199. package/esm/theme/dark.js +11 -18
  200. package/esm/theme/dark.js.map +1 -1
  201. package/esm/theme/light.js +25 -19
  202. package/esm/theme/light.js.map +1 -1
  203. package/esm/transform/select.js +1 -13
  204. package/esm/transform/select.js.map +1 -1
  205. package/esm/transform/selectX.js +1 -1
  206. package/esm/transform/selectX.js.map +1 -1
  207. package/esm/transform/selectY.js +1 -1
  208. package/esm/transform/selectY.js.map +1 -1
  209. package/esm/utils/scale.d.ts +2 -0
  210. package/esm/utils/scale.js +30 -0
  211. package/esm/utils/scale.js.map +1 -0
  212. package/lib/api/chart.d.ts +6 -2
  213. package/lib/api/chart.js +27 -6
  214. package/lib/api/chart.js.map +1 -1
  215. package/lib/api/composition/base.d.ts +4 -0
  216. package/lib/api/composition/base.js +19 -0
  217. package/lib/api/composition/base.js.map +1 -0
  218. package/lib/api/composition/facetCircle.d.ts +2 -3
  219. package/lib/api/composition/facetCircle.js +2 -2
  220. package/lib/api/composition/facetCircle.js.map +1 -1
  221. package/lib/api/composition/facetRect.d.ts +2 -3
  222. package/lib/api/composition/facetRect.js +2 -2
  223. package/lib/api/composition/facetRect.js.map +1 -1
  224. package/lib/api/composition/geoPath.d.ts +2 -3
  225. package/lib/api/composition/geoPath.js +2 -2
  226. package/lib/api/composition/geoPath.js.map +1 -1
  227. package/lib/api/composition/geoView.d.ts +2 -3
  228. package/lib/api/composition/geoView.js +2 -2
  229. package/lib/api/composition/geoView.js.map +1 -1
  230. package/lib/api/composition/index.d.ts +2 -1
  231. package/lib/api/composition/index.js +3 -1
  232. package/lib/api/composition/index.js.map +1 -1
  233. package/lib/api/composition/repeatMatrix.d.ts +2 -3
  234. package/lib/api/composition/repeatMatrix.js +2 -2
  235. package/lib/api/composition/repeatMatrix.js.map +1 -1
  236. package/lib/api/composition/spaceFlex.d.ts +2 -3
  237. package/lib/api/composition/spaceFlex.js +2 -2
  238. package/lib/api/composition/spaceFlex.js.map +1 -1
  239. package/lib/api/composition/spaceLayer.d.ts +2 -3
  240. package/lib/api/composition/spaceLayer.js +2 -2
  241. package/lib/api/composition/spaceLayer.js.map +1 -1
  242. package/lib/api/composition/timingKeyframe.d.ts +2 -3
  243. package/lib/api/composition/timingKeyframe.js +2 -2
  244. package/lib/api/composition/timingKeyframe.js.map +1 -1
  245. package/lib/api/composition/view.d.ts +3 -3
  246. package/lib/api/composition/view.js +4 -4
  247. package/lib/api/composition/view.js.map +1 -1
  248. package/lib/api/mark/mark.d.ts +34 -28
  249. package/lib/api/mark/mark.js +41 -27
  250. package/lib/api/mark/mark.js.map +1 -1
  251. package/lib/api/mark/types.d.ts +1 -0
  252. package/lib/api/node.d.ts +2 -1
  253. package/lib/api/node.js +8 -9
  254. package/lib/api/node.js.map +1 -1
  255. package/lib/component/axis.js +18 -5
  256. package/lib/component/axis.js.map +1 -1
  257. package/lib/component/index.d.ts +2 -0
  258. package/lib/component/index.js +5 -1
  259. package/lib/component/index.js.map +1 -1
  260. package/lib/component/scrollbar.d.ts +9 -0
  261. package/lib/component/scrollbar.js +40 -0
  262. package/lib/component/scrollbar.js.map +1 -0
  263. package/lib/component/scrollbarX.d.ts +7 -0
  264. package/lib/component/scrollbarX.js +13 -0
  265. package/lib/component/scrollbarX.js.map +1 -0
  266. package/lib/component/scrollbarY.d.ts +7 -0
  267. package/lib/component/scrollbarY.js +13 -0
  268. package/lib/component/scrollbarY.js.map +1 -0
  269. package/lib/component/slider.js +3 -13
  270. package/lib/component/slider.js.map +1 -1
  271. package/lib/component/title.js +46 -22
  272. package/lib/component/title.js.map +1 -1
  273. package/lib/data/fold.js +4 -10
  274. package/lib/data/fold.js.map +1 -1
  275. package/lib/data/index.d.ts +2 -2
  276. package/lib/data/index.js +3 -3
  277. package/lib/data/index.js.map +1 -1
  278. package/lib/data/pick.js +10 -2
  279. package/lib/data/pick.js.map +1 -1
  280. package/lib/data/slice.d.ts +8 -0
  281. package/lib/data/slice.js +14 -0
  282. package/lib/data/slice.js.map +1 -0
  283. package/lib/geo/{d3-projection.d.ts → d3Projection.d.ts} +0 -0
  284. package/lib/geo/{d3-projection.js → d3Projection.js} +1 -1
  285. package/lib/geo/d3Projection.js.map +1 -0
  286. package/lib/geo/geoView.js +1 -1
  287. package/lib/geo/geoView.js.map +1 -1
  288. package/lib/interaction/index.d.ts +6 -0
  289. package/lib/interaction/index.js +11 -31
  290. package/lib/interaction/index.js.map +1 -1
  291. package/lib/interaction/native/brushAxisHighlight.d.ts +26 -0
  292. package/lib/interaction/native/brushAxisHighlight.js +164 -0
  293. package/lib/interaction/native/brushAxisHighlight.js.map +1 -0
  294. package/lib/interaction/native/brushFilter.d.ts +14 -0
  295. package/lib/interaction/native/brushFilter.js +127 -0
  296. package/lib/interaction/native/brushFilter.js.map +1 -0
  297. package/lib/interaction/native/brushHighlight.d.ts +30 -5
  298. package/lib/interaction/native/brushHighlight.js +91 -33
  299. package/lib/interaction/native/brushHighlight.js.map +1 -1
  300. package/lib/interaction/native/brushXFilter.d.ts +1 -0
  301. package/lib/interaction/native/brushXFilter.js +10 -0
  302. package/lib/interaction/native/brushXFilter.js.map +1 -0
  303. package/lib/interaction/native/brushXHighlight.d.ts +6 -1
  304. package/lib/interaction/native/brushXHighlight.js +7 -5
  305. package/lib/interaction/native/brushXHighlight.js.map +1 -1
  306. package/lib/interaction/native/brushYFilter.d.ts +1 -0
  307. package/lib/interaction/native/brushYFilter.js +10 -0
  308. package/lib/interaction/native/brushYFilter.js.map +1 -0
  309. package/lib/interaction/native/brushYHighlight.d.ts +6 -1
  310. package/lib/interaction/native/brushYHighlight.js +7 -5
  311. package/lib/interaction/native/brushYHighlight.js.map +1 -1
  312. package/lib/interaction/native/elementHighlight.js +1 -0
  313. package/lib/interaction/native/elementHighlight.js.map +1 -1
  314. package/lib/interaction/native/elementSelect.js +1 -0
  315. package/lib/interaction/native/elementSelect.js.map +1 -1
  316. package/lib/interaction/native/sliderFilter.d.ts +5 -0
  317. package/lib/interaction/native/sliderFilter.js +91 -0
  318. package/lib/interaction/native/sliderFilter.js.map +1 -0
  319. package/lib/interaction/native/tooltip.js +16 -4
  320. package/lib/interaction/native/tooltip.js.map +1 -1
  321. package/lib/interaction/native/utils.d.ts +5 -1
  322. package/lib/interaction/native/utils.js +14 -5
  323. package/lib/interaction/native/utils.js.map +1 -1
  324. package/lib/label-transform/overlapDodgeY.js +8 -0
  325. package/lib/label-transform/overlapDodgeY.js.map +1 -1
  326. package/lib/mark/area.js +1 -1
  327. package/lib/mark/area.js.map +1 -1
  328. package/lib/mark/boxplot.js +5 -18
  329. package/lib/mark/boxplot.js.map +1 -1
  330. package/lib/runtime/component.d.ts +1 -1
  331. package/lib/runtime/component.js +37 -40
  332. package/lib/runtime/component.js.map +1 -1
  333. package/lib/runtime/layout.js +7 -7
  334. package/lib/runtime/layout.js.map +1 -1
  335. package/lib/runtime/plot.d.ts +1 -1
  336. package/lib/runtime/plot.js +67 -24
  337. package/lib/runtime/plot.js.map +1 -1
  338. package/lib/runtime/render.d.ts +0 -1
  339. package/lib/runtime/render.js +4 -35
  340. package/lib/runtime/render.js.map +1 -1
  341. package/lib/runtime/scale.d.ts +2 -1
  342. package/lib/runtime/scale.js +9 -1
  343. package/lib/runtime/scale.js.map +1 -1
  344. package/lib/runtime/transform.js +6 -2
  345. package/lib/runtime/transform.js.map +1 -1
  346. package/lib/runtime/types/common.d.ts +26 -9
  347. package/lib/runtime/types/options.d.ts +2 -5
  348. package/lib/runtime/types/theme.d.ts +2 -5
  349. package/lib/shape/area/curve.js +14 -7
  350. package/lib/shape/area/curve.js.map +1 -1
  351. package/lib/shape/box/box.js +1 -1
  352. package/lib/shape/box/box.js.map +1 -1
  353. package/lib/shape/connector/connector.js +2 -2
  354. package/lib/shape/connector/connector.js.map +1 -1
  355. package/lib/shape/image/image.js +2 -2
  356. package/lib/shape/image/image.js.map +1 -1
  357. package/lib/shape/interval/color.js +3 -1
  358. package/lib/shape/interval/color.js.map +1 -1
  359. package/lib/shape/label/position/default.d.ts +5 -7
  360. package/lib/shape/label/position/default.js +16 -40
  361. package/lib/shape/label/position/default.js.map +1 -1
  362. package/lib/shape/label/position/outside.d.ts +18 -1
  363. package/lib/shape/label/position/outside.js +72 -3
  364. package/lib/shape/label/position/outside.js.map +1 -1
  365. package/lib/shape/label/position/spider.d.ts +1 -1
  366. package/lib/shape/label/position/spider.js +12 -18
  367. package/lib/shape/label/position/spider.js.map +1 -1
  368. package/lib/shape/label/position/surround.d.ts +1 -1
  369. package/lib/shape/label/position/surround.js +11 -13
  370. package/lib/shape/label/position/surround.js.map +1 -1
  371. package/lib/shape/line/curve.js +1 -1
  372. package/lib/shape/line/curve.js.map +1 -1
  373. package/lib/shape/lineXY/line.js +2 -2
  374. package/lib/shape/lineXY/line.js.map +1 -1
  375. package/lib/shape/link/arc.js +2 -2
  376. package/lib/shape/link/arc.js.map +1 -1
  377. package/lib/shape/link/link.js +2 -2
  378. package/lib/shape/link/link.js.map +1 -1
  379. package/lib/shape/link/smooth.js +2 -2
  380. package/lib/shape/link/smooth.js.map +1 -1
  381. package/lib/shape/link/vhv.js +2 -2
  382. package/lib/shape/link/vhv.js.map +1 -1
  383. package/lib/shape/point/color.js +1 -1
  384. package/lib/shape/point/color.js.map +1 -1
  385. package/lib/shape/polygon/polygon.js +3 -3
  386. package/lib/shape/polygon/polygon.js.map +1 -1
  387. package/lib/shape/polygon/ribbon.js +3 -3
  388. package/lib/shape/polygon/ribbon.js.map +1 -1
  389. package/lib/shape/text/advance.js +1 -1
  390. package/lib/shape/text/advance.js.map +1 -1
  391. package/lib/shape/text/badge.js +3 -3
  392. package/lib/shape/text/badge.js.map +1 -1
  393. package/lib/shape/text/text.js +1 -1
  394. package/lib/shape/text/text.js.map +1 -1
  395. package/lib/shape/utils.d.ts +4 -0
  396. package/lib/shape/utils.js +6 -1
  397. package/lib/shape/utils.js.map +1 -1
  398. package/lib/shape/vector/vector.js +3 -3
  399. package/lib/shape/vector/vector.js.map +1 -1
  400. package/lib/spec/data.d.ts +24 -9
  401. package/lib/spec/geometry.d.ts +2 -0
  402. package/lib/spec/interaction.d.ts +28 -3
  403. package/lib/spec/transform.d.ts +2 -2
  404. package/lib/stdlib/index.js +2 -2
  405. package/lib/stdlib/index.js.map +1 -1
  406. package/lib/theme/academy.js +11 -15
  407. package/lib/theme/academy.js.map +1 -1
  408. package/lib/theme/dark.js +11 -18
  409. package/lib/theme/dark.js.map +1 -1
  410. package/lib/theme/light.js +25 -19
  411. package/lib/theme/light.js.map +1 -1
  412. package/lib/transform/select.js +1 -13
  413. package/lib/transform/select.js.map +1 -1
  414. package/lib/transform/selectX.js +1 -1
  415. package/lib/transform/selectX.js.map +1 -1
  416. package/lib/transform/selectY.js +1 -1
  417. package/lib/transform/selectY.js.map +1 -1
  418. package/lib/utils/scale.d.ts +2 -0
  419. package/lib/utils/scale.js +35 -0
  420. package/lib/utils/scale.js.map +1 -0
  421. package/package.json +1 -1
  422. package/src/api/chart.ts +31 -10
  423. package/src/api/composition/base.ts +11 -0
  424. package/src/api/composition/facetCircle.ts +2 -3
  425. package/src/api/composition/facetRect.ts +2 -3
  426. package/src/api/composition/geoPath.ts +2 -3
  427. package/src/api/composition/geoView.ts +2 -3
  428. package/src/api/composition/index.ts +2 -0
  429. package/src/api/composition/repeatMatrix.ts +2 -3
  430. package/src/api/composition/spaceFlex.ts +2 -3
  431. package/src/api/composition/spaceLayer.ts +2 -3
  432. package/src/api/composition/timingKeyframe.ts +2 -3
  433. package/src/api/composition/view.ts +6 -4
  434. package/src/api/mark/mark.ts +48 -27
  435. package/src/api/mark/types.ts +1 -0
  436. package/src/api/node.ts +9 -11
  437. package/src/component/axis.ts +22 -5
  438. package/src/component/index.ts +2 -0
  439. package/src/component/scrollbar.ts +41 -0
  440. package/src/component/scrollbarX.ts +16 -0
  441. package/src/component/scrollbarY.ts +16 -0
  442. package/src/component/slider.ts +3 -12
  443. package/src/component/title.ts +69 -30
  444. package/src/data/fold.ts +6 -10
  445. package/src/data/index.ts +2 -2
  446. package/src/data/pick.ts +11 -2
  447. package/src/data/slice.ts +15 -0
  448. package/src/geo/{d3-projection.ts → d3Projection.ts} +0 -0
  449. package/src/geo/geoView.ts +1 -1
  450. package/src/interaction/index.ts +21 -16
  451. package/src/interaction/native/brushAxisHighlight.ts +194 -0
  452. package/src/interaction/native/brushFilter.ts +143 -0
  453. package/src/interaction/native/brushHighlight.ts +104 -31
  454. package/src/interaction/native/brushXFilter.ts +10 -0
  455. package/src/interaction/native/brushXHighlight.ts +6 -4
  456. package/src/interaction/native/brushYFilter.ts +10 -0
  457. package/src/interaction/native/brushYHighlight.ts +6 -4
  458. package/src/interaction/native/elementHighlight.ts +1 -0
  459. package/src/interaction/native/elementSelect.ts +1 -0
  460. package/src/interaction/native/sliderFilter.ts +112 -0
  461. package/src/interaction/native/tooltip.ts +18 -4
  462. package/src/interaction/native/utils.ts +15 -6
  463. package/src/label-transform/overlapDodgeY.ts +8 -1
  464. package/src/mark/area.ts +1 -1
  465. package/src/mark/boxplot.ts +3 -1
  466. package/src/runtime/component.ts +64 -72
  467. package/src/runtime/layout.ts +6 -6
  468. package/src/runtime/plot.ts +126 -73
  469. package/src/runtime/render.ts +6 -58
  470. package/src/runtime/scale.ts +14 -0
  471. package/src/runtime/transform.ts +6 -2
  472. package/src/runtime/types/common.ts +26 -10
  473. package/src/runtime/types/options.ts +2 -5
  474. package/src/runtime/types/theme.ts +2 -5
  475. package/src/shape/area/curve.ts +15 -8
  476. package/src/shape/box/box.ts +6 -6
  477. package/src/shape/connector/connector.ts +2 -3
  478. package/src/shape/image/image.ts +2 -2
  479. package/src/shape/interval/color.ts +2 -1
  480. package/src/shape/label/position/default.ts +15 -55
  481. package/src/shape/label/position/outside.ts +121 -1
  482. package/src/shape/label/position/spider.ts +12 -19
  483. package/src/shape/label/position/surround.ts +13 -15
  484. package/src/shape/line/curve.ts +1 -1
  485. package/src/shape/lineXY/line.ts +2 -2
  486. package/src/shape/link/arc.ts +2 -2
  487. package/src/shape/link/link.ts +2 -2
  488. package/src/shape/link/smooth.ts +2 -2
  489. package/src/shape/link/vhv.ts +2 -2
  490. package/src/shape/point/color.ts +6 -5
  491. package/src/shape/polygon/polygon.ts +3 -3
  492. package/src/shape/polygon/ribbon.ts +3 -3
  493. package/src/shape/text/advance.ts +4 -1
  494. package/src/shape/text/badge.ts +8 -3
  495. package/src/shape/text/text.ts +1 -1
  496. package/src/shape/utils.ts +6 -5
  497. package/src/shape/vector/vector.ts +3 -3
  498. package/src/spec/action.ts +0 -1
  499. package/src/spec/data.ts +25 -10
  500. package/src/spec/geometry.ts +2 -0
  501. package/src/spec/interaction.ts +41 -2
  502. package/src/spec/transform.ts +3 -1
  503. package/src/stdlib/index.ts +16 -2
  504. package/src/theme/academy.ts +11 -15
  505. package/src/theme/dark.ts +11 -18
  506. package/src/theme/light.ts +25 -19
  507. package/src/transform/select.ts +1 -2
  508. package/src/transform/selectX.ts +1 -1
  509. package/src/transform/selectY.ts +1 -1
  510. package/src/utils/scale.ts +31 -0
  511. package/esm/data/subset.d.ts +0 -7
  512. package/esm/data/subset.js +0 -26
  513. package/esm/data/subset.js.map +0 -1
  514. package/esm/geo/d3-projection.js.map +0 -1
  515. package/lib/data/subset.d.ts +0 -7
  516. package/lib/data/subset.js +0 -30
  517. package/lib/data/subset.js.map +0 -1
  518. package/lib/geo/d3-projection.js.map +0 -1
  519. package/src/.DS_Store +0 -0
  520. package/src/data/.DS_Store +0 -0
  521. package/src/data/subset.ts +0 -35
  522. package/src/shape/.DS_Store +0 -0
@@ -0,0 +1,143 @@
1
+ import { deepMix } from '@antv/util';
2
+ import { subObject } from '../../utils/helper';
3
+ import { invert, domainOf } from '../../utils/scale';
4
+ import { brush as createBrush } from './brushHighlight';
5
+ import { selectPlotArea } from './utils';
6
+
7
+ // Mock dblclick events.
8
+ function dblclick(interval = 300) {
9
+ let preTimeStamp = null;
10
+ return (e) => {
11
+ const { timeStamp } = e;
12
+ if (preTimeStamp !== null && timeStamp - preTimeStamp < interval) {
13
+ preTimeStamp = timeStamp;
14
+ return true;
15
+ }
16
+ preTimeStamp = timeStamp;
17
+ return false;
18
+ };
19
+ }
20
+
21
+ export function brushFilter(
22
+ root,
23
+ {
24
+ filter,
25
+ reset,
26
+ brushRegion,
27
+ extent: optionalExtent,
28
+ reverse,
29
+ series = false,
30
+ ...rest
31
+ },
32
+ ) {
33
+ const brushStyle = subObject(rest, 'mask');
34
+ const { width: rootWidth, height: rootHeight } = root.getBBox();
35
+ const extent = optionalExtent
36
+ ? optionalExtent
37
+ : [0, 0, rootWidth, rootHeight];
38
+ const isDblclick = dblclick();
39
+
40
+ const brush = createBrush(root, {
41
+ ...brushStyle,
42
+ extent,
43
+ brushRegion,
44
+ reverse,
45
+ brushcreated,
46
+ });
47
+
48
+ root.addEventListener('click', click);
49
+
50
+ // Filter when brush created.
51
+ function brushcreated(x, y, x1, y1) {
52
+ filter(x, y, x1, y1);
53
+ brush.remove();
54
+ }
55
+
56
+ // Reset when dblclick.
57
+ function click(e) {
58
+ if (isDblclick(e)) reset();
59
+ }
60
+
61
+ return () => {
62
+ brush.destroy();
63
+ root.removeEventListener('dblclick', click);
64
+ };
65
+ }
66
+
67
+ export function BrushFilter({ hideX = true, hideY = true, ...rest }) {
68
+ return (target, viewInstances) => {
69
+ const { container, view, options: viewOptions, update } = target;
70
+ const plotArea = selectPlotArea(container);
71
+ const defaultOptions = {
72
+ maskFill: '#777',
73
+ maskFillOpacity: '0.3',
74
+ maskStroke: '#fff',
75
+ unhighlightedOpacity: 0.5,
76
+ reverse: false,
77
+ };
78
+
79
+ let filtered = false;
80
+ let filtering = false;
81
+ let newView = view;
82
+
83
+ return brushFilter(plotArea, {
84
+ brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
85
+ filter: async (x, y, x1, y1) => {
86
+ // Avoid redundant filter.
87
+ if (filtering) return;
88
+ filtering = true;
89
+
90
+ // Invert visual range to abstract domain.
91
+ const { scale, coordinate } = newView;
92
+ const { x: scaleX, y: scaleY } = scale;
93
+ const abstractDomain = (point, start) => {
94
+ const [x, y] = coordinate.invert(point);
95
+ return [invert(scaleX, x, start), invert(scaleY, y, start)];
96
+ };
97
+ const p0 = abstractDomain([x, y], true);
98
+ const p1 = abstractDomain([x1, y1], false);
99
+
100
+ // Update the domain of x and y scale to filter data.
101
+ const { marks } = viewOptions;
102
+ const newMarks = marks.map((mark) =>
103
+ deepMix(
104
+ {
105
+ // Hide label to keep smooth transition.
106
+ axis: {
107
+ ...(hideX && { x: { labelTransforms: [{ type: 'hide' }] } }),
108
+ ...(hideY && { y: { labelTransforms: [{ type: 'hide' }] } }),
109
+ },
110
+ },
111
+ mark,
112
+ {
113
+ scale: {
114
+ x: { domain: domainOf(scaleX, [p0[0], p1[0]]) },
115
+ y: { domain: domainOf(scaleY, [p0[1], p1[1]]) },
116
+ },
117
+ },
118
+ ),
119
+ );
120
+
121
+ // Rerender and update view.
122
+ const newOptions = {
123
+ ...viewOptions,
124
+ marks: newMarks,
125
+ clip: true, // Clip shapes out of plot area.
126
+ };
127
+ const newState = await update(newOptions);
128
+ newView = newState.view;
129
+ filtering = false;
130
+ filtered = true;
131
+ },
132
+ reset: () => {
133
+ if (filtering || !filtered) return;
134
+ filtered = false;
135
+ newView = view;
136
+ update(viewOptions);
137
+ },
138
+ extent: undefined,
139
+ ...defaultOptions,
140
+ ...rest,
141
+ });
142
+ };
143
+ }
@@ -7,7 +7,7 @@ import {
7
7
  useState,
8
8
  createValueof,
9
9
  setCursor,
10
- mousePositionClamp,
10
+ brushMousePosition,
11
11
  selectFacetG2Elements,
12
12
  } from './utils';
13
13
 
@@ -27,14 +27,23 @@ function normalizeBounds(x, y, x1, y1, extent) {
27
27
  ];
28
28
  }
29
29
 
30
+ function bboxOf(root: DisplayObject) {
31
+ const { width, height } = root.getBBox();
32
+ return [0, 0, width, height];
33
+ }
34
+
30
35
  export function brush(
31
36
  root: DisplayObject,
32
37
  {
33
- brushed,
34
- brushend,
35
- brushRegion,
36
- extent,
38
+ brushed = () => {},
39
+ brushended = () => {},
40
+ brushcreated = () => {},
41
+ extent = bboxOf(root),
42
+ brushRegion = (x, y, x1, y1, extent) => [x, y, x1, y1],
37
43
  reverse = false,
44
+ fill = '#777',
45
+ fillOpacity = '0.3',
46
+ stroke = '#fff',
38
47
  ...style
39
48
  }: Record<string, any>,
40
49
  ) {
@@ -63,6 +72,9 @@ export function brush(
63
72
  background = new Path({
64
73
  style: {
65
74
  ...style,
75
+ fill,
76
+ fillOpacity,
77
+ stroke,
66
78
  pointerEvents: 'none',
67
79
  },
68
80
  });
@@ -83,6 +95,9 @@ export function brush(
83
95
  // @ts-ignore
84
96
  style: {
85
97
  ...style,
98
+ fill,
99
+ fillOpacity,
100
+ stroke,
86
101
  draggable: true, // Make it response to drag event.
87
102
  },
88
103
  className: 'mask',
@@ -100,10 +115,10 @@ export function brush(
100
115
  resizing = false;
101
116
  mask = null;
102
117
  background = null;
103
- brushend();
118
+ brushended();
104
119
  };
105
120
 
106
- // Update mask and invoke brushend callback.
121
+ // Update mask and invoke brushended callback.
107
122
  const updateMask = (start, end) => {
108
123
  const [x, y, x1, y1] = normalizeBounds(
109
124
  start[0],
@@ -116,6 +131,7 @@ export function brush(
116
131
  if (reverse) updateReverseMask(fx, fy, fx1, fy1);
117
132
  else updateNormalMask(fx, fy, fx1, fy1);
118
133
  brushed(fx, fy, fx1, fy1);
134
+ return [fx, fy, fx1, fy1];
119
135
  };
120
136
 
121
137
  const updateNormalMask = (x, y, x1, y1) => {
@@ -156,7 +172,7 @@ export function brush(
156
172
  // If target is mask, about to update position.
157
173
  const dragstart = (event) => {
158
174
  const { target } = event;
159
- const [offsetX, offsetY] = mousePositionClamp(root, event);
175
+ const [offsetX, offsetY] = brushMousePosition(root, event);
160
176
  if (target === mask) {
161
177
  moveStart = [offsetX, offsetY];
162
178
  return;
@@ -168,7 +184,7 @@ export function brush(
168
184
  // If target is plot area, resize mask.
169
185
  // If target is mask, move mask.
170
186
  const drag = (event) => {
171
- const mouse = mousePositionClamp(root, event);
187
+ const mouse = brushMousePosition(root, event);
172
188
  if (!start) return;
173
189
  if (moveStart) return moveMask(mouse);
174
190
  updateMask(start, mouse);
@@ -185,9 +201,10 @@ export function brush(
185
201
  end = [x + width, y + height];
186
202
  return;
187
203
  }
188
- end = mousePositionClamp(root, event);
189
- updateMask(start, end);
204
+ end = brushMousePosition(root, event);
205
+ const [fx, fy, fx1, fy1] = updateMask(start, end);
190
206
  resizing = false;
207
+ brushcreated(fx, fy, fx1, fy1);
191
208
  };
192
209
 
193
210
  // Hide mask.
@@ -203,36 +220,69 @@ export function brush(
203
220
  else setCursor(root, 'crosshair');
204
221
  };
205
222
 
223
+ const pointerleave = () => {
224
+ setCursor(root, 'default');
225
+ };
226
+
206
227
  root.addEventListener('dragstart', dragstart);
207
228
  root.addEventListener('drag', drag);
208
229
  root.addEventListener('dragend', dragend);
209
230
  root.addEventListener('click', click);
210
231
  root.addEventListener('pointermove', pointermove);
232
+ root.addEventListener('pointerleave', pointerleave);
211
233
 
212
- return () => {
213
- if (mask) mask.remove();
214
- if (background) background.remove();
215
- root.removeEventListener('dragstart', dragstart);
216
- root.removeEventListener('drag', drag);
217
- root.removeEventListener('dragend', dragend);
218
- root.removeEventListener('click', click);
219
- root.removeEventListener('pointermove', pointermove);
234
+ return {
235
+ mask,
236
+ remove() {
237
+ if (mask) removeMask();
238
+ },
239
+ destroy() {
240
+ if (mask) removeMask();
241
+ root.removeEventListener('dragstart', dragstart);
242
+ root.removeEventListener('drag', drag);
243
+ root.removeEventListener('dragend', dragend);
244
+ root.removeEventListener('click', click);
245
+ root.removeEventListener('pointermove', pointermove);
246
+ root.removeEventListener('pointerleave', pointerleave);
247
+ },
220
248
  };
221
249
  }
222
250
 
251
+ function selectSiblingContainers(target, viewInstances, brushKey) {
252
+ return viewInstances
253
+ .filter((d) => {
254
+ if (d === target) return false;
255
+ const { interactions = [] } = d.options;
256
+ return interactions.find((d) => d.brushKey === brushKey);
257
+ })
258
+ .map((d) => selectPlotArea(d.container));
259
+ }
260
+
261
+ /**
262
+ * @todo Brush over view for series view.
263
+ * @todo Test perf.
264
+ */
223
265
  export function brushHighlight(
224
266
  root,
225
267
  {
226
268
  elements: elementof,
269
+ siblings: siblingsof = (root) => [],
227
270
  datum,
228
271
  brushRegion,
229
272
  extent: optionalExtent,
230
273
  reverse,
231
274
  series = false,
275
+ key = (d) => d,
276
+ bboxOf = (root) => {
277
+ const { x, y, width, height } = root.style;
278
+ return { x, y, width, height };
279
+ },
232
280
  ...rest
233
281
  },
234
282
  ) {
235
283
  const elements = elementof(root);
284
+ const siblings = siblingsof(root);
285
+ const siblingElements = siblings.flatMap(elementof);
236
286
  const valueof = createValueof(elements, datum);
237
287
  const brushStyle = subObject(rest, 'mask');
238
288
  const { setState, removeState } = useState(rest, valueof);
@@ -242,24 +292,25 @@ export function brushHighlight(
242
292
  height: rootHeight,
243
293
  x: ordinalX,
244
294
  y: ordinalY,
245
- } = root.getBBox();
295
+ } = bboxOf(root);
246
296
  const extent = optionalExtent
247
297
  ? optionalExtent
248
298
  : [0, 0, rootWidth, rootHeight];
249
299
 
250
- const seriesBrushend = () => {
251
- for (const element of elements) removeState(element, 'unhighlighted');
252
- for (const cloned of clonedElement.values()) cloned.remove();
253
- clonedElement.clear();
254
- };
255
-
256
- const brushend = () => {
257
- for (const element of elements) {
300
+ const brushended = () => {
301
+ for (const element of [...elements, ...siblingElements]) {
258
302
  removeState(element, 'highlighted', 'unhighlighted');
259
303
  }
260
304
  };
261
305
 
262
306
  const brushed = (x, y, x1, y1) => {
307
+ // Hide brush for the sibling view.
308
+ for (const sibling of siblings) sibling.brush?.remove();
309
+
310
+ // Store the key of the highlighted element.
311
+ const keys = new Set();
312
+
313
+ // Highlight and store selected elements.
263
314
  for (const element of elements) {
264
315
  const { min, max } = element.getLocalBounds();
265
316
  const [ex, ey] = min;
@@ -268,8 +319,21 @@ export function brushHighlight(
268
319
  setState(element, 'unhighlighted');
269
320
  } else {
270
321
  setState(element, 'highlighted');
322
+ keys.add(key(element));
271
323
  }
272
324
  }
325
+
326
+ // Highlight elements with same key in sibling view.
327
+ for (const element of siblingElements) {
328
+ if (keys.has(key(element))) setState(element, 'highlighted');
329
+ else setState(element, 'unhighlighted');
330
+ }
331
+ };
332
+
333
+ const seriesBrushend = () => {
334
+ for (const element of elements) removeState(element, 'unhighlighted');
335
+ for (const cloned of clonedElement.values()) cloned.remove();
336
+ clonedElement.clear();
273
337
  };
274
338
 
275
339
  const seriesBrushed = (x, y, x1, y1) => {
@@ -299,12 +363,12 @@ export function brushHighlight(
299
363
  extent,
300
364
  brushRegion,
301
365
  reverse,
302
- brushend: series ? seriesBrushend : brushend,
366
+ brushended: series ? seriesBrushend : brushended,
303
367
  brushed: series ? seriesBrushed : brushed,
304
368
  });
305
369
  }
306
370
 
307
- export function BrushHighlight({ facet, ...rest }) {
371
+ export function BrushHighlight({ facet, brushKey, ...rest }) {
308
372
  return (target, viewInstances) => {
309
373
  const { container, view } = target;
310
374
  const plotArea = selectPlotArea(container);
@@ -334,13 +398,22 @@ export function BrushHighlight({ facet, ...rest }) {
334
398
  ...rest,
335
399
  });
336
400
  }
337
- return brushHighlight(plotArea, {
401
+
402
+ const brush = brushHighlight(plotArea, {
338
403
  elements: selectG2Elements,
404
+ key: (element) => element.__data__.key,
405
+ siblings: () => selectSiblingContainers(target, viewInstances, brushKey),
339
406
  datum: createDatumof(view),
340
407
  brushRegion: (x, y, x1, y1) => [x, y, x1, y1],
341
408
  extent: undefined,
342
409
  ...defaultOptions,
343
410
  ...rest,
344
411
  });
412
+
413
+ // Bind brush to the view it belongs to.
414
+ //@ts-ignore
415
+ plotArea.brush = brush;
416
+
417
+ return () => brush.destroy();
345
418
  };
346
419
  }
@@ -0,0 +1,10 @@
1
+ import { BrushFilter } from './brushFilter';
2
+ import { brushXRegion } from './brushXHighlight';
3
+
4
+ export function BrushXFilter(options) {
5
+ return BrushFilter({
6
+ hideX: true,
7
+ ...options,
8
+ brushRegion: brushXRegion,
9
+ });
10
+ }
@@ -1,11 +1,13 @@
1
1
  import { BrushHighlight } from './brushHighlight';
2
2
 
3
+ export function brushXRegion(x, y, x1, y1, extent) {
4
+ const [, minY, , maxY] = extent;
5
+ return [x, minY, x1, maxY];
6
+ }
7
+
3
8
  export function BrushXHighlight(options) {
4
9
  return BrushHighlight({
5
10
  ...options,
6
- brushRegion: (x, y, x1, y1, extent) => {
7
- const [, minY, , maxY] = extent;
8
- return [x, minY, x1, maxY];
9
- },
11
+ brushRegion: brushXRegion,
10
12
  });
11
13
  }
@@ -0,0 +1,10 @@
1
+ import { BrushFilter } from './brushFilter';
2
+ import { brushYRegion } from './brushYHighlight';
3
+
4
+ export function BrushYFilter(options) {
5
+ return BrushFilter({
6
+ hideY: true,
7
+ ...options,
8
+ brushRegion: brushYRegion,
9
+ });
10
+ }
@@ -1,11 +1,13 @@
1
1
  import { BrushHighlight } from './brushHighlight';
2
2
 
3
+ export function brushYRegion(x, y, x1, y1, extent) {
4
+ const [minX, , maxX] = extent;
5
+ return [minX, y, maxX, y1];
6
+ }
7
+
3
8
  export function BrushYHighlight(options) {
4
9
  return BrushHighlight({
5
10
  ...options,
6
- brushRegion: (x, y, x1, y1, extent) => {
7
- const [minX, , maxX] = extent;
8
- return [minX, y, maxX, y1];
9
- },
11
+ brushRegion: brushYRegion,
10
12
  });
11
13
  }
@@ -60,6 +60,7 @@ export function elementHighlight(
60
60
  return () => {
61
61
  root.removeEventListener('pointerover', pointerover);
62
62
  root.removeEventListener('pointerout', pointerout);
63
+ removeLink();
63
64
  };
64
65
  }
65
66
 
@@ -98,6 +98,7 @@ export function elementSelect(
98
98
 
99
99
  return () => {
100
100
  root.removeEventListener('click', click);
101
+ removeLink();
101
102
  };
102
103
  }
103
104
 
@@ -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,8 +72,12 @@ function hideTooltip(root) {
72
72
  if (tooltipElement) tooltipElement.hide();
73
73
  }
74
74
 
75
- function unique(data) {
76
- return Array.from(new Set(data));
75
+ function destroyTooltip(root) {
76
+ const { tooltipElement } = root;
77
+ if (tooltipElement) {
78
+ tooltipElement.destroy();
79
+ root.tooltipElement = undefined;
80
+ }
77
81
  }
78
82
 
79
83
  function filterDefined(obj) {
@@ -135,13 +139,20 @@ function normalizeTooltip(d) {
135
139
  return isStrictObject(d) ? d : { value: d === undefined ? d : `${d}` };
136
140
  }
137
141
 
142
+ function uniqueTitles(titles) {
143
+ const valueTitle = new Map(
144
+ titles.map((d) => [d instanceof Date ? +d : d, d]),
145
+ );
146
+ return Array.from(valueTitle.values());
147
+ }
148
+
138
149
  function groupItems(
139
150
  elements,
140
151
  item,
141
152
  scale,
142
153
  data = elements.map((d) => d['__data__']),
143
154
  ) {
144
- const T = unique(data.map((d) => d.title)).filter(defined);
155
+ const T = uniqueTitles(data.map((d) => d.title)).filter(defined);
145
156
  const items = data.flatMap((datum, i) => {
146
157
  const element = elements[i];
147
158
  const { title, ...rest } = datum;
@@ -162,7 +173,7 @@ function groupItems(
162
173
  name,
163
174
  color,
164
175
  value,
165
- ...filterDefined(item({ channel: key, value: d })),
176
+ ...filterDefined(item({ channel: key, value })),
166
177
  };
167
178
  })
168
179
  .filter(({ value }) => value !== undefined);
@@ -381,6 +392,8 @@ export function seriesTooltip(
381
392
  root.removeEventListener('pointerover', update);
382
393
  root.removeEventListener('pointerout', update);
383
394
  root.removeEventListener('pointerleave', hide);
395
+ destroyTooltip(root);
396
+ if (crosshairs) hideRuleY(root);
384
397
  };
385
398
  }
386
399
 
@@ -434,6 +447,7 @@ export function tooltip(
434
447
  root.removeEventListener('pointerover', pointerover);
435
448
  root.removeEventListener('pointermove', pointerover);
436
449
  root.removeEventListener('pointerout', pointerout);
450
+ destroyTooltip(root);
437
451
  };
438
452
  }
439
453