@fundar/data-chart-telling 1.17.0 → 1.19.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 (353) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +2 -1
  3. package/dist/configuration/config.svelte.js +4 -3
  4. package/dist/index.d.ts +10 -3
  5. package/dist/index.js +4 -1
  6. package/dist/layout/coordinates/CoordinatesLayout.svelte +3 -1
  7. package/dist/layout/geometry/GeometryLayout.svelte +222 -53
  8. package/dist/layout/geometry/ScaleFreeContext.d.ts +31 -0
  9. package/dist/layout/geometry/ScaleFreeContext.js +65 -0
  10. package/dist/layout/geometry/ScaleFreeMarks.svelte +14 -0
  11. package/dist/layout/geometry/ScaleFreeMarks.svelte.d.ts +7 -0
  12. package/dist/layout/geometry/ScaleGate.svelte.d.ts +8 -0
  13. package/dist/layout/geometry/ScaleGate.svelte.js +95 -0
  14. package/dist/layout/geometry/ScaleGateMarks.svelte +15 -0
  15. package/dist/layout/geometry/ScaleGateMarks.svelte.d.ts +7 -0
  16. package/dist/layout/hover/HoverDefaults.d.ts +52 -0
  17. package/dist/layout/hover/HoverDefaults.js +96 -0
  18. package/dist/layout/hover/HoverLayers.d.ts +35 -0
  19. package/dist/layout/hover/HoverLayers.js +122 -0
  20. package/dist/layout/hover/HoverSettings.d.ts +1 -3
  21. package/dist/layout/hover/HoverSettings.js +3 -2
  22. package/dist/layout/hover/HoverShapes.d.ts +56 -0
  23. package/dist/layout/hover/HoverShapes.js +163 -0
  24. package/dist/layout/hover/PlotHover.svelte.d.ts +18 -0
  25. package/dist/layout/hover/PlotHover.svelte.js +54 -1
  26. package/dist/layout/legend/LegendState.svelte.d.ts +2 -0
  27. package/dist/layout/legend/LegendState.svelte.js +5 -0
  28. package/dist/layout/margins/Box.d.ts +4 -0
  29. package/dist/layout/margins/Box.js +14 -0
  30. package/dist/layout/margins/PlotMargins.svelte.js +26 -1
  31. package/dist/layout/plot/{Plot.svelte.d.ts → AbstractPlot.svelte.d.ts} +3 -3
  32. package/dist/layout/plot/Core.svelte +2 -2
  33. package/dist/layout/plot/PublicPlotContext.d.ts +6 -0
  34. package/dist/layout/plot/PublicPlotContext.js +8 -0
  35. package/dist/layout/styles/ValueLabels.d.ts +118 -59
  36. package/dist/layout/styles/ValueLabels.js +313 -146
  37. package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -9
  38. package/dist/layout/tooltip/TooltipState.svelte.js +28 -29
  39. package/dist/markers/MarkerKinds.d.ts +84 -1
  40. package/dist/markers/MarkerKinds.js +150 -23
  41. package/dist/markers/area/AreaMarker.svelte +1 -1
  42. package/dist/markers/band/BandMarker.svelte +74 -0
  43. package/dist/markers/band/BandMarker.svelte.d.ts +7 -0
  44. package/dist/markers/band/Bands.d.ts +16 -0
  45. package/dist/markers/band/Bands.js +48 -0
  46. package/dist/markers/bar/BarMarker.svelte +29 -70
  47. package/dist/markers/bollinger/BollingerMarker.svelte +1 -1
  48. package/dist/markers/box/BoxMarker.svelte +1 -1
  49. package/dist/markers/dot/DotRadius.d.ts +11 -0
  50. package/dist/markers/dot/DotRadius.js +21 -0
  51. package/dist/markers/hover/HoverMarker.svelte +7 -265
  52. package/dist/markers/hover/HoverMarker.svelte.d.ts +4 -27
  53. package/dist/markers/labels/CurveLabel.svelte +56 -0
  54. package/dist/markers/labels/CurveLabel.svelte.d.ts +9 -0
  55. package/dist/markers/labels/LabelMerge.d.ts +11 -0
  56. package/dist/markers/labels/LabelMerge.js +87 -0
  57. package/dist/markers/labels/MarkerLabel.svelte +36 -0
  58. package/dist/markers/labels/MarkerLabel.svelte.d.ts +10 -0
  59. package/dist/markers/labels/MarkerLabels.d.ts +52 -0
  60. package/dist/markers/labels/MarkerLabels.js +97 -0
  61. package/dist/markers/labels/geometry/BoxGeometry.d.ts +8 -0
  62. package/dist/markers/labels/geometry/BoxGeometry.js +101 -0
  63. package/dist/markers/labels/geometry/CurveGeometry.d.ts +34 -0
  64. package/dist/markers/labels/geometry/CurveGeometry.js +193 -0
  65. package/dist/markers/labels/geometry/PointGeometry.d.ts +9 -0
  66. package/dist/markers/labels/geometry/PointGeometry.js +22 -0
  67. package/dist/markers/labels/layouts/BoxLayout.d.ts +10 -0
  68. package/dist/markers/labels/layouts/BoxLayout.js +49 -0
  69. package/dist/markers/labels/layouts/PathLayout.d.ts +11 -0
  70. package/dist/markers/labels/layouts/PathLayout.js +91 -0
  71. package/dist/markers/labels/layouts/PointLayout.d.ts +19 -0
  72. package/dist/markers/labels/layouts/PointLayout.js +94 -0
  73. package/dist/markers/regression/RegressionMarker.svelte +1 -1
  74. package/dist/markers/text/Covering.d.ts +13 -0
  75. package/dist/markers/text/Covering.js +29 -0
  76. package/dist/markers/text/Declutter.d.ts +24 -3
  77. package/dist/markers/text/Declutter.js +46 -3
  78. package/dist/markers/text/TextMarker.svelte +90 -17
  79. package/dist/markers/text/TextMarker.svelte.d.ts +1 -1
  80. package/dist/markers/tick/TickMarker.svelte +1 -1
  81. package/dist/markers/utils/MarkerChannels.d.ts +1 -1
  82. package/dist/markers/utils/MarkerChannels.js +3 -2
  83. package/dist/markers/utils/PointPixel.d.ts +37 -0
  84. package/dist/markers/utils/PointPixel.js +44 -0
  85. package/dist/markers/violin/ViolinMarker.svelte +1 -1
  86. package/dist/markers/waffle/WaffleMarker.svelte +1 -1
  87. package/dist/phases/Pipeline.d.ts +7 -7
  88. package/dist/phases/Pipeline.js +12 -9
  89. package/dist/phases/context/ContextPhase.d.ts +22 -0
  90. package/dist/phases/context/ContextPhase.js +23 -0
  91. package/dist/phases/context/RowContext.d.ts +37 -0
  92. package/dist/phases/context/RowContext.js +97 -0
  93. package/dist/phases/data/DataPhase.d.ts +4 -4
  94. package/dist/phases/data/DataPhase.js +7 -7
  95. package/dist/phases/hover/HoverPhase.d.ts +6 -7
  96. package/dist/phases/hover/HoverPhase.js +28 -23
  97. package/dist/phases/mapping/MappingPhase.d.ts +4 -4
  98. package/dist/phases/mapping/MappingPhase.js +2 -2
  99. package/dist/phases/markers/MarkerStyles.d.ts +8 -0
  100. package/dist/phases/markers/MarkerStyles.js +24 -6
  101. package/dist/phases/markers/MarkersPhase.d.ts +6 -7
  102. package/dist/phases/markers/MarkersPhase.js +18 -12
  103. package/dist/phases/scales/ScalesPhase.d.ts +4 -4
  104. package/dist/phases/scales/ScalesPhase.js +4 -4
  105. package/dist/phases/sharedScales/SharedScalesPhase.d.ts +2 -2
  106. package/dist/phases/sharedScales/SharedScalesPhase.js +2 -2
  107. package/dist/phases/statistics/MarkerGrouping.d.ts +0 -9
  108. package/dist/phases/statistics/MarkerGrouping.js +5 -48
  109. package/dist/phases/statistics/MarkerInheritance.d.ts +11 -0
  110. package/dist/phases/statistics/MarkerInheritance.js +25 -0
  111. package/dist/phases/statistics/MarkerOrientation.d.ts +26 -0
  112. package/dist/phases/statistics/MarkerOrientation.js +29 -0
  113. package/dist/phases/statistics/StatisticsPhase.js +15 -15
  114. package/dist/phases/styles/StylesPhase.d.ts +3 -3
  115. package/dist/phases/styles/StylesPhase.js +2 -2
  116. package/dist/phases/tooltip/TooltipPhase.d.ts +4 -4
  117. package/dist/phases/tooltip/TooltipPhase.js +10 -7
  118. package/dist/phases/transforms/TransformsPhase.d.ts +3 -3
  119. package/dist/phases/transforms/TransformsPhase.js +7 -5
  120. package/dist/plots/correlation/heatmap/Plot.svelte +2 -2
  121. package/dist/plots/correlation/heatmap/Plot.svelte.d.ts +0 -1
  122. package/dist/plots/correlation/heatmap/defaults.d.ts +2 -2
  123. package/dist/plots/correlation/heatmap/defaults.js +35 -7
  124. package/dist/plots/correlation/heatmap/markers.d.ts +2 -8
  125. package/dist/plots/correlation/heatmap/markers.js +8 -11
  126. package/dist/plots/correlation/scatter/Plot.svelte +2 -2
  127. package/dist/plots/correlation/scatter/Plot.svelte.d.ts +0 -1
  128. package/dist/plots/correlation/scatter/defaults.d.ts +2 -2
  129. package/dist/plots/correlation/scatter/defaults.js +18 -6
  130. package/dist/plots/correlation/scatter/markers.d.ts +2 -11
  131. package/dist/plots/correlation/scatter/markers.js +24 -30
  132. package/dist/plots/distribution/box/BoxSummaries.d.ts +22 -8
  133. package/dist/plots/distribution/box/BoxSummaries.js +99 -40
  134. package/dist/plots/distribution/box/Plot.svelte +2 -2
  135. package/dist/plots/distribution/box/Plot.svelte.d.ts +0 -1
  136. package/dist/plots/distribution/box/defaults.d.ts +2 -2
  137. package/dist/plots/distribution/box/defaults.js +20 -6
  138. package/dist/plots/distribution/box/markers.d.ts +2 -2
  139. package/dist/plots/distribution/box/markers.js +13 -4
  140. package/dist/plots/distribution/density/Plot.svelte +2 -2
  141. package/dist/plots/distribution/density/Plot.svelte.d.ts +0 -1
  142. package/dist/plots/distribution/density/defaults.d.ts +2 -2
  143. package/dist/plots/distribution/density/defaults.js +33 -1
  144. package/dist/plots/distribution/density/markers.d.ts +2 -2
  145. package/dist/plots/distribution/density/markers.js +9 -5
  146. package/dist/plots/distribution/histogram/Plot.svelte +2 -2
  147. package/dist/plots/distribution/histogram/Plot.svelte.d.ts +0 -1
  148. package/dist/plots/distribution/histogram/defaults.d.ts +2 -2
  149. package/dist/plots/distribution/histogram/defaults.js +36 -36
  150. package/dist/plots/distribution/histogram/markers.d.ts +2 -2
  151. package/dist/plots/distribution/histogram/markers.js +7 -6
  152. package/dist/plots/distribution/pyramid/Plot.svelte +2 -2
  153. package/dist/plots/distribution/pyramid/Plot.svelte.d.ts +0 -1
  154. package/dist/plots/distribution/pyramid/defaults.d.ts +2 -2
  155. package/dist/plots/distribution/pyramid/defaults.js +13 -3
  156. package/dist/plots/distribution/pyramid/markers.d.ts +2 -10
  157. package/dist/plots/distribution/pyramid/markers.js +9 -18
  158. package/dist/plots/distribution/violin/Plot.svelte +2 -2
  159. package/dist/plots/distribution/violin/Plot.svelte.d.ts +0 -1
  160. package/dist/plots/distribution/violin/defaults.d.ts +2 -2
  161. package/dist/plots/distribution/violin/defaults.js +20 -7
  162. package/dist/plots/distribution/violin/markers.d.ts +2 -2
  163. package/dist/plots/distribution/violin/markers.js +30 -6
  164. package/dist/plots/evolution/area/Plot.svelte +2 -2
  165. package/dist/plots/evolution/area/Plot.svelte.d.ts +0 -1
  166. package/dist/plots/evolution/area/defaults.d.ts +2 -2
  167. package/dist/plots/evolution/area/defaults.js +5 -8
  168. package/dist/plots/evolution/area/markers.d.ts +2 -2
  169. package/dist/plots/evolution/area/markers.js +7 -5
  170. package/dist/plots/evolution/line/Plot.svelte +2 -2
  171. package/dist/plots/evolution/line/Plot.svelte.d.ts +0 -1
  172. package/dist/plots/evolution/line/defaults.d.ts +2 -2
  173. package/dist/plots/evolution/line/defaults.js +5 -7
  174. package/dist/plots/evolution/line/markers.d.ts +2 -2
  175. package/dist/plots/evolution/line/markers.js +6 -4
  176. package/dist/plots/evolution/slope/Plot.svelte +2 -2
  177. package/dist/plots/evolution/slope/Plot.svelte.d.ts +0 -1
  178. package/dist/plots/evolution/slope/defaults.d.ts +2 -2
  179. package/dist/plots/evolution/slope/defaults.js +11 -6
  180. package/dist/plots/evolution/slope/markers.d.ts +6 -5
  181. package/dist/plots/evolution/slope/markers.js +19 -12
  182. package/dist/plots/evolution/sparkline/Plot.svelte +2 -2
  183. package/dist/plots/evolution/sparkline/Plot.svelte.d.ts +0 -1
  184. package/dist/plots/evolution/sparkline/defaults.d.ts +2 -2
  185. package/dist/plots/evolution/sparkline/defaults.js +5 -2
  186. package/dist/plots/evolution/sparkline/markers.d.ts +2 -2
  187. package/dist/plots/evolution/sparkline/markers.js +6 -4
  188. package/dist/plots/generic/Plot.svelte +42 -0
  189. package/dist/plots/generic/Plot.svelte.d.ts +25 -0
  190. package/dist/plots/generic/defaults.d.ts +4 -0
  191. package/dist/plots/generic/defaults.js +7 -0
  192. package/dist/plots/map/geo/Core.svelte +3 -3
  193. package/dist/plots/map/geo/Plot.svelte +2 -2
  194. package/dist/plots/map/geo/Plot.svelte.d.ts +0 -1
  195. package/dist/plots/map/geo/defaults.d.ts +2 -2
  196. package/dist/plots/map/geo/phases/data.d.ts +1 -1
  197. package/dist/plots/map/geo/phases/data.js +1 -1
  198. package/dist/plots/map/geo/phases/hover.d.ts +2 -2
  199. package/dist/plots/map/geo/phases/hover.js +3 -3
  200. package/dist/plots/map/geo/phases/markers.d.ts +2 -2
  201. package/dist/plots/map/geo/phases/markers.js +3 -3
  202. package/dist/plots/map/geo/phases/scales.d.ts +2 -2
  203. package/dist/plots/map/geo/phases/scales.js +2 -2
  204. package/dist/plots/part-of-a-whole/treemap/Plot.svelte +2 -2
  205. package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +0 -1
  206. package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +2 -2
  207. package/dist/plots/part-of-a-whole/treemap/defaults.js +38 -22
  208. package/dist/plots/ranking/bar/Plot.svelte +2 -2
  209. package/dist/plots/ranking/bar/Plot.svelte.d.ts +0 -1
  210. package/dist/plots/ranking/bar/defaults.d.ts +2 -2
  211. package/dist/plots/ranking/bar/defaults.js +26 -10
  212. package/dist/plots/ranking/bar/markers.d.ts +3 -3
  213. package/dist/plots/ranking/bar/markers.js +17 -33
  214. package/dist/plots/ranking/bullet/Plot.svelte +2 -2
  215. package/dist/plots/ranking/bullet/Plot.svelte.d.ts +0 -1
  216. package/dist/plots/ranking/bullet/defaults.d.ts +2 -2
  217. package/dist/plots/ranking/bullet/defaults.js +24 -4
  218. package/dist/plots/ranking/bullet/markers.d.ts +3 -3
  219. package/dist/plots/ranking/bullet/markers.js +16 -10
  220. package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +4 -11
  221. package/dist/plots/ranking/cleveland/ClevelandMarkers.js +73 -54
  222. package/dist/plots/ranking/cleveland/Plot.svelte +2 -2
  223. package/dist/plots/ranking/cleveland/Plot.svelte.d.ts +0 -1
  224. package/dist/plots/ranking/cleveland/defaults.d.ts +2 -2
  225. package/dist/plots/ranking/cleveland/defaults.js +39 -5
  226. package/dist/plots/ranking/dumbbell/Plot.svelte +2 -2
  227. package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +0 -1
  228. package/dist/plots/ranking/dumbbell/defaults.d.ts +2 -2
  229. package/dist/plots/ranking/forest/Plot.svelte +2 -2
  230. package/dist/plots/ranking/forest/Plot.svelte.d.ts +0 -1
  231. package/dist/plots/ranking/forest/defaults.d.ts +2 -2
  232. package/dist/plots/ranking/lollipop/Plot.svelte +2 -2
  233. package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +0 -1
  234. package/dist/plots/ranking/lollipop/defaults.d.ts +2 -2
  235. package/dist/types/configuration/styling.d.ts +4 -0
  236. package/dist/types/layout/context.d.ts +23 -0
  237. package/dist/types/layout/context.js +1 -0
  238. package/dist/types/layout/hover.d.ts +3 -0
  239. package/dist/types/layout/styles/bullet.d.ts +4 -1
  240. package/dist/types/layout/styles/values.d.ts +59 -13
  241. package/dist/types/layout/tooltip.d.ts +5 -10
  242. package/dist/types/markers/axis/area.d.ts +5 -1
  243. package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
  244. package/dist/types/markers/axis/band.d.ts +24 -0
  245. package/dist/types/markers/axis/band.js +1 -0
  246. package/dist/types/markers/axis/bar.d.ts +7 -4
  247. package/dist/types/markers/axis/bollinger.d.ts +2 -1
  248. package/dist/types/markers/axis/box.d.ts +2 -1
  249. package/dist/types/markers/axis/cell.d.ts +4 -1
  250. package/dist/types/markers/axis/hover.d.ts +60 -15
  251. package/dist/types/markers/axis/line.d.ts +4 -1
  252. package/dist/types/markers/axis/rect.d.ts +4 -1
  253. package/dist/types/markers/axis/regression.d.ts +2 -1
  254. package/dist/types/markers/axis/tick.d.ts +2 -1
  255. package/dist/types/markers/axis/trail.d.ts +4 -1
  256. package/dist/types/markers/axis/violin.d.ts +2 -1
  257. package/dist/types/markers/axis/waffle.d.ts +5 -1
  258. package/dist/types/markers/basic/dot.d.ts +4 -1
  259. package/dist/types/markers/basic/text.d.ts +25 -21
  260. package/dist/types/markers/channels/commonMarkerConfig.d.ts +6 -2
  261. package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +5 -9
  262. package/dist/types/markers/channels/commonMarkerConfigWithOrientation.d.ts +5 -0
  263. package/dist/types/markers/channels/commonMarkerConfigWithOrientation.js +1 -0
  264. package/dist/types/markers/common.d.ts +1 -0
  265. package/dist/types/markers/common.js +1 -0
  266. package/dist/types/markers/labels/box.d.ts +57 -0
  267. package/dist/types/markers/labels/box.js +1 -0
  268. package/dist/types/markers/labels/common.d.ts +15 -0
  269. package/dist/types/markers/labels/common.js +1 -0
  270. package/dist/types/markers/labels/path.d.ts +52 -0
  271. package/dist/types/markers/labels/path.js +1 -0
  272. package/dist/types/markers/labels/point.d.ts +40 -0
  273. package/dist/types/markers/labels/point.js +1 -0
  274. package/dist/types/markers/traits.d.ts +10 -0
  275. package/dist/types/phases/context/phase.d.ts +7 -0
  276. package/dist/types/phases/context/phase.js +1 -0
  277. package/dist/types/phases/data/phase.d.ts +2 -2
  278. package/dist/types/phases/hover/phase.d.ts +10 -7
  279. package/dist/types/phases/index.d.ts +2 -1
  280. package/dist/types/phases/kind.d.ts +11 -8
  281. package/dist/types/phases/mapping/phase.d.ts +2 -2
  282. package/dist/types/phases/markers/phase.d.ts +3 -10
  283. package/dist/types/phases/scales/phase.d.ts +4 -4
  284. package/dist/types/phases/stage.d.ts +3 -3
  285. package/dist/types/phases/state.d.ts +1 -1
  286. package/dist/types/phases/statistics/phase.d.ts +8 -3
  287. package/dist/types/phases/styles/phase.d.ts +18 -5
  288. package/dist/types/phases/transforms/phase.d.ts +4 -2
  289. package/dist/types/plots/constants.d.ts +3 -17
  290. package/dist/types/plots/correlation/heatmap/props.d.ts +3 -2
  291. package/dist/types/plots/correlation/heatmap/state.d.ts +2 -2
  292. package/dist/types/plots/correlation/scatter/props.d.ts +3 -2
  293. package/dist/types/plots/correlation/scatter/state.d.ts +2 -2
  294. package/dist/types/plots/distribution/box/props.d.ts +28 -2
  295. package/dist/types/plots/distribution/box/state.d.ts +6 -17
  296. package/dist/types/plots/distribution/density/props.d.ts +2 -1
  297. package/dist/types/plots/distribution/density/state.d.ts +2 -2
  298. package/dist/types/plots/distribution/histogram/props.d.ts +16 -2
  299. package/dist/types/plots/distribution/histogram/state.d.ts +2 -2
  300. package/dist/types/plots/distribution/pyramid/props.d.ts +3 -2
  301. package/dist/types/plots/distribution/pyramid/state.d.ts +2 -2
  302. package/dist/types/plots/distribution/violin/props.d.ts +6 -2
  303. package/dist/types/plots/distribution/violin/state.d.ts +2 -2
  304. package/dist/types/plots/evolution/area/props.d.ts +3 -2
  305. package/dist/types/plots/evolution/area/state.d.ts +2 -2
  306. package/dist/types/plots/evolution/line/props.d.ts +3 -2
  307. package/dist/types/plots/evolution/line/state.d.ts +2 -2
  308. package/dist/types/plots/evolution/slope/state.d.ts +2 -2
  309. package/dist/types/plots/evolution/sparkline/state.d.ts +2 -2
  310. package/dist/types/plots/generic/props.d.ts +16 -0
  311. package/dist/types/plots/generic/props.js +1 -0
  312. package/dist/types/plots/generic/state.d.ts +4 -0
  313. package/dist/types/plots/generic/state.js +1 -0
  314. package/dist/types/plots/map/geo/state.d.ts +1 -1
  315. package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +18 -6
  316. package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +2 -2
  317. package/dist/types/plots/props.d.ts +3 -0
  318. package/dist/types/plots/ranking/bar/props.d.ts +3 -2
  319. package/dist/types/plots/ranking/bar/state.d.ts +2 -2
  320. package/dist/types/plots/ranking/bullet/state.d.ts +2 -2
  321. package/dist/types/plots/ranking/cleveland/props.d.ts +3 -2
  322. package/dist/types/plots/ranking/cleveland/state.d.ts +2 -2
  323. package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -2
  324. package/dist/types/plots/ranking/dumbbell/state.d.ts +2 -2
  325. package/dist/types/plots/ranking/forest/props.d.ts +5 -2
  326. package/dist/types/plots/ranking/forest/state.d.ts +2 -2
  327. package/dist/types/plots/ranking/lollipop/props.d.ts +3 -2
  328. package/dist/types/plots/ranking/lollipop/state.d.ts +2 -2
  329. package/docs/architecture.md +9 -9
  330. package/docs/markers.md +36 -6
  331. package/docs/plots/evolution/line.md +1 -1
  332. package/docs/plots/evolution/slope.md +1 -1
  333. package/docs/plots/part-of-a-whole/treemap.md +36 -2
  334. package/docs/plots/ranking/bar.md +1 -0
  335. package/docs/plots/ranking/cleveland.md +1 -1
  336. package/docs/state.md +33 -0
  337. package/docs/styles-and-segments.md +2 -15
  338. package/docs/theming.md +2 -1
  339. package/docs/tooltip-and-hover.md +81 -3
  340. package/docs/value-labels.md +159 -0
  341. package/examples/BarValues.svelte +1 -1
  342. package/examples/LineDates.svelte +1 -1
  343. package/examples/ResponsiveLine.svelte +3 -1
  344. package/examples/TreemapHover.svelte +25 -0
  345. package/examples/ValueLabels.svelte +1 -1
  346. package/llms-full.txt +9 -7
  347. package/llms.txt +3 -1
  348. package/package.json +3 -1
  349. package/dist/markers/utils/BoxLabel.d.ts +0 -58
  350. package/dist/markers/utils/BoxLabel.js +0 -175
  351. package/dist/markers/utils/MarkerLabel.svelte +0 -33
  352. package/dist/markers/utils/MarkerLabel.svelte.d.ts +0 -10
  353. /package/dist/layout/plot/{Plot.svelte → AbstractPlot.svelte} +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * svelteplot's plot context as the marks drawn under a `ScaleFreeMarks` see it: the plot's own state and scales,
3
+ * but marks that never join the plot's list of marks.
4
+ *
5
+ * svelteplot works out a plot's scales from every mark it holds - their data and options - so a mark whose data
6
+ * changes at every move of the pointer (a hover's dot, its rule, its value) lays the whole plot out again each time:
7
+ * every scale built anew from every row, every mark scaled again, the margins measured again. A mark that is only
8
+ * drawn on the plot's scales, never shaping them, can be left out of them.
9
+ *
10
+ * Left out, a mark is in none of the scales' `skip` lists either - the marks whose channel values are already
11
+ * output (a color, a symbol, an opacity) and go through no scale. What these marks draw has no scale of its own to
12
+ * go through, so every such channel of theirs is taken as it is: a hover's colors are its points' own, resolved.
13
+ */
14
+ /** The scales whose channel values a scale-free mark takes as they are, never through the scale. */
15
+ const OUTPUT_SCALES = new Set(['color', 'opacity', 'symbol']);
16
+ /** A `skip` list holding every mark: each of the channel's values is output already. */
17
+ const EVERY_MARK = { has: () => true };
18
+ const SKIP_ALL = { get: () => EVERY_MARK };
19
+ /** A Proxy's `get` reading `target`'s own property (a class getter runs on the target, its private fields there). */
20
+ const read = (target, key) => {
21
+ const value = Reflect.get(target, key);
22
+ return typeof value === 'function' ? value.bind(target) : value;
23
+ };
24
+ const scaleViews = new WeakMap();
25
+ const scalesViews = new WeakMap();
26
+ const stateViews = new WeakMap();
27
+ /** One cached view of `target` per object, so a mark that derives from it sees the same one until it changes. */
28
+ function viewOf(cache, target, make) {
29
+ let view = cache.get(target);
30
+ if (!view) {
31
+ view = make(target);
32
+ cache.set(target, view);
33
+ }
34
+ return view;
35
+ }
36
+ /** A scale whose `skip` holds every mark. */
37
+ const outputScale = (scale) => viewOf(scaleViews, scale, (s) => new Proxy(s, { get: (t, k) => (k === 'skip' ? SKIP_ALL : read(t, k)) }));
38
+ /** The plot's scales, its output scales skipping every mark. */
39
+ const scalesView = (scales) => viewOf(scalesViews, scales, (s) => new Proxy(s, {
40
+ get: (t, k) => {
41
+ const scale = read(t, k);
42
+ return OUTPUT_SCALES.has(k) && scale && typeof scale === 'object'
43
+ ? outputScale(scale)
44
+ : scale;
45
+ }
46
+ }));
47
+ /** The plot's state, read live, with its scales as `scalesView` shows them. */
48
+ const stateView = (state) => viewOf(stateViews, state, (s) => new Proxy(s, {
49
+ get: (t, k) => {
50
+ const value = read(t, k);
51
+ return k === 'scales' && value && typeof value === 'object' ? scalesView(value) : value;
52
+ }
53
+ }));
54
+ export const ScaleFreeContext = {
55
+ /** `parent`, the plot's own context, for marks drawn on its scales that never take part in them. */
56
+ of(parent) {
57
+ return {
58
+ ...parent,
59
+ addMark: () => { },
60
+ removeMark: () => { },
61
+ updateMark: () => { },
62
+ getPlotState: () => stateView(parent.getPlotState())
63
+ };
64
+ }
65
+ };
@@ -0,0 +1,14 @@
1
+ <script lang="ts">
2
+ import { getContext, setContext, type Snippet } from 'svelte';
3
+ import { ScaleFreeContext, type SvelteplotContext } from './ScaleFreeContext';
4
+
5
+ /**
6
+ * Draws its markers on the plot's scales without them taking part in the scales: what changes at every move of
7
+ * the pointer - the hover's markers - never makes svelteplot work out the scales again. See `ScaleFreeContext`.
8
+ */
9
+ let { children }: { children: Snippet } = $props();
10
+
11
+ setContext('svelteplot', ScaleFreeContext.of(getContext<SvelteplotContext>('svelteplot')));
12
+ </script>
13
+
14
+ {@render children()}
@@ -0,0 +1,7 @@
1
+ import { type Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ declare const ScaleFreeMarks: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type ScaleFreeMarks = ReturnType<typeof ScaleFreeMarks>;
7
+ export default ScaleFreeMarks;
@@ -0,0 +1,8 @@
1
+ import type { SvelteplotContext } from './ScaleFreeContext';
2
+ export declare const ScaleGate: {
3
+ /**
4
+ * `parent`, the plot's own context, with each mark handed to the plot behind a `GatedMark`: the scales are
5
+ * worked out again when a mark's rows hold something new, not each time the mark copies them.
6
+ */
7
+ of(parent: SvelteplotContext): SvelteplotContext;
8
+ };
@@ -0,0 +1,95 @@
1
+ import { RowContext } from '../../phases/context/RowContext';
2
+ /**
3
+ * A mark as its plot sees it: the mark itself, but for its rows, which change only when they hold something new.
4
+ *
5
+ * svelteplot works a plot's scales out from every mark's rows, again whenever one of them is a new array. A mark
6
+ * hands it a new array each time it copies its rows (any of its props a new value is enough) and the next time
7
+ * one row's style changes, even a style that no scale reads - a hover's, at every move of the pointer. The copy
8
+ * holds the same rows, so the scales would come out the same: the plot is told of it only when a row differs.
9
+ */
10
+ class GatedMark {
11
+ #mark;
12
+ /** The rows the plot last saw, kept while the mark's are a copy of them. */
13
+ data = $derived.by(() => this.#rows(this.#mark.data));
14
+ #seen;
15
+ constructor(mark) {
16
+ this.#mark = mark;
17
+ }
18
+ get id() {
19
+ return this.#mark.id;
20
+ }
21
+ get type() {
22
+ return this.#mark.type;
23
+ }
24
+ get channels() {
25
+ return this.#mark.channels;
26
+ }
27
+ get scales() {
28
+ return this.#mark.scales;
29
+ }
30
+ get options() {
31
+ return this.#mark.options;
32
+ }
33
+ #rows(rows) {
34
+ const seen = this.#seen;
35
+ if (seen && GatedMark.#sameRows(seen, rows))
36
+ return seen;
37
+ this.#seen = rows;
38
+ return rows;
39
+ }
40
+ /** Whether two lists of rows hold the same values, row by row and field by field. */
41
+ static #sameRows(a, b) {
42
+ if (a === b)
43
+ return true;
44
+ if (a.length !== b.length)
45
+ return false;
46
+ for (let i = 0; i < a.length; i++) {
47
+ if (!GatedMark.#sameRow(a[i], b[i]))
48
+ return false;
49
+ }
50
+ return true;
51
+ }
52
+ /**
53
+ * Whether two rows hold the same values, field by field - but for the context the plot keeps on each row, which
54
+ * no scale reads and which the plot works out anew as it lays its rows out again.
55
+ */
56
+ static #sameRow(a, b) {
57
+ if (a === b)
58
+ return true;
59
+ if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null)
60
+ return false;
61
+ const keys = Reflect.ownKeys(a);
62
+ if (keys.length !== Reflect.ownKeys(b).length)
63
+ return false;
64
+ return keys.every((key) => key === RowContext.key ||
65
+ Object.is(a[key], b[key]));
66
+ }
67
+ }
68
+ export const ScaleGate = {
69
+ /**
70
+ * `parent`, the plot's own context, with each mark handed to the plot behind a `GatedMark`: the scales are
71
+ * worked out again when a mark's rows hold something new, not each time the mark copies them.
72
+ */
73
+ of(parent) {
74
+ // Which gate stands for which mark: bookkeeping no view reads, so nothing has to react to it.
75
+ // eslint-disable-next-line svelte/prefer-svelte-reactivity
76
+ const gates = new Map();
77
+ return {
78
+ ...parent,
79
+ addMark: (mark) => {
80
+ if (gates.has(mark.id))
81
+ return;
82
+ const gate = new GatedMark(mark);
83
+ gates.set(mark.id, gate);
84
+ parent.addMark(gate);
85
+ },
86
+ removeMark: (mark) => {
87
+ const gate = gates.get(mark.id);
88
+ if (!gate)
89
+ return;
90
+ gates.delete(mark.id);
91
+ parent.removeMark(gate);
92
+ }
93
+ };
94
+ }
95
+ };
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { getContext, setContext, type Snippet } from 'svelte';
3
+ import { ScaleGate } from './ScaleGate.svelte';
4
+ import type { SvelteplotContext } from './ScaleFreeContext';
5
+
6
+ /**
7
+ * Hands every mark drawn under it to svelteplot's plot behind a gate: the plot works its scales out again when a
8
+ * mark's rows hold something new, not each time the mark copies them. See `ScaleGate`.
9
+ */
10
+ let { children }: { children: Snippet } = $props();
11
+
12
+ setContext('svelteplot', ScaleGate.of(getContext<SvelteplotContext>('svelteplot')));
13
+ </script>
14
+
15
+ {@render children()}
@@ -0,0 +1,7 @@
1
+ import { type Snippet } from 'svelte';
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ declare const ScaleGateMarks: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type ScaleGateMarks = ReturnType<typeof ScaleGateMarks>;
7
+ export default ScaleGateMarks;
@@ -0,0 +1,52 @@
1
+ import type { HoverDisplayPoint, HoverStrategy } from '../../types/layout/hover';
2
+ import type { HoverLayerMarker, HoverLook, HoverMarkerConfig } from '../../types/markers/common';
3
+ import type { PlotStylesConfig } from '../../types/configuration/styling';
4
+ /** An end of a span: a field of the hovered point's context (else of its row), or a function of the point. */
5
+ type SpanEnd = string | ((point: HoverDisplayPoint) => unknown);
6
+ /**
7
+ * The hover a plot kind draws, and how an author's `hover` marker is laid over it. Its parts - a crosshair rule, a
8
+ * band, a dot, a label - are the markers a kind composes its own hover from; each takes the configuration's
9
+ * `hover` look as it is drawn (see `HoverLayers`).
10
+ */
11
+ export declare class HoverDefaults {
12
+ /** A crosshair along `axis`, at the point under the pointer. */
13
+ static rule(axis: 'x' | 'y'): HoverLayerMarker;
14
+ /** The band of each hovered category along `axis`, or its series' slice of it when it alone is hovered there. */
15
+ static band(axis: 'x' | 'y'): HoverLayerMarker;
16
+ /**
17
+ * The span of the point under the pointer along `axis`, from `from` to `to`, across the whole of the other axis -
18
+ * where a band is no category's: a histogram's bin, an interval on a continuous axis. Each end is a field of the
19
+ * point's context (a bin's `from` and `to`) - else of its row - or a function of the point.
20
+ */
21
+ static span(axis: 'x' | 'y', from: SpanEnd, to: SpanEnd): HoverLayerMarker;
22
+ /** A dot on each hovered point, in its series' color. */
23
+ static dot(): HoverLayerMarker;
24
+ /** Each hovered point's label, in its series' color. */
25
+ static text(): HoverLayerMarker;
26
+ /**
27
+ * A hover that only restyles the shapes, with `active` and `others`: a treemap's tiles, a heatmap's cells. The
28
+ * hovered one is outlined, in the configuration's `hover.active`.
29
+ */
30
+ static shapes(cfg: PlotStylesConfig): HoverLook;
31
+ /** The hovered category's band along `axis`, behind the plot's shapes: a bar's, a box's, a violin's. */
32
+ static behindBand(axis: 'x' | 'y'): HoverLook;
33
+ /** The span of the point under the pointer along `axis`, behind the plot's shapes: a histogram's bin. */
34
+ static behindSpan(axis: 'x' | 'y', from: SpanEnd, to: SpanEnd): HoverLook;
35
+ /**
36
+ * A rule along the value axis at the point under the pointer, and a dot and a label on each point - for a plot
37
+ * whose other axis holds a few positions or categories, where a crosshair along it says little (a slope's, a
38
+ * Cleveland plot's).
39
+ */
40
+ static valueRule(valueAxis: 'x' | 'y'): HoverLook;
41
+ /**
42
+ * The hover every plot kind starts from: a crosshair along each axis its `strategy` matches along (unless
43
+ * `crosshair` is off), and a dot and a label on each hovered point.
44
+ */
45
+ static of(strategy: HoverStrategy, crosshair?: boolean | undefined): HoverLook;
46
+ /**
47
+ * An author's `hover` marker over its kind's `look`: `active` and `others` field by field, `back` and `front`
48
+ * the author's when set (an empty list draws nothing), the kind's otherwise.
49
+ */
50
+ static merge(look: HoverLook, marker: HoverMarkerConfig): HoverMarkerConfig;
51
+ }
52
+ export {};
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The hover a plot kind draws, and how an author's `hover` marker is laid over it. Its parts - a crosshair rule, a
3
+ * band, a dot, a label - are the markers a kind composes its own hover from; each takes the configuration's
4
+ * `hover` look as it is drawn (see `HoverLayers`).
5
+ */
6
+ export class HoverDefaults {
7
+ /** A crosshair along `axis`, at the point under the pointer. */
8
+ static rule(axis) {
9
+ return { type: 'rule', axis, points: 'active' };
10
+ }
11
+ /** The band of each hovered category along `axis`, or its series' slice of it when it alone is hovered there. */
12
+ static band(axis) {
13
+ return { type: 'band', axis };
14
+ }
15
+ /**
16
+ * The span of the point under the pointer along `axis`, from `from` to `to`, across the whole of the other axis -
17
+ * where a band is no category's: a histogram's bin, an interval on a continuous axis. Each end is a field of the
18
+ * point's context (a bin's `from` and `to`) - else of its row - or a function of the point.
19
+ */
20
+ static span(axis, from, to) {
21
+ const end = (side) => typeof side === 'function'
22
+ ? side
23
+ : (point) => point.context?.[side] ?? point.row?.[side];
24
+ return {
25
+ type: 'rect',
26
+ [`${axis}1`]: end(from),
27
+ [`${axis}2`]: end(to),
28
+ points: 'active'
29
+ };
30
+ }
31
+ /** A dot on each hovered point, in its series' color. */
32
+ static dot() {
33
+ return { type: 'dot' };
34
+ }
35
+ /** Each hovered point's label, in its series' color. */
36
+ static text() {
37
+ return { type: 'text' };
38
+ }
39
+ /**
40
+ * A hover that only restyles the shapes, with `active` and `others`: a treemap's tiles, a heatmap's cells. The
41
+ * hovered one is outlined, in the configuration's `hover.active`.
42
+ */
43
+ static shapes(cfg) {
44
+ return { back: [], front: [], active: { ...cfg.hover.active } };
45
+ }
46
+ /** The hovered category's band along `axis`, behind the plot's shapes: a bar's, a box's, a violin's. */
47
+ static behindBand(axis) {
48
+ return { back: [HoverDefaults.band(axis)], front: [] };
49
+ }
50
+ /** The span of the point under the pointer along `axis`, behind the plot's shapes: a histogram's bin. */
51
+ static behindSpan(axis, from, to) {
52
+ return { back: [HoverDefaults.span(axis, from, to)], front: [] };
53
+ }
54
+ /**
55
+ * A rule along the value axis at the point under the pointer, and a dot and a label on each point - for a plot
56
+ * whose other axis holds a few positions or categories, where a crosshair along it says little (a slope's, a
57
+ * Cleveland plot's).
58
+ */
59
+ static valueRule(valueAxis) {
60
+ return {
61
+ back: [HoverDefaults.rule(valueAxis)],
62
+ front: [HoverDefaults.dot(), HoverDefaults.text()]
63
+ };
64
+ }
65
+ /**
66
+ * The hover every plot kind starts from: a crosshair along each axis its `strategy` matches along (unless
67
+ * `crosshair` is off), and a dot and a label on each hovered point.
68
+ */
69
+ static of(strategy, crosshair = true) {
70
+ const axes = strategy === 'x'
71
+ ? ['x']
72
+ : strategy === 'y'
73
+ ? ['y']
74
+ : strategy === 'punctual'
75
+ ? ['x', 'y']
76
+ : [];
77
+ return {
78
+ back: crosshair === false ? [] : axes.map((axis) => HoverDefaults.rule(axis)),
79
+ front: [HoverDefaults.dot(), HoverDefaults.text()]
80
+ };
81
+ }
82
+ /**
83
+ * An author's `hover` marker over its kind's `look`: `active` and `others` field by field, `back` and `front`
84
+ * the author's when set (an empty list draws nothing), the kind's otherwise.
85
+ */
86
+ static merge(look, marker) {
87
+ const styles = (own, base) => own || base ? { ...base, ...own } : undefined;
88
+ return {
89
+ ...marker,
90
+ active: styles(marker.active, look.active),
91
+ others: styles(marker.others, look.others),
92
+ back: marker.back ?? look.back ?? [],
93
+ front: marker.front ?? look.front ?? []
94
+ };
95
+ }
96
+ }
@@ -0,0 +1,35 @@
1
+ import type { BandSlice, HoverDisplayPoint } from '../../types/layout/hover';
2
+ import type { HoverLayerMarker, HoverMarkerConfig } from '../../types/markers/common';
3
+ import type { PlotStylesConfig } from '../../types/configuration/styling';
4
+ type Point = HoverDisplayPoint & {
5
+ row?: unknown;
6
+ };
7
+ /** One marker a hover layer draws, keyed so it keeps its place while the hover moves, and the slice it is moved into. */
8
+ export type HoverLayerPart = {
9
+ key: string;
10
+ marker: HoverLayerMarker;
11
+ slice?: BandSlice;
12
+ };
13
+ /** Some hovered points: of the whole plot, of one series, or of one segment of it, with the one under the pointer. */
14
+ export type HoverPointGroup = {
15
+ key: string;
16
+ points: Point[];
17
+ active: Point | null;
18
+ };
19
+ /**
20
+ * The markers a `hover` marker draws in its `back` and `front` layers, over the hovered points: each with the
21
+ * points as its rows, unless it has `data` of its own, placed at them, and split by the slice of the band a point
22
+ * sits in (a grouped bar's series), to be moved into it - all but a `band`, which takes the slice itself.
23
+ */
24
+ export declare class HoverLayers {
25
+ #private;
26
+ /** `points` with their label written as `marker`'s number fields, or its `format`, ask. */
27
+ static labelled<T extends Point>(points: readonly T[], marker: HoverMarkerConfig, cfg: PlotStylesConfig): T[];
28
+ /**
29
+ * The markers of `marker`'s `layer` over a group of points. A marker over points that sit in a slice of their
30
+ * band is one part per slice, which `slice` names, to be moved into it as it is drawn - the move is in pixels,
31
+ * so it is left to the drawing, which knows the band's width.
32
+ */
33
+ static parts(marker: HoverMarkerConfig, layer: 'back' | 'front', group: HoverPointGroup, cfg: PlotStylesConfig): HoverLayerPart[];
34
+ }
35
+ export {};
@@ -0,0 +1,122 @@
1
+ import { NumberFormat } from '../../utils/NumberFormat';
2
+ /**
3
+ * The markers a `hover` marker draws in its `back` and `front` layers, over the hovered points: each with the
4
+ * points as its rows, unless it has `data` of its own, placed at them, and split by the slice of the band a point
5
+ * sits in (a grouped bar's series), to be moved into it - all but a `band`, which takes the slice itself.
6
+ */
7
+ export class HoverLayers {
8
+ /** The kinds placed by `x` and `y`, which default to the point's. */
9
+ static #PLACED = new Set(['dot', 'text', 'tick', 'image', 'line', 'trail']);
10
+ /** `points` with their label written as `marker`'s number fields, or its `format`, ask. */
11
+ static labelled(points, marker, cfg) {
12
+ const numberOf = NumberFormat.maybe(NumberFormat.displayOf(marker), cfg);
13
+ const number = numberOf ?? NumberFormat.of(undefined, cfg);
14
+ const { format } = marker;
15
+ if (!format && !numberOf)
16
+ return [...points];
17
+ return points.map((point) => {
18
+ if (format)
19
+ return { ...point, label: format(point, number) };
20
+ const value = Number(point.label);
21
+ const written = point.label !== undefined && point.label !== '' && Number.isFinite(value)
22
+ ? numberOf(value)
23
+ : point.label;
24
+ return { ...point, label: written ?? '' };
25
+ });
26
+ }
27
+ /**
28
+ * The markers of `marker`'s `layer` over a group of points. A marker over points that sit in a slice of their
29
+ * band is one part per slice, which `slice` names, to be moved into it as it is drawn - the move is in pixels,
30
+ * so it is left to the drawing, which knows the band's width.
31
+ */
32
+ static parts(marker, layer, group, cfg) {
33
+ if (group.points.length === 0)
34
+ return [];
35
+ return (marker[layer] ?? []).flatMap((nested, i) => {
36
+ const key = `${layer}-${group.key}-${i}`;
37
+ const { points: which, ...own } = nested;
38
+ if (own.data)
39
+ return [{ key, marker: own }];
40
+ const rows = HoverLayers.#pointsOf(which, group);
41
+ if (rows.length === 0)
42
+ return [];
43
+ const placed = HoverLayers.#placed(HoverLayers.#inHover(own, cfg));
44
+ if (own.type === 'band')
45
+ return [{ key, marker: { ...placed, data: rows } }];
46
+ return HoverLayers.#bySlice(rows).map(({ slice, points }) => ({
47
+ key: `${key}-${slice ? `${slice.start},${slice.end}` : ''}`,
48
+ marker: { ...placed, data: points },
49
+ slice
50
+ }));
51
+ });
52
+ }
53
+ /** The points a nested marker draws: all of them, the one under the pointer, or those a function keeps. */
54
+ static #pointsOf(which, group) {
55
+ if (which === 'active')
56
+ return group.active ? [group.active] : [];
57
+ if (typeof which === 'function')
58
+ return group.points.filter(which);
59
+ return group.points;
60
+ }
61
+ /**
62
+ * `marker` with what it leaves unset taken from the hover: a `rule` at each point along its axis and a `band`
63
+ * around it, in its slice; a `text` writes the point's label; each in the configuration's `hover` look (a `rect`
64
+ * too, in its `area` one), and a `dot` and a `text` in the point's series color.
65
+ */
66
+ static #inHover(marker, cfg) {
67
+ const own = marker;
68
+ const color = (point) => point.color ?? 'currentColor';
69
+ switch (marker.type) {
70
+ case 'rule':
71
+ return {
72
+ ...marker,
73
+ value: own.value ?? ((point) => point[marker.axis]),
74
+ styles: { ...cfg.hover.rule, ...own.styles }
75
+ };
76
+ case 'band':
77
+ return {
78
+ ...marker,
79
+ value: own.value ?? ((point) => point[marker.axis]),
80
+ slice: own.slice ?? ((point) => point.areaInset),
81
+ styles: { ...cfg.hover.area, ...own.styles }
82
+ };
83
+ case 'rect':
84
+ return { ...marker, styles: { ...cfg.hover.area, ...own.styles } };
85
+ case 'dot':
86
+ return {
87
+ ...marker,
88
+ styles: { ...cfg.hover.dot, dotFill: color, dotStroke: color, ...own.styles }
89
+ };
90
+ case 'text':
91
+ return {
92
+ ...marker,
93
+ text: own.text ?? ((point) => point.label),
94
+ styles: { ...cfg.hover.font, fill: color, ...own.styles }
95
+ };
96
+ default:
97
+ return marker;
98
+ }
99
+ }
100
+ /** `marker` placed at the points: its own `x` and `y`, else the point's. */
101
+ static #placed(marker) {
102
+ if (!HoverLayers.#PLACED.has(marker.type))
103
+ return marker;
104
+ const own = marker;
105
+ return {
106
+ ...marker,
107
+ x: own.x ?? ((point) => point.x),
108
+ y: own.y ?? ((point) => point.y)
109
+ };
110
+ }
111
+ /** `points` split by the slice of the band each one sits in, in the order they come. */
112
+ static #bySlice(points) {
113
+ const groups = new Map();
114
+ for (const point of points) {
115
+ const slice = point.areaInset;
116
+ const id = slice ? `${slice.start},${slice.end}` : '';
117
+ const group = groups.get(id) ?? groups.set(id, { slice, points: [] }).get(id);
118
+ group.points.push(point);
119
+ }
120
+ return [...groups.values()];
121
+ }
122
+ }
@@ -1,4 +1,4 @@
1
- import type { TooltipContext, TooltipProp } from '../../types/layout/tooltip';
1
+ import type { TooltipProp } from '../../types/layout/tooltip';
2
2
  import type { HoverPoint, HoverStrategy } from '../../types/layout/hover';
3
3
  import { PlotAxes } from '../../phases/data/PlotAxes';
4
4
  import type { HoverConfig, PointMatchingStrategy, TooltipConfig } from '../../types/plots/props';
@@ -31,7 +31,5 @@ export declare class HoverSettings<TRow extends Record<string, unknown>> {
31
31
  defaultStrategy: HoverStrategy;
32
32
  pointMatching?: PointMatchingStrategy;
33
33
  number?: (value: number) => string;
34
- /** What the plot knows of a row, the third argument of the author's own `format` - see {@link TooltipContext}. */
35
- context?: (row: TRow) => TooltipContext;
36
34
  }): HoverConfig<TRow>;
37
35
  }
@@ -1,3 +1,4 @@
1
+ import { RowContext } from '../../phases/context/RowContext';
1
2
  import { PlotAxes } from '../../phases/data/PlotAxes';
2
3
  /**
3
4
  * A plot's hover as its `tooltip` and hover marker set it up: whether it is on,
@@ -33,7 +34,7 @@ export class HoverSettings {
33
34
  }
34
35
  /** A plot's `hover` config; its tooltip reads as `format` unless it sets its own. */
35
36
  static buildConfig(args) {
36
- const { tooltip, format, sort, markers, points, label, defaultStrategy, pointMatching, context } = args;
37
+ const { tooltip, format, sort, markers, points, label, defaultStrategy, pointMatching } = args;
37
38
  const number = args.number ?? String;
38
39
  const settings = new HoverSettings(tooltip, markers, defaultStrategy);
39
40
  return {
@@ -45,7 +46,7 @@ export class HoverSettings {
45
46
  tooltip: tooltip && {
46
47
  ...tooltip,
47
48
  format: tooltip.format
48
- ? (row) => tooltip.format(row, number, context?.(row) ?? {})
49
+ ? (row) => tooltip.format(row, number, RowContext.of(row))
49
50
  : format,
50
51
  ...(sort ? { sort } : {})
51
52
  },
@@ -0,0 +1,56 @@
1
+ import type { HoverShapeStyle } from '../../types/markers/common';
2
+ import type { PlotStylesConfig } from '../../types/configuration/styling';
3
+ type Row = Record<string, unknown>;
4
+ type Role = 'active' | 'other';
5
+ /** What a hover marker sets for the shapes linked to the hover. */
6
+ type ShapeRule = {
7
+ active?: HoverShapeStyle;
8
+ others?: HoverShapeStyle;
9
+ series?: string;
10
+ };
11
+ /** What the plot tells about each row the shapes draw. */
12
+ export type HoverShapesReach = {
13
+ /** How the hover reaches a row - see `PlotHover.roleOf`. */
14
+ roleOf: (row: Row, series?: string) => Role | null;
15
+ /** Whether the legend dims the row's series, which then keeps its own fill and opacities. */
16
+ dimmed: (row: Row) => boolean;
17
+ cfg: PlotStylesConfig;
18
+ };
19
+ /**
20
+ * The look the plot's hover markers give the shapes of every marker linked to the hover (`hover: true` or
21
+ * `'style'`): the hovered ones take `active`, the others `others`, each over the shape's own style. A shape
22
+ * the legend dims keeps its own fill and opacities; one the hover cannot reach (hidden, omitted) is untouched.
23
+ *
24
+ * The marker stays one marker over all its rows, whatever is hovered: each style the hover sets is a function of
25
+ * the row that asks the hover how it reaches it. Moving the pointer then only draws the marker's shapes again in
26
+ * their new look - their rows and options do not change, so svelteplot never works the plot's scales out again
27
+ * (it does so from every mark's data and options, and a style with no scale is never read for them).
28
+ */
29
+ export declare class HoverShapes {
30
+ #private;
31
+ constructor(markers: readonly ({
32
+ type: string;
33
+ } & ShapeRule)[]);
34
+ /** Whether any hover marker restyles shapes. */
35
+ get any(): boolean;
36
+ /** Whether `marker`'s shapes take the hover's styles. */
37
+ static links(marker: object): boolean;
38
+ /**
39
+ * `marker` with each style the hover sets as a function of the row: the hovered rows take `active`, the others
40
+ * `others`, and while nothing is hovered every row its own style. A marker the hover does not style is returned
41
+ * as it is. `rows` are what the marker draws without `data` of its own.
42
+ *
43
+ * The outline `active` sets is not the shape's own: {@link outline} draws it over every shape, whole.
44
+ */
45
+ styled<T extends object>(marker: T, rows: readonly unknown[], reach: HoverShapesReach): T;
46
+ /** Whether any rule outlines the hovered shapes: an `active` that sets one of the stroke's fields. */
47
+ get outlines(): boolean;
48
+ /**
49
+ * The outline of `marker`'s hovered shapes, to draw over every shape of the plot: the marker over its hovered
50
+ * rows only, with no fill, no label and no pointer of its own. A shape is drawn in its marker's order, so its
51
+ * neighbours drawn after it would cover part of its outline - a treemap's tile, a heatmap's cell with no gap.
52
+ * `undefined` when no rule outlines the shapes or nothing of the marker is hovered.
53
+ */
54
+ outline<T extends object>(marker: T, rows: readonly unknown[], reach: HoverShapesReach): T | undefined;
55
+ }
56
+ export {};