@fundar/data-chart-telling 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (220) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +2 -1
  3. package/dist/configuration/config.svelte.js +1 -1
  4. package/dist/index.d.ts +3 -1
  5. package/dist/index.js +2 -1
  6. package/dist/layout/coordinates/CoordinatesLayout.svelte +3 -1
  7. package/dist/layout/geometry/GeometryLayout.svelte +57 -22
  8. package/dist/layout/geometry/ScaleFreeContext.d.ts +31 -0
  9. package/dist/layout/geometry/ScaleFreeContext.js +65 -0
  10. package/dist/layout/geometry/ScaleFreeMarks.svelte +14 -0
  11. package/dist/layout/geometry/ScaleFreeMarks.svelte.d.ts +7 -0
  12. package/dist/layout/geometry/ScaleGate.svelte.d.ts +8 -0
  13. package/dist/layout/geometry/ScaleGate.svelte.js +95 -0
  14. package/dist/layout/geometry/ScaleGateMarks.svelte +15 -0
  15. package/dist/layout/geometry/ScaleGateMarks.svelte.d.ts +7 -0
  16. package/dist/layout/hover/HoverShapes.d.ts +20 -8
  17. package/dist/layout/hover/HoverShapes.js +119 -59
  18. package/dist/layout/margins/Box.d.ts +4 -0
  19. package/dist/layout/margins/Box.js +14 -0
  20. package/dist/layout/margins/PlotMargins.svelte.js +26 -1
  21. package/dist/layout/plot/{Plot.svelte.d.ts → AbstractPlot.svelte.d.ts} +3 -3
  22. package/dist/layout/styles/ValueLabels.d.ts +109 -58
  23. package/dist/layout/styles/ValueLabels.js +299 -141
  24. package/dist/markers/MarkerKinds.d.ts +79 -1
  25. package/dist/markers/MarkerKinds.js +149 -23
  26. package/dist/markers/area/AreaMarker.svelte +1 -1
  27. package/dist/markers/bar/BarMarker.svelte +8 -6
  28. package/dist/markers/bollinger/BollingerMarker.svelte +1 -1
  29. package/dist/markers/box/BoxMarker.svelte +1 -1
  30. package/dist/markers/dot/DotRadius.d.ts +11 -0
  31. package/dist/markers/dot/DotRadius.js +21 -0
  32. package/dist/markers/labels/CurveLabel.svelte +56 -0
  33. package/dist/markers/labels/CurveLabel.svelte.d.ts +9 -0
  34. package/dist/markers/labels/LabelMerge.d.ts +11 -0
  35. package/dist/markers/labels/LabelMerge.js +87 -0
  36. package/dist/markers/labels/MarkerLabel.svelte +36 -0
  37. package/dist/markers/labels/MarkerLabel.svelte.d.ts +10 -0
  38. package/dist/markers/labels/MarkerLabels.d.ts +52 -0
  39. package/dist/markers/labels/MarkerLabels.js +97 -0
  40. package/dist/markers/labels/geometry/BoxGeometry.d.ts +8 -0
  41. package/dist/markers/labels/geometry/BoxGeometry.js +101 -0
  42. package/dist/markers/labels/geometry/CurveGeometry.d.ts +34 -0
  43. package/dist/markers/labels/geometry/CurveGeometry.js +193 -0
  44. package/dist/markers/labels/geometry/PointGeometry.d.ts +9 -0
  45. package/dist/markers/labels/geometry/PointGeometry.js +22 -0
  46. package/dist/markers/labels/layouts/BoxLayout.d.ts +10 -0
  47. package/dist/markers/labels/layouts/BoxLayout.js +49 -0
  48. package/dist/markers/labels/layouts/PathLayout.d.ts +11 -0
  49. package/dist/markers/labels/layouts/PathLayout.js +91 -0
  50. package/dist/markers/labels/layouts/PointLayout.d.ts +19 -0
  51. package/dist/markers/labels/layouts/PointLayout.js +94 -0
  52. package/dist/markers/regression/RegressionMarker.svelte +1 -1
  53. package/dist/markers/text/Covering.d.ts +13 -0
  54. package/dist/markers/text/Covering.js +29 -0
  55. package/dist/markers/text/Declutter.d.ts +24 -3
  56. package/dist/markers/text/Declutter.js +46 -3
  57. package/dist/markers/text/TextMarker.svelte +90 -17
  58. package/dist/markers/text/TextMarker.svelte.d.ts +1 -1
  59. package/dist/markers/tick/TickMarker.svelte +1 -1
  60. package/dist/markers/utils/MarkerChannels.d.ts +1 -1
  61. package/dist/markers/utils/MarkerChannels.js +3 -2
  62. package/dist/markers/violin/ViolinMarker.svelte +1 -1
  63. package/dist/markers/waffle/WaffleMarker.svelte +1 -1
  64. package/dist/phases/context/RowContext.d.ts +2 -0
  65. package/dist/phases/context/RowContext.js +2 -0
  66. package/dist/phases/markers/MarkerStyles.js +14 -11
  67. package/dist/phases/markers/MarkersPhase.d.ts +2 -3
  68. package/dist/phases/markers/MarkersPhase.js +17 -11
  69. package/dist/phases/statistics/MarkerGrouping.js +5 -32
  70. package/dist/phases/statistics/MarkerInheritance.d.ts +11 -0
  71. package/dist/phases/statistics/MarkerInheritance.js +25 -0
  72. package/dist/phases/statistics/MarkerOrientation.d.ts +26 -0
  73. package/dist/phases/statistics/MarkerOrientation.js +29 -0
  74. package/dist/phases/statistics/StatisticsPhase.js +15 -15
  75. package/dist/phases/transforms/TransformsPhase.js +5 -3
  76. package/dist/plots/correlation/heatmap/Plot.svelte +2 -2
  77. package/dist/plots/correlation/heatmap/Plot.svelte.d.ts +0 -1
  78. package/dist/plots/correlation/heatmap/defaults.js +14 -1
  79. package/dist/plots/correlation/heatmap/markers.d.ts +0 -6
  80. package/dist/plots/correlation/heatmap/markers.js +5 -9
  81. package/dist/plots/correlation/scatter/Plot.svelte +2 -2
  82. package/dist/plots/correlation/scatter/Plot.svelte.d.ts +0 -1
  83. package/dist/plots/correlation/scatter/defaults.js +9 -3
  84. package/dist/plots/correlation/scatter/markers.d.ts +0 -9
  85. package/dist/plots/correlation/scatter/markers.js +21 -28
  86. package/dist/plots/distribution/box/BoxSummaries.d.ts +5 -0
  87. package/dist/plots/distribution/box/BoxSummaries.js +9 -0
  88. package/dist/plots/distribution/box/Plot.svelte +2 -2
  89. package/dist/plots/distribution/box/Plot.svelte.d.ts +0 -1
  90. package/dist/plots/distribution/box/defaults.js +11 -0
  91. package/dist/plots/distribution/box/markers.js +10 -1
  92. package/dist/plots/distribution/density/Plot.svelte +2 -2
  93. package/dist/plots/distribution/density/Plot.svelte.d.ts +0 -1
  94. package/dist/plots/distribution/density/defaults.js +16 -0
  95. package/dist/plots/distribution/density/markers.js +5 -1
  96. package/dist/plots/distribution/histogram/Plot.svelte +2 -2
  97. package/dist/plots/distribution/histogram/Plot.svelte.d.ts +0 -1
  98. package/dist/plots/distribution/histogram/defaults.js +16 -11
  99. package/dist/plots/distribution/histogram/markers.js +3 -3
  100. package/dist/plots/distribution/pyramid/Plot.svelte +2 -2
  101. package/dist/plots/distribution/pyramid/Plot.svelte.d.ts +0 -1
  102. package/dist/plots/distribution/pyramid/defaults.js +9 -2
  103. package/dist/plots/distribution/pyramid/markers.d.ts +0 -8
  104. package/dist/plots/distribution/pyramid/markers.js +6 -16
  105. package/dist/plots/distribution/violin/Plot.svelte +2 -2
  106. package/dist/plots/distribution/violin/Plot.svelte.d.ts +0 -1
  107. package/dist/plots/distribution/violin/defaults.js +11 -0
  108. package/dist/plots/distribution/violin/markers.js +27 -3
  109. package/dist/plots/evolution/area/Plot.svelte +2 -2
  110. package/dist/plots/evolution/area/Plot.svelte.d.ts +0 -1
  111. package/dist/plots/evolution/area/defaults.js +4 -7
  112. package/dist/plots/evolution/area/markers.js +3 -1
  113. package/dist/plots/evolution/line/Plot.svelte +2 -2
  114. package/dist/plots/evolution/line/Plot.svelte.d.ts +0 -1
  115. package/dist/plots/evolution/line/defaults.js +4 -6
  116. package/dist/plots/evolution/line/markers.js +3 -1
  117. package/dist/plots/evolution/slope/Plot.svelte +2 -2
  118. package/dist/plots/evolution/slope/Plot.svelte.d.ts +0 -1
  119. package/dist/plots/evolution/slope/defaults.js +4 -3
  120. package/dist/plots/evolution/slope/markers.d.ts +4 -3
  121. package/dist/plots/evolution/slope/markers.js +16 -9
  122. package/dist/plots/evolution/sparkline/Plot.svelte +2 -2
  123. package/dist/plots/evolution/sparkline/Plot.svelte.d.ts +0 -1
  124. package/dist/plots/evolution/sparkline/defaults.js +1 -1
  125. package/dist/plots/evolution/sparkline/markers.js +3 -1
  126. package/dist/plots/generic/Plot.svelte +42 -0
  127. package/dist/plots/generic/Plot.svelte.d.ts +25 -0
  128. package/dist/plots/generic/defaults.d.ts +4 -0
  129. package/dist/plots/generic/defaults.js +7 -0
  130. package/dist/plots/map/geo/Plot.svelte +2 -2
  131. package/dist/plots/map/geo/Plot.svelte.d.ts +0 -1
  132. package/dist/plots/part-of-a-whole/treemap/Plot.svelte +2 -2
  133. package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +0 -1
  134. package/dist/plots/part-of-a-whole/treemap/defaults.js +2 -2
  135. package/dist/plots/ranking/bar/Plot.svelte +2 -2
  136. package/dist/plots/ranking/bar/Plot.svelte.d.ts +0 -1
  137. package/dist/plots/ranking/bar/defaults.js +13 -3
  138. package/dist/plots/ranking/bar/markers.js +10 -27
  139. package/dist/plots/ranking/bullet/Plot.svelte +2 -2
  140. package/dist/plots/ranking/bullet/Plot.svelte.d.ts +0 -1
  141. package/dist/plots/ranking/bullet/defaults.js +20 -0
  142. package/dist/plots/ranking/bullet/markers.js +7 -1
  143. package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +2 -9
  144. package/dist/plots/ranking/cleveland/ClevelandMarkers.js +65 -47
  145. package/dist/plots/ranking/cleveland/Plot.svelte +2 -2
  146. package/dist/plots/ranking/cleveland/Plot.svelte.d.ts +0 -1
  147. package/dist/plots/ranking/cleveland/defaults.js +33 -2
  148. package/dist/plots/ranking/dumbbell/Plot.svelte +2 -2
  149. package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +0 -1
  150. package/dist/plots/ranking/forest/Plot.svelte +2 -2
  151. package/dist/plots/ranking/forest/Plot.svelte.d.ts +0 -1
  152. package/dist/plots/ranking/lollipop/Plot.svelte +2 -2
  153. package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +0 -1
  154. package/dist/types/layout/context.d.ts +2 -0
  155. package/dist/types/layout/styles/bullet.d.ts +4 -1
  156. package/dist/types/layout/styles/values.d.ts +51 -11
  157. package/dist/types/markers/axis/area.d.ts +5 -1
  158. package/dist/types/markers/axis/bar.d.ts +5 -2
  159. package/dist/types/markers/axis/bollinger.d.ts +2 -1
  160. package/dist/types/markers/axis/box.d.ts +2 -1
  161. package/dist/types/markers/axis/cell.d.ts +4 -1
  162. package/dist/types/markers/axis/line.d.ts +4 -1
  163. package/dist/types/markers/axis/rect.d.ts +4 -1
  164. package/dist/types/markers/axis/regression.d.ts +2 -1
  165. package/dist/types/markers/axis/tick.d.ts +2 -1
  166. package/dist/types/markers/axis/trail.d.ts +4 -1
  167. package/dist/types/markers/axis/violin.d.ts +2 -1
  168. package/dist/types/markers/axis/waffle.d.ts +5 -1
  169. package/dist/types/markers/basic/dot.d.ts +4 -1
  170. package/dist/types/markers/basic/text.d.ts +25 -21
  171. package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +5 -9
  172. package/dist/types/markers/channels/commonMarkerConfigWithOrientation.d.ts +5 -0
  173. package/dist/types/markers/channels/commonMarkerConfigWithOrientation.js +1 -0
  174. package/dist/types/markers/labels/box.d.ts +57 -0
  175. package/dist/types/markers/labels/box.js +1 -0
  176. package/dist/types/markers/labels/common.d.ts +15 -0
  177. package/dist/types/markers/labels/common.js +1 -0
  178. package/dist/types/markers/labels/path.d.ts +52 -0
  179. package/dist/types/markers/labels/path.js +1 -0
  180. package/dist/types/markers/labels/point.d.ts +40 -0
  181. package/dist/types/markers/labels/point.js +1 -0
  182. package/dist/types/markers/traits.d.ts +10 -0
  183. package/dist/types/phases/markers/phase.d.ts +1 -8
  184. package/dist/types/phases/statistics/phase.d.ts +8 -3
  185. package/dist/types/phases/styles/phase.d.ts +15 -3
  186. package/dist/types/phases/transforms/phase.d.ts +2 -0
  187. package/dist/types/plots/constants.d.ts +0 -12
  188. package/dist/types/plots/correlation/heatmap/props.d.ts +3 -2
  189. package/dist/types/plots/correlation/scatter/props.d.ts +3 -2
  190. package/dist/types/plots/distribution/box/props.d.ts +6 -2
  191. package/dist/types/plots/distribution/density/props.d.ts +2 -1
  192. package/dist/types/plots/distribution/histogram/props.d.ts +3 -2
  193. package/dist/types/plots/distribution/pyramid/props.d.ts +3 -2
  194. package/dist/types/plots/distribution/violin/props.d.ts +4 -1
  195. package/dist/types/plots/evolution/area/props.d.ts +3 -2
  196. package/dist/types/plots/evolution/line/props.d.ts +3 -2
  197. package/dist/types/plots/generic/props.d.ts +16 -0
  198. package/dist/types/plots/generic/props.js +1 -0
  199. package/dist/types/plots/generic/state.d.ts +4 -0
  200. package/dist/types/plots/generic/state.js +1 -0
  201. package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +4 -2
  202. package/dist/types/plots/ranking/bar/props.d.ts +3 -2
  203. package/dist/types/plots/ranking/cleveland/props.d.ts +3 -2
  204. package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -2
  205. package/dist/types/plots/ranking/forest/props.d.ts +5 -2
  206. package/dist/types/plots/ranking/lollipop/props.d.ts +3 -2
  207. package/docs/architecture.md +9 -9
  208. package/docs/markers.md +2 -4
  209. package/docs/plots/ranking/cleveland.md +1 -1
  210. package/docs/styles-and-segments.md +1 -14
  211. package/docs/value-labels.md +159 -0
  212. package/examples/BarValues.svelte +1 -1
  213. package/llms-full.txt +2 -2
  214. package/llms.txt +1 -0
  215. package/package.json +3 -1
  216. package/dist/markers/utils/BoxLabel.d.ts +0 -58
  217. package/dist/markers/utils/BoxLabel.js +0 -175
  218. package/dist/markers/utils/MarkerLabel.svelte +0 -33
  219. package/dist/markers/utils/MarkerLabel.svelte.d.ts +0 -10
  220. /package/dist/layout/plot/{Plot.svelte → AbstractPlot.svelte} +0 -0
@@ -1,6 +1,7 @@
1
- import type { ValueLabels } from '../../../layout/styles/ValueLabels';
1
+ import { ValueLabels } from '../../../layout/styles/ValueLabels';
2
2
  import type { EdgeBox } from '../../../types/layout/box';
3
- import type { AxisBasedMarkersConfig, TextMarkerConfig } from '../../../types/markers/common';
3
+ import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
4
+ import type { MarkerLabelConfig } from '../../../types/markers/labels/common';
4
5
  import type { SlopePlotState, SlopePlotEnv } from '../../../types/plots/evolution/slope/state';
5
6
  /**
6
7
  * SlopePlot's "markers" phase: each series' line, with a dot on every point
@@ -11,6 +12,6 @@ export declare function buildMarks<TData extends Record<string, unknown>>(state:
11
12
  * SlopePlot's value labels: the series' first points labelled before them and
12
13
  * its last ones after, each end spread apart where its labels would overlap.
13
14
  */
14
- export declare function buildValueLabels<TData extends Record<string, unknown>>(labels: ValueLabels, state: SlopePlotState<TData>): TextMarkerConfig[];
15
+ export declare function buildValueLabels<TData extends Record<string, unknown>>(labels: ValueLabels, state: SlopePlotState<TData>, env: SlopePlotEnv): MarkerLabelConfig[];
15
16
  /** Where SlopePlot's labels are expected to sit: past the points at both ends. */
16
17
  export declare function buildReach<TData extends Record<string, unknown>>(labels: ValueLabels, state: SlopePlotState<TData>): EdgeBox[];
@@ -1,9 +1,10 @@
1
1
  import { getConfiguration } from '../../../configuration/config.svelte';
2
2
  import { buildLineMarkers } from '../line/markers';
3
3
  import { ProcessedPositions } from '../../../phases/transforms/ProcessedPositions';
4
- /** The anchor of the labels at the plot's start: the mirror of the end's, so `'start'` always reads outward. */
5
- function startAnchor(anchor) {
6
- return anchor === 'start' ? 'end' : anchor === 'end' ? 'start' : anchor;
4
+ import { ValueLabels } from '../../../layout/styles/ValueLabels';
5
+ /** The side of the labels at the plot's start: the mirror of the end's, so `'after'` always reads outward. */
6
+ function startSide(side) {
7
+ return side === 'after' ? 'before' : side === 'before' ? 'after' : side;
7
8
  }
8
9
  /** The value a position is told apart by: a date by its time. */
9
10
  const keyOf = (value) => (value instanceof Date ? value.getTime() : value);
@@ -24,13 +25,17 @@ export function buildMarks(state, env) {
24
25
  }
25
26
  }))
26
27
  }));
27
- return buildLineMarkers({
28
+ const lines = buildLineMarkers({
28
29
  groupedSeries: groups,
29
30
  colorFor: state.colorForSeries,
30
31
  disabledStrokeFor: (name) => env.interaction?.strokeFor(name),
31
32
  disabledDotsFor: (name) => env.interaction?.dotsFor(name),
32
33
  curve: state.styles?.curve
33
34
  });
35
+ const labels = state.valueLabels?.show
36
+ ? buildValueLabels(state.valueLabels, state, env)
37
+ : undefined;
38
+ return ValueLabels.onMarkers(lines, 'line', labels);
34
39
  }
35
40
  /** The rows labelled at the plot's first position and at its last, each series' own. */
36
41
  function labelledEnds(state) {
@@ -52,25 +57,27 @@ function labelledEnds(state) {
52
57
  * SlopePlot's value labels: the series' first points labelled before them and
53
58
  * its last ones after, each end spread apart where its labels would overlap.
54
59
  */
55
- export function buildValueLabels(labels, state) {
60
+ export function buildValueLabels(labels, state, env) {
56
61
  if (!state.processedData)
57
62
  return [];
63
+ if (labels.layout === 'path')
64
+ return labels.alongSeries(state, env);
58
65
  const { start, end } = labelledEnds(state);
59
66
  return [
60
- ...labels.atSeriesEnds(state, {
67
+ ...labels.atSeriesEnds(state, env, {
61
68
  rows: start,
62
- anchor: startAnchor(labels.anchor),
69
+ side: startSide(labels.side),
63
70
  lane: true,
64
71
  flip: false
65
72
  }),
66
- ...labels.atSeriesEnds(state, { rows: end, lane: true })
73
+ ...labels.atSeriesEnds(state, env, { rows: end, lane: true })
67
74
  ];
68
75
  }
69
76
  /** Where SlopePlot's labels are expected to sit: past the points at both ends. */
70
77
  export function buildReach(labels, state) {
71
78
  // Labels before the first position reach the left edge, those after the last one the right.
72
79
  const before = labels
73
- .reachAtSeriesEnds(state, startAnchor(labels.anchor))
80
+ .reachAtSeriesEnds(state, startSide(labels.side))
74
81
  .map(({ box, edges }) => ({ box, edges: edges.filter((edge) => edge !== 'right') }));
75
82
  const after = labels
76
83
  .reachAtSeriesEnds(state)
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TData extends Record<string, unknown>">
2
- import Plot from '../../../layout/plot/Plot.svelte';
2
+ import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
3
3
  import { buildSparklineDefaults } from './defaults';
4
4
  import type {
5
5
  SparklinePlotProps,
@@ -28,7 +28,7 @@
28
28
  }: SparklinePlotProps<TData> = $props();
29
29
  </script>
30
30
 
31
- <Plot
31
+ <AbstractPlot
32
32
  core={core as SparklinePlotCoreProps<TData>}
33
33
  defaults={buildSparklineDefaults}
34
34
  bind:margins
@@ -1,4 +1,3 @@
1
- import Plot from '../../../layout/plot/Plot.svelte';
2
1
  import type { SparklinePlotProps } from '../../../types/plots/evolution/sparkline/props';
3
2
  declare function $$render<TData extends Record<string, unknown>>(): {
4
3
  props: SparklinePlotProps<TData>;
@@ -19,7 +19,7 @@ export function buildSparklineDefaults() {
19
19
  format: (value, number) => number(value)
20
20
  }
21
21
  },
22
- markers: { marks: buildMarks, valueLabels: line.markers.valueLabels },
22
+ markers: { marks: buildMarks },
23
23
  // Small and bare: a dot on the hovered point, and nothing else.
24
24
  hover: { ...line.hover, marker: () => ({ back: [], front: [HoverDefaults.dot()] }) }
25
25
  };
@@ -1,3 +1,4 @@
1
+ import { ValueLabels } from '../../../layout/styles/ValueLabels';
1
2
  import { getConfiguration } from '../../../configuration/config.svelte';
2
3
  import { buildLineMarkers } from '../line/markers';
3
4
  import { resolveAccessor } from '../../../utils/accessors';
@@ -52,5 +53,6 @@ export function buildMarks(state, env) {
52
53
  }
53
54
  ];
54
55
  });
55
- return [...lines, ...dots];
56
+ const labels = state.valueLabels?.show ? state.valueLabels.forSeries(state, env) : undefined;
57
+ return [...ValueLabels.onMarkers(lines, 'line', labels), ...dots];
56
58
  }
@@ -0,0 +1,42 @@
1
+ <script lang="ts" generics="TData extends Record<string, unknown>">
2
+ import AbstractPlot from '../../layout/plot/AbstractPlot.svelte';
3
+ import { buildGenericDefaults } from './defaults';
4
+ import type { GenericPlotProps, GenericPlotCoreProps } from '../../types/plots/generic/props';
5
+
6
+ /**
7
+ * A plot of no kind: no shapes or defaults of its own, only its `markers`. `data` and the channels
8
+ * are optional; markers without their own take them, and its `segments`, `transforms`, `styles`,
9
+ * chrome, `timeline` and `facet` work as on any plot.
10
+ * `margins` is bindable: it reports the margin the plot settled on.
11
+ */
12
+ let {
13
+ title,
14
+ subtitle,
15
+ caption,
16
+ header,
17
+ footer,
18
+ legend,
19
+ order,
20
+ timeline,
21
+ facet,
22
+ tooltip,
23
+ margins = $bindable(),
24
+ ...core
25
+ }: GenericPlotProps<TData> = $props();
26
+ </script>
27
+
28
+ <AbstractPlot
29
+ core={core as GenericPlotCoreProps<TData>}
30
+ defaults={buildGenericDefaults}
31
+ bind:margins
32
+ {title}
33
+ {subtitle}
34
+ {caption}
35
+ {header}
36
+ {footer}
37
+ {legend}
38
+ {order}
39
+ {timeline}
40
+ {facet}
41
+ {tooltip}
42
+ />
@@ -0,0 +1,25 @@
1
+ import type { GenericPlotProps } from '../../types/plots/generic/props';
2
+ declare function $$render<TData extends Record<string, unknown>>(): {
3
+ props: GenericPlotProps<TData>;
4
+ exports: {};
5
+ bindings: "margins";
6
+ slots: {};
7
+ events: {};
8
+ };
9
+ declare class __sveltets_Render<TData extends Record<string, unknown>> {
10
+ props(): ReturnType<typeof $$render<TData>>['props'];
11
+ events(): ReturnType<typeof $$render<TData>>['events'];
12
+ slots(): ReturnType<typeof $$render<TData>>['slots'];
13
+ bindings(): "margins";
14
+ exports(): {};
15
+ }
16
+ interface $$IsomorphicComponent {
17
+ new <TData extends Record<string, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData>['props']>, ReturnType<__sveltets_Render<TData>['events']>, ReturnType<__sveltets_Render<TData>['slots']>> & {
18
+ $$bindings?: ReturnType<__sveltets_Render<TData>['bindings']>;
19
+ } & ReturnType<__sveltets_Render<TData>['exports']>;
20
+ <TData extends Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<TData>['props']> & {}): ReturnType<__sveltets_Render<TData>['exports']>;
21
+ z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
22
+ }
23
+ declare const Plot: $$IsomorphicComponent;
24
+ type Plot<TData extends Record<string, unknown>> = InstanceType<typeof Plot<TData>>;
25
+ export default Plot;
@@ -0,0 +1,4 @@
1
+ import type { AxisPlotDefaults } from '../../types/phases';
2
+ import type { GenericPlotState, GenericPlotEnv } from '../../types/plots/generic/state';
3
+ /** The plot with no kind: it draws only its `markers`. */
4
+ export declare function buildGenericDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<GenericPlotState<TData>, GenericPlotEnv>;
@@ -0,0 +1,7 @@
1
+ /** The plot with no kind: it draws only its `markers`. */
2
+ export function buildGenericDefaults() {
3
+ return {
4
+ data: { segments: { color: (style) => style?.fill } },
5
+ markers: { marks: () => [] }
6
+ };
7
+ }
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" generics="TProps extends Record<string, unknown>">
2
2
  import Core from './Core.svelte';
3
- import Plot from '../../../layout/plot/Plot.svelte';
3
+ import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
4
4
  import { merge } from '../../../utils/merge';
5
5
  import { buildGeoDefaults } from './defaults';
6
6
  import { buildGeoSlicing } from './slices';
@@ -87,7 +87,7 @@
87
87
  }
88
88
  </script>
89
89
 
90
- <Plot
90
+ <AbstractPlot
91
91
  {Core}
92
92
  core={core as GeoPlotCoreProps<TProps>}
93
93
  defaults={buildGeoDefaults}
@@ -1,4 +1,3 @@
1
- import Plot from '../../../layout/plot/Plot.svelte';
2
1
  import type { GeoPlotProps } from '../../../types/plots/map/geo/props';
3
2
  declare function $$render<TProps extends Record<string, unknown>>(): {
4
3
  props: GeoPlotProps<TProps>;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TData extends Record<string, unknown>">
2
- import Plot from '../../../layout/plot/Plot.svelte';
2
+ import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
3
3
  import { buildTreemapDefaults } from './defaults';
4
4
  import type {
5
5
  TreemapPlotProps,
@@ -30,7 +30,7 @@
30
30
  }: TreemapPlotProps<TData> = $props();
31
31
  </script>
32
32
 
33
- <Plot
33
+ <AbstractPlot
34
34
  core={core as TreemapPlotCoreProps<TData>}
35
35
  defaults={buildTreemapDefaults}
36
36
  bind:margins
@@ -1,4 +1,3 @@
1
- import Plot from '../../../layout/plot/Plot.svelte';
2
1
  import type { TreemapPlotProps } from '../../../types/plots/part-of-a-whole/treemap/props';
3
2
  declare function $$render<TData extends Record<string, unknown>>(): {
4
3
  props: TreemapPlotProps<TData>;
@@ -87,7 +87,7 @@ function buildMarks(state, env) {
87
87
  };
88
88
  /** The label of a series' tiles: the name over the share, fitted - or the share alone where the name does not fit. */
89
89
  const labelOf = (labels) => {
90
- const shape = labels.shapeLabel(env, (row) => `${contextOf(row).name}
90
+ const shape = labels.label(env, (row) => `${contextOf(row).name}
91
91
  ${shareText(row)}`, { fontSize: look.fontSize });
92
92
  return {
93
93
  ...shape,
@@ -155,7 +155,7 @@ export function buildTreemapDefaults() {
155
155
  }),
156
156
  fit: () => ({ x: { domain: [0, 1], fitted: true }, y: { domain: [0, 1], fitted: true } })
157
157
  },
158
- styles: { values: { show: true } },
158
+ styles: { values: { show: true, layout: 'box' } },
159
159
  markers: { marks: buildMarks },
160
160
  hover: {
161
161
  strategy: 'punctual',
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TData extends Record<string, unknown>">
2
- import Plot from '../../../layout/plot/Plot.svelte';
2
+ import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
3
3
  import { buildBarDefaults } from './defaults';
4
4
  import type { BarPlotProps, BarPlotCoreProps } from '../../../types/plots/ranking/bar/props';
5
5
 
@@ -24,7 +24,7 @@
24
24
  }: BarPlotProps<TData> = $props();
25
25
  </script>
26
26
 
27
- <Plot
27
+ <AbstractPlot
28
28
  core={core as BarPlotCoreProps<TData>}
29
29
  defaults={buildBarDefaults}
30
30
  bind:margins
@@ -1,4 +1,3 @@
1
- import Plot from '../../../layout/plot/Plot.svelte';
2
1
  import type { BarPlotProps } from '../../../types/plots/ranking/bar/props';
3
2
  declare function $$render<TData extends Record<string, unknown>>(): {
4
3
  props: BarPlotProps<TData>;
@@ -59,17 +59,27 @@ export function buildBarDefaults() {
59
59
  }),
60
60
  fit: (state) => fitValueDomain(state)
61
61
  },
62
+ transforms: { labels: {} },
62
63
  styles: {
63
64
  values: {
65
+ layout: (state) => ProcessedPositions.span(state.processedData, PlotAxes.valueOf(state))
66
+ .stacked
67
+ ? 'box'
68
+ : 'path',
69
+ layouts: {
70
+ path: { edge: 'tip', side: 'outside' },
71
+ box: { anchor: 'middle' },
72
+ point: { anchor: 'top', side: 'above' }
73
+ },
64
74
  // An `'outside'` label sits past its bar's end, which the tallest bar takes to the edge.
65
75
  reach: (labels, state) => {
66
- if (labels.anchor !== 'outside')
76
+ if (!labels.pastTip)
67
77
  return [];
68
78
  const axis = PlotAxes.valueOf(state);
69
79
  if (ProcessedPositions.span(state.processedData, axis).stacked)
70
80
  return [];
71
81
  if (!state.axes?.isHorizontal) {
72
- const offset = labels.offset('y');
82
+ const offset = labels.offset();
73
83
  const boxes = [
74
84
  labels.edgeBox('0', { x: 'middle', y: 'before' }, { y: -offset }, ['top'])
75
85
  ];
@@ -82,7 +92,7 @@ export function buildBarDefaults() {
82
92
  return boxes;
83
93
  }
84
94
  // A bar below zero reaches out to the left, with its label turned that way.
85
- const offset = labels.offset('x');
95
+ const offset = labels.offset();
86
96
  return labels
87
97
  .extremes(state.resolvedSeries ?? [], PlotAxes.valueOf(state), 'both')
88
98
  .map(({ series, value }) => value < 0
@@ -4,7 +4,6 @@ import { GAP_KIND, GAP_VALUE, SERIES_ID_KEY } from '../../../phases/transforms/T
4
4
  import { seriesIdOf } from '../../../utils/grouping';
5
5
  import { resolveGapAreaStyle } from '../../utils/gaps';
6
6
  import { PlotAxes } from '../../../phases/data/PlotAxes';
7
- import { ValueLabels } from '../../../layout/styles/ValueLabels';
8
7
  const GAP_KINDS = ['start', 'middle', 'end'];
9
8
  /**
10
9
  * Where a bar plot's bars sit, read off the state its phases leave: each
@@ -89,21 +88,14 @@ export function buildMarks(state, env) {
89
88
  // which stays a field key whenever the plot has no transforms.
90
89
  const valueOf = (channel) => (geometry.stacked || channel === undefined ? top : channel);
91
90
  const gapValue = valueOf(channels[valueAxis]);
92
- // What each bar writes in itself: its value, anchored along the bar by `anchor` - past its tip
93
- // (`'outside'`), just inside it (`'start'`), at its base (`'end'`) or in the middle. A stacked bar's
94
- // label is always in the middle of its segment.
95
- const labels = state.valueLabels?.show ? state.valueLabels : undefined;
96
- const valueRead = ValueLabels.valueOf(state);
97
- const turns = !!labels && !geometry.stacked && ValueLabels.followsSign(labels.anchor);
98
- const labelAnchor = (negative) => ValueLabels.boxAnchor(labels?.anchor ?? 'outside', {
99
- isHorizontal,
100
- negative,
101
- stacked: geometry.stacked
102
- });
103
- const labelFor = (name, slice, negative) => labels && {
104
- ...labels.shapeLabel(env, (d) => labels.format(Number(valueRead(d)), d, name), {
91
+ // What each bar writes about itself: its value, in the layout of `styles.values` - by default past its tip, or
92
+ // in the middle of a stacked bar's segment.
93
+ const labels = state.valueLabels?.show && state.valueLabels.writes('value') ? state.valueLabels : undefined;
94
+ const labelFor = (name, slice) => labels && {
95
+ ...labels.label(env, (d) => labels.text(d), {
105
96
  fill: 'currentColor',
106
- ...labelAnchor(negative)
97
+ labelled: state.labelled,
98
+ seriesColor: () => colorForSeries(name)
107
99
  }),
108
100
  bandSlice: slice
109
101
  };
@@ -155,18 +147,9 @@ export function buildMarks(state, env) {
155
147
  };
156
148
  const real = seg.data.filter(isReal);
157
149
  const value = valueOf(group.series[valueAxis]);
158
- // A label past the tip turns with the sign of its value, so the bars below zero are a marker of their own.
159
- const parts = turns
160
- ? [false, true].map((negative) => ({
161
- negative,
162
- rows: real.filter((row) => Number(valueRead(row)) < 0 === negative)
163
- }))
164
- : [{ negative: false, rows: real }];
165
- for (const { negative, rows } of parts) {
166
- const marker = makeMarker(rows, slice, value, styles, labelFor(name, slice, negative));
167
- if (marker)
168
- segmentMarkers.push(marker);
169
- }
150
+ const marker = makeMarker(real, slice, value, styles, labelFor(name, slice));
151
+ if (marker)
152
+ segmentMarkers.push(marker);
170
153
  }
171
154
  const id = seriesIdOf(group.series);
172
155
  const fills = [...(gapFillMaps.get(id)?.values() ?? [])];
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TData extends Record<string, unknown>">
2
- import Plot from '../../../layout/plot/Plot.svelte';
2
+ import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
3
3
  import { buildBulletDefaults } from './defaults';
4
4
  import type { BulletPlotProps, BulletPlotCoreProps } from '../../../types/plots/ranking/bullet/props';
5
5
 
@@ -25,7 +25,7 @@
25
25
  }: BulletPlotProps<TData> = $props();
26
26
  </script>
27
27
 
28
- <Plot
28
+ <AbstractPlot
29
29
  core={core as BulletPlotCoreProps<TData>}
30
30
  defaults={buildBulletDefaults}
31
31
  bind:margins
@@ -1,4 +1,3 @@
1
- import Plot from '../../../layout/plot/Plot.svelte';
2
1
  import type { BulletPlotProps } from '../../../types/plots/ranking/bullet/props';
3
2
  declare function $$render<TData extends Record<string, unknown>>(): {
4
3
  props: BulletPlotProps<TData>;
@@ -1,3 +1,5 @@
1
+ import { ValueLabels } from '../../../layout/styles/ValueLabels';
2
+ import { RowNumbers } from '../../utils/RowNumbers';
1
3
  import { buildBarDefaults, fitValueDomain } from '../bar/defaults';
2
4
  import { buildMarks, buildReach } from './markers';
3
5
  /**
@@ -19,6 +21,24 @@ export function buildBulletDefaults() {
19
21
  }),
20
22
  fit: (state, env) => fitValueDomain(state, buildReach(state, env))
21
23
  },
24
+ // Each bar's target and range bounds, for its tooltip, hover and value labels to read.
25
+ context: (state) => ((row) => ({
26
+ target: RowNumbers.of(state.target, row),
27
+ ranges: (state.ranges ?? [])
28
+ .map((range) => RowNumbers.of(range, row))
29
+ .filter((bound) => bound !== undefined)
30
+ .sort((a, b) => a - b)
31
+ })),
32
+ styles: {
33
+ ...bar.styles,
34
+ values: {
35
+ ...bar.styles?.values,
36
+ parts: {
37
+ placements: (state) => ValueLabels.besideBand(state, ['target', 'ranges']),
38
+ default: ['value']
39
+ }
40
+ }
41
+ },
22
42
  markers: { ...bar.markers, marks: buildMarks }
23
43
  };
24
44
  }
@@ -1,3 +1,4 @@
1
+ import { ValueLabels } from '../../../layout/styles/ValueLabels';
1
2
  import { buildMarks as buildBarMarks, buildBarGeometry } from '../bar/markers';
2
3
  import { GAP_VALUE } from '../../../phases/transforms/TransformsPhase';
3
4
  import { RowNumbers } from '../../utils/RowNumbers';
@@ -85,5 +86,10 @@ export function buildMarks(state, env) {
85
86
  }
86
87
  }
87
88
  ];
88
- return [...ranges, ...bars, ...ticks];
89
+ // Its other parts `styles.values` labels - the target, the range bounds - beside the band; the bars write the value.
90
+ const geometry = buildBarGeometry(state, env.cfg.bar.seriesPadding);
91
+ const labels = state.valueLabels?.show
92
+ ? state.valueLabels.partMarkers(env, (state.processedData?.data ?? []).filter((row) => row[GAP_VALUE] === undefined && geometry.spanOf(row) !== undefined), ValueLabels.bandPoint(state, geometry.categoryOf), { skip: ['value'] })
93
+ : [];
94
+ return [...ranges, ...bars, ...ticks, ...labels];
89
95
  }
@@ -1,6 +1,6 @@
1
1
  import { ValueLabels } from '../../../layout/styles/ValueLabels';
2
2
  import type { ClevelandPlotState, ClevelandPlotEnv, ClevelandOptions } from '../../../types/plots/ranking/cleveland/state';
3
- import type { AxisBasedMarkersConfig, TextMarkerConfig } from '../../../types/markers/common';
3
+ import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
4
4
  import type { EdgeBox } from '../../../types/layout/box';
5
5
  /**
6
6
  * The marks of the Cleveland family of plots, which differ only by their
@@ -8,7 +8,7 @@ import type { EdgeBox } from '../../../types/layout/box';
8
8
  * highest value (from the baseline, for a lollipop) with a dot at each value.
9
9
  * A category with one dot gets a stem in that dot's series color, restyled by
10
10
  * the segment its dot belongs to; a category with several gets one neutral
11
- * connector. The "markers" phase takes its `marks`, `valueLabels` and `reach`.
11
+ * connector. The "markers" phase takes its `marks` and `reach`.
12
12
  */
13
13
  export declare class ClevelandMarkers {
14
14
  #private;
@@ -17,13 +17,6 @@ export declare class ClevelandMarkers {
17
17
  static resetWarnings(): void;
18
18
  /** The plot's connectors, then its dots, which draw on top of them. */
19
19
  marks: <TData extends Record<string, unknown>>(state: ClevelandPlotState<TData>, env: ClevelandPlotEnv) => AxisBasedMarkersConfig[];
20
- /**
21
- * The value labels of the dots `styles.values.of` picks, one `'text'` marker
22
- * per place a dot can hold in its range - past the top end (above, or right
23
- * of it), past the bottom end (below, or left of it) and, for the dots
24
- * between, beside it - and per series, when they take their series' color.
25
- */
26
- valueLabels: <TData extends Record<string, unknown>>(labels: ValueLabels, state: ClevelandPlotState<TData>, env: ClevelandPlotEnv) => TextMarkerConfig[];
27
20
  /**
28
21
  * Room for the labels past the dots at the end of the value axis, so the
29
22
  * farthest one fits inside the figure instead of crossing its edge. Only the