@visactor/vgrammar-core 0.7.7 → 0.8.0

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 (542) hide show
  1. package/cjs/component/axis.js.map +1 -1
  2. package/cjs/component/datazoom.d.ts +7 -4
  3. package/cjs/component/datazoom.js +21 -43
  4. package/cjs/component/datazoom.js.map +1 -1
  5. package/cjs/component/grid.js.map +1 -1
  6. package/cjs/component/index.d.ts +0 -2
  7. package/cjs/component/index.js +1 -19
  8. package/cjs/component/index.js.map +1 -1
  9. package/cjs/component/label.js.map +1 -1
  10. package/cjs/component/legend.d.ts +1 -3
  11. package/cjs/component/legend.js +5 -26
  12. package/cjs/component/legend.js.map +1 -1
  13. package/cjs/component/player.d.ts +1 -2
  14. package/cjs/component/player.js +15 -31
  15. package/cjs/component/player.js.map +1 -1
  16. package/cjs/component/scale.d.ts +1 -0
  17. package/cjs/component/scale.js +3 -0
  18. package/cjs/component/scale.js.map +1 -1
  19. package/cjs/component/scrollbar.d.ts +3 -4
  20. package/cjs/component/scrollbar.js +12 -54
  21. package/cjs/component/scrollbar.js.map +1 -1
  22. package/cjs/component/slider.d.ts +2 -5
  23. package/cjs/component/slider.js +4 -26
  24. package/cjs/component/slider.js.map +1 -1
  25. package/cjs/component/title.js.map +1 -1
  26. package/cjs/core/factory.d.ts +6 -3
  27. package/cjs/core/factory.js +9 -2
  28. package/cjs/core/factory.js.map +1 -1
  29. package/cjs/env.d.ts +1 -0
  30. package/cjs/env.js +20 -0
  31. package/cjs/env.js.map +1 -0
  32. package/cjs/glyph/index.js +2 -1
  33. package/cjs/glyph/link-path.js +1 -2
  34. package/cjs/graph/animation/animate.js +25 -19
  35. package/cjs/graph/animation/animate.js.map +1 -1
  36. package/cjs/graph/animation/animation/grow-cartesian.js.map +1 -1
  37. package/cjs/graph/animation/animator.js +4 -4
  38. package/cjs/graph/animation/animator.js.map +1 -1
  39. package/cjs/graph/animation/attribute.d.ts +2 -2
  40. package/cjs/graph/animation/attribute.js +12 -12
  41. package/cjs/graph/animation/attribute.js.map +1 -1
  42. package/cjs/graph/animation/morph.js +4 -4
  43. package/cjs/graph/animation/morph.js.map +1 -1
  44. package/cjs/graph/attributes/index.js +1 -1
  45. package/cjs/graph/attributes/index.js.map +1 -1
  46. package/cjs/graph/canvas-renderer.d.ts +1 -1
  47. package/cjs/graph/canvas-renderer.js +5 -5
  48. package/cjs/graph/canvas-renderer.js.map +1 -1
  49. package/cjs/graph/element.d.ts +1 -1
  50. package/cjs/graph/element.js +4 -4
  51. package/cjs/graph/element.js.map +1 -1
  52. package/cjs/graph/enums.d.ts +25 -8
  53. package/cjs/graph/enums.js +23 -14
  54. package/cjs/graph/enums.js.map +1 -1
  55. package/cjs/graph/glyph-element.d.ts +1 -1
  56. package/cjs/graph/glyph-element.js.map +1 -1
  57. package/cjs/graph/mark/encode.d.ts +0 -3
  58. package/cjs/graph/mark/encode.js +3 -12
  59. package/cjs/graph/mark/encode.js.map +1 -1
  60. package/cjs/graph/mark/large-rects.d.ts +2 -2
  61. package/cjs/graph/mark/large-rects.js +3 -3
  62. package/cjs/graph/mark/large-rects.js.map +1 -1
  63. package/cjs/graph/mark/large-symbols.d.ts +2 -2
  64. package/cjs/graph/mark/large-symbols.js +3 -3
  65. package/cjs/graph/mark/large-symbols.js.map +1 -1
  66. package/cjs/graph/util/env.js +2 -2
  67. package/cjs/graph/util/env.js.map +1 -1
  68. package/cjs/graph/util/events-extend.d.ts +1 -1
  69. package/cjs/graph/util/events-extend.js +1 -1
  70. package/cjs/graph/util/events-extend.js.map +1 -1
  71. package/cjs/graph/util/graphic.d.ts +3 -3
  72. package/cjs/graph/util/graphic.js +21 -21
  73. package/cjs/graph/util/graphic.js.map +1 -1
  74. package/cjs/index.d.ts +5 -1
  75. package/cjs/index.js +13 -3
  76. package/cjs/index.js.map +1 -1
  77. package/cjs/interactions/base-tooltip.d.ts +29 -0
  78. package/cjs/interactions/base-tooltip.js +74 -0
  79. package/cjs/interactions/base-tooltip.js.map +1 -0
  80. package/cjs/interactions/base.d.ts +14 -0
  81. package/cjs/interactions/base.js +41 -0
  82. package/cjs/interactions/base.js.map +1 -0
  83. package/cjs/interactions/brush-active.d.ts +17 -0
  84. package/cjs/interactions/brush-active.js +27 -0
  85. package/cjs/interactions/brush-active.js.map +1 -0
  86. package/cjs/interactions/brush-base.d.ts +43 -0
  87. package/cjs/interactions/brush-base.js +106 -0
  88. package/cjs/interactions/brush-base.js.map +1 -0
  89. package/cjs/interactions/brush-filter.d.ts +24 -0
  90. package/cjs/interactions/brush-filter.js +34 -0
  91. package/cjs/interactions/brush-filter.js.map +1 -0
  92. package/cjs/interactions/brush-highlight.d.ts +17 -0
  93. package/cjs/interactions/brush-highlight.js +34 -0
  94. package/cjs/interactions/brush-highlight.js.map +1 -0
  95. package/cjs/interactions/crosshair.d.ts +53 -0
  96. package/cjs/{component → interactions}/crosshair.js +80 -79
  97. package/cjs/interactions/crosshair.js.map +1 -0
  98. package/cjs/interactions/datazoom-filter.d.ts +13 -0
  99. package/cjs/interactions/datazoom-filter.js +42 -0
  100. package/cjs/interactions/datazoom-filter.js.map +1 -0
  101. package/cjs/interactions/dimension-tooltip.d.ts +18 -0
  102. package/cjs/interactions/dimension-tooltip.js +99 -0
  103. package/cjs/interactions/dimension-tooltip.js.map +1 -0
  104. package/cjs/interactions/drill-down.d.ts +25 -0
  105. package/cjs/interactions/drill-down.js +48 -0
  106. package/cjs/interactions/drill-down.js.map +1 -0
  107. package/cjs/interactions/element-active-by-legend.d.ts +17 -0
  108. package/cjs/interactions/element-active-by-legend.js +44 -0
  109. package/cjs/interactions/element-active-by-legend.js.map +1 -0
  110. package/cjs/interactions/element-active.d.ts +16 -0
  111. package/cjs/interactions/element-active.js +33 -0
  112. package/cjs/interactions/element-active.js.map +1 -0
  113. package/cjs/interactions/element-highlight-by-group.d.ts +17 -0
  114. package/cjs/interactions/element-highlight-by-group.js +53 -0
  115. package/cjs/interactions/element-highlight-by-group.js.map +1 -0
  116. package/cjs/interactions/element-highlight-by-key.d.ts +17 -0
  117. package/cjs/interactions/element-highlight-by-key.js +53 -0
  118. package/cjs/interactions/element-highlight-by-key.js.map +1 -0
  119. package/cjs/interactions/element-highlight-by-legend.d.ts +17 -0
  120. package/cjs/interactions/element-highlight-by-legend.js +47 -0
  121. package/cjs/interactions/element-highlight-by-legend.js.map +1 -0
  122. package/cjs/interactions/element-highlight-by-name.d.ts +18 -0
  123. package/cjs/interactions/element-highlight-by-name.js +59 -0
  124. package/cjs/interactions/element-highlight-by-name.js.map +1 -0
  125. package/cjs/interactions/element-highlight.d.ts +17 -0
  126. package/cjs/interactions/element-highlight.js +48 -0
  127. package/cjs/interactions/element-highlight.js.map +1 -0
  128. package/cjs/interactions/element-select.d.ts +18 -0
  129. package/cjs/interactions/element-select.js +42 -0
  130. package/cjs/interactions/element-select.js.map +1 -0
  131. package/cjs/interactions/filter.d.ts +20 -0
  132. package/cjs/interactions/filter.js +37 -0
  133. package/cjs/interactions/filter.js.map +1 -0
  134. package/cjs/interactions/fish-eye.d.ts +38 -0
  135. package/cjs/interactions/fish-eye.js +109 -0
  136. package/cjs/interactions/fish-eye.js.map +1 -0
  137. package/cjs/interactions/index.d.ts +50 -0
  138. package/cjs/interactions/index.js +386 -0
  139. package/cjs/interactions/index.js.map +1 -0
  140. package/cjs/interactions/legend-filter.d.ts +13 -0
  141. package/cjs/interactions/legend-filter.js +33 -0
  142. package/cjs/interactions/legend-filter.js.map +1 -0
  143. package/cjs/interactions/player-filter.d.ts +14 -0
  144. package/cjs/interactions/player-filter.js +32 -0
  145. package/cjs/interactions/player-filter.js.map +1 -0
  146. package/cjs/interactions/roll-up.d.ts +16 -0
  147. package/cjs/interactions/roll-up.js +47 -0
  148. package/cjs/interactions/roll-up.js.map +1 -0
  149. package/cjs/interactions/scrollbar-filter.d.ts +13 -0
  150. package/cjs/interactions/scrollbar-filter.js +54 -0
  151. package/cjs/interactions/scrollbar-filter.js.map +1 -0
  152. package/cjs/interactions/slider-filter.d.ts +13 -0
  153. package/cjs/interactions/slider-filter.js +32 -0
  154. package/cjs/interactions/slider-filter.js.map +1 -0
  155. package/cjs/interactions/tooltip.d.ts +15 -0
  156. package/cjs/interactions/tooltip.js +62 -0
  157. package/cjs/interactions/tooltip.js.map +1 -0
  158. package/cjs/interactions/view-drag-mixin.d.ts +22 -0
  159. package/cjs/interactions/view-drag-mixin.js +52 -0
  160. package/cjs/interactions/view-drag-mixin.js.map +1 -0
  161. package/cjs/interactions/view-drag.d.ts +19 -0
  162. package/cjs/interactions/view-drag.js +49 -0
  163. package/cjs/interactions/view-drag.js.map +1 -0
  164. package/cjs/interactions/view-navigation-base.d.ts +17 -0
  165. package/cjs/interactions/view-navigation-base.js +81 -0
  166. package/cjs/interactions/view-navigation-base.js.map +1 -0
  167. package/cjs/interactions/view-roam.d.ts +30 -0
  168. package/cjs/interactions/view-roam.js +93 -0
  169. package/cjs/interactions/view-roam.js.map +1 -0
  170. package/cjs/interactions/view-scroll-mixin.d.ts +10 -0
  171. package/cjs/interactions/view-scroll-mixin.js +45 -0
  172. package/cjs/interactions/view-scroll-mixin.js.map +1 -0
  173. package/cjs/interactions/view-scroll.d.ts +17 -0
  174. package/cjs/interactions/view-scroll.js +37 -0
  175. package/cjs/interactions/view-scroll.js.map +1 -0
  176. package/cjs/interactions/view-utils.d.ts +14 -0
  177. package/cjs/interactions/view-utils.js +73 -0
  178. package/cjs/interactions/view-utils.js.map +1 -0
  179. package/cjs/interactions/view-zoom-mixin.d.ts +29 -0
  180. package/cjs/interactions/view-zoom-mixin.js +77 -0
  181. package/cjs/interactions/view-zoom-mixin.js.map +1 -0
  182. package/cjs/interactions/view-zoom.d.ts +23 -0
  183. package/cjs/interactions/view-zoom.js +53 -0
  184. package/cjs/interactions/view-zoom.js.map +1 -0
  185. package/cjs/parse/coordinate.js +1 -1
  186. package/cjs/parse/event.d.ts +2 -0
  187. package/cjs/parse/event.js +8 -4
  188. package/cjs/parse/event.js.map +1 -1
  189. package/cjs/parse/mark.js +1 -1
  190. package/cjs/parse/option.js +2 -1
  191. package/cjs/parse/scale.js +1 -1
  192. package/cjs/parse/transform.js +1 -1
  193. package/cjs/parse/util.js +1 -1
  194. package/cjs/parse/view.js +1 -1
  195. package/cjs/semantic-marks/cell.d.ts +1 -1
  196. package/cjs/semantic-marks/cell.js +4 -4
  197. package/cjs/semantic-marks/cell.js.map +1 -1
  198. package/cjs/semantic-marks/interval.d.ts +1 -1
  199. package/cjs/semantic-marks/interval.js +1 -1
  200. package/cjs/semantic-marks/text.js +1 -1
  201. package/cjs/theme/dark.js +1 -1
  202. package/cjs/theme/default.js +1 -1
  203. package/cjs/theme/theme-manager.js +1 -1
  204. package/cjs/transforms/index.js +1 -1
  205. package/cjs/transforms/mark/dodge.js +4 -4
  206. package/cjs/transforms/mark/dodge.js.map +1 -1
  207. package/cjs/transforms/mark/jitter.js +2 -2
  208. package/cjs/transforms/mark/jitter.js.map +1 -1
  209. package/cjs/types/animate.d.ts +1 -1
  210. package/cjs/types/animate.js +1 -1
  211. package/cjs/types/animate.js.map +1 -1
  212. package/cjs/types/base.js +1 -1
  213. package/cjs/types/component.d.ts +16 -88
  214. package/cjs/types/component.js +1 -1
  215. package/cjs/types/component.js.map +1 -1
  216. package/cjs/types/coordinate.js +1 -1
  217. package/cjs/types/data.js +2 -1
  218. package/cjs/types/dataflow.js +1 -1
  219. package/cjs/types/element.d.ts +1 -1
  220. package/cjs/types/element.js +1 -1
  221. package/cjs/types/element.js.map +1 -1
  222. package/cjs/types/event.d.ts +11 -4
  223. package/cjs/types/event.js +1 -1
  224. package/cjs/types/event.js.map +1 -1
  225. package/cjs/types/glyph.js +1 -1
  226. package/cjs/types/grammar.d.ts +6 -2
  227. package/cjs/types/grammar.js +1 -1
  228. package/cjs/types/grammar.js.map +1 -1
  229. package/cjs/types/hooks.js +1 -1
  230. package/cjs/types/index.d.ts +1 -0
  231. package/cjs/types/index.js +3 -2
  232. package/cjs/types/index.js.map +1 -1
  233. package/cjs/types/interaction.d.ts +353 -0
  234. package/cjs/types/interaction.js +6 -0
  235. package/cjs/types/interaction.js.map +1 -0
  236. package/cjs/types/mark.d.ts +2 -3
  237. package/cjs/types/mark.js.map +1 -1
  238. package/cjs/types/morph.d.ts +1 -1
  239. package/cjs/types/morph.js.map +1 -1
  240. package/cjs/types/plot.d.ts +1 -1
  241. package/cjs/types/plot.js.map +1 -1
  242. package/cjs/types/renderer.d.ts +1 -1
  243. package/cjs/types/renderer.js.map +1 -1
  244. package/cjs/types/theme.d.ts +1 -1
  245. package/cjs/types/theme.js.map +1 -1
  246. package/cjs/types/view.d.ts +13 -14
  247. package/cjs/types/view.js.map +1 -1
  248. package/cjs/util/scale.d.ts +4 -0
  249. package/cjs/util/scale.js +24 -0
  250. package/cjs/util/scale.js.map +1 -0
  251. package/cjs/util/text.d.ts +1 -1
  252. package/cjs/util/text.js +3 -3
  253. package/cjs/util/text.js.map +1 -1
  254. package/cjs/view/View.d.ts +9 -13
  255. package/cjs/view/View.js +49 -74
  256. package/cjs/view/View.js.map +1 -1
  257. package/cjs/view/component.d.ts +2 -6
  258. package/cjs/view/component.js +1 -19
  259. package/cjs/view/component.js.map +1 -1
  260. package/cjs/view/dataflow.js +1 -1
  261. package/cjs/view/dataflow.js.map +1 -1
  262. package/cjs/view/events.d.ts +1 -1
  263. package/cjs/view/mark.d.ts +2 -2
  264. package/cjs/view/mark.js +12 -10
  265. package/cjs/view/mark.js.map +1 -1
  266. package/cjs/view/scale.d.ts +7 -1
  267. package/cjs/view/scale.js +17 -3
  268. package/cjs/view/scale.js.map +1 -1
  269. package/es/component/axis.js.map +1 -1
  270. package/es/component/datazoom.d.ts +7 -4
  271. package/es/component/datazoom.js +26 -42
  272. package/es/component/datazoom.js.map +1 -1
  273. package/es/component/grid.js.map +1 -1
  274. package/es/component/index.d.ts +0 -2
  275. package/es/component/index.js +0 -4
  276. package/es/component/index.js.map +1 -1
  277. package/es/component/label.js.map +1 -1
  278. package/es/component/legend.d.ts +1 -3
  279. package/es/component/legend.js +11 -26
  280. package/es/component/legend.js.map +1 -1
  281. package/es/component/player.d.ts +1 -2
  282. package/es/component/player.js +17 -30
  283. package/es/component/player.js.map +1 -1
  284. package/es/component/scale.d.ts +1 -0
  285. package/es/component/scale.js +3 -0
  286. package/es/component/scale.js.map +1 -1
  287. package/es/component/scrollbar.d.ts +3 -4
  288. package/es/component/scrollbar.js +17 -53
  289. package/es/component/scrollbar.js.map +1 -1
  290. package/es/component/slider.d.ts +2 -5
  291. package/es/component/slider.js +9 -25
  292. package/es/component/slider.js.map +1 -1
  293. package/es/component/title.js.map +1 -1
  294. package/es/core/factory.d.ts +6 -3
  295. package/es/core/factory.js +9 -2
  296. package/es/core/factory.js.map +1 -1
  297. package/es/env.d.ts +1 -0
  298. package/es/env.js +1 -0
  299. package/es/env.js.map +1 -0
  300. package/es/glyph/index.js +2 -1
  301. package/es/glyph/link-path.js +1 -2
  302. package/es/graph/animation/animate.js +24 -19
  303. package/es/graph/animation/animate.js.map +1 -1
  304. package/es/graph/animation/animation/grow-cartesian.js.map +1 -1
  305. package/es/graph/animation/animator.js +1 -1
  306. package/es/graph/animation/animator.js.map +1 -1
  307. package/es/graph/animation/attribute.d.ts +2 -2
  308. package/es/graph/animation/attribute.js +7 -7
  309. package/es/graph/animation/attribute.js.map +1 -1
  310. package/es/graph/animation/morph.js +1 -1
  311. package/es/graph/animation/morph.js.map +1 -1
  312. package/es/graph/attributes/index.js +1 -1
  313. package/es/graph/attributes/index.js.map +1 -1
  314. package/es/graph/canvas-renderer.d.ts +1 -1
  315. package/es/graph/canvas-renderer.js +3 -1
  316. package/es/graph/canvas-renderer.js.map +1 -1
  317. package/es/graph/element.d.ts +1 -1
  318. package/es/graph/element.js +3 -3
  319. package/es/graph/element.js.map +1 -1
  320. package/es/graph/enums.d.ts +25 -8
  321. package/es/graph/enums.js +27 -11
  322. package/es/graph/enums.js.map +1 -1
  323. package/es/graph/glyph-element.d.ts +1 -1
  324. package/es/graph/glyph-element.js.map +1 -1
  325. package/es/graph/mark/encode.d.ts +0 -3
  326. package/es/graph/mark/encode.js +0 -10
  327. package/es/graph/mark/encode.js.map +1 -1
  328. package/es/graph/mark/large-rects.d.ts +2 -2
  329. package/es/graph/mark/large-rects.js +1 -1
  330. package/es/graph/mark/large-rects.js.map +1 -1
  331. package/es/graph/mark/large-symbols.d.ts +2 -2
  332. package/es/graph/mark/large-symbols.js +1 -1
  333. package/es/graph/mark/large-symbols.js.map +1 -1
  334. package/es/graph/util/env.js +1 -1
  335. package/es/graph/util/env.js.map +1 -1
  336. package/es/graph/util/events-extend.d.ts +1 -1
  337. package/es/graph/util/events-extend.js +1 -1
  338. package/es/graph/util/events-extend.js.map +1 -1
  339. package/es/graph/util/graphic.d.ts +3 -3
  340. package/es/graph/util/graphic.js +1 -1
  341. package/es/graph/util/graphic.js.map +1 -1
  342. package/es/index.d.ts +5 -1
  343. package/es/index.js +11 -2
  344. package/es/index.js.map +1 -1
  345. package/es/interactions/base-tooltip.d.ts +29 -0
  346. package/es/interactions/base-tooltip.js +73 -0
  347. package/es/interactions/base-tooltip.js.map +1 -0
  348. package/es/interactions/base.d.ts +14 -0
  349. package/es/interactions/base.js +32 -0
  350. package/es/interactions/base.js.map +1 -0
  351. package/es/interactions/brush-active.d.ts +17 -0
  352. package/es/interactions/brush-active.js +23 -0
  353. package/es/interactions/brush-active.js.map +1 -0
  354. package/es/interactions/brush-base.d.ts +43 -0
  355. package/es/interactions/brush-base.js +103 -0
  356. package/es/interactions/brush-base.js.map +1 -0
  357. package/es/interactions/brush-filter.d.ts +24 -0
  358. package/es/interactions/brush-filter.js +33 -0
  359. package/es/interactions/brush-filter.js.map +1 -0
  360. package/es/interactions/brush-highlight.d.ts +17 -0
  361. package/es/interactions/brush-highlight.js +31 -0
  362. package/es/interactions/brush-highlight.js.map +1 -0
  363. package/es/interactions/crosshair.d.ts +53 -0
  364. package/es/{component → interactions}/crosshair.js +82 -81
  365. package/es/interactions/crosshair.js.map +1 -0
  366. package/es/interactions/datazoom-filter.d.ts +13 -0
  367. package/es/interactions/datazoom-filter.js +40 -0
  368. package/es/interactions/datazoom-filter.js.map +1 -0
  369. package/es/interactions/dimension-tooltip.d.ts +18 -0
  370. package/es/interactions/dimension-tooltip.js +99 -0
  371. package/es/interactions/dimension-tooltip.js.map +1 -0
  372. package/es/interactions/drill-down.d.ts +25 -0
  373. package/es/interactions/drill-down.js +46 -0
  374. package/es/interactions/drill-down.js.map +1 -0
  375. package/es/interactions/element-active-by-legend.d.ts +17 -0
  376. package/es/interactions/element-active-by-legend.js +43 -0
  377. package/es/interactions/element-active-by-legend.js.map +1 -0
  378. package/es/interactions/element-active.d.ts +16 -0
  379. package/es/interactions/element-active.js +29 -0
  380. package/es/interactions/element-active.js.map +1 -0
  381. package/es/interactions/element-highlight-by-group.d.ts +17 -0
  382. package/es/interactions/element-highlight-by-group.js +49 -0
  383. package/es/interactions/element-highlight-by-group.js.map +1 -0
  384. package/es/interactions/element-highlight-by-key.d.ts +17 -0
  385. package/es/interactions/element-highlight-by-key.js +50 -0
  386. package/es/interactions/element-highlight-by-key.js.map +1 -0
  387. package/es/interactions/element-highlight-by-legend.d.ts +17 -0
  388. package/es/interactions/element-highlight-by-legend.js +46 -0
  389. package/es/interactions/element-highlight-by-legend.js.map +1 -0
  390. package/es/interactions/element-highlight-by-name.d.ts +18 -0
  391. package/es/interactions/element-highlight-by-name.js +56 -0
  392. package/es/interactions/element-highlight-by-name.js.map +1 -0
  393. package/es/interactions/element-highlight.d.ts +17 -0
  394. package/es/interactions/element-highlight.js +43 -0
  395. package/es/interactions/element-highlight.js.map +1 -0
  396. package/es/interactions/element-select.d.ts +18 -0
  397. package/es/interactions/element-select.js +38 -0
  398. package/es/interactions/element-select.js.map +1 -0
  399. package/es/interactions/filter.d.ts +20 -0
  400. package/es/interactions/filter.js +31 -0
  401. package/es/interactions/filter.js.map +1 -0
  402. package/es/interactions/fish-eye.d.ts +38 -0
  403. package/es/interactions/fish-eye.js +105 -0
  404. package/es/interactions/fish-eye.js.map +1 -0
  405. package/es/interactions/index.d.ts +50 -0
  406. package/es/interactions/index.js +149 -0
  407. package/es/interactions/index.js.map +1 -0
  408. package/es/interactions/legend-filter.d.ts +13 -0
  409. package/es/interactions/legend-filter.js +32 -0
  410. package/es/interactions/legend-filter.js.map +1 -0
  411. package/es/interactions/player-filter.d.ts +14 -0
  412. package/es/interactions/player-filter.js +32 -0
  413. package/es/interactions/player-filter.js.map +1 -0
  414. package/es/interactions/roll-up.d.ts +16 -0
  415. package/es/interactions/roll-up.js +45 -0
  416. package/es/interactions/roll-up.js.map +1 -0
  417. package/es/interactions/scrollbar-filter.d.ts +13 -0
  418. package/es/interactions/scrollbar-filter.js +50 -0
  419. package/es/interactions/scrollbar-filter.js.map +1 -0
  420. package/es/interactions/slider-filter.d.ts +13 -0
  421. package/es/interactions/slider-filter.js +29 -0
  422. package/es/interactions/slider-filter.js.map +1 -0
  423. package/es/interactions/tooltip.d.ts +15 -0
  424. package/es/interactions/tooltip.js +58 -0
  425. package/es/interactions/tooltip.js.map +1 -0
  426. package/es/interactions/view-drag-mixin.d.ts +22 -0
  427. package/es/interactions/view-drag-mixin.js +46 -0
  428. package/es/interactions/view-drag-mixin.js.map +1 -0
  429. package/es/interactions/view-drag.d.ts +19 -0
  430. package/es/interactions/view-drag.js +47 -0
  431. package/es/interactions/view-drag.js.map +1 -0
  432. package/es/interactions/view-navigation-base.d.ts +17 -0
  433. package/es/interactions/view-navigation-base.js +78 -0
  434. package/es/interactions/view-navigation-base.js.map +1 -0
  435. package/es/interactions/view-roam.d.ts +30 -0
  436. package/es/interactions/view-roam.js +91 -0
  437. package/es/interactions/view-roam.js.map +1 -0
  438. package/es/interactions/view-scroll-mixin.d.ts +10 -0
  439. package/es/interactions/view-scroll-mixin.js +37 -0
  440. package/es/interactions/view-scroll-mixin.js.map +1 -0
  441. package/es/interactions/view-scroll.d.ts +17 -0
  442. package/es/interactions/view-scroll.js +35 -0
  443. package/es/interactions/view-scroll.js.map +1 -0
  444. package/es/interactions/view-utils.d.ts +14 -0
  445. package/es/interactions/view-utils.js +60 -0
  446. package/es/interactions/view-utils.js.map +1 -0
  447. package/es/interactions/view-zoom-mixin.d.ts +29 -0
  448. package/es/interactions/view-zoom-mixin.js +68 -0
  449. package/es/interactions/view-zoom-mixin.js.map +1 -0
  450. package/es/interactions/view-zoom.d.ts +23 -0
  451. package/es/interactions/view-zoom.js +51 -0
  452. package/es/interactions/view-zoom.js.map +1 -0
  453. package/es/parse/event.d.ts +2 -0
  454. package/es/parse/event.js +5 -1
  455. package/es/parse/event.js.map +1 -1
  456. package/es/parse/option.js +2 -1
  457. package/es/parse/scale.js +1 -2
  458. package/es/semantic-marks/cell.d.ts +1 -1
  459. package/es/semantic-marks/cell.js +4 -2
  460. package/es/semantic-marks/cell.js.map +1 -1
  461. package/es/semantic-marks/interval.d.ts +1 -1
  462. package/es/semantic-marks/interval.js +1 -1
  463. package/es/semantic-marks/text.js +1 -1
  464. package/es/theme/dark.js +1 -1
  465. package/es/theme/default.js +1 -1
  466. package/es/theme/theme-manager.js +1 -1
  467. package/es/transforms/index.js +1 -1
  468. package/es/transforms/mark/dodge.js +2 -2
  469. package/es/transforms/mark/dodge.js.map +1 -1
  470. package/es/transforms/mark/jitter.js +2 -2
  471. package/es/transforms/mark/jitter.js.map +1 -1
  472. package/es/types/animate.d.ts +1 -1
  473. package/es/types/animate.js +1 -1
  474. package/es/types/animate.js.map +1 -1
  475. package/es/types/base.js +1 -1
  476. package/es/types/component.d.ts +16 -88
  477. package/es/types/component.js +1 -1
  478. package/es/types/component.js.map +1 -1
  479. package/es/types/coordinate.js +1 -1
  480. package/es/types/data.js +2 -1
  481. package/es/types/dataflow.js +1 -1
  482. package/es/types/element.d.ts +1 -1
  483. package/es/types/element.js +1 -1
  484. package/es/types/element.js.map +1 -1
  485. package/es/types/event.d.ts +11 -4
  486. package/es/types/event.js +1 -1
  487. package/es/types/event.js.map +1 -1
  488. package/es/types/glyph.js +1 -1
  489. package/es/types/grammar.d.ts +6 -2
  490. package/es/types/grammar.js +1 -1
  491. package/es/types/grammar.js.map +1 -1
  492. package/es/types/hooks.js +1 -1
  493. package/es/types/index.d.ts +1 -0
  494. package/es/types/index.js +3 -1
  495. package/es/types/index.js.map +1 -1
  496. package/es/types/interaction.d.ts +353 -0
  497. package/es/types/interaction.js +2 -0
  498. package/es/types/interaction.js.map +1 -0
  499. package/es/types/mark.d.ts +2 -3
  500. package/es/types/mark.js.map +1 -1
  501. package/es/types/morph.d.ts +1 -1
  502. package/es/types/morph.js.map +1 -1
  503. package/es/types/plot.d.ts +1 -1
  504. package/es/types/plot.js.map +1 -1
  505. package/es/types/renderer.d.ts +1 -1
  506. package/es/types/renderer.js.map +1 -1
  507. package/es/types/theme.d.ts +1 -1
  508. package/es/types/theme.js.map +1 -1
  509. package/es/types/view.d.ts +13 -14
  510. package/es/types/view.js.map +1 -1
  511. package/es/util/scale.d.ts +4 -0
  512. package/es/util/scale.js +15 -0
  513. package/es/util/scale.js.map +1 -0
  514. package/es/util/text.d.ts +1 -1
  515. package/es/util/text.js +1 -1
  516. package/es/util/text.js.map +1 -1
  517. package/es/view/View.d.ts +9 -13
  518. package/es/view/View.js +49 -69
  519. package/es/view/View.js.map +1 -1
  520. package/es/view/component.d.ts +2 -6
  521. package/es/view/component.js +0 -20
  522. package/es/view/component.js.map +1 -1
  523. package/es/view/dataflow.js +1 -1
  524. package/es/view/dataflow.js.map +1 -1
  525. package/es/view/events.d.ts +1 -1
  526. package/es/view/mark.d.ts +2 -2
  527. package/es/view/mark.js +12 -10
  528. package/es/view/mark.js.map +1 -1
  529. package/es/view/scale.d.ts +7 -1
  530. package/es/view/scale.js +17 -2
  531. package/es/view/scale.js.map +1 -1
  532. package/package.json +9 -8
  533. package/cjs/component/crosshair.d.ts +0 -50
  534. package/cjs/component/crosshair.js.map +0 -1
  535. package/cjs/component/tooltip.d.ts +0 -62
  536. package/cjs/component/tooltip.js +0 -305
  537. package/cjs/component/tooltip.js.map +0 -1
  538. package/es/component/crosshair.d.ts +0 -50
  539. package/es/component/crosshair.js.map +0 -1
  540. package/es/component/tooltip.d.ts +0 -62
  541. package/es/component/tooltip.js +0 -303
  542. package/es/component/tooltip.js.map +0 -1
@@ -0,0 +1,99 @@
1
+ import { AABBBounds, array, getAngleByPoint, isString, throttle } from "@visactor/vutils";
2
+
3
+ import { BaseTooltip } from "./base-tooltip";
4
+
5
+ import { generateTooltipAttributes } from "./base-tooltip";
6
+
7
+ import { BridgeElementKey } from "../graph/constants";
8
+
9
+ import { invokeFunctionType } from "../parse/util";
10
+
11
+ const isEqualTooltipDatum = (current, previous) => {
12
+ const currentDatum = array(current), previousDatum = array(previous);
13
+ return currentDatum.length === previousDatum.length && (currentDatum.every((datum => previousDatum.includes(datum))) && previousDatum.every((datum => currentDatum.includes(datum))));
14
+ }, computeTooltipFilterValue = (point, scale, type, groupSize, tooltipCenter) => {
15
+ if ("x" === type) return scale.invert(point.x);
16
+ if ("y" === type) return scale.invert(point.y);
17
+ if ("radius" === type) {
18
+ const center = null != tooltipCenter ? tooltipCenter : {
19
+ x: groupSize.width / 2,
20
+ y: groupSize.height / 2
21
+ }, radius = Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2);
22
+ return scale.invert(radius);
23
+ }
24
+ if ("angle" === type) {
25
+ const center = null != tooltipCenter ? tooltipCenter : {
26
+ x: groupSize.width / 2,
27
+ y: groupSize.height / 2
28
+ }, angle = getAngleByPoint(center, point);
29
+ return scale.invert(angle < 0 ? angle + 2 * Math.PI : angle);
30
+ }
31
+ return scale.invert(point.x);
32
+ };
33
+
34
+ export class DimensionTooltip extends BaseTooltip {
35
+ constructor(view, options) {
36
+ var _a, _b, _c;
37
+ super(view, options), this.type = DimensionTooltip.type, this._avoidMarks = [],
38
+ this._tooltipDataFilter = null, this.handleTooltipShow = throttle((event => {
39
+ var _a, _b, _c;
40
+ const scale = (isString(this.options.scale) ? this.view.getScaleById(this.options.scale) : this.options.scale).getScale(), groupGraphicItem = this._container.getGroupGraphicItem(), point = {
41
+ x: 0,
42
+ y: 0
43
+ };
44
+ groupGraphicItem.globalTransMatrix.transformPoint(event.canvas, point);
45
+ const groupSize = {
46
+ width: groupGraphicItem.attribute.width,
47
+ height: groupGraphicItem.attribute.height
48
+ };
49
+ if (point.x < 0 || point.x > groupGraphicItem.attribute.width || point.y < 0 || point.y > groupGraphicItem.attribute.height) return void this._tooltipComponent.hideAll();
50
+ const eventTargetMark = null === (_b = null === (_a = event.target) || void 0 === _a ? void 0 : _a[BridgeElementKey]) || void 0 === _b ? void 0 : _b.mark;
51
+ if (this._avoidMarks.includes(eventTargetMark)) return void this._tooltipComponent.hideAll();
52
+ const target = null === (_c = this.options.target) || void 0 === _c ? void 0 : _c.data, lastDataGrammar = target ? isString(target) ? this.view.getDataById(target) : target : null, data = lastDataGrammar ? lastDataGrammar.getValue() : [], filterValue = computeTooltipFilterValue(point, scale, this.options.tooltipType, groupSize, this.options.center), tooltipDatum = this._tooltipDataFilter ? data.filter((datum => this._tooltipDataFilter(datum, filterValue))) : [];
53
+ if (this._tooltipComponent.showAll(), isEqualTooltipDatum(tooltipDatum, this._lastDatum)) return void this._tooltipComponent.setAttributes({
54
+ pointerX: point.x,
55
+ pointerY: point.y
56
+ });
57
+ this._lastDatum = tooltipDatum;
58
+ const boundsStart = {
59
+ x: 0,
60
+ y: 0
61
+ };
62
+ groupGraphicItem.globalTransMatrix.transformPoint({
63
+ x: 0,
64
+ y: 0
65
+ }, boundsStart);
66
+ const boundsEnd = {
67
+ x: 0,
68
+ y: 0
69
+ };
70
+ groupGraphicItem.globalTransMatrix.transformPoint({
71
+ x: this.view.getSignalById("width").getValue(),
72
+ y: this.view.getSignalById("height").getValue()
73
+ }, boundsEnd);
74
+ const bounds = (new AABBBounds).set(boundsStart.x, boundsStart.y, boundsEnd.x, boundsEnd.y), {title: title, content: content} = this._computeTitleContent(tooltipDatum), theme = this.view.getCurrentTheme(), addition = invokeFunctionType(this.options.attributes, this.parameters(), {}), attributes = generateTooltipAttributes(point, title, content, bounds, theme, addition);
75
+ this._tooltipComponent.setAttributes(attributes);
76
+ }), 10), this.handleTooltipHide = event => {
77
+ this._tooltipComponent.hideAll();
78
+ }, this.options = Object.assign({}, DimensionTooltip.defaultOptions, options), this._marks = view.getMarksBySelector(this.options.selector),
79
+ this._avoidMarks = null !== (_a = view.getMarksBySelector(this.options.avoidMark)) && void 0 !== _a ? _a : [],
80
+ this._container = null !== (_c = null === (_b = view.getMarksBySelector(this.options.container)) || void 0 === _b ? void 0 : _b[0]) && void 0 !== _c ? _c : view.rootMark;
81
+ }
82
+ getEvents() {
83
+ const filter = this.options.target.filter;
84
+ return this._tooltipDataFilter = isString(filter) ? (datum, filterValue) => filterValue === datum[filter] : filter,
85
+ [ {
86
+ type: this.options.trigger,
87
+ handler: this.handleTooltipShow
88
+ }, {
89
+ type: this.options.resetTrigger,
90
+ handler: this.handleTooltipHide
91
+ } ];
92
+ }
93
+ }
94
+
95
+ DimensionTooltip.type = "dimension-tooltip", DimensionTooltip.defaultOptions = {
96
+ trigger: "pointermove",
97
+ resetTrigger: "pointerleave"
98
+ };
99
+ //# sourceMappingURL=dimension-tooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/dimension-tooltip.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEnD,MAAM,mBAAmB,GAAG,CAAC,OAAc,EAAE,QAAe,EAAE,EAAE;IAC9D,MAAM,YAAY,GAA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CAAC,kBAAkB,GAAG,QAAQ,CAAC,MAAM,CAAC;YACxC,CAAC,CAAC,CAAC,KAAU,EAAE,WAAkB,EAAE,EAAE,CAAC,WAAW,KAAK,KAAK,CAAC,MAAM,CAAC;YACnE,CAAC,CAAC,MAAM,CAAC;QAEX,OAAO;YACL,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE;YAC/D,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,iBAAiB,EAAE;SACrE,CAAC;IACJ,CAAC;;AA/BM,qBAAI,GAAW,mBAAmB,CAAC;AAGnC,+BAAc,GAA4C;IAC/D,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,cAAc;CAC7B,CAAC","file":"dimension-tooltip.js","sourcesContent":["import type { IPointLike } from '@visactor/vutils';\n// eslint-disable-next-line no-duplicate-imports\nimport { AABBBounds, array, getAngleByPoint, isString, throttle } from '@visactor/vutils';\nimport type { DimensionTooltipOptions, IGroupMark, IMark, IView, TooltipType } from '../types';\nimport { BaseTooltip } from './base-tooltip';\n// eslint-disable-next-line no-duplicate-imports\nimport { generateTooltipAttributes } from './base-tooltip';\nimport { BridgeElementKey } from '../graph/constants';\nimport type { IBaseScale } from '@visactor/vscale';\nimport { invokeFunctionType } from '../parse/util';\n\nconst isEqualTooltipDatum = (current: any[], previous: any[]) => {\n const currentDatum = array(current);\n const previousDatum = array(previous);\n if (currentDatum.length !== previousDatum.length) {\n return false;\n }\n return (\n currentDatum.every(datum => previousDatum.includes(datum)) &&\n previousDatum.every(datum => currentDatum.includes(datum))\n );\n};\n\nconst computeTooltipFilterValue = (\n point: IPointLike,\n scale: IBaseScale,\n type: TooltipType,\n groupSize: { width: number; height: number },\n tooltipCenter?: IPointLike\n) => {\n if (type === 'x') {\n return scale.invert(point.x);\n }\n if (type === 'y') {\n return scale.invert(point.y);\n }\n if (type === 'radius') {\n const center = tooltipCenter ?? { x: groupSize.width / 2, y: groupSize.height / 2 };\n const radius = Math.sqrt((center.x - point.x) ** 2 + (center.y - point.y) ** 2);\n return scale.invert(radius);\n }\n if (type === 'angle') {\n const center = tooltipCenter ?? { x: groupSize.width / 2, y: groupSize.height / 2 };\n const angle = getAngleByPoint(center, point);\n return scale.invert(angle < 0 ? angle + Math.PI * 2 : angle);\n }\n return scale.invert(point.x);\n};\n\nexport class DimensionTooltip extends BaseTooltip<DimensionTooltipOptions> {\n static type: string = 'dimension-tooltip';\n type: string = DimensionTooltip.type;\n\n static defaultOptions: Omit<DimensionTooltipOptions, 'target'> = {\n trigger: 'pointermove',\n resetTrigger: 'pointerleave'\n };\n protected _avoidMarks: IMark[] = [];\n protected _lastDatum: any;\n protected _tooltipDataFilter: ((datum: any, filterValue: any[]) => boolean) | null = null;\n protected _container: IGroupMark;\n\n constructor(view: IView, options?: DimensionTooltipOptions) {\n super(view, options);\n this.options = Object.assign({}, DimensionTooltip.defaultOptions, options);\n this._marks = view.getMarksBySelector(this.options.selector);\n this._avoidMarks = view.getMarksBySelector(this.options.avoidMark) ?? [];\n this._container = (view.getMarksBySelector(this.options.container)?.[0] as IGroupMark) ?? view.rootMark;\n }\n\n protected getEvents() {\n const filter = this.options.target.filter;\n\n this._tooltipDataFilter = isString(filter)\n ? (datum: any, filterValue: any[]) => filterValue === datum[filter]\n : filter;\n\n return [\n { type: this.options.trigger, handler: this.handleTooltipShow },\n { type: this.options.resetTrigger, handler: this.handleTooltipHide }\n ];\n }\n\n protected handleTooltipShow = throttle((event: any) => {\n const scaleGrammar = isString(this.options.scale) ? this.view.getScaleById(this.options.scale) : this.options.scale;\n const scale = scaleGrammar.getScale();\n const groupGraphicItem = this._container.getGroupGraphicItem();\n // FIXME: waiting for vRender to add transformed position to event\n const point = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint(event.canvas, point);\n const groupSize = { width: groupGraphicItem.attribute.width, height: groupGraphicItem.attribute.height };\n\n // if pointer is not within the area of group, hide tooltip\n if (\n point.x < 0 ||\n point.x > groupGraphicItem.attribute.width ||\n point.y < 0 ||\n point.y > groupGraphicItem.attribute.height\n ) {\n this._tooltipComponent.hideAll();\n return;\n }\n // if pointer is hovered on the avoided marks, hide tooltip\n const eventTargetMark = event.target?.[BridgeElementKey]?.mark;\n if (this._avoidMarks.includes(eventTargetMark)) {\n this._tooltipComponent.hideAll();\n return;\n }\n\n const target = this.options.target?.data;\n const lastDataGrammar = !target ? null : isString(target) ? this.view.getDataById(target) : target;\n const data = lastDataGrammar ? lastDataGrammar.getValue() : [];\n\n const filterValue = computeTooltipFilterValue(\n point,\n scale,\n this.options.tooltipType,\n groupSize,\n this.options.center\n );\n const tooltipDatum = this._tooltipDataFilter\n ? data.filter(datum => this._tooltipDataFilter(datum, filterValue))\n : [];\n\n this._tooltipComponent.showAll();\n if (isEqualTooltipDatum(tooltipDatum, this._lastDatum)) {\n // only update pointer when element is not changed\n this._tooltipComponent.setAttributes({ pointerX: point.x, pointerY: point.y } as any);\n return;\n }\n this._lastDatum = tooltipDatum;\n\n // compute tooltip bounds\n const boundsStart = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint({ x: 0, y: 0 }, boundsStart);\n const boundsEnd = { x: 0, y: 0 };\n groupGraphicItem.globalTransMatrix.transformPoint(\n {\n x: this.view.getSignalById('width').getValue() as number,\n y: this.view.getSignalById('height').getValue() as number\n },\n boundsEnd\n );\n const bounds = new AABBBounds().set(boundsStart.x, boundsStart.y, boundsEnd.x, boundsEnd.y);\n const { title, content } = this._computeTitleContent(tooltipDatum);\n const theme = this.view.getCurrentTheme();\n const addition = invokeFunctionType(this.options.attributes, this.parameters(), {}) as any;\n const attributes = generateTooltipAttributes(point, title, content, bounds, theme, addition);\n this._tooltipComponent.setAttributes(attributes);\n }, 10);\n\n protected handleTooltipHide = (event: any) => {\n this._tooltipComponent.hideAll();\n };\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { IPolygon } from '@visactor/vrender-core';
2
+ import type { DrillDownOptions, IView, InteractionEvent } from '../types';
3
+ import { BrushBase } from './brush-base';
4
+ import { type IBounds } from '@visactor/vutils';
5
+ import type { FilterMixin } from './filter';
6
+ export interface DrillDown extends Pick<FilterMixin, '_data' | '_filterValue' | '_dataFilter' | 'handleFilter' | '_filterData'>, BrushBase<DrillDownOptions> {
7
+ }
8
+ export declare class DrillDown extends BrushBase<DrillDownOptions> {
9
+ static type: string;
10
+ type: string;
11
+ static defaultOptions: Omit<DrillDownOptions, 'target'>;
12
+ constructor(view: IView, option?: DrillDownOptions);
13
+ protected getEvents(): {
14
+ type: string;
15
+ handler: import("../types").InteractionEventHandler;
16
+ }[];
17
+ handleBrushUpdate: (options: {
18
+ operateType: string;
19
+ operateMask: IPolygon;
20
+ operatedMaskAABBBounds: {
21
+ [name: string]: IBounds;
22
+ };
23
+ }) => void;
24
+ handleTrigger: (event: InteractionEvent) => void;
25
+ }
@@ -0,0 +1,46 @@
1
+ import { BrushBase } from "./brush-base";
2
+
3
+ import { isString, array } from "@visactor/vutils";
4
+
5
+ import { DataFilterRank } from "../graph";
6
+
7
+ export class DrillDown extends BrushBase {
8
+ constructor(view, option) {
9
+ super(view, Object.assign({}, DrillDown.defaultOptions, option)), this.type = DrillDown.type,
10
+ this.handleBrushUpdate = options => {
11
+ const elements = [];
12
+ let filterValue = [];
13
+ this._marks.forEach((mark => {
14
+ mark.elements.forEach((el => {
15
+ this.isBrushContainGraphicItem(options.operateMask, el.getGraphicItem()) && (elements.push(el),
16
+ filterValue = filterValue.concat(array(el.getDatum())));
17
+ }));
18
+ })), this._data && (filterValue = Array.from(new Set(filterValue)), this._filterValue && filterValue.length === this._filterValue.length && !filterValue.some((datum => !this._filterValue.includes(datum))) || (this._filterValue = filterValue,
19
+ this.handleFilter())), this.dispatchEvent(options, elements);
20
+ }, this.handleTrigger = event => {
21
+ const element = event.element;
22
+ if (element && this._marks && this._marks.includes(element.mark)) {
23
+ const filterValue = array(element.getDatum());
24
+ this._filterValue && filterValue.length === this._filterValue.length && !filterValue.some((datum => !this._filterValue.includes(datum))) || (this._filterValue = filterValue,
25
+ this.handleFilter());
26
+ }
27
+ }, this._data = isString(this.options.target.data) ? view.getDataById(this.options.target.data) : this.options.target.data;
28
+ }
29
+ getEvents() {
30
+ if (!this._data) return [];
31
+ const transform = this.options.target.transform;
32
+ return this._filterData(this._data, null, DataFilterRank.drillDown, null, void 0, ((data, filterValue) => {
33
+ const nextData = filterValue || data;
34
+ return transform ? transform(data, filterValue) : nextData;
35
+ })), this.options.brush ? super.getEvents() : [ {
36
+ type: this.options.trigger,
37
+ handler: this.handleTrigger
38
+ } ];
39
+ }
40
+ }
41
+
42
+ DrillDown.type = "drill-down", DrillDown.defaultOptions = {
43
+ brush: !1,
44
+ trigger: "click"
45
+ };
46
+ //# sourceMappingURL=drill-down.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/drill-down.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAgB,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C,MAAM,OAAO,SAAU,SAAQ,SAA2B;IASxD,YAAY,IAAW,EAAE,MAAyB;QAChD,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC;QARnE,SAAI,GAAW,SAAS,CAAC,IAAI,CAAC;QAsC9B,sBAAiB,GAAG,CAAC,OAIpB,EAAE,EAAE;YACH,MAAM,QAAQ,GAAiC,EAAE,CAAC;YAElD,IAAI,WAAW,GAAU,EAAE,CAAC;YAE5B,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,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AAO,CAAC,OAAO;gBAC1B,OAAO,EAAE,IAAI,CAAC,aAAa;aAC5B;SACF,CAAC;IACJ,CAAC;;AArCM,cAAI,GAAW,YAAY,CAAC;AAG5B,wBAAc,GAAqC;IACxD,KAAK,EAAE,KAAK;IACZ,OAAO,EAAE,OAAO;CACjB,CAAC","file":"drill-down.js","sourcesContent":["import type { IPolygon } from '@visactor/vrender-core';\nimport type { DrillDownOptions, IElement, IGlyphElement, IView, InteractionEvent } from '../types';\nimport { BrushBase } from './brush-base';\nimport { isString, type IBounds, array } from '@visactor/vutils';\nimport { DataFilterRank } from '../graph';\nimport type { FilterMixin } from './filter';\n\nexport interface DrillDown\n extends Pick<FilterMixin, '_data' | '_filterValue' | '_dataFilter' | 'handleFilter' | '_filterData'>,\n BrushBase<DrillDownOptions> {}\n\nexport class DrillDown extends BrushBase<DrillDownOptions> {\n static type: string = 'drill-down';\n type: string = DrillDown.type;\n\n static defaultOptions: Omit<DrillDownOptions, 'target'> = {\n brush: false,\n trigger: 'click'\n };\n\n constructor(view: IView, option?: DrillDownOptions) {\n super(view, Object.assign({}, DrillDown.defaultOptions, option));\n this._data = isString(this.options.target.data)\n ? view.getDataById(this.options.target.data)\n : this.options.target.data;\n }\n\n protected getEvents() {\n if (!this._data) {\n return [];\n }\n\n const transform = this.options.target.transform;\n const dataTransform = (data: any[], filterValue: any) => {\n const nextData = !filterValue ? data : filterValue;\n return transform ? transform(data, filterValue) : nextData;\n };\n\n this._filterData(this._data, null, DataFilterRank.drillDown, null, undefined, dataTransform);\n\n if (this.options.brush) {\n return super.getEvents();\n }\n return [\n {\n type: this.options.trigger,\n handler: this.handleTrigger\n }\n ];\n }\n\n handleBrushUpdate = (options: {\n operateType: string;\n operateMask: IPolygon;\n operatedMaskAABBBounds: { [name: string]: IBounds };\n }) => {\n const elements: (IElement | IGlyphElement)[] = [];\n\n let filterValue: any[] = [];\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isActive = this.isBrushContainGraphicItem(options.operateMask, el.getGraphicItem());\n\n if (isActive) {\n elements.push(el);\n filterValue = filterValue.concat(array(el.getDatum()));\n }\n });\n });\n\n if (this._data) {\n // remove repeated datum\n filterValue = Array.from(new Set(filterValue));\n\n // shallow compare\n if (\n !this._filterValue ||\n filterValue.length !== this._filterValue.length ||\n filterValue.some(datum => !this._filterValue.includes(datum))\n ) {\n this._filterValue = filterValue;\n this.handleFilter();\n }\n }\n\n this.dispatchEvent(options, elements);\n };\n\n handleTrigger = (event: InteractionEvent) => {\n const element = event.element;\n if (element && this._marks && this._marks.includes(element.mark)) {\n const filterValue = array(element.getDatum());\n // shallow compare\n if (\n !this._filterValue ||\n filterValue.length !== this._filterValue.length ||\n filterValue.some(datum => !this._filterValue.includes(datum))\n ) {\n this._filterValue = filterValue;\n this.handleFilter();\n }\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { ElementActiveByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ import { LegendEvent } from '@visactor/vrender-components';
4
+ export declare class ElementActiveByLegend extends BaseInteraction<ElementActiveByLegendOptions> {
5
+ static type: string;
6
+ type: string;
7
+ static defaultOptions: ElementActiveByLegendOptions;
8
+ options: ElementActiveByLegendOptions;
9
+ protected _marks?: IMark[];
10
+ constructor(view: IView, options?: ElementActiveByLegendOptions);
11
+ protected getEvents(): {
12
+ type: LegendEvent;
13
+ handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
14
+ }[];
15
+ handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
16
+ handleReset: (e: InteractionEvent) => void;
17
+ }
@@ -0,0 +1,43 @@
1
+ import { InteractionStateEnum } from "../graph/enums";
2
+
3
+ import { BaseInteraction } from "./base";
4
+
5
+ import { LegendEvent } from "@visactor/vrender-components";
6
+
7
+ import { isNil } from "@visactor/vutils";
8
+
9
+ export class ElementActiveByLegend extends BaseInteraction {
10
+ constructor(view, options) {
11
+ super(view, options), this.type = ElementActiveByLegend.type, this.handleStart = (e, element) => {
12
+ var _a, _b;
13
+ const itemKey = null === (_b = null === (_a = e.detail) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b.id;
14
+ isNil(itemKey) || this._marks.forEach((mark => {
15
+ mark.elements.forEach((el => {
16
+ el[this.options.filterType] === itemKey ? el.addState(this.options.state) : el.removeState(this.options.state);
17
+ }));
18
+ }));
19
+ }, this.handleReset = e => {
20
+ this._marks.forEach((mark => {
21
+ mark.elements.forEach((el => {
22
+ el.hasState(this.options.state) && el.removeState(this.options.state);
23
+ }));
24
+ }));
25
+ }, this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options),
26
+ this._marks = view.getMarksBySelector(this.options.selector);
27
+ }
28
+ getEvents() {
29
+ return [ {
30
+ type: LegendEvent.legendItemHover,
31
+ handler: this.handleStart
32
+ }, {
33
+ type: LegendEvent.legendItemUnHover,
34
+ handler: this.handleReset
35
+ } ];
36
+ }
37
+ }
38
+
39
+ ElementActiveByLegend.type = "element-active-by-legend", ElementActiveByLegend.defaultOptions = {
40
+ state: InteractionStateEnum.active,
41
+ filterType: "groupKey"
42
+ };
43
+ //# sourceMappingURL=element-active-by-legend.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/element-active-by-legend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,OAAO,qBAAsB,SAAQ,eAA6C;IAWtF,YAAY,IAAW,EAAE,OAAsC;QAC7D,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAVvB,SAAI,GAAW,qBAAqB,CAAC,IAAI,CAAC;QA6B1C,gBAAW,GAAG,CA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,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAES,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,WAAW,CAAC,eAAe;gBACjC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD;gBACE,IAAI,EAAE,WAAW,CAAC,iBAAiB;gBACnC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;SACF,CAAC;IACJ,CAAC;;AA5BM,0BAAI,GAAW,0BAA0B,CAAC;AAG1C,oCAAc,GAAiC;IACpD,KAAK,EAAE,oBAAoB,CAAC,MAAM;IAClC,UAAU,EAAE,UAAU;CACvB,CAAC","file":"element-active-by-legend.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type { ElementActiveByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { LegendEvent } from '@visactor/vrender-components';\nimport { isNil } from '@visactor/vutils';\n\nexport class ElementActiveByLegend extends BaseInteraction<ElementActiveByLegendOptions> {\n static type: string = 'element-active-by-legend';\n type: string = ElementActiveByLegend.type;\n\n static defaultOptions: ElementActiveByLegendOptions = {\n state: InteractionStateEnum.active,\n filterType: 'groupKey'\n };\n options: ElementActiveByLegendOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementActiveByLegendOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActiveByLegend.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: LegendEvent.legendItemHover,\n handler: this.handleStart\n },\n {\n type: LegendEvent.legendItemUnHover,\n handler: this.handleReset\n }\n ];\n }\n\n handleStart = (e: InteractionEvent, element: IElement | IGlyphElement) => {\n const itemKey = e.detail?.data?.id;\n\n if (isNil(itemKey)) {\n return;\n }\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isActive = el[this.options.filterType] === itemKey;\n\n if (isActive) {\n el.addState(this.options.state);\n } else {\n el.removeState(this.options.state);\n }\n });\n });\n };\n\n handleReset = (e: InteractionEvent) => {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.state)) {\n el.removeState(this.options.state);\n }\n });\n });\n };\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import type { ElementActiveOptions, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ export declare class ElementActive extends BaseInteraction<ElementActiveOptions> {
4
+ static type: string;
5
+ type: string;
6
+ static defaultOptions: ElementActiveOptions;
7
+ options: ElementActiveOptions;
8
+ protected _marks?: IMark[];
9
+ constructor(view: IView, options?: ElementActiveOptions);
10
+ protected getEvents(): {
11
+ type: import("../types").EventType;
12
+ handler: (e: InteractionEvent) => void;
13
+ }[];
14
+ handleStart: (e: InteractionEvent) => void;
15
+ handleReset: (e: InteractionEvent) => void;
16
+ }
@@ -0,0 +1,29 @@
1
+ import { InteractionStateEnum } from "../graph/enums";
2
+
3
+ import { BaseInteraction } from "./base";
4
+
5
+ export class ElementActive extends BaseInteraction {
6
+ constructor(view, options) {
7
+ super(view, options), this.type = ElementActive.type, this.handleStart = e => {
8
+ e.element && this._marks && this._marks.includes(e.element.mark) && e.element.addState(this.options.state);
9
+ }, this.handleReset = e => {
10
+ e.element && this._marks && this._marks.includes(e.element.mark) && e.element.removeState(this.options.state);
11
+ }, this.options = Object.assign({}, ElementActive.defaultOptions, options), this._marks = view.getMarksBySelector(this.options.selector);
12
+ }
13
+ getEvents() {
14
+ return [ {
15
+ type: this.options.trigger,
16
+ handler: this.handleStart
17
+ }, {
18
+ type: this.options.resetTrigger,
19
+ handler: this.handleReset
20
+ } ];
21
+ }
22
+ }
23
+
24
+ ElementActive.type = "element-active", ElementActive.defaultOptions = {
25
+ state: InteractionStateEnum.active,
26
+ trigger: "pointerover",
27
+ resetTrigger: "pointerout"
28
+ };
29
+ //# sourceMappingURL=element-active.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/element-active.ts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,CAAC,WAAW;aAC1B;YACD,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;SAC/D,CAAC;IACJ,CAAC;;AA1BM,kBAAI,GAAW,gBAAgB,CAAC;AAGhC,4BAAc,GAAyB;IAC5C,KAAK,EAAE,oBAAoB,CAAC,MAAM;IAClC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-active.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type { ElementActiveOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\n\nexport class ElementActive extends BaseInteraction<ElementActiveOptions> {\n static type: string = 'element-active';\n type: string = ElementActive.type;\n\n static defaultOptions: ElementActiveOptions = {\n state: InteractionStateEnum.active,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementActiveOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementActiveOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementActive.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element) {\n if (this._marks && this._marks.includes(e.element.mark)) {\n e.element.addState(this.options.state);\n }\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n if (e.element) {\n if (this._marks && this._marks.includes(e.element.mark)) {\n e.element.removeState(this.options.state);\n }\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ export declare class ElementHighlightByGroup extends BaseInteraction<ElementHighlightOptions> {
4
+ static type: string;
5
+ type: string;
6
+ static defaultOptions: ElementHighlightOptions;
7
+ options: ElementHighlightOptions;
8
+ protected _marks?: IMark[];
9
+ constructor(view: IView, options?: ElementHighlightOptions);
10
+ protected getEvents(): {
11
+ type: import("../types").EventType;
12
+ handler: (e: InteractionEvent) => void;
13
+ }[];
14
+ clearPrevElements(): void;
15
+ handleStart: (e: InteractionEvent) => void;
16
+ handleReset: (e: InteractionEvent) => void;
17
+ }
@@ -0,0 +1,49 @@
1
+ import { isNil } from "@visactor/vutils";
2
+
3
+ import { BaseInteraction } from "./base";
4
+
5
+ import { InteractionStateEnum } from "../graph/enums";
6
+
7
+ export class ElementHighlightByGroup extends BaseInteraction {
8
+ constructor(view, options) {
9
+ super(view, options), this.type = ElementHighlightByGroup.type, this.handleStart = e => {
10
+ if (e.element && this._marks && this._marks.includes(e.element.mark)) {
11
+ const highlightKey = e.element.groupKey;
12
+ if (isNil(highlightKey)) return;
13
+ this._marks.forEach((mark => {
14
+ mark.elements.forEach((el => {
15
+ el.groupKey === highlightKey ? (el.removeState(this.options.blurState), el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
16
+ el.addState(this.options.blurState));
17
+ }));
18
+ }));
19
+ }
20
+ }, this.handleReset = e => {
21
+ e.element && this._marks && this._marks.includes(e.element.mark) && this.clearPrevElements();
22
+ }, this.options = Object.assign({}, ElementHighlightByGroup.defaultOptions, options),
23
+ this._marks = view.getMarksBySelector(this.options.selector);
24
+ }
25
+ getEvents() {
26
+ return [ {
27
+ type: this.options.trigger,
28
+ handler: this.handleStart
29
+ }, {
30
+ type: this.options.resetTrigger,
31
+ handler: this.handleReset
32
+ } ];
33
+ }
34
+ clearPrevElements() {
35
+ this._marks.forEach((mark => {
36
+ mark.elements.forEach((el => {
37
+ el.hasState(this.options.highlightState) && el.removeState(this.options.highlightState),
38
+ el.hasState(this.options.blurState) && el.removeState(this.options.blurState);
39
+ }));
40
+ }));
41
+ }
42
+ }
43
+
44
+ ElementHighlightByGroup.type = "element-highlight-by-group", ElementHighlightByGroup.defaultOptions = {
45
+ highlightState: InteractionStateEnum.highlight,
46
+ blurState: InteractionStateEnum.blur,
47
+ trigger: "pointerover",
48
+ resetTrigger: "pointerout"
49
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/element-highlight-by-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,OAAO,uBAAwB,SAAQ,eAAwC;IAanF,YAAY,IAAW,EAAE,OAAiC;QACxD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAZvB,SAAI,GAAW,uBAAuB,CAAC,IAAI,CAAC;QA0C5C,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACpE,MAAM,YAAY,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;gBAExC,IAAI,KAAK,CAAC,YAAY,CAAC,EAAE;oBACvB,OAAO;iBACR;gBACD,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;oBACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;wBACzB,MAAM,WAAW,GAAG,EAAE,CAAC,QAAQ,KAAK,YAAY,CAAC;wBAEjD,IAAI,WAAW,EAAE;4BACf,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;4BACvC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;yBAC1C;6BAAM;4BACL,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;4BAC5C,EA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C,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;oBACvC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;iBACxC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAzCM,4BAAI,GAAW,4BAA4B,CAAC;AAG5C,sCAAc,GAA4B;IAC/C,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-highlight-by-group.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { InteractionStateEnum } from '../graph/enums';\n\nexport class ElementHighlightByGroup extends BaseInteraction<ElementHighlightOptions> {\n static type: string = 'element-highlight-by-group';\n type: string = ElementHighlightByGroup.type;\n\n static defaultOptions: ElementHighlightOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementHighlightOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByGroup.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n clearPrevElements() {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.highlightState)) {\n el.removeState(this.options.highlightState);\n }\n\n if (el.hasState(this.options.blurState)) {\n el.removeState(this.options.blurState);\n }\n });\n });\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element && this._marks && this._marks.includes(e.element.mark)) {\n const highlightKey = e.element.groupKey;\n\n if (isNil(highlightKey)) {\n return;\n }\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el.groupKey === highlightKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n const hasActiveElement = e.element && this._marks && this._marks.includes(e.element.mark);\n\n if (hasActiveElement) {\n this.clearPrevElements();\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ export declare class ElementHighlightByKey extends BaseInteraction<ElementHighlightOptions> {
4
+ static type: string;
5
+ type: string;
6
+ static defaultOptions: ElementHighlightOptions;
7
+ options: ElementHighlightOptions;
8
+ protected _marks?: IMark[];
9
+ constructor(view: IView, options?: ElementHighlightOptions);
10
+ protected getEvents(): {
11
+ type: import("../types").EventType;
12
+ handler: (e: InteractionEvent) => void;
13
+ }[];
14
+ clearPrevElements(): void;
15
+ handleStart: (e: InteractionEvent) => void;
16
+ handleReset: (e: InteractionEvent) => void;
17
+ }
@@ -0,0 +1,50 @@
1
+ import { isNil } from "@visactor/vutils";
2
+
3
+ import { BaseInteraction } from "./base";
4
+
5
+ import { InteractionStateEnum } from "../graph/enums";
6
+
7
+ export class ElementHighlightByKey extends BaseInteraction {
8
+ constructor(view, options) {
9
+ super(view, options), this.type = ElementHighlightByKey.type, this.handleStart = e => {
10
+ if (e.element && this._marks && this._marks.includes(e.element.mark)) {
11
+ const highlightKey = e.element.key;
12
+ if (isNil(highlightKey)) return;
13
+ this._marks.forEach((mark => {
14
+ mark.elements.forEach((el => {
15
+ el.key === highlightKey ? (el.removeState(this.options.blurState), el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
16
+ el.addState(this.options.blurState));
17
+ }));
18
+ }));
19
+ }
20
+ }, this.handleReset = e => {
21
+ e.element && this._marks && this._marks.includes(e.element.mark) && this.clearPrevElements();
22
+ }, this.options = Object.assign({}, ElementHighlightByKey.defaultOptions, options),
23
+ this._marks = view.getMarksBySelector(this.options.selector);
24
+ }
25
+ getEvents() {
26
+ return [ {
27
+ type: this.options.trigger,
28
+ handler: this.handleStart
29
+ }, {
30
+ type: this.options.resetTrigger,
31
+ handler: this.handleReset
32
+ } ];
33
+ }
34
+ clearPrevElements() {
35
+ this._marks.forEach((mark => {
36
+ mark.elements.forEach((el => {
37
+ el.hasState(this.options.highlightState) && el.removeState(this.options.highlightState),
38
+ el.hasState(this.options.blurState) && el.removeState(this.options.blurState);
39
+ }));
40
+ }));
41
+ }
42
+ }
43
+
44
+ ElementHighlightByKey.type = "element-highlight-by-key", ElementHighlightByKey.defaultOptions = {
45
+ highlightState: InteractionStateEnum.highlight,
46
+ blurState: InteractionStateEnum.blur,
47
+ trigger: "pointerover",
48
+ resetTrigger: "pointerout"
49
+ };
50
+ //# sourceMappingURL=element-highlight-by-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/interactions/element-highlight-by-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,OAAO,qBAAsB,SAAQ,eAAwC;IAajF,YAAY,IAAW,EAAE,OAAiC;QACxD,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAZvB,SAAI,GAAW,qBAAqB,CAAC,IAAI,CAAC;QA0C1C,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,CAAC,OAAO,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACpE,MAAM,YAAY,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QACjB,OAAO;YACL;gBACE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;gBAC1B,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;SAC/D,CAAC;IACJ,CAAC;IAED,iBAAiB;QACf,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;gBACzB,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE;oBAC5C,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;iBAC7C;gBAED,IAAI,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;oBACvC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;iBACxC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;;AAzCM,0BAAI,GAAW,0BAA0B,CAAC;AAG1C,oCAAc,GAA4B;IAC/C,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,OAAO,EAAE,aAAa;IACtB,YAAY,EAAE,YAAY;CAC3B,CAAC","file":"element-highlight-by-key.js","sourcesContent":["import { isNil } from '@visactor/vutils';\nimport type { ElementHighlightOptions, IMark, IView, InteractionEvent } from '../types';\nimport { BaseInteraction } from './base';\nimport { InteractionStateEnum } from '../graph/enums';\n\nexport class ElementHighlightByKey extends BaseInteraction<ElementHighlightOptions> {\n static type: string = 'element-highlight-by-key';\n type: string = ElementHighlightByKey.type;\n\n static defaultOptions: ElementHighlightOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n trigger: 'pointerover',\n resetTrigger: 'pointerout'\n };\n options: ElementHighlightOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByKey.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: this.options.trigger,\n handler: this.handleStart\n },\n { type: this.options.resetTrigger, handler: this.handleReset }\n ];\n }\n\n clearPrevElements() {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n if (el.hasState(this.options.highlightState)) {\n el.removeState(this.options.highlightState);\n }\n\n if (el.hasState(this.options.blurState)) {\n el.removeState(this.options.blurState);\n }\n });\n });\n }\n\n handleStart = (e: InteractionEvent) => {\n if (e.element && this._marks && this._marks.includes(e.element.mark)) {\n const highlightKey = e.element.key;\n\n if (isNil(highlightKey)) {\n return;\n }\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el.key === highlightKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n }\n };\n\n handleReset = (e: InteractionEvent) => {\n const hasActiveElement = e.element && this._marks && this._marks.includes(e.element.mark);\n\n if (hasActiveElement) {\n this.clearPrevElements();\n }\n };\n}\n"]}
@@ -0,0 +1,17 @@
1
+ import type { ElementHighlightByLegendOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ import { LegendEvent } from '@visactor/vrender-components';
4
+ export declare class ElementHighlightByLegend extends BaseInteraction<ElementHighlightByLegendOptions> {
5
+ static type: string;
6
+ type: string;
7
+ static defaultOptions: ElementHighlightByLegendOptions;
8
+ options: ElementHighlightByLegendOptions;
9
+ protected _marks?: IMark[];
10
+ constructor(view: IView, options?: ElementHighlightByLegendOptions);
11
+ protected getEvents(): {
12
+ type: LegendEvent;
13
+ handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
14
+ }[];
15
+ handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
16
+ handleReset: (e: InteractionEvent) => void;
17
+ }
@@ -0,0 +1,46 @@
1
+ import { InteractionStateEnum } from "../graph/enums";
2
+
3
+ import { BaseInteraction } from "./base";
4
+
5
+ import { LegendEvent } from "@visactor/vrender-components";
6
+
7
+ import { isNil } from "@visactor/vutils";
8
+
9
+ export class ElementHighlightByLegend extends BaseInteraction {
10
+ constructor(view, options) {
11
+ super(view, options), this.type = ElementHighlightByLegend.type, this.handleStart = (e, element) => {
12
+ var _a, _b;
13
+ const itemKey = null === (_b = null === (_a = e.detail) || void 0 === _a ? void 0 : _a.data) || void 0 === _b ? void 0 : _b.id;
14
+ isNil(itemKey) || this._marks.forEach((mark => {
15
+ mark.elements.forEach((el => {
16
+ el[this.options.filterType] === itemKey ? (el.removeState(this.options.blurState),
17
+ el.addState(this.options.highlightState)) : (el.removeState(this.options.highlightState),
18
+ el.addState(this.options.blurState));
19
+ }));
20
+ }));
21
+ }, this.handleReset = e => {
22
+ this._marks.forEach((mark => {
23
+ mark.elements.forEach((el => {
24
+ el.removeState(this.options.blurState), el.removeState(this.options.highlightState);
25
+ }));
26
+ }));
27
+ }, this.options = Object.assign({}, ElementHighlightByLegend.defaultOptions, options),
28
+ this._marks = view.getMarksBySelector(this.options.selector);
29
+ }
30
+ getEvents() {
31
+ return [ {
32
+ type: LegendEvent.legendItemHover,
33
+ handler: this.handleStart
34
+ }, {
35
+ type: LegendEvent.legendItemUnHover,
36
+ handler: this.handleReset
37
+ } ];
38
+ }
39
+ }
40
+
41
+ ElementHighlightByLegend.type = "element-highlight-by-legend", ElementHighlightByLegend.defaultOptions = {
42
+ highlightState: InteractionStateEnum.highlight,
43
+ blurState: InteractionStateEnum.blur,
44
+ filterType: "groupKey"
45
+ };
46
+ //# sourceMappingURL=element-highlight-by-legend.js.map
@@ -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;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,gBAAW,GAAG,CAAC,CAAmB,EAAE,EAAE;YACpC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACzB,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;oBACzB,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;oBACvC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;gBAC9C,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QA5CA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,wBAAwB,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;QAEnF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IAES,SAAS;QACjB,OAAO;YACL;gBACE,IAAI,EAAE,WAAW,CAAC,eAAe;gBACjC,OAAO,EAAE,IAAI,CAAC,WAAW;aAC1B;YACD,EAAE,IAAI,EAAE,WAAW,CAAC,iBAAiB,EAAE,OAAO,EAAE,IAAI,CAAC,WAAW,EAAE;SACnE,CAAC;IACJ,CAAC;;AA1BM,6BAAI,GAAW,6BAA6B,CAAC;AAG7C,uCAAc,GAAoC;IACvD,cAAc,EAAE,oBAAoB,CAAC,SAAS;IAC9C,SAAS,EAAE,oBAAoB,CAAC,IAAI;IACpC,UAAU,EAAE,UAAU;CACvB,CAAC","file":"element-highlight-by-legend.js","sourcesContent":["import { InteractionStateEnum } from '../graph/enums';\nimport type {\n ElementHighlightByLegendOptions,\n IElement,\n IGlyphElement,\n IMark,\n IView,\n InteractionEvent\n} from '../types';\nimport { BaseInteraction } from './base';\nimport { LegendEvent } from '@visactor/vrender-components';\nimport { isNil } from '@visactor/vutils';\n\nexport class ElementHighlightByLegend extends BaseInteraction<ElementHighlightByLegendOptions> {\n static type: string = 'element-highlight-by-legend';\n type: string = ElementHighlightByLegend.type;\n\n static defaultOptions: ElementHighlightByLegendOptions = {\n highlightState: InteractionStateEnum.highlight,\n blurState: InteractionStateEnum.blur,\n filterType: 'groupKey'\n };\n options: ElementHighlightByLegendOptions;\n protected _marks?: IMark[];\n\n constructor(view: IView, options?: ElementHighlightByLegendOptions) {\n super(view, options);\n this.options = Object.assign({}, ElementHighlightByLegend.defaultOptions, options);\n\n this._marks = view.getMarksBySelector(this.options.selector);\n }\n\n protected getEvents() {\n return [\n {\n type: LegendEvent.legendItemHover,\n handler: this.handleStart\n },\n { type: LegendEvent.legendItemUnHover, handler: this.handleReset }\n ];\n }\n\n handleStart = (e: InteractionEvent, element: IElement | IGlyphElement) => {\n const itemKey = e.detail?.data?.id;\n\n if (isNil(itemKey)) {\n return;\n }\n\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n const isHighlight = el[this.options.filterType] === itemKey;\n\n if (isHighlight) {\n el.removeState(this.options.blurState);\n el.addState(this.options.highlightState);\n } else {\n el.removeState(this.options.highlightState);\n el.addState(this.options.blurState);\n }\n });\n });\n };\n\n handleReset = (e: InteractionEvent) => {\n this._marks.forEach(mark => {\n mark.elements.forEach(el => {\n el.removeState(this.options.blurState);\n el.removeState(this.options.highlightState);\n });\n });\n };\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { ElementHighlightByNameOptions, IElement, IGlyphElement, IMark, IView, InteractionEvent } from '../types';
2
+ import { BaseInteraction } from './base';
3
+ export declare class ElementHighlightByName extends BaseInteraction<ElementHighlightByNameOptions> {
4
+ static type: string;
5
+ type: string;
6
+ static defaultOptions: ElementHighlightByNameOptions;
7
+ options: ElementHighlightByNameOptions;
8
+ protected _marks?: IMark[];
9
+ constructor(view: IView, options?: ElementHighlightByNameOptions);
10
+ protected getEvents(): {
11
+ type: import("../types").EventType;
12
+ handler: (e: InteractionEvent, element: IGlyphElement<any> | IElement) => void;
13
+ }[];
14
+ protected _filterByName(e: InteractionEvent): boolean;
15
+ protected _parseTargetKey(e: InteractionEvent, element: IElement | IGlyphElement): any;
16
+ handleStart: (e: InteractionEvent, element: IElement | IGlyphElement) => void;
17
+ handleReset: (e: InteractionEvent) => void;
18
+ }