@fundar/data-chart-telling 1.1.0 → 1.2.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 (524) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +6 -6
  3. package/dist/configuration/config.svelte.d.ts +1 -1
  4. package/dist/configuration/config.svelte.js +165 -100
  5. package/dist/configuration/themes/index.d.ts +5 -1428
  6. package/dist/index.d.ts +23 -14
  7. package/dist/index.js +20 -11
  8. package/dist/layout/base/BasePlotLayout.svelte +115 -50
  9. package/dist/layout/base/BasePlotLayout.svelte.d.ts +1 -38
  10. package/dist/layout/coordinates/CoordinatesLayout.svelte +42 -40
  11. package/dist/layout/coordinates/CoordinatesLayout.svelte.d.ts +0 -2
  12. package/dist/layout/coordinates/ProjectionZoom.svelte +48 -0
  13. package/dist/layout/coordinates/ProjectionZoom.svelte.d.ts +10 -0
  14. package/dist/layout/coordinates/ZoomedProjection.d.ts +11 -0
  15. package/dist/layout/coordinates/ZoomedProjection.js +24 -0
  16. package/dist/layout/coordinates/camera.svelte.js +11 -8
  17. package/dist/layout/coordinates/projections/argentina.js +1 -1
  18. package/dist/layout/coordinates/projections/fit.d.ts +1 -1
  19. package/dist/layout/coordinates/projections/fit.js +1 -1
  20. package/dist/layout/coordinates/zoom.svelte.d.ts +4 -5
  21. package/dist/layout/coordinates/zoom.svelte.js +4 -5
  22. package/dist/layout/facet/FacetLayout.svelte +1 -1
  23. package/dist/layout/facet/config.js +1 -1
  24. package/dist/layout/figure/Figure.svelte +2 -0
  25. package/dist/layout/geometry/GeometryLayout.svelte +14 -9
  26. package/dist/layout/geometry/GeometryLayout.svelte.d.ts +0 -3
  27. package/dist/layout/geometry/MarkerOffset.svelte +28 -0
  28. package/dist/layout/geometry/MarkerOffset.svelte.d.ts +13 -0
  29. package/dist/layout/grid/GridCell.svelte +6 -8
  30. package/dist/layout/legend/ContinuousSection.svelte +44 -9
  31. package/dist/layout/legend/DiscreteBadgeItem.svelte +2 -2
  32. package/dist/layout/legend/DiscreteSection.svelte +2 -2
  33. package/dist/layout/legend/DiscreteSymbolIcon.svelte +1 -1
  34. package/dist/layout/legend/LegendChannels.js +36 -12
  35. package/dist/layout/legend/LegendLayout.svelte +9 -1
  36. package/dist/layout/legend/LegendState.svelte.d.ts +4 -0
  37. package/dist/layout/legend/LegendState.svelte.js +20 -3
  38. package/dist/layout/legend/SizeSection.svelte +1 -1
  39. package/dist/layout/margins/PlotMargins.svelte.d.ts +2 -5
  40. package/dist/layout/margins/PlotMargins.svelte.js +4 -8
  41. package/dist/layout/plot/Slice.d.ts +5 -1
  42. package/dist/layout/plot/Slice.js +14 -4
  43. package/dist/layout/scales/NiceTicks.d.ts +3 -0
  44. package/dist/layout/scales/NiceTicks.js +4 -0
  45. package/dist/layout/scales/ScalesLayout.svelte +72 -7
  46. package/dist/layout/scales/ScalesLayout.svelte.d.ts +5 -0
  47. package/dist/layout/scales/SveltePlotScale.d.ts +2 -2
  48. package/dist/layout/scales/SveltePlotScale.js +13 -6
  49. package/dist/layout/scales/TickLabels.d.ts +32 -0
  50. package/dist/layout/scales/TickLabels.js +55 -0
  51. package/dist/layout/styles/StylesLayout.svelte +2 -2
  52. package/dist/layout/styles/ValueLabels.d.ts +33 -5
  53. package/dist/layout/styles/ValueLabels.js +80 -21
  54. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  55. package/dist/layout/tooltip/Tooltip.svelte +4 -4
  56. package/dist/layout/tooltip/Tooltip.svelte.d.ts +4 -4
  57. package/dist/layout/tooltip/TooltipState.svelte.js +1 -1
  58. package/dist/markers/MarkerKinds.d.ts +5 -0
  59. package/dist/markers/MarkerKinds.js +1 -0
  60. package/dist/markers/area/AreaMarker.svelte +15 -63
  61. package/dist/markers/arrow/ArrowMarker.svelte +51 -9
  62. package/dist/markers/bar/BarMarker.svelte +8 -4
  63. package/dist/markers/bollinger/BollingerMarker.svelte +33 -18
  64. package/dist/markers/box/BoxMarker.svelte +40 -9
  65. package/dist/markers/delta/Delta.js +1 -1
  66. package/dist/markers/dot/DotMarker.svelte +24 -27
  67. package/dist/markers/image/ImageMarker.svelte +17 -12
  68. package/dist/markers/inset/InsetMarker.svelte +2 -2
  69. package/dist/markers/line/LineMarker.svelte +1 -0
  70. package/dist/markers/link/LinkMarker.svelte +174 -29
  71. package/dist/markers/regression/RegressionMarker.svelte +16 -33
  72. package/dist/markers/rule/RuleMarker.svelte +9 -3
  73. package/dist/markers/text/Declutter.d.ts +4 -0
  74. package/dist/markers/text/Declutter.js +26 -11
  75. package/dist/markers/text/TextMarker.svelte +91 -48
  76. package/dist/markers/tick/TickMarker.svelte +27 -25
  77. package/dist/markers/utils/MarkerChannels.d.ts +24 -0
  78. package/dist/markers/utils/MarkerChannels.js +42 -7
  79. package/dist/markers/utils/RowOffset.d.ts +23 -0
  80. package/dist/markers/utils/RowOffset.js +23 -0
  81. package/dist/markers/utils/RowOffsetMarks.svelte +30 -0
  82. package/dist/markers/utils/RowOffsetMarks.svelte.d.ts +33 -0
  83. package/dist/markers/utils/RowStroke.d.ts +31 -0
  84. package/dist/markers/utils/RowStroke.js +28 -0
  85. package/dist/markers/violin/ViolinMarker.svelte +75 -0
  86. package/dist/markers/violin/ViolinMarker.svelte.d.ts +7 -0
  87. package/dist/markers/violin/ViolinProfiles.d.ts +29 -0
  88. package/dist/markers/violin/ViolinProfiles.js +55 -0
  89. package/dist/markers/waffle/WaffleMarker.svelte +17 -37
  90. package/dist/phases/Pipeline.d.ts +5 -0
  91. package/dist/phases/Pipeline.js +5 -0
  92. package/dist/phases/data/DataPhase.js +3 -3
  93. package/dist/phases/data/PlotAxes.d.ts +10 -0
  94. package/dist/phases/data/PlotAxes.js +14 -1
  95. package/dist/phases/facet/FacetPanels.d.ts +1 -0
  96. package/dist/phases/facet/FacetPanels.js +1 -0
  97. package/dist/phases/mapping/MappingPhase.js +1 -1
  98. package/dist/phases/markers/MarkersPhase.js +2 -1
  99. package/dist/phases/scales/CategoryOrder.d.ts +23 -0
  100. package/dist/phases/scales/CategoryOrder.js +73 -0
  101. package/dist/phases/scales/ScalesPhase.js +21 -7
  102. package/dist/phases/sharedScales/SharedScalesPhase.d.ts +3 -2
  103. package/dist/phases/sharedScales/SharedScalesPhase.js +5 -2
  104. package/dist/phases/statistics/Statistics.d.ts +10 -6
  105. package/dist/phases/statistics/Statistics.js +20 -10
  106. package/dist/phases/statistics/StatisticsPhase.js +7 -2
  107. package/dist/phases/statistics/methods/BollingerStatistic.d.ts +1 -1
  108. package/dist/phases/statistics/methods/BollingerStatistic.js +13 -11
  109. package/dist/phases/statistics/methods/BoxStatistic.d.ts +1 -1
  110. package/dist/phases/statistics/methods/BoxStatistic.js +14 -12
  111. package/dist/phases/statistics/methods/Density2dStatistic.d.ts +1 -1
  112. package/dist/phases/statistics/methods/Density2dStatistic.js +13 -11
  113. package/dist/phases/statistics/methods/DensityStatistic.d.ts +1 -1
  114. package/dist/phases/statistics/methods/DensityStatistic.js +11 -9
  115. package/dist/phases/statistics/methods/DeviationStatistic.d.ts +8 -0
  116. package/dist/phases/statistics/methods/DeviationStatistic.js +111 -0
  117. package/dist/phases/statistics/methods/MovingAverageStatistic.d.ts +1 -1
  118. package/dist/phases/statistics/methods/MovingAverageStatistic.js +11 -9
  119. package/dist/phases/statistics/methods/RegressionStatistic.d.ts +1 -1
  120. package/dist/phases/statistics/methods/RegressionStatistic.js +16 -14
  121. package/dist/phases/transforms/ProcessedPositions.js +1 -1
  122. package/dist/phases/transforms/TransformsPhase.js +49 -3
  123. package/dist/phases/transforms/ValueSelection.d.ts +30 -0
  124. package/dist/phases/transforms/ValueSelection.js +53 -0
  125. package/dist/plots/{heatmap → correlation/heatmap}/Plot.svelte +5 -2
  126. package/dist/plots/{heatmap → correlation/heatmap}/Plot.svelte.d.ts +2 -2
  127. package/dist/plots/{heatmap → correlation/heatmap}/defaults.d.ts +2 -2
  128. package/dist/plots/{heatmap → correlation/heatmap}/defaults.js +5 -5
  129. package/dist/plots/{heatmap → correlation/heatmap}/markers.d.ts +4 -4
  130. package/dist/plots/{heatmap → correlation/heatmap}/markers.js +3 -3
  131. package/dist/plots/{scatter → correlation/scatter}/Plot.svelte +5 -2
  132. package/dist/plots/{scatter → correlation/scatter}/Plot.svelte.d.ts +2 -2
  133. package/dist/plots/{scatter → correlation/scatter}/defaults.d.ts +2 -2
  134. package/dist/plots/{scatter → correlation/scatter}/defaults.js +4 -4
  135. package/dist/plots/{scatter → correlation/scatter}/markers.d.ts +4 -4
  136. package/dist/plots/{scatter → correlation/scatter}/markers.js +3 -3
  137. package/dist/plots/{box → distribution/box}/BoxSummaries.d.ts +2 -2
  138. package/dist/plots/{box → distribution/box}/BoxSummaries.js +6 -6
  139. package/dist/plots/{box → distribution/box}/Plot.svelte +2 -2
  140. package/dist/plots/{box → distribution/box}/Plot.svelte.d.ts +2 -2
  141. package/dist/plots/{box → distribution/box}/defaults.d.ts +2 -2
  142. package/dist/plots/{box → distribution/box}/defaults.js +1 -1
  143. package/dist/plots/{box → distribution/box}/markers.d.ts +2 -2
  144. package/dist/plots/distribution/density/Plot.svelte +45 -0
  145. package/dist/plots/distribution/density/Plot.svelte.d.ts +26 -0
  146. package/dist/plots/distribution/density/defaults.d.ts +9 -0
  147. package/dist/plots/distribution/density/defaults.js +29 -0
  148. package/dist/plots/distribution/density/markers.d.ts +9 -0
  149. package/dist/plots/distribution/density/markers.js +42 -0
  150. package/dist/plots/{histogram → distribution/histogram}/Plot.svelte +2 -2
  151. package/dist/plots/{histogram → distribution/histogram}/Plot.svelte.d.ts +2 -2
  152. package/dist/plots/{histogram → distribution/histogram}/defaults.d.ts +2 -2
  153. package/dist/plots/{histogram → distribution/histogram}/defaults.js +3 -3
  154. package/dist/plots/{histogram → distribution/histogram}/markers.d.ts +3 -3
  155. package/dist/plots/{histogram → distribution/histogram}/markers.js +5 -5
  156. package/dist/plots/{pyramid → distribution/pyramid}/Plot.svelte +5 -2
  157. package/dist/plots/{pyramid → distribution/pyramid}/Plot.svelte.d.ts +2 -2
  158. package/dist/plots/{pyramid → distribution/pyramid}/defaults.d.ts +2 -2
  159. package/dist/plots/{pyramid → distribution/pyramid}/defaults.js +6 -6
  160. package/dist/plots/{pyramid → distribution/pyramid}/markers.d.ts +4 -4
  161. package/dist/plots/{pyramid → distribution/pyramid}/markers.js +6 -6
  162. package/dist/plots/distribution/violin/Plot.svelte +45 -0
  163. package/dist/plots/distribution/violin/Plot.svelte.d.ts +26 -0
  164. package/dist/plots/distribution/violin/defaults.d.ts +10 -0
  165. package/dist/plots/distribution/violin/defaults.js +58 -0
  166. package/dist/plots/distribution/violin/markers.d.ts +10 -0
  167. package/dist/plots/distribution/violin/markers.js +71 -0
  168. package/dist/plots/{area → evolution/area}/Plot.svelte +2 -2
  169. package/dist/plots/{area → evolution/area}/Plot.svelte.d.ts +2 -2
  170. package/dist/plots/{area → evolution/area}/defaults.d.ts +2 -2
  171. package/dist/plots/{area → evolution/area}/defaults.js +2 -0
  172. package/dist/plots/{area → evolution/area}/markers.d.ts +2 -2
  173. package/dist/plots/{area → evolution/area}/markers.js +1 -1
  174. package/dist/plots/{line → evolution/line}/Plot.svelte +2 -2
  175. package/dist/plots/{line → evolution/line}/Plot.svelte.d.ts +2 -2
  176. package/dist/plots/{line → evolution/line}/defaults.d.ts +2 -2
  177. package/dist/plots/{line → evolution/line}/defaults.js +2 -0
  178. package/dist/plots/{line → evolution/line}/markers.d.ts +11 -8
  179. package/dist/plots/{line → evolution/line}/markers.js +6 -4
  180. package/dist/plots/evolution/slope/Plot.svelte +42 -0
  181. package/dist/plots/evolution/slope/Plot.svelte.d.ts +26 -0
  182. package/dist/plots/evolution/slope/defaults.d.ts +8 -0
  183. package/dist/plots/evolution/slope/defaults.js +31 -0
  184. package/dist/plots/evolution/slope/markers.d.ts +16 -0
  185. package/dist/plots/evolution/slope/markers.js +79 -0
  186. package/dist/plots/evolution/sparkline/Plot.svelte +45 -0
  187. package/dist/plots/evolution/sparkline/Plot.svelte.d.ts +26 -0
  188. package/dist/plots/evolution/sparkline/defaults.d.ts +7 -0
  189. package/dist/plots/evolution/sparkline/defaults.js +23 -0
  190. package/dist/plots/evolution/sparkline/markers.d.ts +7 -0
  191. package/dist/plots/evolution/sparkline/markers.js +56 -0
  192. package/dist/plots/{geo → map/geo}/Core.svelte +11 -10
  193. package/dist/plots/{geo → map/geo}/Core.svelte.d.ts +1 -1
  194. package/dist/plots/map/geo/GeoFeatures.svelte.d.ts +9 -0
  195. package/dist/plots/map/geo/GeoFeatures.svelte.js +55 -0
  196. package/dist/plots/map/geo/GeoGeometry.d.ts +27 -0
  197. package/dist/plots/map/geo/GeoGeometry.js +142 -0
  198. package/dist/plots/map/geo/GeoSegments.d.ts +16 -0
  199. package/dist/plots/map/geo/GeoSegments.js +23 -0
  200. package/dist/plots/{geo → map/geo}/Plot.svelte +10 -10
  201. package/dist/plots/{geo → map/geo}/Plot.svelte.d.ts +2 -2
  202. package/dist/plots/{geo → map/geo}/defaults.d.ts +2 -2
  203. package/dist/plots/{geo → map/geo}/defaults.js +1 -1
  204. package/dist/plots/{geo → map/geo}/phases/data.d.ts +1 -1
  205. package/dist/plots/{geo → map/geo}/phases/data.js +7 -6
  206. package/dist/plots/{geo → map/geo}/phases/hover.d.ts +1 -1
  207. package/dist/plots/{geo → map/geo}/phases/hover.js +2 -2
  208. package/dist/plots/{geo → map/geo}/phases/markers.d.ts +1 -1
  209. package/dist/plots/{geo → map/geo}/phases/markers.js +6 -10
  210. package/dist/plots/{geo → map/geo}/phases/scales.d.ts +2 -2
  211. package/dist/plots/{geo → map/geo}/phases/scales.js +28 -12
  212. package/dist/plots/{geo → map/geo}/phases/tooltip.d.ts +1 -1
  213. package/dist/plots/map/geo/phases/tooltip.js +5 -0
  214. package/dist/plots/{geo → map/geo}/slices.d.ts +2 -2
  215. package/dist/plots/{geo → map/geo}/slices.js +2 -2
  216. package/dist/plots/{bar → ranking/bar}/Plot.svelte +2 -2
  217. package/dist/plots/{bar → ranking/bar}/Plot.svelte.d.ts +2 -2
  218. package/dist/plots/ranking/bar/defaults.d.ts +16 -0
  219. package/dist/plots/{bar → ranking/bar}/defaults.js +15 -9
  220. package/dist/plots/{bar → ranking/bar}/markers.d.ts +8 -8
  221. package/dist/plots/{bar → ranking/bar}/markers.js +8 -17
  222. package/dist/plots/ranking/bullet/Plot.svelte +42 -0
  223. package/dist/plots/ranking/bullet/Plot.svelte.d.ts +26 -0
  224. package/dist/plots/ranking/bullet/defaults.d.ts +8 -0
  225. package/dist/plots/ranking/bullet/defaults.js +24 -0
  226. package/dist/plots/ranking/bullet/markers.d.ts +10 -0
  227. package/dist/plots/ranking/bullet/markers.js +90 -0
  228. package/dist/plots/ranking/cleveland/ClevelandConnector.d.ts +48 -0
  229. package/dist/plots/ranking/cleveland/ClevelandConnector.js +140 -0
  230. package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +33 -0
  231. package/dist/plots/ranking/cleveland/ClevelandMarkers.js +375 -0
  232. package/dist/plots/ranking/cleveland/ClevelandRanges.d.ts +31 -0
  233. package/dist/plots/ranking/cleveland/ClevelandRanges.js +116 -0
  234. package/dist/plots/ranking/cleveland/Plot.svelte +45 -0
  235. package/dist/plots/ranking/cleveland/Plot.svelte.d.ts +26 -0
  236. package/dist/plots/ranking/cleveland/defaults.d.ts +13 -0
  237. package/dist/plots/ranking/cleveland/defaults.js +66 -0
  238. package/dist/plots/ranking/dumbbell/Plot.svelte +45 -0
  239. package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +26 -0
  240. package/dist/plots/ranking/dumbbell/defaults.d.ts +9 -0
  241. package/dist/plots/ranking/dumbbell/defaults.js +19 -0
  242. package/dist/plots/ranking/forest/Plot.svelte +42 -0
  243. package/dist/plots/ranking/forest/Plot.svelte.d.ts +26 -0
  244. package/dist/plots/ranking/forest/defaults.d.ts +11 -0
  245. package/dist/plots/ranking/forest/defaults.js +20 -0
  246. package/dist/plots/ranking/lollipop/Plot.svelte +45 -0
  247. package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +26 -0
  248. package/dist/plots/ranking/lollipop/defaults.d.ts +9 -0
  249. package/dist/plots/ranking/lollipop/defaults.js +18 -0
  250. package/dist/plots/utils/RowNumbers.d.ts +16 -0
  251. package/dist/plots/utils/RowNumbers.js +24 -0
  252. package/dist/plots/utils/gaps.js +1 -1
  253. package/dist/plots/utils/segments.js +1 -1
  254. package/dist/types/configuration/styling.d.ts +276 -143
  255. package/dist/types/layout/coordinates.d.ts +5 -4
  256. package/dist/types/layout/legend.d.ts +21 -5
  257. package/dist/types/layout/plot.d.ts +44 -1
  258. package/dist/types/layout/scales.d.ts +39 -7
  259. package/dist/types/layout/statistics/deviation.d.ts +40 -0
  260. package/dist/types/layout/statistics/index.d.ts +7 -2
  261. package/dist/types/layout/styles/base.d.ts +18 -0
  262. package/dist/types/layout/styles/bullet.d.ts +25 -0
  263. package/dist/types/layout/styles/connector.d.ts +98 -0
  264. package/dist/types/layout/styles/curve.d.ts +11 -0
  265. package/dist/types/layout/styles/frame.d.ts +17 -0
  266. package/dist/types/layout/styles/gaps.d.ts +12 -0
  267. package/dist/types/layout/styles/geo.d.ts +55 -0
  268. package/dist/types/layout/styles/index.d.ts +8 -0
  269. package/dist/types/layout/styles/index.js +8 -0
  270. package/dist/types/layout/styles/values.d.ts +47 -0
  271. package/dist/types/layout/timeline.d.ts +5 -2
  272. package/dist/types/layout/tooltip.d.ts +6 -2
  273. package/dist/types/markers/axis/area.d.ts +2 -2
  274. package/dist/types/markers/axis/arrow.d.ts +3 -0
  275. package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
  276. package/dist/types/markers/axis/bar.d.ts +1 -1
  277. package/dist/types/markers/axis/box.d.ts +5 -0
  278. package/dist/types/markers/axis/difference.d.ts +2 -2
  279. package/dist/types/markers/axis/image.d.ts +3 -2
  280. package/dist/types/markers/axis/line.d.ts +2 -0
  281. package/dist/types/markers/axis/rule.d.ts +9 -0
  282. package/dist/types/markers/axis/trail.d.ts +2 -3
  283. package/dist/types/markers/axis/violin.d.ts +25 -0
  284. package/dist/types/markers/basic/dot.d.ts +3 -2
  285. package/dist/types/markers/basic/text.d.ts +13 -3
  286. package/dist/types/markers/channels/commonMarkerConfig.d.ts +7 -3
  287. package/dist/types/markers/channels/commonMarkerConfigWithRowOffset.d.ts +13 -0
  288. package/dist/types/markers/common.d.ts +1 -1
  289. package/dist/types/markers/common.js +1 -0
  290. package/dist/types/markers/geo/link.d.ts +5 -1
  291. package/dist/types/phases/index.d.ts +1 -1
  292. package/dist/types/phases/scales/phase.d.ts +5 -1
  293. package/dist/types/phases/state.d.ts +15 -2
  294. package/dist/types/phases/statistics/source.d.ts +3 -1
  295. package/dist/types/phases/transforms/phase.d.ts +22 -0
  296. package/dist/types/plots/{heatmap → correlation/heatmap}/props.d.ts +6 -6
  297. package/dist/types/plots/{heatmap → correlation/heatmap}/state.d.ts +4 -4
  298. package/dist/types/plots/{scatter → correlation/scatter}/props.d.ts +6 -6
  299. package/dist/types/plots/{scatter → correlation/scatter}/state.d.ts +2 -2
  300. package/dist/types/plots/{box → distribution/box}/props.d.ts +6 -6
  301. package/dist/types/plots/{box → distribution/box}/state.d.ts +3 -3
  302. package/dist/types/plots/distribution/density/props.d.ts +23 -0
  303. package/dist/types/plots/distribution/density/state.d.ts +6 -0
  304. package/dist/types/plots/{histogram → distribution/histogram}/props.d.ts +7 -7
  305. package/dist/types/plots/{histogram → distribution/histogram}/state.d.ts +2 -2
  306. package/dist/types/plots/distribution/histogram/state.js +1 -0
  307. package/dist/types/plots/{pyramid → distribution/pyramid}/props.d.ts +6 -6
  308. package/dist/types/plots/distribution/pyramid/props.js +1 -0
  309. package/dist/types/plots/{pyramid → distribution/pyramid}/state.d.ts +3 -3
  310. package/dist/types/plots/distribution/pyramid/state.js +1 -0
  311. package/dist/types/plots/distribution/violin/props.d.ts +23 -0
  312. package/dist/types/plots/distribution/violin/props.js +1 -0
  313. package/dist/types/plots/distribution/violin/state.d.ts +6 -0
  314. package/dist/types/plots/distribution/violin/state.js +1 -0
  315. package/dist/types/plots/{area → evolution/area}/props.d.ts +6 -6
  316. package/dist/types/plots/evolution/area/props.js +1 -0
  317. package/dist/types/plots/{area → evolution/area}/state.d.ts +2 -2
  318. package/dist/types/plots/evolution/area/state.js +1 -0
  319. package/dist/types/plots/evolution/line/props.d.ts +10 -0
  320. package/dist/types/plots/evolution/line/props.js +1 -0
  321. package/dist/types/plots/{line → evolution/line}/state.d.ts +3 -3
  322. package/dist/types/plots/evolution/line/state.js +1 -0
  323. package/dist/types/plots/evolution/slope/props.d.ts +5 -0
  324. package/dist/types/plots/evolution/slope/props.js +1 -0
  325. package/dist/types/plots/evolution/slope/state.d.ts +5 -0
  326. package/dist/types/plots/evolution/slope/state.js +1 -0
  327. package/dist/types/plots/evolution/sparkline/props.d.ts +5 -0
  328. package/dist/types/plots/evolution/sparkline/props.js +1 -0
  329. package/dist/types/plots/evolution/sparkline/state.d.ts +5 -0
  330. package/dist/types/plots/evolution/sparkline/state.js +1 -0
  331. package/dist/types/plots/{geo → map/geo}/props.d.ts +8 -8
  332. package/dist/types/plots/map/geo/props.js +1 -0
  333. package/dist/types/plots/{geo → map/geo}/state.d.ts +18 -11
  334. package/dist/types/plots/map/geo/state.js +1 -0
  335. package/dist/types/plots/props.d.ts +1 -1
  336. package/dist/types/plots/{bar → ranking/bar}/props.d.ts +6 -6
  337. package/dist/types/plots/ranking/bar/props.js +1 -0
  338. package/dist/types/plots/{bar → ranking/bar}/state.d.ts +2 -2
  339. package/dist/types/plots/ranking/bar/state.js +1 -0
  340. package/dist/types/plots/ranking/bullet/props.d.ts +22 -0
  341. package/dist/types/plots/ranking/bullet/props.js +1 -0
  342. package/dist/types/plots/ranking/bullet/state.d.ts +5 -0
  343. package/dist/types/plots/ranking/bullet/state.js +1 -0
  344. package/dist/types/plots/ranking/cleveland/props.d.ts +10 -0
  345. package/dist/types/plots/ranking/cleveland/props.js +1 -0
  346. package/dist/types/plots/ranking/cleveland/state.d.ts +49 -0
  347. package/dist/types/plots/ranking/cleveland/state.js +1 -0
  348. package/dist/types/plots/ranking/dumbbell/props.d.ts +10 -0
  349. package/dist/types/plots/ranking/dumbbell/props.js +1 -0
  350. package/dist/types/plots/ranking/dumbbell/state.d.ts +5 -0
  351. package/dist/types/plots/ranking/dumbbell/state.js +1 -0
  352. package/dist/types/plots/ranking/forest/props.d.ts +23 -0
  353. package/dist/types/plots/ranking/forest/props.js +1 -0
  354. package/dist/types/plots/ranking/forest/state.d.ts +5 -0
  355. package/dist/types/plots/ranking/forest/state.js +1 -0
  356. package/dist/types/plots/ranking/lollipop/props.d.ts +10 -0
  357. package/dist/types/plots/ranking/lollipop/props.js +1 -0
  358. package/dist/types/plots/ranking/lollipop/state.d.ts +5 -0
  359. package/dist/types/plots/ranking/lollipop/state.js +1 -0
  360. package/dist/types/plots/segments/common.d.ts +4 -1
  361. package/dist/utils/OpacityScale.d.ts +14 -0
  362. package/dist/utils/OpacityScale.js +43 -0
  363. package/dist/utils/{symbol.d.ts → SymbolPath.d.ts} +0 -12
  364. package/dist/utils/{symbol.js → SymbolPath.js} +0 -24
  365. package/dist/utils/SymbolScale.d.ts +18 -0
  366. package/dist/utils/SymbolScale.js +29 -0
  367. package/dist/utils/color/ColorRamp.d.ts +27 -0
  368. package/dist/utils/color/ColorRamp.js +120 -0
  369. package/dist/utils/color/CssColor.d.ts +19 -0
  370. package/dist/utils/color/CssColor.js +114 -0
  371. package/dist/utils/color/Palette.d.ts +21 -0
  372. package/dist/utils/color/Palette.js +52 -0
  373. package/dist/utils/color/index.d.ts +11 -3
  374. package/dist/utils/color/index.js +14 -3
  375. package/dist/utils/grouping.js +1 -1
  376. package/docs/architecture.md +1 -1
  377. package/docs/chrome.md +2 -2
  378. package/docs/composer.md +2 -2
  379. package/docs/concepts.md +1 -1
  380. package/docs/development.md +1 -1
  381. package/docs/facets.md +3 -3
  382. package/docs/getting-started.md +2 -2
  383. package/docs/legend.md +13 -11
  384. package/docs/markers.md +29 -27
  385. package/docs/plots/correlation/heatmap.md +26 -0
  386. package/docs/plots/correlation/scatter.md +35 -0
  387. package/docs/plots/distribution/box.md +28 -0
  388. package/docs/plots/distribution/density.md +26 -0
  389. package/docs/plots/distribution/histogram.md +33 -0
  390. package/docs/plots/distribution/pyramid.md +31 -0
  391. package/docs/plots/distribution/violin.md +35 -0
  392. package/docs/plots/evolution/area.md +32 -0
  393. package/docs/plots/evolution/line.md +93 -0
  394. package/docs/plots/evolution/slope.md +39 -0
  395. package/docs/plots/evolution/sparkline.md +34 -0
  396. package/docs/plots/ranking/bar.md +59 -0
  397. package/docs/plots/ranking/bullet.md +37 -0
  398. package/docs/plots/ranking/cleveland.md +54 -0
  399. package/docs/plots/ranking/dumbbell.md +39 -0
  400. package/docs/plots/ranking/forest.md +40 -0
  401. package/docs/plots/ranking/lollipop.md +39 -0
  402. package/docs/plots.md +22 -280
  403. package/docs/scales.md +30 -24
  404. package/docs/styles-and-segments.md +24 -21
  405. package/docs/theming.md +23 -20
  406. package/docs/timeline.md +3 -3
  407. package/docs/tooltip-and-hover.md +10 -10
  408. package/docs/transforms-and-statistics.md +13 -12
  409. package/examples/BarValues.svelte +1 -1
  410. package/examples/Box.svelte +1 -1
  411. package/examples/Bullet.svelte +17 -0
  412. package/examples/Chrome.svelte +1 -1
  413. package/examples/ChromeOrder.svelte +1 -1
  414. package/examples/Cleveland.svelte +15 -0
  415. package/examples/Composer.svelte +2 -2
  416. package/examples/CustomTooltip.svelte +1 -1
  417. package/examples/Density.svelte +7 -0
  418. package/examples/Dumbbell.svelte +16 -0
  419. package/examples/Facets.svelte +1 -1
  420. package/examples/FacetsCarousel.svelte +1 -1
  421. package/examples/FacetsRowsCols.svelte +1 -1
  422. package/examples/FirstPlot.svelte +1 -1
  423. package/examples/Forest.svelte +17 -0
  424. package/examples/Gaps.svelte +2 -2
  425. package/examples/GroupedBars.svelte +1 -1
  426. package/examples/Heatmap.svelte +3 -3
  427. package/examples/HeatmapSegments.svelte +8 -8
  428. package/examples/Histogram.svelte +1 -1
  429. package/examples/HorizontalBars.svelte +1 -1
  430. package/examples/LegendSections.svelte +1 -1
  431. package/examples/LegendToggle.svelte +1 -1
  432. package/examples/LineByRegion.svelte +1 -1
  433. package/examples/LineDates.svelte +1 -1
  434. package/examples/LineStep.svelte +16 -0
  435. package/examples/LineStepSegment.svelte +18 -0
  436. package/examples/Lollipop.svelte +17 -0
  437. package/examples/Markers.svelte +1 -1
  438. package/examples/MovingAverage.svelte +1 -1
  439. package/examples/Pyramid.svelte +9 -2
  440. package/examples/Regression.svelte +2 -2
  441. package/examples/ResponsiveLine.svelte +1 -1
  442. package/examples/Scales.svelte +1 -1
  443. package/examples/Scatter.svelte +2 -2
  444. package/examples/SegmentHighlight.svelte +1 -1
  445. package/examples/Segments.svelte +1 -1
  446. package/examples/SegmentsBySeries.svelte +1 -1
  447. package/examples/Slope.svelte +17 -0
  448. package/examples/Sparkline.svelte +14 -0
  449. package/examples/StackedArea.svelte +1 -1
  450. package/examples/StackedBars.svelte +1 -1
  451. package/examples/TimelinePlayer.svelte +1 -1
  452. package/examples/TimelineRule.svelte +1 -1
  453. package/examples/Tooltip.svelte +1 -1
  454. package/examples/ValueLabels.svelte +1 -1
  455. package/examples/Violin.svelte +14 -0
  456. package/examples/datasets/argentina-chile-trends.ts +34 -0
  457. package/examples/datasets/commodity-prices.ts +48 -0
  458. package/examples/datasets/countries-over-time.ts +368 -0
  459. package/examples/datasets/daily-temperature.ts +121 -0
  460. package/examples/datasets/earthquakes.ts +977 -0
  461. package/examples/datasets/flight-routes.ts +29 -0
  462. package/examples/datasets/height-density.ts +37 -0
  463. package/examples/datasets/heights.ts +370 -0
  464. package/examples/datasets/index.ts +24 -0
  465. package/examples/datasets/inflation-by-region.ts +44 -0
  466. package/examples/datasets/inflation-ranges.ts +34 -0
  467. package/examples/datasets/iris-flower.ts +207 -0
  468. package/examples/datasets/life-expectancy.ts +95 -0
  469. package/examples/datasets/napoleons-march.ts +182 -0
  470. package/examples/datasets/penguins.ts +54 -0
  471. package/examples/datasets/population-by-age-with-gaps.ts +23 -0
  472. package/examples/datasets/population-by-age.ts +890 -0
  473. package/examples/datasets/province-population.ts +521 -0
  474. package/examples/datasets/stock-prices.ts +63 -0
  475. package/examples/datasets/weather-stations-over-time.ts +31 -0
  476. package/examples/datasets/weather-stations.ts +22 -0
  477. package/examples/datasets/wind-vectors.ts +30 -0
  478. package/examples/datasets/world-temperature.ts +400 -0
  479. package/llms-full.txt +22 -11
  480. package/llms.txt +32 -4
  481. package/package.json +10 -1
  482. package/dist/plots/bar/defaults.d.ts +0 -9
  483. package/dist/plots/geo/features.svelte.d.ts +0 -5
  484. package/dist/plots/geo/features.svelte.js +0 -44
  485. package/dist/plots/geo/phases/tooltip.js +0 -5
  486. package/dist/plots/utils/geoAccessors.d.ts +0 -72
  487. package/dist/plots/utils/geoAccessors.js +0 -220
  488. package/dist/plots/utils/geoSegments.d.ts +0 -29
  489. package/dist/plots/utils/geoSegments.js +0 -37
  490. package/dist/types/layout/styles.d.ts +0 -122
  491. package/dist/types/markers/axis/curveName.d.ts +0 -2
  492. package/dist/types/plots/line/props.d.ts +0 -10
  493. package/dist/utils/color/contrast.d.ts +0 -9
  494. package/dist/utils/color/contrast.js +0 -40
  495. package/dist/utils/color/cssColor.d.ts +0 -4
  496. package/dist/utils/color/cssColor.js +0 -77
  497. package/dist/utils/color/ramp.d.ts +0 -17
  498. package/dist/utils/color/ramp.js +0 -110
  499. package/dist/utils/opacity.d.ts +0 -9
  500. package/dist/utils/opacity.js +0 -38
  501. package/examples/data.ts +0 -324
  502. /package/dist/plots/{box → distribution/box}/markers.js +0 -0
  503. /package/dist/types/layout/{styles.js → statistics/deviation.js} +0 -0
  504. /package/dist/types/{markers/axis/curveName.js → layout/styles/base.js} +0 -0
  505. /package/dist/types/{plots/area/props.js → layout/styles/bullet.js} +0 -0
  506. /package/dist/types/{plots/area/state.js → layout/styles/connector.js} +0 -0
  507. /package/dist/types/{plots/bar/props.js → layout/styles/curve.js} +0 -0
  508. /package/dist/types/{plots/bar/state.js → layout/styles/frame.js} +0 -0
  509. /package/dist/types/{plots/box/props.js → layout/styles/gaps.js} +0 -0
  510. /package/dist/types/{plots/box/state.js → layout/styles/geo.js} +0 -0
  511. /package/dist/types/{plots/geo/props.js → layout/styles/values.js} +0 -0
  512. /package/dist/types/{plots/geo/state.js → markers/axis/violin.js} +0 -0
  513. /package/dist/types/{plots/heatmap/props.js → markers/channels/commonMarkerConfigWithRowOffset.js} +0 -0
  514. /package/dist/types/plots/{histogram → correlation/heatmap}/props.js +0 -0
  515. /package/dist/types/plots/{heatmap → correlation/heatmap}/state.js +0 -0
  516. /package/dist/types/plots/{line → correlation/scatter}/props.js +0 -0
  517. /package/dist/types/plots/{histogram → correlation/scatter}/state.js +0 -0
  518. /package/dist/types/plots/{pyramid → distribution/box}/props.js +0 -0
  519. /package/dist/types/plots/{line → distribution/box}/state.js +0 -0
  520. /package/dist/types/plots/{scatter → distribution/density}/props.js +0 -0
  521. /package/dist/types/plots/{pyramid → distribution/density}/state.js +0 -0
  522. /package/dist/types/plots/{scatter/state.js → distribution/histogram/props.js} +0 -0
  523. /package/dist/{plots/utils → utils}/accessors.d.ts +0 -0
  524. /package/dist/{plots/utils → utils}/accessors.js +0 -0
@@ -1,9 +1,8 @@
1
1
  import { ProcessedPositions } from '../../phases/transforms/ProcessedPositions';
2
2
  import { Box } from '../margins/Box';
3
- import { resolveAccessor } from '../../plots/utils/accessors';
3
+ import { resolveAccessor } from '../../utils/accessors';
4
4
  import { SERIES_ID_KEY, SERIES_KEY } from '../../phases/transforms/TransformsPhase';
5
5
  import { seriesIdOf } from '../../utils/grouping';
6
- import { Transforms } from '../../phases/transforms/Transforms';
7
6
  import { isGapValue } from '../../plots/utils/gaps';
8
7
  import { PlotAxes } from '../../phases/data/PlotAxes';
9
8
  /**
@@ -21,6 +20,8 @@ export class ValueLabels {
21
20
  fontSize;
22
21
  /** The connectors of labels that had to move apart. */
23
22
  strokeStyle;
23
+ /** `'series'` writes each label in its series' color; any other CSS color writes them all in it. */
24
+ color;
24
25
  /** How labels that would overlap move apart - the configuration's `text.declutter`. */
25
26
  declutter;
26
27
  /** Where the labels are expected to sit: boxes around their points, on the edges those can reach. */
@@ -34,6 +35,7 @@ export class ValueLabels {
34
35
  this.font = values?.fontStyle;
35
36
  this.fontSize = typeof this.font?.fontSize === 'number' ? this.font.fontSize : 12;
36
37
  this.strokeStyle = values?.strokeStyle;
38
+ this.color = values?.color;
37
39
  this.declutter = cfg.text.declutter;
38
40
  this.#cfg = cfg;
39
41
  this.reach = (this.show && reach?.(this)) || [];
@@ -43,6 +45,18 @@ export class ValueLabels {
43
45
  const { reach } = options;
44
46
  return new ValueLabels(values, cfg, options, reach && ((labels) => reach(labels, state)));
45
47
  }
48
+ /** The configuration the labels were built under, for a plot kind's own label defaults. */
49
+ get config() {
50
+ return this.#cfg;
51
+ }
52
+ /**
53
+ * The fill every label takes whatever its series: the author's own
54
+ * `fontStyle.fill`, else a literal `color`. `undefined` leaves each label to
55
+ * its plot's default (its series' color, or the axis').
56
+ */
57
+ get fill() {
58
+ return this.font?.fill ?? (this.color === 'series' ? undefined : this.color);
59
+ }
46
60
  /** One line of label text's height. */
47
61
  get lineHeight() {
48
62
  return this.fontSize * 1.2;
@@ -133,13 +147,45 @@ export class ValueLabels {
133
147
  * (`filter` + `selectLast`, per series), at its top (a stacked row's
134
148
  * `y2`), labelled with its own value and placed by `anchor`. Labels that
135
149
  * would overlap fan out into a shared column (`declutter`), colored by the
136
- * segment the row falls in.
150
+ * segment the row falls in. A plot that labels each end of its series apart
151
+ * passes the `rows` and `anchor` of one end, and `lane` to route its labels
152
+ * out to a lane whether or not they overlap (`flip: false` keeps one on the
153
+ * left in the margin instead of flipping it over its points).
137
154
  */
138
- atSeriesEnds(state) {
155
+ atSeriesEnds(state, end = {}) {
156
+ if (end.rows)
157
+ return this.#seriesEnds(state, end);
158
+ // A label on a series' first point would sit on its own line: it goes out to a lane instead.
159
+ const firsts = ValueLabels.#firstRows(state);
160
+ const labelled = state.labelled ?? [];
161
+ return [
162
+ ...this.#seriesEnds(state, { rows: labelled.filter((row) => !firsts.has(row)) }),
163
+ ...this.#seriesEnds(state, {
164
+ rows: labelled.filter((row) => firsts.has(row)),
165
+ lane: { elbowGap: ValueLabels.FIRST_LANE_GAP }
166
+ })
167
+ ];
168
+ }
169
+ /** How far (px) a lane takes the label of a series' first point from it - clear of the line that leaves it. */
170
+ static FIRST_LANE_GAP = 28;
171
+ /** The first row of every series that has more than one. */
172
+ static #firstRows(state) {
173
+ const first = new Map();
174
+ const counts = new Map();
175
+ for (const row of state.processedData?.data ?? []) {
176
+ const id = String(row[SERIES_ID_KEY]);
177
+ if (!first.has(id))
178
+ first.set(id, row);
179
+ counts.set(id, (counts.get(id) ?? 0) + 1);
180
+ }
181
+ return new Set([...first].filter(([id]) => (counts.get(id) ?? 0) > 1).map(([, row]) => row));
182
+ }
183
+ #seriesEnds(state, end) {
139
184
  const processed = state.processedData;
140
185
  if (!processed)
141
186
  return [];
142
- const { font, anchor, format } = this;
187
+ const { font, format } = this;
188
+ const anchor = end.anchor ?? this.anchor;
143
189
  const position = ProcessedPositions.of(processed);
144
190
  const topOf = (d) => position.y(d);
145
191
  const nameOf = (d) => String(d[SERIES_KEY]);
@@ -153,33 +199,39 @@ export class ValueLabels {
153
199
  group?.color ??
154
200
  state.colorForSeries?.(nameOf(d)));
155
201
  };
156
- const marker = Transforms.resolve({
202
+ const marker = {
157
203
  type: 'text',
158
- data: processed.data,
204
+ // The rows the "transforms" phase picked for the labels: by default each series' last.
205
+ data: end.rows ?? state.labelled ?? [],
159
206
  x: (processed.channels.x ?? position.x),
160
207
  y: (processed.channels.y2 ?? processed.channels.y ?? topOf),
161
208
  grouping: SERIES_ID_KEY,
162
- transforms: [
163
- {
164
- type: 'filter',
165
- filter: (d) => !isGapValue(valueOf(d)) && !isGapValue(topOf(d))
166
- },
167
- { type: 'selectLast' }
168
- ],
169
209
  text: (d) => format(Number(valueOf(d)), nameOf(d)),
170
210
  styles: {
171
211
  ...font,
212
+ ...(this.fill ? { fill: this.fill } : {}),
172
213
  fontSize: font?.fontSize ?? 12,
173
214
  dx: font?.dx ?? (anchor === 'start' ? 6 : anchor === 'end' ? -6 : 0),
174
215
  dy: font?.dy ?? (anchor === 'outside' ? -8 : 0),
175
216
  textAnchor: this.textAnchor ?? (anchor === 'start' || anchor === 'end' ? anchor : 'middle'),
176
217
  lineAnchor: font?.lineAnchor ?? (anchor === 'outside' ? 'bottom' : 'middle')
177
218
  },
178
- fill: font?.fill ? undefined : colorOf,
179
- declutter: { connector: this.strokeStyle }
180
- }, processed.data);
219
+ fill: this.fill ? undefined : colorOf,
220
+ declutter: {
221
+ connector: this.strokeStyle,
222
+ aligned: !!end.lane && (anchor === 'start' || anchor === 'end'),
223
+ elbowGap: typeof end.lane === 'object' ? end.lane.elbowGap : undefined,
224
+ flip: end.flip
225
+ }
226
+ };
181
227
  return marker.data?.length ? [marker] : [];
182
228
  }
229
+ /** The rows of a series-over-`x` plot that cannot be labelled: a gap, or a stack with no top. For the "transforms" phase's `labels.skip`. */
230
+ static skipGaps(state) {
231
+ const valueOf = ValueLabels.valueOf(state);
232
+ const top = ProcessedPositions.of(state.processedData).y;
233
+ return (row) => isGapValue(valueOf(row)) || isGapValue(top(row));
234
+ }
183
235
  /**
184
236
  * Where {@link atSeriesEnds}' labels are expected to sit: past each
185
237
  * series' last point, at the right edge (or the left, for labels set
@@ -188,9 +240,9 @@ export class ValueLabels {
188
240
  * domain when the scales set one, so it holds across a timeline; else off
189
241
  * every value.
190
242
  */
191
- reachAtSeriesEnds(state) {
243
+ reachAtSeriesEnds(state, anchor = this.anchor) {
192
244
  const series = state.resolvedSeries ?? [];
193
- const { anchor, font, format } = this;
245
+ const { font, format } = this;
194
246
  const dx = typeof font?.dx === 'number' ? font.dx : anchor === 'start' ? 6 : anchor === 'end' ? -6 : 0;
195
247
  const dy = typeof font?.dy === 'number' ? font.dy : anchor === 'outside' ? -8 : 0;
196
248
  const textAnchor = this.textAnchor ?? (anchor === 'start' ? 'start' : anchor === 'end' ? 'end' : 'middle');
@@ -203,11 +255,18 @@ export class ValueLabels {
203
255
  const { elbowGap, laneStep, labelGap } = this.declutter;
204
256
  const lanes = elbowGap + (series.length - 1) * laneStep + labelGap;
205
257
  const at = { x: series.length > 1 ? (Math.sign(dx) || 1) * lanes : dx, y: dy };
258
+ // Only a label that can sit at the plot's right end - any but a first point's - reaches that edge.
259
+ const selects = state.labelSelects ?? [];
260
+ const atRight = selects.length === 0 || selects.some((select) => select !== 'first');
261
+ // Likewise a label set before its point reaches the left edge only from a point that can sit there: any but a last one - or a last one that is also the first, of a series with a single point.
262
+ const atLeft = selects.length === 0 ||
263
+ selects.some((select) => select !== 'last') ||
264
+ series.some((s) => s.data.length < 2);
206
265
  const edges = [
207
266
  'top',
208
267
  'bottom',
209
- ...(dx < 0 ? ['left'] : []),
210
- ...(dx >= 0 || series.length > 1 ? ['right'] : [])
268
+ ...(dx < 0 && atLeft ? ['left'] : []),
269
+ ...((dx >= 0 || series.length > 1) && atRight ? ['right'] : [])
211
270
  ];
212
271
  const texts = [];
213
272
  const domain = state.scales.y?.domain;
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
2
  import { untrack } from 'svelte';
3
- import { resolveAccessor } from '../../plots/utils/accessors';
3
+ import { resolveAccessor } from '../../utils/accessors';
4
4
  import TimelineFrame from './TimelineFrame.svelte';
5
5
  import { TimelineSteps } from './TimelineSteps';
6
6
  import { TimelineTime } from './TimelineTime';
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
2
  import type { Snippet } from 'svelte';
3
3
  import { TooltipState } from './TooltipState.svelte';
4
- import type { TooltipAnchorX, TooltipAnchorY } from '../../types/layout/tooltip';
4
+ import type { TooltipAnchorX, TooltipAnchorY, TooltipRow } from '../../types/layout/tooltip';
5
5
 
6
6
  /**
7
7
  * A plot's floating tooltip at `(x, y)`, inside a `position: relative`
@@ -28,13 +28,13 @@
28
28
  visible: boolean;
29
29
  x: number;
30
30
  y: number;
31
- /** Every row the hover matched. */
32
- rows: TRow[];
31
+ /** Every row the hover matched, with the color the plot draws it in. */
32
+ rows: TooltipRow<TRow>[];
33
33
  format: (row: TRow) => string;
34
34
  /** The order the `format` text reads the rows in. Unset, as matched. */
35
35
  sort?: (a: TRow, b: TRow) => number;
36
36
  /** Custom tooltip body, given every row; replaces the `format` text and the default box. */
37
- content?: Snippet<[{ rows: TRow[] }]>;
37
+ content?: Snippet<[{ rows: TooltipRow<TRow>[] }]>;
38
38
  /** Box the tooltip must stay within. Defaults to its plot's box. */
39
39
  bounds?: { width: number; height: number };
40
40
  /** Preferred horizontal side of the point. Defaults to `'right'`. */
@@ -1,18 +1,18 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { TooltipAnchorX, TooltipAnchorY } from '../../types/layout/tooltip';
2
+ import type { TooltipAnchorX, TooltipAnchorY, TooltipRow } from '../../types/layout/tooltip';
3
3
  declare function $$render<TRow extends Record<string, unknown>>(): {
4
4
  props: {
5
5
  visible: boolean;
6
6
  x: number;
7
7
  y: number;
8
- /** Every row the hover matched. */
9
- rows: TRow[];
8
+ /** Every row the hover matched, with the color the plot draws it in. */
9
+ rows: TooltipRow<TRow>[];
10
10
  format: (row: TRow) => string;
11
11
  /** The order the `format` text reads the rows in. Unset, as matched. */
12
12
  sort?: (a: TRow, b: TRow) => number;
13
13
  /** Custom tooltip body, given every row; replaces the `format` text and the default box. */
14
14
  content?: Snippet<[{
15
- rows: TRow[];
15
+ rows: TooltipRow<TRow>[];
16
16
  }]>;
17
17
  /** Box the tooltip must stay within. Defaults to its plot's box. */
18
18
  bounds?: {
@@ -1,6 +1,6 @@
1
1
  import { Box } from '../margins/Box';
2
2
  import { PlotMargins } from '../margins/PlotMargins.svelte';
3
- import { resolveAccessor } from '../../plots/utils/accessors';
3
+ import { resolveAccessor } from '../../utils/accessors';
4
4
  import { SERIES_KEY } from '../../phases/transforms/TransformsPhase';
5
5
  import { ValueLabels } from '../styles/ValueLabels';
6
6
  /** A tooltip anchor as the side of the point the tooltip sits on. */
@@ -155,6 +155,11 @@ export declare class MarkerKinds {
155
155
  clip: false;
156
156
  drawsRows: false;
157
157
  };
158
+ violin: {
159
+ clip: true;
160
+ drawsRows: true;
161
+ legendSymbol: "area";
162
+ };
158
163
  voronoi: {
159
164
  clip: true;
160
165
  drawsRows: true;
@@ -38,6 +38,7 @@ export class MarkerKinds {
38
38
  tick: { clip: true, drawsRows: true },
39
39
  trail: { clip: true, drawsRows: true, legendSymbol: 'line' },
40
40
  vector: { clip: false, drawsRows: false },
41
+ violin: { clip: true, drawsRows: true, legendSymbol: 'area' },
41
42
  voronoi: { clip: true, drawsRows: true },
42
43
  voronoiMesh: { clip: true, drawsRows: true },
43
44
  waffle: { clip: true, drawsRows: true }
@@ -15,6 +15,7 @@
15
15
 
16
16
  const plot = usePlot();
17
17
  const isHorizontal = $derived(plot.axes?.isHorizontal ?? false);
18
+ const AreaMark = $derived(isHorizontal ? AreaX : AreaY);
18
19
 
19
20
  const cfg = $derived(getConfiguration());
20
21
  const data = $derived(marker.data ?? []);
@@ -29,82 +30,33 @@
29
30
  const y2 = $derived(hasYBand ? marker.y2 : (marker.y ?? 0));
30
31
  const x1 = $derived(hasXBand ? marker.x1 : 0);
31
32
  const x2 = $derived(hasXBand ? marker.x2 : (marker.x ?? 0));
33
+ /** The band's two ends: along `x` when the plot runs horizontally, else along `y`. */
34
+ const band = $derived(isHorizontal ? { x1, x2 } : { y1, y2 });
32
35
  </script>
33
36
 
34
- {#if opacityBuckets}
35
- {#each opacityBuckets as bucket (bucket.value)}
36
- {#if isHorizontal}
37
- <AreaX
38
- data={bucket.data}
39
- x={marker.x}
40
- {x1}
41
- {x2}
42
- y={marker.y}
43
- z={marker.grouping}
44
- stack={false}
45
- curve={marker.curve}
46
- tension={marker.tension}
47
- fill={channelFill ?? marker.styles?.fill}
48
- fillOpacity={bucket.value}
49
- stroke={marker.styles?.stroke}
50
- strokeWidth={marker.styles?.strokeWidth}
51
- strokeOpacity={marker.styles?.strokeOpacity}
52
- strokeDasharray={marker.styles?.strokeDasharray}
53
- />
54
- {:else}
55
- <AreaY
56
- data={bucket.data}
57
- x={marker.x}
58
- y={marker.y}
59
- {y1}
60
- {y2}
61
- z={marker.grouping}
62
- stack={false}
63
- curve={marker.curve}
64
- tension={marker.tension}
65
- fill={channelFill ?? marker.styles?.fill}
66
- fillOpacity={bucket.value}
67
- stroke={marker.styles?.stroke}
68
- strokeWidth={marker.styles?.strokeWidth}
69
- strokeOpacity={marker.styles?.strokeOpacity}
70
- strokeDasharray={marker.styles?.strokeDasharray}
71
- />
72
- {/if}
73
- {/each}
74
- {:else if isHorizontal}
75
- <AreaX
76
- {data}
37
+ {#snippet area(rows: typeof data, fillOpacity: number | undefined)}
38
+ <AreaMark
39
+ data={rows}
77
40
  x={marker.x}
78
- {x1}
79
- {x2}
80
41
  y={marker.y}
42
+ {...band}
81
43
  z={marker.grouping}
82
44
  stack={false}
83
45
  curve={marker.curve}
84
46
  tension={marker.tension}
85
47
  fill={channelFill ?? marker.styles?.fill}
86
- fillOpacity={marker.styles?.fillOpacity ?? cfg.area.fillOpacity}
48
+ {fillOpacity}
87
49
  stroke={marker.styles?.stroke}
88
50
  strokeWidth={marker.styles?.strokeWidth}
89
51
  strokeOpacity={marker.styles?.strokeOpacity}
90
52
  strokeDasharray={marker.styles?.strokeDasharray}
91
53
  />
54
+ {/snippet}
55
+
56
+ {#if opacityBuckets}
57
+ {#each opacityBuckets as bucket (bucket.value)}
58
+ {@render area(bucket.data, bucket.value)}
59
+ {/each}
92
60
  {:else}
93
- <AreaY
94
- {data}
95
- x={marker.x}
96
- y={marker.y}
97
- {y1}
98
- {y2}
99
- z={marker.grouping}
100
- stack={false}
101
- curve={marker.curve}
102
- tension={marker.tension}
103
- fill={channelFill ?? marker.styles?.fill}
104
- fillOpacity={marker.styles?.fillOpacity ?? cfg.area.fillOpacity}
105
- stroke={marker.styles?.stroke}
106
- strokeWidth={marker.styles?.strokeWidth}
107
- strokeOpacity={marker.styles?.strokeOpacity}
108
- strokeDasharray={marker.styles?.strokeDasharray}
109
- />
61
+ {@render area(data, marker.styles?.fillOpacity ?? cfg.area.fillOpacity)}
110
62
  {/if}
@@ -1,19 +1,61 @@
1
1
  <script lang="ts">
2
2
  import { Arrow } from 'svelteplot';
3
+ import { usePlot } from '../../layout/plot/usePlot';
4
+ import { RowStroke } from '../utils/RowStroke';
3
5
  import type { ArrowMarkerConfig } from '../../types/markers/common';
4
6
 
5
- /** Renders one `'arrow'` marker as `<Arrow>` - a point-to-point annotation. Restates svelteplot's own defaults, which an explicit `undefined` would otherwise erase. */
7
+ /**
8
+ * Renders one `'arrow'` marker as `<Arrow>` - a point-to-point annotation.
9
+ * Restates svelteplot's own defaults, which an explicit `undefined` would
10
+ * otherwise erase. An arrow on a band axis ends at the middle of its band: the
11
+ * `<Arrow>` mark reads its start as the band's first edge and its end as the
12
+ * last, so such an arrow is placed in pixels instead.
13
+ */
6
14
  let { marker }: { marker: ArrowMarkerConfig } = $props();
7
15
 
16
+ const plot = usePlot().svelteplot;
8
17
  const data = $derived(marker.data ?? []);
18
+ /** Each row's own stroke, over the marker's `styles`. */
19
+ const row = $derived(RowStroke.of(marker, marker.styles, { stroke: 'currentColor' }));
20
+
21
+ type Row = Record<string, unknown>;
22
+ type Channel = string | number | ((d: never) => unknown) | undefined;
23
+ /** A channel of a row: a field key, a function of the row, or a literal. */
24
+ const read = (channel: Channel, d: Row) =>
25
+ typeof channel === 'string'
26
+ ? d[channel]
27
+ : typeof channel === 'function'
28
+ ? (channel as (d: Row) => unknown)(d)
29
+ : channel;
30
+ /** Where `value` sits along `axis`, in pixels, at the middle of its band on a band axis. */
31
+ const pixel = (axis: 'x' | 'y', value: unknown) => {
32
+ const scale = plot.scales[axis];
33
+ const at = scale.fn(value as never) as number;
34
+ return scale.type === 'band' ? at + scale.fn.bandwidth() / 2 : at;
35
+ };
36
+ const onBand = $derived(plot.scales.x.type === 'band' || plot.scales.y.type === 'band');
37
+ /** The rows with their ends in pixels, when an axis is a band. */
38
+ const placed = $derived(
39
+ onBand
40
+ ? data.map((d) => ({
41
+ ...d,
42
+ __x1: pixel('x', read(marker.x1, d as Row)),
43
+ __x2: pixel('x', read(marker.x2, d as Row)),
44
+ __y1: pixel('y', read(marker.y1, d as Row)),
45
+ __y2: pixel('y', read(marker.y2, d as Row))
46
+ }))
47
+ : data
48
+ );
49
+ /** A pixel channel the scales leave alone. */
50
+ const own = (key: string) => ({ value: (d: Row) => d[key], scale: null }) as never;
9
51
  </script>
10
52
 
11
53
  <Arrow
12
- {data}
13
- x1={marker.x1}
14
- y1={marker.y1}
15
- x2={marker.x2}
16
- y2={marker.y2}
54
+ data={placed}
55
+ x1={onBand ? own('__x1') : marker.x1}
56
+ y1={onBand ? own('__y1') : marker.y1}
57
+ x2={onBand ? own('__x2') : marker.x2}
58
+ y2={onBand ? own('__y2') : marker.y2}
17
59
  bend={marker.bend}
18
60
  headAngle={marker.headAngle ?? 60}
19
61
  headLength={marker.headLength ?? 8}
@@ -21,8 +63,8 @@
21
63
  insetStart={marker.insetStart}
22
64
  insetEnd={marker.insetEnd}
23
65
  sweep={marker.sweep}
24
- stroke={marker.styles?.stroke ?? 'currentColor'}
25
- strokeWidth={marker.styles?.strokeWidth}
26
- strokeOpacity={marker.styles?.strokeOpacity}
66
+ stroke={row.stroke}
67
+ strokeWidth={row.strokeWidth}
68
+ strokeOpacity={row.strokeOpacity}
27
69
  strokeDasharray={marker.styles?.strokeDasharray}
28
70
  />
@@ -43,14 +43,17 @@
43
43
  {#if marker.role === 'segment'}
44
44
  {@const categoryScale = categoryScaleFor(marker.isHorizontal)}
45
45
  {@const bandwidth = categoryScale?.type === 'band' ? categoryScale.fn.bandwidth() : 0}
46
+ {@const centered =
47
+ marker.thickness != null ? Math.max(0, (bandwidth - marker.thickness) / 2) : undefined}
46
48
  {#if marker.isHorizontal}
47
49
  <BarX
48
50
  {data}
49
51
  y={marker.y}
50
52
  x1={marker.x1}
51
53
  x2={marker.x2}
52
- insetTop={marker.insetTop != null ? marker.insetTop * bandwidth : undefined}
53
- insetBottom={marker.insetBottom != null ? marker.insetBottom * bandwidth : undefined}
54
+ insetTop={centered ?? (marker.insetTop != null ? marker.insetTop * bandwidth : undefined)}
55
+ insetBottom={centered ??
56
+ (marker.insetBottom != null ? marker.insetBottom * bandwidth : undefined)}
54
57
  fill={channelFill ?? marker.styles?.fill}
55
58
  fillOpacity={marker.styles?.fillOpacity}
56
59
  stroke={marker.styles?.stroke}
@@ -65,8 +68,9 @@
65
68
  x={marker.x}
66
69
  y1={marker.y1}
67
70
  y2={marker.y2}
68
- insetLeft={marker.insetLeft != null ? marker.insetLeft * bandwidth : undefined}
69
- insetRight={marker.insetRight != null ? marker.insetRight * bandwidth : undefined}
71
+ insetLeft={centered ?? (marker.insetLeft != null ? marker.insetLeft * bandwidth : undefined)}
72
+ insetRight={centered ??
73
+ (marker.insetRight != null ? marker.insetRight * bandwidth : undefined)}
70
74
  fill={channelFill ?? marker.styles?.fill}
71
75
  fillOpacity={marker.styles?.fillOpacity}
72
76
  stroke={marker.styles?.stroke}
@@ -1,6 +1,10 @@
1
1
  <script lang="ts">
2
+ import { SvelteMap } from 'svelte/reactivity';
2
3
  import { BollingerX, BollingerY } from 'svelteplot';
3
4
  import { usePlot } from '../../layout/plot/usePlot';
5
+ import { MarkerChannels } from '../utils/MarkerChannels';
6
+ import { resolveAccessor } from '../../utils/accessors';
7
+ import { getConfiguration } from '../../configuration/config.svelte';
4
8
  import type { BollingerMarkerConfig } from '../../types/markers/common';
5
9
 
6
10
  /**
@@ -9,36 +13,47 @@
9
13
  * (`usePlot().axes`). A `stroke`-independent `fill`-style option
10
14
  * is deliberately not offered - confirmed empirically to have no visible
11
15
  * effect on svelteplot's own line (see `BollingerStatisticOptions`'s own
12
- * doc comment).
16
+ * doc comment). svelteplot draws one line and one band over all its rows, so
17
+ * with a `grouping` each group is drawn as a mark of its own, in the color
18
+ * the plot gives that group unless `styles` sets one.
13
19
  */
14
20
  let { marker }: { marker: BollingerMarkerConfig } = $props();
15
21
 
16
22
  const plot = usePlot();
17
23
  const isHorizontal = $derived(plot.axes?.isHorizontal ?? false);
24
+ const BollingerMark = $derived(isHorizontal ? BollingerX : BollingerY);
18
25
 
26
+ const cfg = $derived(getConfiguration());
19
27
  const data = $derived(marker.data ?? []);
28
+
29
+ /** The rows of each group, in the order the groups first appear. */
30
+ const groups = $derived.by(() => {
31
+ if (!marker.grouping) return [{ key: 'all', rows: data }];
32
+ const groupOf = resolveAccessor(marker.grouping as never) as (row: unknown) => unknown;
33
+ const byKey = new SvelteMap<string, typeof data>();
34
+ for (const row of data) {
35
+ const key = String(groupOf(row));
36
+ const rows = byKey.get(key);
37
+ if (rows) rows.push(row);
38
+ else byKey.set(key, [row]);
39
+ }
40
+ return [...byKey].map(([key, rows]) => ({ key, rows }));
41
+ });
42
+
43
+ /** What the plot's palette gives a row's group. */
44
+ const groupFill = $derived(MarkerChannels.buildFill(data, marker.grouping, marker.scales, cfg));
20
45
  </script>
21
46
 
22
- {#if isHorizontal}
23
- <BollingerX
24
- {data}
25
- x={marker.x}
26
- y={marker.y}
27
- n={marker.n}
28
- k={marker.k}
29
- stroke={marker.styles?.stroke}
30
- strokeOpacity={marker.styles?.strokeOpacity}
31
- fill={marker.styles?.bandFill}
32
- />
33
- {:else}
34
- <BollingerY
35
- {data}
47
+ {#each groups as group (group.key)}
48
+ {@const color = marker.grouping ? groupFill?.(group.rows[0]) : undefined}
49
+ <BollingerMark
50
+ data={group.rows}
36
51
  x={marker.x}
37
52
  y={marker.y}
38
53
  n={marker.n}
39
54
  k={marker.k}
40
- stroke={marker.styles?.stroke}
55
+ stroke={marker.styles?.stroke ?? color}
41
56
  strokeOpacity={marker.styles?.strokeOpacity}
42
- fill={marker.styles?.bandFill}
57
+ fill={marker.styles?.bandFill ?? color}
43
58
  />
44
- {/if}
59
+ {/each}
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { BoxX, BoxY } from 'svelteplot';
3
3
  import { usePlot } from '../../layout/plot/usePlot';
4
- import { contrastTextColor } from '../../utils/color';
4
+ import { CssColor } from '../../utils/color';
5
5
  import { getConfiguration } from '../../configuration/config.svelte';
6
6
  import type { BoxMarkerConfig } from '../../types/markers/common';
7
7
 
@@ -18,6 +18,33 @@
18
18
 
19
19
  const plot = usePlot();
20
20
  const isHorizontal = $derived(plot.axes?.isHorizontal ?? false);
21
+ const BoxMark = $derived(isHorizontal ? BoxX : BoxY);
22
+
23
+ /**
24
+ * With `thickness`, the box is that many pixels across, centered on the
25
+ * marker's share of its category's band (`slot`), instead of filling the band:
26
+ * the bar's insets and every sub-mark's offset follow it.
27
+ */
28
+ const thickness = $derived(marker.thickness);
29
+ const slotIndex = $derived(marker.slot?.index ?? 0);
30
+ const slotCount = $derived(marker.slot?.count ?? 1);
31
+ const bandwidth = $derived.by(() => {
32
+ const scale = isHorizontal ? plot.svelteplot.scales.y : plot.svelteplot.scales.x;
33
+ return scale?.type === 'band' ? scale.fn.bandwidth() : 0;
34
+ });
35
+ const placement = $derived.by(() => {
36
+ if (thickness == null || !bandwidth) return undefined;
37
+ const share = bandwidth / slotCount;
38
+ const offset = share * slotIndex + share / 2 - bandwidth / 2;
39
+ const inset = Math.max(0, (bandwidth - thickness) / 2);
40
+ return {
41
+ inset,
42
+ side: isHorizontal
43
+ ? { insetTop: inset, insetBottom: inset }
44
+ : { insetLeft: inset, insetRight: inset },
45
+ shift: isHorizontal ? { dy: offset } : { dx: offset }
46
+ };
47
+ });
21
48
 
22
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
50
  const data = $derived((marker.data ?? []) as any[]);
@@ -39,12 +66,15 @@
39
66
  (typeof marker.bar === 'object' && marker.bar.fill != null
40
67
  ? (marker.bar.fill as string)
41
68
  : undefined) ?? cfg.palette[0],
69
+ ...placement?.side,
70
+ ...placement?.shift,
42
71
  ...(typeof marker.bar === 'object' ? marker.bar : {})
43
72
  });
44
73
  const barFill = $derived(bar.fill as string);
45
74
 
46
75
  /** `bar.insetLeft`/`insetRight` averaged into one symmetric value - a tick's own `inset` is a single number/percentage, not independent left/right. */
47
76
  const tickInset = $derived.by(() => {
77
+ if (placement) return placement.inset;
48
78
  const l = typeof bar.insetLeft === 'number' ? bar.insetLeft : undefined;
49
79
  const r = typeof bar.insetRight === 'number' ? bar.insetRight : undefined;
50
80
  if (l === undefined && r === undefined) return undefined;
@@ -77,14 +107,19 @@
77
107
  return out;
78
108
  }
79
109
 
80
- const ruleDefault = $derived(lineStyleDefaults(barFill));
81
- const dotDefault = $derived(fillStyleDefaults());
110
+ const ruleDefault = $derived({ ...lineStyleDefaults(barFill), ...placement?.shift });
111
+ const dotDefault: Record<string, unknown> = $derived({
112
+ ...fillStyleDefaults(),
113
+ ...placement?.shift
114
+ });
82
115
  const tickMedianDefault = $derived({
83
- ...lineStyleDefaults(contrastTextColor(barFill)),
116
+ ...lineStyleDefaults(CssColor.contrastText(barFill)),
117
+ ...placement?.shift,
84
118
  ...(tickInset !== undefined ? { inset: tickInset } : {})
85
119
  });
86
120
  const tickMinMaxDefault = $derived({
87
121
  ...lineStyleDefaults(barFill),
122
+ ...placement?.shift,
88
123
  ...(tickInset !== undefined ? { inset: tickInset } : {})
89
124
  });
90
125
 
@@ -136,8 +171,4 @@
136
171
  });
137
172
  </script>
138
173
 
139
- {#if isHorizontal}
140
- <BoxX {data} x={marker.x} y={marker.y} sort={marker.sort} {...passthrough} />
141
- {:else}
142
- <BoxY {data} x={marker.x} y={marker.y} sort={marker.sort} {...passthrough} />
143
- {/if}
174
+ <BoxMark {data} x={marker.x} y={marker.y} sort={marker.sort} {...passthrough} />
@@ -1,4 +1,4 @@
1
- import { resolveAccessor } from '../../plots/utils/accessors';
1
+ import { resolveAccessor } from '../../utils/accessors';
2
2
  /**
3
3
  * A delta marker's measure: the gap, at one position along `axis`, between
4
4
  * the two curves (or axis lines) it compares. A target series is read where