@fundar/data-chart-telling 1.16.0 → 1.18.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 (330) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/dist/configuration/ConfigVars.svelte +14 -0
  3. package/dist/configuration/ConfigVars.svelte.d.ts +3 -0
  4. package/dist/configuration/config.svelte.d.ts +5 -0
  5. package/dist/configuration/config.svelte.js +20 -6
  6. package/dist/configuration/themes/dark.js +1 -1
  7. package/dist/configuration/themes/editorial.js +1 -1
  8. package/dist/index.d.ts +12 -4
  9. package/dist/index.js +4 -1
  10. package/dist/layout/base/BasePlotLayout.svelte +1 -1
  11. package/dist/layout/figure/Figure.svelte +5 -12
  12. package/dist/layout/figure/FigureChrome.svelte +2 -10
  13. package/dist/layout/geometry/GeometryLayout.svelte +219 -44
  14. package/dist/layout/hover/HoverDefaults.d.ts +52 -0
  15. package/dist/layout/hover/HoverDefaults.js +96 -0
  16. package/dist/layout/hover/HoverLayers.d.ts +35 -0
  17. package/dist/layout/hover/HoverLayers.js +122 -0
  18. package/dist/layout/hover/HoverSettings.js +4 -1
  19. package/dist/layout/hover/HoverShapes.d.ts +44 -0
  20. package/dist/layout/hover/HoverShapes.js +103 -0
  21. package/dist/layout/hover/PlotHover.svelte.d.ts +18 -0
  22. package/dist/layout/hover/PlotHover.svelte.js +54 -1
  23. package/dist/layout/legend/DisabledStyle.d.ts +1 -1
  24. package/dist/layout/legend/DisabledStyle.js +1 -1
  25. package/dist/layout/legend/DiscreteBadgeItem.svelte +1 -1
  26. package/dist/layout/legend/DiscreteSection.svelte +1 -1
  27. package/dist/layout/legend/LegendState.svelte.d.ts +14 -2
  28. package/dist/layout/legend/LegendState.svelte.js +23 -4
  29. package/dist/layout/legend/LegendText.d.ts +4 -1
  30. package/dist/layout/legend/LegendText.js +7 -1
  31. package/dist/layout/margins/PlotMargins.svelte.d.ts +2 -2
  32. package/dist/layout/margins/PlotMargins.svelte.js +2 -2
  33. package/dist/layout/plot/Core.svelte +2 -2
  34. package/dist/layout/plot/Plot.svelte +4 -2
  35. package/dist/layout/plot/Plot.svelte.d.ts +2 -1
  36. package/dist/layout/plot/PublicPlotContext.d.ts +6 -0
  37. package/dist/layout/plot/PublicPlotContext.js +8 -0
  38. package/dist/layout/scales/ScalesLayout.svelte +1 -1
  39. package/dist/layout/styles/ValueLabels.d.ts +43 -4
  40. package/dist/layout/styles/ValueLabels.js +87 -19
  41. package/dist/layout/timeline/Timeline.svelte +5 -1
  42. package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -9
  43. package/dist/layout/tooltip/TooltipState.svelte.js +28 -29
  44. package/dist/markers/MarkerKinds.d.ts +5 -0
  45. package/dist/markers/MarkerKinds.js +1 -0
  46. package/dist/markers/area/AreaMarker.svelte +3 -0
  47. package/dist/markers/arrow/ArrowMarker.svelte +9 -5
  48. package/dist/markers/band/BandMarker.svelte +74 -0
  49. package/dist/markers/band/BandMarker.svelte.d.ts +7 -0
  50. package/dist/markers/band/Bands.d.ts +16 -0
  51. package/dist/markers/band/Bands.js +48 -0
  52. package/dist/markers/bar/BarMarker.svelte +50 -96
  53. package/dist/markers/bollinger/BollingerMarker.svelte +3 -0
  54. package/dist/markers/box/BoxMarker.svelte +3 -1
  55. package/dist/markers/cell/CellMarker.svelte +11 -7
  56. package/dist/markers/contour/ContourMarker.svelte +3 -0
  57. package/dist/markers/delaunay/DelaunayLinkMarker.svelte +9 -5
  58. package/dist/markers/delaunay/DelaunayMeshMarker.svelte +3 -0
  59. package/dist/markers/density/DensityMarker.svelte +3 -0
  60. package/dist/markers/difference/DifferenceMarker.svelte +3 -0
  61. package/dist/markers/dot/DotMarker.svelte +11 -6
  62. package/dist/markers/geo/GraticuleMarker.svelte +3 -0
  63. package/dist/markers/geo/SphereMarker.svelte +3 -0
  64. package/dist/markers/hover/HoverMarker.svelte +7 -249
  65. package/dist/markers/hover/HoverMarker.svelte.d.ts +4 -27
  66. package/dist/markers/hull/HullMarker.svelte +3 -0
  67. package/dist/markers/image/ImageMarker.svelte +3 -0
  68. package/dist/markers/line/LineMarker.svelte +3 -0
  69. package/dist/markers/link/LinkMarker.svelte +3 -0
  70. package/dist/markers/raster/RasterMarker.svelte +3 -0
  71. package/dist/markers/rect/RectMarker.svelte +25 -17
  72. package/dist/markers/regression/RegressionMarker.svelte +3 -0
  73. package/dist/markers/rule/RuleMarker.svelte +15 -5
  74. package/dist/markers/text/TextFit.d.ts +44 -0
  75. package/dist/markers/text/TextFit.js +86 -0
  76. package/dist/markers/text/TextMarker.svelte +186 -90
  77. package/dist/markers/text/TextMarker.svelte.d.ts +2 -0
  78. package/dist/markers/tick/TickMarker.svelte +9 -3
  79. package/dist/markers/trail/TrailMarker.svelte +3 -0
  80. package/dist/markers/utils/BoxLabel.d.ts +58 -0
  81. package/dist/markers/utils/BoxLabel.js +175 -0
  82. package/dist/markers/utils/MarkerEvents.d.ts +23 -0
  83. package/dist/markers/utils/MarkerEvents.js +44 -0
  84. package/dist/markers/utils/MarkerLabel.svelte +33 -0
  85. package/dist/markers/utils/MarkerLabel.svelte.d.ts +10 -0
  86. package/dist/markers/utils/PointPixel.d.ts +37 -0
  87. package/dist/markers/utils/PointPixel.js +44 -0
  88. package/dist/markers/utils/RowStroke.d.ts +9 -21
  89. package/dist/markers/utils/RowStroke.js +10 -21
  90. package/dist/markers/utils/RowStyle.d.ts +26 -0
  91. package/dist/markers/utils/RowStyle.js +55 -0
  92. package/dist/markers/vector/VectorMarker.svelte +3 -0
  93. package/dist/markers/voronoi/VoronoiMarker.svelte +9 -5
  94. package/dist/markers/voronoi/VoronoiMeshMarker.svelte +3 -0
  95. package/dist/markers/waffle/WaffleMarker.svelte +9 -5
  96. package/dist/phases/Pipeline.d.ts +10 -8
  97. package/dist/phases/Pipeline.js +13 -9
  98. package/dist/phases/context/ContextPhase.d.ts +22 -0
  99. package/dist/phases/context/ContextPhase.js +23 -0
  100. package/dist/phases/context/RowContext.d.ts +35 -0
  101. package/dist/phases/context/RowContext.js +95 -0
  102. package/dist/phases/data/DataPhase.d.ts +4 -4
  103. package/dist/phases/data/DataPhase.js +53 -12
  104. package/dist/phases/hover/HoverPhase.d.ts +6 -7
  105. package/dist/phases/hover/HoverPhase.js +28 -15
  106. package/dist/phases/mapping/MappingPhase.d.ts +4 -4
  107. package/dist/phases/mapping/MappingPhase.js +4 -3
  108. package/dist/phases/markers/MarkerStyles.d.ts +26 -0
  109. package/dist/phases/markers/MarkerStyles.js +126 -0
  110. package/dist/phases/markers/MarkersPhase.d.ts +5 -5
  111. package/dist/phases/markers/MarkersPhase.js +8 -6
  112. package/dist/phases/scales/ScalesPhase.d.ts +4 -4
  113. package/dist/phases/scales/ScalesPhase.js +4 -4
  114. package/dist/phases/sharedScales/SharedScalesPhase.d.ts +2 -2
  115. package/dist/phases/sharedScales/SharedScalesPhase.js +2 -2
  116. package/dist/phases/statistics/MarkerGrouping.d.ts +0 -9
  117. package/dist/phases/statistics/MarkerGrouping.js +0 -16
  118. package/dist/phases/statistics/StatisticsPhase.js +1 -1
  119. package/dist/phases/styles/StylesPhase.d.ts +3 -3
  120. package/dist/phases/styles/StylesPhase.js +2 -2
  121. package/dist/phases/tooltip/TooltipPhase.d.ts +4 -4
  122. package/dist/phases/tooltip/TooltipPhase.js +10 -7
  123. package/dist/phases/transforms/Transforms.js +3 -1
  124. package/dist/phases/transforms/TransformsPhase.d.ts +3 -3
  125. package/dist/phases/transforms/TransformsPhase.js +60 -6
  126. package/dist/phases/transforms/methods/TreemapTransform.d.ts +28 -0
  127. package/dist/phases/transforms/methods/TreemapTransform.js +119 -0
  128. package/dist/plots/correlation/heatmap/defaults.d.ts +2 -2
  129. package/dist/plots/correlation/heatmap/defaults.js +23 -8
  130. package/dist/plots/correlation/heatmap/markers.d.ts +2 -10
  131. package/dist/plots/correlation/heatmap/markers.js +11 -37
  132. package/dist/plots/correlation/scatter/defaults.d.ts +2 -2
  133. package/dist/plots/correlation/scatter/defaults.js +9 -3
  134. package/dist/plots/correlation/scatter/markers.d.ts +3 -3
  135. package/dist/plots/correlation/scatter/markers.js +6 -5
  136. package/dist/plots/distribution/box/BoxSummaries.d.ts +17 -8
  137. package/dist/plots/distribution/box/BoxSummaries.js +90 -40
  138. package/dist/plots/distribution/box/defaults.d.ts +2 -2
  139. package/dist/plots/distribution/box/defaults.js +9 -6
  140. package/dist/plots/distribution/box/markers.d.ts +2 -2
  141. package/dist/plots/distribution/box/markers.js +3 -3
  142. package/dist/plots/distribution/density/defaults.d.ts +2 -2
  143. package/dist/plots/distribution/density/defaults.js +17 -1
  144. package/dist/plots/distribution/density/markers.d.ts +2 -2
  145. package/dist/plots/distribution/density/markers.js +4 -4
  146. package/dist/plots/distribution/histogram/defaults.d.ts +2 -2
  147. package/dist/plots/distribution/histogram/defaults.js +22 -27
  148. package/dist/plots/distribution/histogram/markers.d.ts +3 -12
  149. package/dist/plots/distribution/histogram/markers.js +21 -62
  150. package/dist/plots/distribution/pyramid/defaults.d.ts +2 -2
  151. package/dist/plots/distribution/pyramid/defaults.js +7 -4
  152. package/dist/plots/distribution/pyramid/markers.d.ts +2 -12
  153. package/dist/plots/distribution/pyramid/markers.js +16 -66
  154. package/dist/plots/distribution/violin/defaults.d.ts +2 -2
  155. package/dist/plots/distribution/violin/defaults.js +9 -7
  156. package/dist/plots/distribution/violin/markers.d.ts +2 -2
  157. package/dist/plots/distribution/violin/markers.js +4 -4
  158. package/dist/plots/evolution/area/defaults.d.ts +2 -2
  159. package/dist/plots/evolution/area/defaults.js +1 -1
  160. package/dist/plots/evolution/area/markers.d.ts +2 -2
  161. package/dist/plots/evolution/area/markers.js +4 -4
  162. package/dist/plots/evolution/line/defaults.d.ts +2 -2
  163. package/dist/plots/evolution/line/defaults.js +1 -1
  164. package/dist/plots/evolution/line/markers.d.ts +2 -2
  165. package/dist/plots/evolution/line/markers.js +3 -3
  166. package/dist/plots/evolution/slope/defaults.d.ts +2 -2
  167. package/dist/plots/evolution/slope/defaults.js +8 -4
  168. package/dist/plots/evolution/slope/markers.d.ts +2 -2
  169. package/dist/plots/evolution/slope/markers.js +3 -3
  170. package/dist/plots/evolution/sparkline/defaults.d.ts +2 -2
  171. package/dist/plots/evolution/sparkline/defaults.js +5 -2
  172. package/dist/plots/evolution/sparkline/markers.d.ts +2 -2
  173. package/dist/plots/evolution/sparkline/markers.js +3 -3
  174. package/dist/plots/map/geo/Core.svelte +3 -3
  175. package/dist/plots/map/geo/defaults.d.ts +2 -2
  176. package/dist/plots/map/geo/phases/data.d.ts +1 -1
  177. package/dist/plots/map/geo/phases/data.js +1 -1
  178. package/dist/plots/map/geo/phases/hover.d.ts +2 -2
  179. package/dist/plots/map/geo/phases/hover.js +3 -3
  180. package/dist/plots/map/geo/phases/markers.d.ts +2 -2
  181. package/dist/plots/map/geo/phases/markers.js +5 -4
  182. package/dist/plots/map/geo/phases/scales.d.ts +2 -2
  183. package/dist/plots/map/geo/phases/scales.js +2 -2
  184. package/dist/plots/part-of-a-whole/treemap/Plot.svelte +47 -0
  185. package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +26 -0
  186. package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +10 -0
  187. package/dist/plots/part-of-a-whole/treemap/defaults.js +183 -0
  188. package/dist/plots/ranking/bar/defaults.d.ts +2 -2
  189. package/dist/plots/ranking/bar/defaults.js +15 -9
  190. package/dist/plots/ranking/bar/markers.d.ts +4 -14
  191. package/dist/plots/ranking/bar/markers.js +45 -86
  192. package/dist/plots/ranking/bullet/defaults.d.ts +2 -2
  193. package/dist/plots/ranking/bullet/defaults.js +4 -4
  194. package/dist/plots/ranking/bullet/markers.d.ts +3 -3
  195. package/dist/plots/ranking/bullet/markers.js +11 -12
  196. package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +3 -3
  197. package/dist/plots/ranking/cleveland/ClevelandMarkers.js +28 -23
  198. package/dist/plots/ranking/cleveland/defaults.d.ts +2 -2
  199. package/dist/plots/ranking/cleveland/defaults.js +7 -4
  200. package/dist/plots/ranking/dumbbell/defaults.d.ts +2 -2
  201. package/dist/plots/ranking/forest/defaults.d.ts +2 -2
  202. package/dist/plots/ranking/lollipop/defaults.d.ts +2 -2
  203. package/dist/types/configuration/styling.d.ts +31 -2
  204. package/dist/types/layout/context.d.ts +21 -0
  205. package/dist/types/layout/context.js +1 -0
  206. package/dist/types/layout/hover.d.ts +3 -0
  207. package/dist/types/layout/legend.d.ts +8 -1
  208. package/dist/types/layout/mapping.d.ts +12 -3
  209. package/dist/types/layout/scales.d.ts +6 -0
  210. package/dist/types/layout/styles/values.d.ts +8 -2
  211. package/dist/types/layout/tooltip.d.ts +11 -4
  212. package/dist/types/markers/axis/arrow.d.ts +2 -8
  213. package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
  214. package/dist/types/markers/axis/band.d.ts +24 -0
  215. package/dist/types/markers/axis/band.js +1 -0
  216. package/dist/types/markers/axis/bar.d.ts +6 -10
  217. package/dist/types/markers/axis/cell.d.ts +5 -5
  218. package/dist/types/markers/axis/delaunayLink.d.ts +2 -2
  219. package/dist/types/markers/axis/hover.d.ts +60 -15
  220. package/dist/types/markers/axis/rect.d.ts +4 -8
  221. package/dist/types/markers/axis/rule.d.ts +2 -16
  222. package/dist/types/markers/axis/tick.d.ts +2 -2
  223. package/dist/types/markers/axis/voronoi.d.ts +2 -2
  224. package/dist/types/markers/axis/waffle.d.ts +4 -3
  225. package/dist/types/markers/basic/dot.d.ts +2 -2
  226. package/dist/types/markers/basic/text.d.ts +56 -14
  227. package/dist/types/markers/channels/commonMarkerConfig.d.ts +8 -1
  228. package/dist/types/markers/channels/commonMarkerConfigWithArea.d.ts +1 -2
  229. package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +10 -0
  230. package/dist/types/markers/channels/commonMarkerConfigWithLabel.js +1 -0
  231. package/dist/types/markers/channels/commonMarkerEvents.d.ts +17 -0
  232. package/dist/types/markers/channels/commonMarkerEvents.js +13 -0
  233. package/dist/types/markers/common.d.ts +1 -0
  234. package/dist/types/markers/common.js +1 -0
  235. package/dist/types/markers/geo/contour.d.ts +2 -1
  236. package/dist/types/markers/geo/graticule.d.ts +2 -1
  237. package/dist/types/markers/geo/link.d.ts +2 -1
  238. package/dist/types/markers/geo/sphere.d.ts +2 -1
  239. package/dist/types/markers/geo/vector.d.ts +2 -1
  240. package/dist/types/phases/context/phase.d.ts +7 -0
  241. package/dist/types/phases/context/phase.js +1 -0
  242. package/dist/types/phases/data/phase.d.ts +7 -2
  243. package/dist/types/phases/hover/phase.d.ts +10 -5
  244. package/dist/types/phases/index.d.ts +2 -1
  245. package/dist/types/phases/kind.d.ts +11 -8
  246. package/dist/types/phases/mapping/phase.d.ts +2 -2
  247. package/dist/types/phases/markers/phase.d.ts +3 -3
  248. package/dist/types/phases/scales/phase.d.ts +4 -4
  249. package/dist/types/phases/stage.d.ts +3 -3
  250. package/dist/types/phases/state.d.ts +8 -1
  251. package/dist/types/phases/statistics/phase.d.ts +2 -1
  252. package/dist/types/phases/styles/phase.d.ts +3 -2
  253. package/dist/types/phases/transforms/phase.d.ts +13 -2
  254. package/dist/types/plots/constants.d.ts +17 -19
  255. package/dist/types/plots/correlation/heatmap/props.d.ts +3 -3
  256. package/dist/types/plots/correlation/heatmap/state.d.ts +2 -2
  257. package/dist/types/plots/correlation/scatter/props.d.ts +3 -3
  258. package/dist/types/plots/correlation/scatter/state.d.ts +2 -2
  259. package/dist/types/plots/data/common.d.ts +19 -6
  260. package/dist/types/plots/data/geo.d.ts +1 -1
  261. package/dist/types/plots/distribution/box/props.d.ts +25 -3
  262. package/dist/types/plots/distribution/box/state.d.ts +6 -17
  263. package/dist/types/plots/distribution/density/props.d.ts +3 -11
  264. package/dist/types/plots/distribution/density/state.d.ts +2 -2
  265. package/dist/types/plots/distribution/histogram/props.d.ts +16 -11
  266. package/dist/types/plots/distribution/histogram/state.d.ts +2 -2
  267. package/dist/types/plots/distribution/pyramid/props.d.ts +3 -3
  268. package/dist/types/plots/distribution/pyramid/state.d.ts +2 -2
  269. package/dist/types/plots/distribution/violin/props.d.ts +4 -3
  270. package/dist/types/plots/distribution/violin/state.d.ts +2 -2
  271. package/dist/types/plots/evolution/area/props.d.ts +3 -3
  272. package/dist/types/plots/evolution/area/state.d.ts +2 -2
  273. package/dist/types/plots/evolution/line/props.d.ts +3 -3
  274. package/dist/types/plots/evolution/line/state.d.ts +2 -2
  275. package/dist/types/plots/evolution/slope/state.d.ts +2 -2
  276. package/dist/types/plots/evolution/sparkline/state.d.ts +2 -2
  277. package/dist/types/plots/map/geo/state.d.ts +1 -1
  278. package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +29 -0
  279. package/dist/types/plots/part-of-a-whole/treemap/props.js +1 -0
  280. package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +6 -0
  281. package/dist/types/plots/part-of-a-whole/treemap/state.js +1 -0
  282. package/dist/types/plots/props.d.ts +10 -4
  283. package/dist/types/plots/ranking/bar/props.d.ts +3 -3
  284. package/dist/types/plots/ranking/bar/state.d.ts +2 -2
  285. package/dist/types/plots/ranking/bullet/state.d.ts +2 -2
  286. package/dist/types/plots/ranking/cleveland/props.d.ts +3 -3
  287. package/dist/types/plots/ranking/cleveland/state.d.ts +2 -2
  288. package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -3
  289. package/dist/types/plots/ranking/dumbbell/state.d.ts +2 -2
  290. package/dist/types/plots/ranking/forest/props.d.ts +3 -3
  291. package/dist/types/plots/ranking/forest/state.d.ts +2 -2
  292. package/dist/types/plots/ranking/lollipop/props.d.ts +3 -3
  293. package/dist/types/plots/ranking/lollipop/state.d.ts +2 -2
  294. package/dist/types/plots/styling.d.ts +24 -0
  295. package/dist/types/transforms/index.d.ts +3 -1
  296. package/dist/types/transforms/treemap.d.ts +32 -0
  297. package/dist/types/transforms/treemap.js +5 -0
  298. package/dist/utils/color/ColorTones.d.ts +19 -0
  299. package/dist/utils/color/ColorTones.js +64 -0
  300. package/dist/utils/color/CssColor.d.ts +14 -5
  301. package/dist/utils/color/CssColor.js +69 -27
  302. package/dist/utils/color/index.d.ts +4 -0
  303. package/dist/utils/color/index.js +4 -0
  304. package/dist/utils/grouping.d.ts +18 -1
  305. package/dist/utils/grouping.js +31 -0
  306. package/docs/concepts.md +3 -2
  307. package/docs/legend.md +8 -5
  308. package/docs/markers.md +110 -28
  309. package/docs/plots/evolution/line.md +1 -1
  310. package/docs/plots/evolution/slope.md +1 -1
  311. package/docs/plots/part-of-a-whole/treemap.md +103 -0
  312. package/docs/plots/ranking/bar.md +2 -1
  313. package/docs/plots/ranking/cleveland.md +1 -1
  314. package/docs/plots.md +21 -20
  315. package/docs/scales.md +3 -0
  316. package/docs/state.md +34 -1
  317. package/docs/styles-and-segments.md +20 -19
  318. package/docs/theming.md +6 -12
  319. package/docs/tooltip-and-hover.md +81 -3
  320. package/docs/transforms-and-statistics.md +17 -16
  321. package/examples/LineDates.svelte +1 -1
  322. package/examples/ResponsiveLine.svelte +3 -1
  323. package/examples/Treemap.svelte +13 -0
  324. package/examples/TreemapHover.svelte +25 -0
  325. package/examples/ValueLabels.svelte +1 -1
  326. package/examples/datasets/economic-activity.ts +40 -0
  327. package/examples/datasets/index.ts +1 -0
  328. package/llms-full.txt +11 -9
  329. package/llms.txt +4 -1
  330. package/package.json +3 -1
@@ -25,8 +25,8 @@ export class ClevelandMarkers {
25
25
  warned.clear();
26
26
  }
27
27
  /** The plot's connectors, then its dots, which draw on top of them. */
28
- marks = (state, ctx) => {
29
- const { cfg, interaction } = ctx;
28
+ marks = (state, env) => {
29
+ const { cfg, interaction } = env;
30
30
  const style = cfg[this.#options.config];
31
31
  const { isHorizontal } = ClevelandMarkers.#geometry(state);
32
32
  const ranges = ClevelandRanges.of(state, this.#options.fromBaseline ?? false, ClevelandConnector.ends(state), this.#options.interval ?? false);
@@ -45,7 +45,7 @@ export class ClevelandMarkers {
45
45
  // color and its segment's style; the legend dims it with the series.
46
46
  const size = state.channels?.r;
47
47
  const dotRadius = typeof size === 'number' ? size : style.dotRadius;
48
- const neutral = style.connectorColor ?? cfg.axis.color;
48
+ const neutral = style.connectorColor ?? 'currentColor';
49
49
  // `styles.stroke` is the connectors' look below everything the author sets for them: a segment's
50
50
  // stroke wins over `styles.connector`, which wins over it. A function of the series styles only
51
51
  // the connector of a lone dot, which has a series; the connector of several dots has none.
@@ -135,10 +135,12 @@ export class ClevelandMarkers {
135
135
  data: group.flatMap((look) => look.rows),
136
136
  value: 'category',
137
137
  ...(isHorizontal ? { x1: 'from', x2: 'to' } : { y1: 'from', y2: 'to' }),
138
- stroke: 'stroke',
139
- strokeWidth: 'strokeWidth',
140
- strokeOpacity: 'strokeOpacity',
141
- ...(Object.keys(pattern).length > 0 ? { styles: pattern } : {})
138
+ styles: {
139
+ ...pattern,
140
+ stroke: 'stroke',
141
+ strokeWidth: 'strokeWidth',
142
+ strokeOpacity: 'strokeOpacity'
143
+ }
142
144
  }));
143
145
  // The arrows, one marker per pattern like the lines, each from its `from` dot to its `to` dot.
144
146
  const head = connector.arrow;
@@ -157,12 +159,14 @@ export class ClevelandMarkers {
157
159
  headLength: head.headLength,
158
160
  headAngle: head.headAngle,
159
161
  // The shaft starts and ends at the edge of its dots, not under them.
160
- insetStart: dotRadius,
161
- insetEnd: dotRadius,
162
- stroke: 'stroke',
163
- strokeWidth: 'strokeWidth',
164
- strokeOpacity: 'strokeOpacity',
165
- ...(Object.keys(pattern).length > 0 ? { styles: pattern } : {})
162
+ styles: {
163
+ ...pattern,
164
+ insetStart: dotRadius,
165
+ insetEnd: dotRadius,
166
+ stroke: 'stroke',
167
+ strokeWidth: 'strokeWidth',
168
+ strokeOpacity: 'strokeOpacity'
169
+ }
166
170
  }
167
171
  ];
168
172
  });
@@ -183,6 +187,7 @@ export class ClevelandMarkers {
183
187
  type: 'dot',
184
188
  series: name,
185
189
  data: segment.data,
190
+ hover: 'style',
186
191
  ...(isHorizontal ? { x: value, y: category } : { x: category, y: value }),
187
192
  r,
188
193
  styles: {
@@ -202,7 +207,7 @@ export class ClevelandMarkers {
202
207
  ...caps,
203
208
  ...arrows,
204
209
  ...dots,
205
- ...this.#connectorLabels(state, ctx, connector, looks, isHorizontal)
210
+ ...this.#connectorLabels(state, env, connector, looks, isHorizontal)
206
211
  ];
207
212
  };
208
213
  /** The dash, cap and join a connector is drawn with, leaving out what is not set. */
@@ -239,7 +244,7 @@ export class ClevelandMarkers {
239
244
  }));
240
245
  }
241
246
  /** The label on each connector, when `styles.connector.label` asks for one: written at its middle, beside it or on it. */
242
- #connectorLabels(state, ctx, connector, looks, isHorizontal) {
247
+ #connectorLabels(state, env, connector, looks, isHorizontal) {
243
248
  const label = connector.label;
244
249
  if (!label)
245
250
  return [];
@@ -251,7 +256,7 @@ export class ClevelandMarkers {
251
256
  return [];
252
257
  const font = label.fontStyle;
253
258
  // Beside a connector: clear of half its thickest, and a few px.
254
- const clear = Math.max(...data.map((row) => Number(row.strokeWidth))) / 2 + ctx.cfg.connector.labelGap;
259
+ const clear = Math.max(...data.map((row) => Number(row.strokeWidth))) / 2 + env.cfg.connector.labelGap;
255
260
  const inside = label.anchor === 'middle';
256
261
  const at = inside
257
262
  ? { dx: 0, dy: 0, textAnchor: 'middle', lineAnchor: 'middle' }
@@ -266,8 +271,8 @@ export class ClevelandMarkers {
266
271
  text: 'text',
267
272
  styles: {
268
273
  ...font,
269
- fill: font?.fill ?? ctx.cfg.axis.color,
270
- fontSize: font?.fontSize ?? ctx.cfg.connector.labelFontSize,
274
+ fill: font?.fill ?? 'currentColor',
275
+ fontSize: font?.fontSize ?? env.cfg.connector.labelFontSize,
271
276
  dx: font?.dx ?? at.dx,
272
277
  dy: font?.dy ?? at.dy,
273
278
  textAnchor: font?.textAnchor && font.textAnchor !== 'outside' ? font.textAnchor : at.textAnchor,
@@ -282,7 +287,7 @@ export class ClevelandMarkers {
282
287
  * of it), past the bottom end (below, or left of it) and, for the dots
283
288
  * between, beside it - and per series, when they take their series' color.
284
289
  */
285
- valueLabels = (labels, state, ctx) => {
290
+ valueLabels = (labels, state, env) => {
286
291
  if (!state.processedData?.data.length)
287
292
  return [];
288
293
  const { isHorizontal } = ClevelandMarkers.#geometry(state);
@@ -290,7 +295,7 @@ export class ClevelandMarkers {
290
295
  const { font, format } = labels;
291
296
  const read = ValueLabels.valueOf(state);
292
297
  const valueOf = ProcessedPositions.of(state.processedData, PlotAxes.valueOf(state))[PlotAxes.valueOf(state)];
293
- const gap = labels.offset(isHorizontal ? 'x' : 'y', ctx.cfg[this.#options.config].labelGap);
298
+ const gap = labels.offset(isHorizontal ? 'x' : 'y', env.cfg[this.#options.config].labelGap);
294
299
  const nameOf = (d) => String(d[SERIES_KEY]);
295
300
  const picked = this.#picked(state);
296
301
  // Where a label sits from its dot, by role: along the range (past an end) or across it (between).
@@ -308,7 +313,7 @@ export class ClevelandMarkers {
308
313
  // What fills the labels of a series: the one fill all share, its own color, or the axis'.
309
314
  const fillOf = (series) => labels.fill ??
310
315
  (labels.color === 'series' ? state.colorForSeries(series) : undefined) ??
311
- ctx.cfg.axis.color;
316
+ 'currentColor';
312
317
  const names = labels.color === 'series' && !labels.fill
313
318
  ? (state.resolvedSeries ?? []).map((s) => s.name)
314
319
  : [''];
@@ -325,7 +330,7 @@ export class ClevelandMarkers {
325
330
  type: 'text',
326
331
  data,
327
332
  ...(isHorizontal ? { x: value, y: category } : { x: category, y: value }),
328
- text: (d) => format(Number(read(d) ?? valueOf(d)), nameOf(d), d),
333
+ text: (d) => format(Number(read(d) ?? valueOf(d)), d, nameOf(d)),
329
334
  styles: {
330
335
  ...font,
331
336
  fill: fillOf(name),
@@ -354,7 +359,7 @@ export class ClevelandMarkers {
354
359
  return [labels.edgeBox('0', { x: 'middle', y: 'before' }, at, ['top'])];
355
360
  }
356
361
  const at = { x: labels.offset('x', gap) };
357
- const texts = new Set(top.map(({ dot }) => labels.format(dot.value, dot.series, dot.row)));
362
+ const texts = new Set(top.map(({ dot }) => labels.format(dot.value, dot.row, dot.series)));
358
363
  return [...texts].map((text) => labels.edgeBox(text, { x: 'after', y: 'middle' }, at, ['right']));
359
364
  };
360
365
  /**
@@ -1,5 +1,5 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotCtx } from '../../../types/plots/ranking/cleveland/state';
2
+ import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotEnv } from '../../../types/plots/ranking/cleveland/state';
3
3
  /**
4
4
  * ClevelandPlot on the shared pipeline, and the base of its wrappers: per
5
5
  * category along one category axis - `x`, or `y` for sideways rows, as the
@@ -10,4 +10,4 @@ import type { ClevelandOptions, ClevelandPlotState, ClevelandPlotCtx } from '../
10
10
  * what it checks about the series before drawing. Its plot defaults to hover
11
11
  * along the category axis.
12
12
  */
13
- export declare function buildClevelandDefaults<TData extends Record<string, unknown>>(options?: ClevelandOptions): AxisPlotDefaults<ClevelandPlotState<TData>, ClevelandPlotCtx>;
13
+ export declare function buildClevelandDefaults<TData extends Record<string, unknown>>(options?: ClevelandOptions): AxisPlotDefaults<ClevelandPlotState<TData>, ClevelandPlotEnv>;
@@ -1,4 +1,5 @@
1
1
  import { ClevelandMarkers } from './ClevelandMarkers';
2
+ import { HoverDefaults } from '../../../layout/hover/HoverDefaults';
2
3
  import { ClevelandRanges } from './ClevelandRanges';
3
4
  import { NiceTicks } from '../../../layout/scales/NiceTicks';
4
5
  import { PlotAxes } from '../../../phases/data/PlotAxes';
@@ -53,16 +54,18 @@ export function buildClevelandDefaults(options = { name: 'ClevelandPlot', config
53
54
  fit: options.interval
54
55
  ? (state) => fitInterval(state, options.fromBaseline ?? false)
55
56
  : undefined,
56
- defaults: (_state, ctx) => ({
57
+ defaults: (_state, env) => ({
57
58
  category: {
58
- paddingInner: ctx.cfg[options.config].paddingInner,
59
- paddingOuter: ctx.cfg[options.config].paddingOuter
59
+ paddingInner: env.cfg[options.config].paddingInner,
60
+ paddingOuter: env.cfg[options.config].paddingOuter
60
61
  }
61
62
  })
62
63
  },
63
64
  // A dot is labelled by what its category's dots say: the first, the highest... of each.
64
65
  transforms: { labels: { group: 'category', skip: ClevelandRanges.skipGaps } },
65
66
  styles: { values: { reach: markers.reach } },
66
- markers: { marks: markers.marks, valueLabels: markers.valueLabels }
67
+ markers: { marks: markers.marks, valueLabels: markers.valueLabels },
68
+ // A rule along the value axis at the hovered dot, and a dot and a label on each one of its category.
69
+ hover: { marker: (state) => HoverDefaults.valueRule(PlotAxes.valueOf(state)) }
67
70
  };
68
71
  }
@@ -1,9 +1,9 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { DumbbellPlotState, DumbbellPlotCtx } from '../../../types/plots/ranking/dumbbell/state';
2
+ import type { DumbbellPlotState, DumbbellPlotEnv } from '../../../types/plots/ranking/dumbbell/state';
3
3
  /**
4
4
  * DumbbellPlot on the shared pipeline: a ClevelandPlot of exactly two series,
5
5
  * so every category is two dots joined by a connector - the change, or the gap,
6
6
  * between them. It warns when it has another number of series, which
7
7
  * `LollipopPlot` (one) and `ClevelandPlot` (any) are for.
8
8
  */
9
- export declare function buildDumbbellDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DumbbellPlotState<TData>, DumbbellPlotCtx>;
9
+ export declare function buildDumbbellDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DumbbellPlotState<TData>, DumbbellPlotEnv>;
@@ -1,5 +1,5 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { ForestPlotState, ForestPlotCtx } from '../../../types/plots/ranking/forest/state';
2
+ import type { ForestPlotState, ForestPlotEnv } from '../../../types/plots/ranking/forest/state';
3
3
  /**
4
4
  * ForestPlot on the shared pipeline: a ClevelandPlot whose dot is an estimate
5
5
  * and whose stem is its interval - each row's `lower` and `upper`, or `error`
@@ -8,4 +8,4 @@ import type { ForestPlotState, ForestPlotCtx } from '../../../types/plots/rankin
8
8
  * for - or `facet`, to compare the series side by side. The value axis fits the
9
9
  * intervals' ends.
10
10
  */
11
- export declare function buildForestDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<ForestPlotState<TData>, ForestPlotCtx>;
11
+ export declare function buildForestDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<ForestPlotState<TData>, ForestPlotEnv>;
@@ -1,9 +1,9 @@
1
1
  import type { AxisPlotDefaults } from '../../../types/phases';
2
- import type { LollipopPlotState, LollipopPlotCtx } from '../../../types/plots/ranking/lollipop/state';
2
+ import type { LollipopPlotState, LollipopPlotEnv } from '../../../types/plots/ranking/lollipop/state';
3
3
  /**
4
4
  * LollipopPlot on the shared pipeline: a ClevelandPlot of one value per
5
5
  * category, whose stem rises from the baseline - zero, or the nearest end of a
6
6
  * pinned value domain - to the dot. It warns when a category has values in
7
7
  * several series, which `DumbbellPlot` and `ClevelandPlot` are for.
8
8
  */
9
- export declare function buildLollipopDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<LollipopPlotState<TData>, LollipopPlotCtx>;
9
+ export declare function buildLollipopDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<LollipopPlotState<TData>, LollipopPlotEnv>;
@@ -70,7 +70,7 @@ export type PlotStylesConfig = {
70
70
  palette: string[];
71
71
  /** Default shape cycle for the `symbol` channel, in order. */
72
72
  symbols: SymbolType[];
73
- /** The default continuous ramp, the on-cell label colour and the default opacity-channel range. */
73
+ /** The default continuous ramp and the default opacity-channel range. */
74
74
  continuous: {
75
75
  /** The ramp's first color, when it is not a named `scheme`. */
76
76
  min: string;
@@ -80,7 +80,6 @@ export type PlotStylesConfig = {
80
80
  scheme?: string;
81
81
  /** The part of `scheme` to use, as `[from, to]` fractions of it: `[0.2, 1]` skips the near-white start of `'blues'`. */
82
82
  schemeRange?: [number, number];
83
- labelColor: string;
84
83
  opacityRange: [number, number];
85
84
  };
86
85
  /**
@@ -244,6 +243,8 @@ export type PlotStylesConfig = {
244
243
  dot: DotStyle;
245
244
  font: FontStyle;
246
245
  area: AreaStyle;
246
+ /** How a hovered shape looks on a plot whose hover only restyles its shapes (a treemap's tile, a heatmap's cell). */
247
+ active: StrokeStyle;
247
248
  };
248
249
  facet: {
249
250
  /** Position badge shown in `carousel`/`paginated` facet modes. */
@@ -264,6 +265,19 @@ export type PlotStylesConfig = {
264
265
  disabledOpacity: number;
265
266
  };
266
267
  };
268
+ /** The tiles of a `TreemapPlot` and the labels written on them. */
269
+ treemap: {
270
+ /** The line between tiles. */
271
+ stroke: string;
272
+ /** Its width, in px. */
273
+ strokeWidth: number;
274
+ /** Font size of a tile's label, in px. */
275
+ fontSize: number;
276
+ /** The room kept between a tile's edge and its label, in px. */
277
+ padding: number;
278
+ /** Line height of a tile's label, as a multiple of its font size. */
279
+ lineHeight: number;
280
+ };
267
281
  /** Timeline gutter styling. */
268
282
  timeline: {
269
283
  axisColor: string;
@@ -367,6 +381,8 @@ export type PlotStylesConfig = {
367
381
  /** Gap, in px, between a connector and its label when it is written beside it. */
368
382
  labelGap: number;
369
383
  };
384
+ /** The `band` marker's style, under its own `styles`. */
385
+ band: AreaStyle;
370
386
  /** The `delta` marker's label offset and anchor, per axis the delta is taken on. A marker's own `text` wins. */
371
387
  delta: {
372
388
  text: Record<'x' | 'y', {
@@ -378,6 +394,19 @@ export type PlotStylesConfig = {
378
394
  };
379
395
  /** Default text-marker behavior. */
380
396
  text: {
397
+ /** Defaults of the `label` a shape writes in itself (`rect`, `cell`, `bar`, `waffle`), each overridden by the label's own `gap` and `fit`. */
398
+ label: {
399
+ /** Pixels between a label and the edge it is anchored to. */
400
+ gap: number;
401
+ /** Pixels a fitted label keeps free inside each edge of its shape. */
402
+ padding: number;
403
+ /** The smallest size a fitted label is written at, in px. */
404
+ minFontSize: number;
405
+ /** The fewest letters worth writing when a fitted label is cut short; under them its `fallback` is written. */
406
+ minLetters: number;
407
+ /** The colors a label inside its shape is written in: the one that reads best on the shape's color. A label's own `fill` wins. */
408
+ contrast: string[];
409
+ };
381
410
  /** Geometry and connector of a decluttered text marker (`declutter`) - e.g. LinePlot's end-of-line value labels. */
382
411
  declutter: {
383
412
  /** Shortest lane's distance (px) from the point before a connector bends. */
@@ -0,0 +1,21 @@
1
+ /**
2
+ * What a plot knows of one of the rows it draws: the series it is drawn in, where it sits, and the value it shows
3
+ * - the dataset's own, or the one the plot works out for it (a density's estimate, a bin's count). It is worked
4
+ * out once per row, as the plot reads its data, and every place that writes about a row reads it: a tooltip's
5
+ * `format`, a hover's points and labels, the value labels, and an author's own markers (see `RowContext.of`).
6
+ * A plot kind that works out more about a row gives a type that extends this one.
7
+ */
8
+ export type PlotRowContext<TRow = Record<string, unknown>> = {
9
+ /** The name of the series the row is drawn in, on the plots that have series. */
10
+ series?: string;
11
+ /** The row's value on `x`: its own (not a stack's running total), else where the plot's transforms put it. */
12
+ x?: unknown;
13
+ /** The row's value on `y`, as `x`. */
14
+ y?: unknown;
15
+ /** The value the row shows, on the plot's value axis, when it is a number. */
16
+ value?: number;
17
+ /** The row itself, as the plot drew it: the data's fields, plus whatever its transforms added. */
18
+ row?: TRow;
19
+ };
20
+ /** A plot kind's own context of a row: the shared one, with what the kind works out for it. */
21
+ export type KindRowContext<TExtra extends object, TRow = Record<string, unknown>> = PlotRowContext<TRow> & TExtra;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,4 @@
1
+ import type { PlotRowContext } from './context';
1
2
  import type { AxisValue } from './mapping';
2
3
  /**
3
4
  * How the hover highlight finds related points within a facet.
@@ -41,6 +42,8 @@ export type HoverDisplayPoint = {
41
42
  color?: string;
42
43
  /** A 'grouped' series' own slice of the category band, as start/end fractions (0-1) of the whole band. `undefined` means the whole band. */
43
44
  areaInset?: BandSlice;
45
+ /** What the plot knows of the point's row: its series, where it sits, its value and whatever its kind works out - see {@link PlotRowContext}. */
46
+ context?: PlotRowContext;
44
47
  };
45
48
  /** A candidate point for hover matching/highlighting - also carries its source row. */
46
49
  export type HoverPoint<T> = HoverDisplayPoint & {
@@ -20,7 +20,12 @@ export type LegendDisabledStyle = {
20
20
  * What a legend toggle does to a series once it's off: `'dim'` dims it in
21
21
  * place (styled by `style`), `'hide'` makes it fully transparent while the
22
22
  * axes keep its range, `'omit'` removes it from the plot entirely, rescaling
23
- * the axes to what's left.
23
+ * the axes to what's left - the other series keep their values, and a part of
24
+ * a whole (a treemap's tile) its share and its place. `'rescale'` removes it
25
+ * too, and the parts left make the whole again: a stack's visible parts are
26
+ * scaled up to the total each category had, and a treemap's tiles are laid out
27
+ * and given their shares anew, as the new 100%. On a plot of no parts it is an
28
+ * `'omit'`.
24
29
  */
25
30
  export type LegendDisabledAction = {
26
31
  mode: 'dim';
@@ -29,6 +34,8 @@ export type LegendDisabledAction = {
29
34
  mode: 'hide';
30
35
  } | {
31
36
  mode: 'omit';
37
+ } | {
38
+ mode: 'rescale';
32
39
  };
33
40
  export type LegendItem = {
34
41
  name: string;
@@ -14,7 +14,9 @@ export type ChannelValue = {
14
14
  * Splits `data` into one series per distinct value - the structural
15
15
  * grouping key. Defaults to `color` when omitted, so a single `color`
16
16
  * accessor groups *and* colors series; pass both to split by one field
17
- * while coloring by another.
17
+ * while coloring by another. A dotted name (`'sector.branch'`) groups by several
18
+ * levels, outermost first: a plot that nests (a treemap) nests by them, any other
19
+ * splits by their combination - see {@link GroupingAccessor}.
18
20
  */
19
21
  grouping: unknown;
20
22
  /**
@@ -34,6 +36,8 @@ export type ChannelValue = {
34
36
  r: number;
35
37
  /** Vector/spike magnitude - a literal number is a fixed pixel length. Configure via `scales.length`. */
36
38
  length: number;
39
+ /** What a row amounts to as a part of a whole: a treemap tile's area. A plot without parts ignores it. */
40
+ value: number;
37
41
  };
38
42
  /** Every channel a plot maps from its rows. */
39
43
  export type ChannelName = keyof ChannelValue;
@@ -46,9 +50,14 @@ export type AxisChannelName = 'x' | 'y';
46
50
  export type IndependentChannelName = 'color' | 'grouping' | 'opacity' | 'symbol';
47
51
  /** The size channels, which also take a literal number as a fixed pixel size that bypasses their scale. */
48
52
  export type SizeChannelName = 'r' | 'length';
49
- /** Every channel as a plot prop: a field key or accessor function (or a literal size, for a size channel). */
53
+ /**
54
+ * What a plot's rows group by: a field, the fields of several levels joined by dots (`'sector.branch'`,
55
+ * outermost first), or a function of the row. A dotted name is a field when the rows have one by that name.
56
+ */
57
+ export type GroupingAccessor<TData> = (keyof TData & string) | `${keyof TData & string}.${string}` | ((row: TData) => unknown);
58
+ /** Every channel as a plot prop: a field key or accessor function (or a literal size, for a size channel); `grouping` also takes levels - see {@link GroupingAccessor}. */
50
59
  export type ChannelAccessors<TData extends Record<string, unknown>> = {
51
- [K in keyof ChannelValue]?: Accessor<TData, ChannelValue[K]> | (K extends SizeChannelName ? number : never);
60
+ [K in keyof ChannelValue]?: K extends 'grouping' ? GroupingAccessor<TData> : Accessor<TData, ChannelValue[K]> | (K extends SizeChannelName ? number : never);
52
61
  };
53
62
  /** One channel's own resolved data accessor - mirrors svelteplot's own `ChannelAccessor`. */
54
63
  export type ResolvedChannel<TData, TValue = AxisValue> = {
@@ -19,6 +19,12 @@ export type ColorScaleConfig = {
19
19
  pivot?: number;
20
20
  /** Fallback color for a missing/unmapped value. Defaults to `'#ccc'`. */
21
21
  unknown?: string;
22
+ /**
23
+ * With a `grouping` of several levels (`'sector.kind.branch'`), the level its colors reach: `1` (the default)
24
+ * gives each outermost value its color, and a deeper one gives each value down to that level a tone of its
25
+ * outermost value's color - `2` a tone per kind within its sector's color. Ignored by a continuous ramp.
26
+ */
27
+ depth?: number;
22
28
  };
23
29
  /** How groups sharing the same `grouping`/`color` value are ordered: `reverse` flips which sorts first (e.g. PyramidPlot's left/right sides). */
24
30
  export type GroupingScaleConfig = {
@@ -1,6 +1,7 @@
1
1
  import type { ValueAnchor } from '../../plots/constants';
2
2
  import type { FontStyle, StrokeStyle } from '../../plots/styling';
3
3
  import type { NumberDisplay } from '../numbers';
4
+ import type { PlotRowContext } from '../context';
4
5
  /**
5
6
  * Which of a group's rows get a value label: its first or last, or the one
6
7
  * with the lowest or highest value (read on the plot's value axis). The group
@@ -38,8 +39,13 @@ export type ValuesStyle = NumberDisplay & {
38
39
  * CSS color writes them all in it. `fontStyle.fill` wins when it is set.
39
40
  */
40
41
  color?: 'series' | (string & {});
41
- /** A label's text, in place of the value as `decimals`, `prefix`, `suffix` and `signDisplay` write it, from its row's own value (a histogram bin's count) and its series - and, on the plots that label one row each, that row, for the other fields of the data. */
42
- format?: (value: number, seriesName: string, row?: Record<string, unknown>, number?: (value: number) => string) => string;
42
+ /**
43
+ * A label's text, in place of the value as `decimals`, `prefix`, `suffix` and `signDisplay` write it: from the
44
+ * value it shows (a histogram bin's count, a tile's share), `number`, which writes a value as those fields ask,
45
+ * and `context`, what the plot knows of the labelled row - its `series`, `x`, `y`, whatever its kind works out
46
+ * and, where the label has one, the `row` itself, for the other fields of the data (see {@link PlotRowContext}).
47
+ */
48
+ format?: (value: number, number: (value: number) => string, context: PlotRowContext) => string;
43
49
  /** Hovering a label dims every other series, like toggling them off in the legend. */
44
50
  hoverIsolate?: boolean;
45
51
  fontStyle?: FontStyle;
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HoverStrategy } from './hover';
3
3
  import type { NumberDisplay } from './numbers';
4
+ import type { PlotRowContext } from './context';
4
5
  /**
5
6
  * Preferred horizontal placement of the tooltip beside the cursor; it moves
6
7
  * to the other side when it would overflow. Defaults to `'right'`.
@@ -12,18 +13,24 @@ export type TooltipAnchorY = 'top' | 'middle' | 'bottom';
12
13
  export type TooltipRow<TRow> = TRow & {
13
14
  seriesColor?: string;
14
15
  };
16
+ /** What a plot knows of a hovered row, the third argument of a tooltip's `format` - see {@link PlotRowContext}. */
17
+ export type TooltipContext = PlotRowContext;
15
18
  /**
16
19
  * Author-facing tooltip option on the chart kinds. `true` = enable with defaults. `decimals`, `prefix`,
17
20
  * `suffix` and `signDisplay` write the value the default text shows - the one on the plot's value axis (the
18
21
  * x of a horizontal bar chart), and a heatmap's color value - and the numbers a custom `format` writes with its `number`.
19
22
  */
20
- export type TooltipOptions<TRow extends Record<string, unknown>> = NumberDisplay & {
23
+ export type TooltipOptions<TRow extends Record<string, unknown>, TContext extends TooltipContext = TooltipContext> = NumberDisplay & {
21
24
  /** Matching strategy. Defaults to the chart kind's own default. */
22
25
  strategy?: HoverStrategy;
23
26
  /** Highlight the hovered point in every synced plot too. Defaults to `false`. */
24
27
  sync?: boolean;
25
- /** Custom tooltip text for a row (supports `\n`). Defaults per chart kind. `number` writes a value as the display fields above ask. */
26
- format?: (row: TRow, number: (value: number) => string) => string;
28
+ /**
29
+ * Custom tooltip text for a row (supports `\n`). Defaults per chart kind. `number` writes a value as the display
30
+ * fields above ask, and `context` is what the plot knows of the row: its series, `x`, `y`, the value it shows and
31
+ * whatever its kind works out (a tile's share, a box's quartiles) - see {@link PlotRowContext}.
32
+ */
33
+ format?: (row: TRow, number: (value: number) => string, context: TContext) => string;
27
34
  /** Named subset of crossing series to include. Omitted = all matched. */
28
35
  series?: string[];
29
36
  /** Custom tooltip body; replaces `format` when given. Its rows carry a `seriesColor` - see {@link TooltipRow}. */
@@ -36,4 +43,4 @@ export type TooltipOptions<TRow extends Record<string, unknown>> = NumberDisplay
36
43
  anchorY?: TooltipAnchorY;
37
44
  };
38
45
  /** Either a bare on/off flag or the full option object. */
39
- export type TooltipProp<TRow extends Record<string, unknown>> = boolean | TooltipOptions<TRow>;
46
+ export type TooltipProp<TRow extends Record<string, unknown>, TContext extends TooltipContext = TooltipContext> = boolean | TooltipOptions<TRow, TContext>;
@@ -1,4 +1,4 @@
1
- import type { StrokeStyle } from '../../plots/styling';
1
+ import type { StrokeStyle, PerRow, DirectedInsetStyle } from '../../plots/styling';
2
2
  import type { CommonMarkerConfigWithInterval } from '../channels/commonMarkerConfigWithInterval';
3
3
  /** A point-to-point arrow (svelteplot's `Arrow`), from `x1`/`y1` to `x2`/`y2`. */
4
4
  export type ArrowMarkerConfig = {
@@ -7,12 +7,6 @@ export type ArrowMarkerConfig = {
7
7
  bend?: number | true;
8
8
  headAngle?: number;
9
9
  headLength?: number;
10
- inset?: number;
11
- insetStart?: number;
12
- insetEnd?: number;
13
10
  sweep?: 1 | 0 | -1 | '+x' | '-x' | '+y' | '-y';
14
- stroke?: string | ((d: any) => string | undefined);
15
- strokeWidth?: string | ((d: any) => number);
16
- strokeOpacity?: string | ((d: any) => number);
17
- styles?: StrokeStyle;
11
+ styles?: PerRow<StrokeStyle & DirectedInsetStyle>;
18
12
  } & CommonMarkerConfigWithInterval;
@@ -23,8 +23,9 @@ import type { TrailMarkerConfig } from './trail';
23
23
  import type { WaffleMarkerConfig } from './waffle';
24
24
  import type { ViolinMarkerConfig } from './violin';
25
25
  import type { RuleMarkerConfig } from './rule';
26
+ import type { BandMarkerConfig } from './band';
26
27
  import type { HoverMarkerConfig } from './hover';
27
28
  import type { CustomComponentMarkerConfig } from './component';
28
29
  import type { DeltaMarkerConfig } from './delta';
29
30
  /** Every marker kind an axis-based plot can render. */
30
- export type AxisBasedMarkersConfig = BasicMarkersConfig | LineMarkerConfig | BarMarkerConfig | CellMarkerConfig | RectMarkerConfig | RegressionMarkerConfig | BollingerMarkerConfig | AreaMarkerConfig | DensityMarkerConfig | BoxMarkerConfig | HullMarkerConfig | DifferenceMarkerConfig | ArrowMarkerConfig | BrushMarkerConfig | DelaunayLinkMarkerConfig | DelaunayMeshMarkerConfig | VoronoiMarkerConfig | VoronoiMeshMarkerConfig | ImageMarkerConfig | RasterMarkerConfig | TickMarkerConfig | TrailMarkerConfig | WaffleMarkerConfig | ViolinMarkerConfig | RuleMarkerConfig | HoverMarkerConfig | CustomComponentMarkerConfig | DeltaMarkerConfig;
31
+ export type AxisBasedMarkersConfig = BasicMarkersConfig | LineMarkerConfig | BarMarkerConfig | CellMarkerConfig | RectMarkerConfig | RegressionMarkerConfig | BollingerMarkerConfig | AreaMarkerConfig | DensityMarkerConfig | BoxMarkerConfig | HullMarkerConfig | DifferenceMarkerConfig | ArrowMarkerConfig | BrushMarkerConfig | DelaunayLinkMarkerConfig | DelaunayMeshMarkerConfig | VoronoiMarkerConfig | VoronoiMeshMarkerConfig | ImageMarkerConfig | RasterMarkerConfig | TickMarkerConfig | TrailMarkerConfig | WaffleMarkerConfig | ViolinMarkerConfig | RuleMarkerConfig | BandMarkerConfig | HoverMarkerConfig | CustomComponentMarkerConfig | DeltaMarkerConfig;
@@ -0,0 +1,24 @@
1
+ import type { AxisValue } from '../../layout/mapping';
2
+ import type { BandSlice } from '../../layout/hover';
3
+ import type { AreaStyle, PerRow } from '../../plots/styling';
4
+ import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
5
+ /**
6
+ * The band of a category on a band axis, across the whole of the other axis: one per category, however many rows
7
+ * name it. On an axis that is not a band scale it draws nothing.
8
+ */
9
+ export type BandMarkerConfig = {
10
+ type: 'band';
11
+ axis: 'x' | 'y';
12
+ /**
13
+ * Which band. A list draws one at each category (without `data`); with `data`, a field key or a function of the
14
+ * row gives each row's own.
15
+ */
16
+ value: AxisValue | string | (AxisValue | string)[] | ((d: any) => AxisValue);
17
+ /**
18
+ * The part of the band it fills, as the fractions of its width left out at its start and its end (a grouped
19
+ * bar's series' slice). A function of the row gives each row's own; a band several rows share fills what all of
20
+ * them do. Unset, the whole band.
21
+ */
22
+ slice?: BandSlice | ((d: any) => BandSlice | undefined);
23
+ styles?: PerRow<AreaStyle>;
24
+ } & Omit<CommonMarkerConfig, 'x' | 'y'>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,18 +1,14 @@
1
1
  import type { AxisValue } from '../../layout/mapping';
2
- import type { AreaStyle } from '../../plots/styling';
2
+ import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
3
+ import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
3
4
  import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
4
5
  import type { CommonMarkerConfigWithInterval } from '../channels/commonMarkerConfigWithInterval';
5
- /** A bar mark; `role` tells a visible segment from the hover hit area and highlight. */
6
+ /** A bar mark; `role` tells a visible segment from the hover hit area. */
6
7
  export type BarMarkerConfig = {
7
8
  type: 'bar';
8
- role: 'segment' | 'hitArea' | 'highlight';
9
+ role: 'segment' | 'hitArea';
9
10
  isHorizontal: boolean;
10
- insetTop?: number;
11
- insetBottom?: number;
12
- insetLeft?: number;
13
- insetRight?: number;
14
11
  thickness?: number;
15
- styles?: AreaStyle;
12
+ styles?: PerRow<AreaStyle> & InsetStyle;
16
13
  category?: AxisValue;
17
- hover?: boolean;
18
- } & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval;
14
+ } & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel;
@@ -1,9 +1,9 @@
1
- import type { AreaStyle } from '../../plots/styling';
1
+ import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
2
2
  import type { CommonMarkerConfigWithArea } from '../channels/commonMarkerConfigWithArea';
3
+ import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
3
4
  import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
4
- /** A heatmap cell mark; `fill` is always set per row. */
5
+ /** A heatmap cell mark; its `fill` is set per row, by `color` or `styles.fill`. */
5
6
  export type CellMarkerConfig = {
6
7
  type: 'cell';
7
- styles?: AreaStyle;
8
- inset?: number;
9
- } & CommonMarkerConfigWithColor & Required<Pick<CommonMarkerConfigWithArea, 'fill'>>;
8
+ styles?: PerRow<AreaStyle & Pick<InsetStyle, 'inset'>>;
9
+ } & CommonMarkerConfigWithColor & CommonMarkerConfigWithArea & CommonMarkerConfigWithLabel;
@@ -1,7 +1,7 @@
1
- import type { AreaStyle } from '../../plots/styling';
1
+ import type { AreaStyle, PerRow } from '../../plots/styling';
2
2
  import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
3
3
  /** One line per Delaunay triangulation edge (svelteplot's `DelaunayLink`). */
4
4
  export type DelaunayLinkMarkerConfig = {
5
5
  type: 'delaunayLink';
6
- styles?: AreaStyle;
6
+ styles?: PerRow<AreaStyle>;
7
7
  } & CommonMarkerConfigWithColor;