@fundar/data-chart-telling 0.0.25 → 0.0.27

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 (198) hide show
  1. package/dist/charts/BaseChart.svelte +18 -10
  2. package/dist/charts/BaseChart.svelte.d.ts +4 -2
  3. package/dist/charts/bar/Chart.svelte +2 -0
  4. package/dist/charts/heatmap/Chart.svelte +5 -3
  5. package/dist/charts/heatmap/Chart.svelte.d.ts +1 -2
  6. package/dist/charts/line/Chart.svelte +2 -0
  7. package/dist/charts/pyramid/Chart.svelte +5 -3
  8. package/dist/charts/pyramid/Chart.svelte.d.ts +1 -2
  9. package/dist/charts/scatter/Chart.svelte +95 -0
  10. package/dist/charts/scatter/Chart.svelte.d.ts +28 -0
  11. package/dist/configuration/config.svelte.js +28 -0
  12. package/dist/configuration/themes/dark.js +4 -0
  13. package/dist/configuration/themes/index.d.ts +112 -0
  14. package/dist/index.d.ts +26 -16
  15. package/dist/index.js +11 -3
  16. package/dist/layout/coordinates/CoordinatesLayout.svelte +93 -0
  17. package/dist/layout/{plot/RuleLayout.svelte.d.ts → coordinates/CoordinatesLayout.svelte.d.ts} +13 -16
  18. package/dist/layout/coordinates/margins.d.ts +16 -0
  19. package/dist/layout/coordinates/margins.js +11 -0
  20. package/dist/{plots/geo → layout/coordinates}/projections/argentina.d.ts +1 -1
  21. package/dist/layout/{geo → coordinates}/resolveProjection.d.ts +1 -1
  22. package/dist/layout/coordinates/resolveProjection.js +24 -0
  23. package/dist/{plots/geo → layout/coordinates}/zoom.svelte.d.ts +1 -1
  24. package/dist/layout/facet/FacetIndicator.svelte +31 -0
  25. package/dist/layout/facet/FacetIndicator.svelte.d.ts +8 -0
  26. package/dist/layout/facet/FacetLayout.svelte +249 -24
  27. package/dist/layout/facet/FacetLayout.svelte.d.ts +7 -1
  28. package/dist/layout/geometry/GeometryLayout.svelte +231 -0
  29. package/dist/layout/geometry/GeometryLayout.svelte.d.ts +62 -0
  30. package/dist/layout/legend/ContinuousSection.svelte +1 -1
  31. package/dist/layout/legend/ContinuousSection.svelte.d.ts +1 -1
  32. package/dist/layout/legend/DiscreteSection.svelte +1 -1
  33. package/dist/layout/legend/DiscreteSection.svelte.d.ts +1 -1
  34. package/dist/layout/legend/LegendLayout.svelte +1 -1
  35. package/dist/layout/legend/LegendLayout.svelte.d.ts +1 -1
  36. package/dist/layout/legend/interaction.svelte.d.ts +9 -1
  37. package/dist/layout/legend/interaction.svelte.js +9 -1
  38. package/dist/layout/plot/BasePlotLayout.svelte +142 -155
  39. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +61 -51
  40. package/dist/layout/plot/margins.d.ts +0 -16
  41. package/dist/layout/plot/margins.js +0 -11
  42. package/dist/layout/{plot/AxisLayout.svelte → scales/ScalesLayout.svelte} +23 -16
  43. package/dist/layout/{plot/AxisLayout.svelte.d.ts → scales/ScalesLayout.svelte.d.ts} +4 -5
  44. package/dist/layout/scales/buildScale.d.ts +8 -0
  45. package/dist/layout/scales/buildScale.js +43 -0
  46. package/dist/layout/styles/StylesLayout.svelte +75 -0
  47. package/dist/layout/styles/StylesLayout.svelte.d.ts +15 -0
  48. package/dist/{plots/geo → layout/styles}/TileLayer.svelte +2 -2
  49. package/dist/{plots/geo → layout/styles}/TileLayer.svelte.d.ts +1 -1
  50. package/dist/layout/timeline/Timeline.svelte +1 -1
  51. package/dist/layout/timeline/Timeline.svelte.d.ts +1 -1
  52. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  53. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
  54. package/dist/layout/tooltip/Tooltip.svelte +16 -20
  55. package/dist/layout/tooltip/Tooltip.svelte.d.ts +5 -0
  56. package/dist/layout/tooltip/TooltipLayout.svelte +7 -1
  57. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +4 -0
  58. package/dist/layout/tooltip/controller.svelte.d.ts +4 -5
  59. package/dist/layout/tooltip/controller.svelte.js +42 -16
  60. package/dist/layout/tooltip/resolveTooltipPlacement.d.ts +24 -0
  61. package/dist/layout/tooltip/resolveTooltipPlacement.js +49 -0
  62. package/dist/layout/tooltip/utils.d.ts +27 -19
  63. package/dist/layout/tooltip/utils.js +16 -15
  64. package/dist/markers/BarMarker.svelte +92 -0
  65. package/dist/markers/BarMarker.svelte.d.ts +7 -0
  66. package/dist/markers/CellMarker.svelte +21 -0
  67. package/dist/markers/CellMarker.svelte.d.ts +7 -0
  68. package/dist/markers/ContourMarker.svelte +28 -0
  69. package/dist/markers/ContourMarker.svelte.d.ts +7 -0
  70. package/dist/markers/DeltaMarker.svelte +32 -39
  71. package/dist/markers/DeltaMarker.svelte.d.ts +4 -5
  72. package/dist/markers/DotMarker.svelte +35 -6
  73. package/dist/markers/DotMarker.svelte.d.ts +11 -2
  74. package/dist/markers/GeoFeaturesMarker.svelte +19 -0
  75. package/dist/markers/GeoFeaturesMarker.svelte.d.ts +7 -0
  76. package/dist/markers/GeoHoverMarker.svelte +25 -0
  77. package/dist/markers/GeoHoverMarker.svelte.d.ts +9 -0
  78. package/dist/markers/GraticuleMarker.svelte +18 -0
  79. package/dist/markers/GraticuleMarker.svelte.d.ts +7 -0
  80. package/dist/markers/HoverMarker.svelte +34 -35
  81. package/dist/markers/HoverMarker.svelte.d.ts +15 -9
  82. package/dist/markers/LineMarker.svelte +19 -0
  83. package/dist/markers/LineMarker.svelte.d.ts +7 -0
  84. package/dist/markers/LinkMarker.svelte +42 -0
  85. package/dist/markers/LinkMarker.svelte.d.ts +7 -0
  86. package/dist/markers/RuleMarker.svelte +24 -0
  87. package/dist/markers/RuleMarker.svelte.d.ts +10 -0
  88. package/dist/markers/SphereMarker.svelte +15 -0
  89. package/dist/markers/SphereMarker.svelte.d.ts +7 -0
  90. package/dist/markers/TextMarker.svelte +1 -1
  91. package/dist/markers/TextMarker.svelte.d.ts +1 -1
  92. package/dist/markers/VectorMarker.svelte +20 -0
  93. package/dist/markers/VectorMarker.svelte.d.ts +7 -0
  94. package/dist/markers/inset/InsetMarker.svelte +38 -45
  95. package/dist/markers/inset/InsetMarker.svelte.d.ts +6 -2
  96. package/dist/plots/bar/Plot.svelte +96 -87
  97. package/dist/plots/bar/Plot.svelte.d.ts +4 -5
  98. package/dist/plots/bar/ValueLabels.svelte +70 -24
  99. package/dist/plots/bar/ValueLabels.svelte.d.ts +11 -2
  100. package/dist/plots/bar/buildBarMarkers.d.ts +30 -0
  101. package/dist/plots/bar/buildBarMarkers.js +100 -0
  102. package/dist/plots/bar/layout.svelte.d.ts +1 -2
  103. package/dist/plots/bar/layout.svelte.js +1 -1
  104. package/dist/plots/geo/Plot.svelte +113 -387
  105. package/dist/plots/geo/Plot.svelte.d.ts +5 -4
  106. package/dist/plots/geo/buildGeoMarkers.d.ts +33 -0
  107. package/dist/plots/geo/buildGeoMarkers.js +47 -0
  108. package/dist/plots/heatmap/Plot.svelte +27 -52
  109. package/dist/plots/heatmap/Plot.svelte.d.ts +4 -5
  110. package/dist/plots/heatmap/ValueLabels.svelte +5 -5
  111. package/dist/plots/heatmap/ValueLabels.svelte.d.ts +3 -3
  112. package/dist/plots/heatmap/buildCellMarkers.d.ts +21 -0
  113. package/dist/plots/heatmap/buildCellMarkers.js +25 -0
  114. package/dist/plots/line/Plot.svelte +73 -141
  115. package/dist/plots/line/Plot.svelte.d.ts +4 -4
  116. package/dist/plots/line/ValueLabels.svelte +84 -85
  117. package/dist/plots/line/ValueLabels.svelte.d.ts +10 -1
  118. package/dist/plots/line/buildLineMarkers.d.ts +15 -0
  119. package/dist/plots/line/buildLineMarkers.js +57 -0
  120. package/dist/plots/pyramid/Plot.svelte +80 -121
  121. package/dist/plots/pyramid/Plot.svelte.d.ts +4 -5
  122. package/dist/plots/pyramid/ValueLabels.svelte +71 -25
  123. package/dist/plots/pyramid/ValueLabels.svelte.d.ts +11 -2
  124. package/dist/plots/pyramid/buildPyramidBarMarkers.d.ts +19 -0
  125. package/dist/plots/pyramid/buildPyramidBarMarkers.js +32 -0
  126. package/dist/plots/scatter/Plot.svelte +242 -0
  127. package/dist/{layout/plot/GridLayout.svelte.d.ts → plots/scatter/Plot.svelte.d.ts} +9 -7
  128. package/dist/plots/scatter/ValueLabels.svelte +149 -0
  129. package/dist/plots/{bar/BarSegments.svelte.d.ts → scatter/ValueLabels.svelte.d.ts} +17 -15
  130. package/dist/plots/scatter/buildScatterMarkers.d.ts +11 -0
  131. package/dist/plots/scatter/buildScatterMarkers.js +37 -0
  132. package/dist/plots/scatter/resolveRadiusPaddedDomain.d.ts +10 -0
  133. package/dist/plots/scatter/resolveRadiusPaddedDomain.js +23 -0
  134. package/dist/plots/utils/declutter.d.ts +55 -37
  135. package/dist/plots/utils/declutter.js +79 -64
  136. package/dist/plots/utils/geoAccessors.d.ts +1 -1
  137. package/dist/plots/utils/geoAccessors.js +1 -1
  138. package/dist/plots/utils/labelOverflow.svelte.d.ts +51 -0
  139. package/dist/plots/utils/labelOverflow.svelte.js +116 -0
  140. package/dist/plots/utils/legendDisabled.d.ts +1 -1
  141. package/dist/plots/utils/segments.d.ts +17 -10
  142. package/dist/plots/utils/segments.js +26 -16
  143. package/dist/types/charts/common.d.ts +3 -50
  144. package/dist/types/charts/props.d.ts +8 -8
  145. package/dist/types/configuration/styling.d.ts +26 -2
  146. package/dist/types/{plots/scales/geo.d.ts → layout/coordinates.d.ts} +33 -1
  147. package/dist/types/layout/facet.d.ts +41 -0
  148. package/dist/types/layout/geometry.d.ts +17 -0
  149. package/dist/types/layout/legend.d.ts +65 -1
  150. package/dist/types/{plots/axis.d.ts → layout/scales.d.ts} +11 -0
  151. package/dist/types/layout/styles.d.ts +115 -0
  152. package/dist/types/layout/timeline.d.ts +32 -0
  153. package/dist/types/layout/tooltip.d.ts +20 -1
  154. package/dist/types/markers/all.d.ts +11 -0
  155. package/dist/types/markers/all.js +1 -0
  156. package/dist/types/markers/base.d.ts +45 -0
  157. package/dist/types/markers/base.js +1 -0
  158. package/dist/types/markers/common.d.ts +64 -16
  159. package/dist/types/markers/geo.d.ts +75 -100
  160. package/dist/types/markers/line.d.ts +34 -0
  161. package/dist/types/markers/line.js +1 -0
  162. package/dist/types/markers/props.d.ts +1 -1
  163. package/dist/types/plots/data/common.d.ts +1 -1
  164. package/dist/types/plots/data/scatter.d.ts +13 -0
  165. package/dist/types/plots/data/scatter.js +1 -0
  166. package/dist/types/plots/props.d.ts +46 -74
  167. package/dist/types/plots/segments/common.d.ts +6 -12
  168. package/dist/types/plots/segments/config.d.ts +1 -1
  169. package/dist/types/plots/styling.d.ts +10 -0
  170. package/dist/{plots/utils → utils}/delta.d.ts +2 -2
  171. package/dist/{plots/utils → utils}/delta.js +1 -1
  172. package/dist/utils/edgeAwareAnchor.d.ts +37 -0
  173. package/dist/utils/edgeAwareAnchor.js +65 -0
  174. package/dist/utils/grouping.d.ts +1 -1
  175. package/dist/utils/interpolate.d.ts +2 -2
  176. package/package.json +3 -1
  177. package/dist/layout/geo/GeoLayout.svelte +0 -51
  178. package/dist/layout/geo/GeoLayout.svelte.d.ts +0 -24
  179. package/dist/layout/geo/resolveProjection.js +0 -48
  180. package/dist/layout/plot/GridLayout.svelte +0 -30
  181. package/dist/layout/plot/RuleLayout.svelte +0 -111
  182. package/dist/plots/bar/BarSegments.svelte +0 -69
  183. package/dist/types/charts/legend.d.ts +0 -60
  184. package/dist/types/plots/delta.d.ts +0 -19
  185. package/dist/types/plots/styles/common.d.ts +0 -52
  186. package/dist/types/plots/styles/geo.d.ts +0 -42
  187. /package/dist/{plots/geo → layout/coordinates}/projections/argentina.js +0 -0
  188. /package/dist/{plots/geo → layout/coordinates}/projections/fit.d.ts +0 -0
  189. /package/dist/{plots/geo → layout/coordinates}/projections/fit.js +0 -0
  190. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.d.ts +0 -0
  191. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.js +0 -0
  192. /package/dist/{plots/geo → layout/coordinates}/zoom.svelte.js +0 -0
  193. /package/dist/types/{charts/legend.js → layout/coordinates.js} +0 -0
  194. /package/dist/types/{plots/axis.js → layout/facet.js} +0 -0
  195. /package/dist/types/{plots/delta.js → layout/geometry.js} +0 -0
  196. /package/dist/types/{plots/scales/geo.js → layout/scales.js} +0 -0
  197. /package/dist/types/{plots/styles/common.js → layout/styles.js} +0 -0
  198. /package/dist/types/{plots/styles/geo.js → layout/timeline.js} +0 -0
@@ -35,22 +35,6 @@ function areaMatchesXY(xVal, yVal, area) {
35
35
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
36
36
  (area.y.to === undefined || yVal <= area.y.to);
37
37
  }
38
- /**
39
- * For each segment in `segs`, returns the subset of `data` rows whose x value
40
- * (from `xAccessor`) falls inside any of the segment's x ranges. Rows are
41
- * not deduplicated across segments — a row that matches multiple segments
42
- * appears in each resulting array.
43
- *
44
- * Used by component and hover markers with the `'segment'` strategy.
45
- */
46
- export function getDataForSegments(data, xAccessor, segs) {
47
- return segs.map((seg) => {
48
- const areas = seg.areas;
49
- if (!areas || areas.length === 0)
50
- return data;
51
- return data.filter((d) => areas.some((area) => areaMatchesX(xAccessor(d), area)));
52
- });
53
- }
54
38
  /**
55
39
  * Warns about obvious configuration mistakes: multiple catch-all segments
56
40
  * (no `areas`) in the same series list. Since catch-alls are evaluated last
@@ -209,3 +193,29 @@ export function buildGroupedSeries(seriesList, segments, connect = true) {
209
193
  visualSegments: resolveSeriesSegments(s, resolveSegmentsForSeries(segments, s.name), connect),
210
194
  }));
211
195
  }
196
+ /**
197
+ * Builds the `ScopedMarkerGroup[]` a `Plot.svelte` hands to `GeometryLayout`
198
+ * for rendering `series`-scoped `hover`/`component` markers — one group per
199
+ * series, carrying its resolved segments' match predicates and colors.
200
+ * `colorFor` resolves a series' own default color; `segmentColorFor` reads
201
+ * whichever field counts as "color" out of that plot kind's segment style
202
+ * shape (e.g. `fill` vs `stroke.stroke`), since that's the only part of this
203
+ * that isn't shared across plot kinds.
204
+ */
205
+ export function buildScopedMarkerGroups(args) {
206
+ const { groupedSeries, segments, colorFor, segmentColorFor } = args;
207
+ return groupedSeries.map((group, seriesIndex) => {
208
+ const defaultColor = colorFor(group.series, seriesIndex);
209
+ const xFor = resolveAccessor(group.series.x);
210
+ const segs = resolveSegmentsForSeries(segments, group.series.name);
211
+ return {
212
+ name: group.series.name,
213
+ data: group.series.data,
214
+ color: defaultColor,
215
+ segments: segs.map((seg) => ({
216
+ match: (row) => matchesSegmentX(xFor(row), seg),
217
+ color: segmentColorFor(seg.style, defaultColor),
218
+ })),
219
+ };
220
+ });
221
+ }
@@ -1,66 +1,19 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { AxisValue } from '../plots/axis';
3
- import type { Accessor } from '../plots/data/common';
4
- import type { EasingName, EasingFn } from './interpolate';
5
- export type TimeValue = number;
6
- export type Orientation = 'horizontal' | 'vertical';
7
- export type FacetColumns = number | {
8
- desktop: number;
9
- mobile: number;
10
- };
2
+ import type { TimeValue } from '../layout/timeline';
3
+ import type { LegendPlotContext } from '../layout/legend';
11
4
  export type ChartBoxContext = {
12
5
  width: number;
13
6
  height: number;
14
7
  };
15
8
  export type ChartBoxSnippet = Snippet<[ChartBoxContext]>;
16
- export type FacetCellContext<TRow extends Record<string, unknown>> = {
17
- facetValue: string;
18
- data: TRow[];
19
- width: number;
20
- height: number;
21
- };
22
- export type FacetCellSnippet<TRow extends Record<string, unknown>> = Snippet<[
23
- FacetCellContext<TRow>
24
- ]>;
25
- export type TimelineChildContext<TRow extends Record<string, unknown>> = {
26
- selectedValue: TimeValue;
27
- data: TRow[];
28
- width: number;
29
- height: number;
30
- };
31
- export type TimelineChildSnippet<TRow extends Record<string, unknown>> = Snippet<[
32
- TimelineChildContext<TRow>
33
- ]>;
34
9
  export type ChartPlotContext<TRow extends Record<string, unknown>> = {
35
10
  data: TRow[];
36
11
  width: number;
37
12
  height: number;
38
13
  facetValue?: string;
39
14
  selectedValue?: TimeValue;
15
+ legend?: LegendPlotContext;
40
16
  };
41
17
  export type ChartPlotSnippet<TRow extends Record<string, unknown>> = Snippet<[
42
18
  ChartPlotContext<TRow>
43
19
  ]>;
44
- export type TimelineInterpolation<TRow extends Record<string, unknown>> = {
45
- key?: Accessor<TRow, unknown>;
46
- value?: Accessor<TRow, AxisValue>;
47
- create?: (lower: TRow, upper: TRow, x: TimeValue, value: number) => TRow;
48
- progressEasing?: EasingName | EasingFn;
49
- segmentEasing?: EasingName | EasingFn;
50
- };
51
- export type TimelineConfig<TRow extends Record<string, unknown>> = {
52
- accessor: Accessor<TRow, TimeValue>;
53
- progress: number;
54
- values?: TimeValue[];
55
- orientation?: Orientation;
56
- show?: boolean;
57
- thickness?: number;
58
- filterMode?: 'exact' | 'upTo';
59
- interpolate?: boolean | TimelineInterpolation<TRow>;
60
- };
61
- export type FacetConfig<TRow extends Record<string, unknown>> = {
62
- by: Accessor<TRow, unknown>;
63
- columns?: FacetColumns;
64
- values?: string[];
65
- gap?: number;
66
- };
@@ -1,13 +1,13 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { AxisValue } from '../plots/axis';
2
+ import type { AxisValue, AxisBasedScalesConfig } from '../layout/scales';
3
3
  import type { Accessor } from '../plots/data/common';
4
- import type { AxisBasedScalesConfig } from '../plots/props';
5
- import type { BasePlotStyles } from '../plots/styles/common';
4
+ import type { BasePlotStylesConfig } from '../layout/styles';
6
5
  import type { SegmentsConfig, MarginConfig } from '../plots/props';
7
- import type { Marker } from '../markers/common';
6
+ import type { AxisBasedMarkersConfig } from '../markers/common';
8
7
  import type { TooltipProp } from '../layout/tooltip';
9
- import type { LegendSection } from './legend';
10
- import type { FacetConfig, TimelineConfig } from './common';
8
+ import type { LegendSection } from '../layout/legend';
9
+ import type { FacetConfig } from '../layout/facet';
10
+ import type { TimelineConfig } from '../layout/timeline';
11
11
  /**
12
12
  * Common props accepted by every chart component (bar, line, heatmap, pyramid,
13
13
  * …). The `TSegmentStyle` parameter lets each chart narrow `segments` to its
@@ -30,9 +30,9 @@ export type ChartProps<TRow extends Record<string, unknown>, TSegmentStyle exten
30
30
  x: Accessor<TRow, AxisValue>;
31
31
  y: Accessor<TRow, AxisValue>;
32
32
  z?: Accessor<TRow, unknown>;
33
- styles?: BasePlotStyles;
33
+ styles?: BasePlotStylesConfig;
34
34
  segments?: SegmentsConfig<TSegmentStyle>;
35
- markers?: Marker[];
35
+ markers?: AxisBasedMarkersConfig[];
36
36
  scales?: AxisBasedScalesConfig<TRow>;
37
37
  margins?: MarginConfig;
38
38
  facet?: FacetConfig<TRow>;
@@ -1,4 +1,4 @@
1
- import type { StrokeStyle, DotStyle, FontStyle } from '../plots/styling';
1
+ import type { StrokeStyle, DotStyle, FontStyle, AreaStyle } from '../plots/styling';
2
2
  export type TextStyle = {
3
3
  /** font-family */
4
4
  font: string;
@@ -101,17 +101,41 @@ export type ChartConfig = {
101
101
  connectorWidth: number;
102
102
  };
103
103
  };
104
+ /** Default scatter point geometry. */
105
+ scatter: {
106
+ dotRadius: number;
107
+ };
104
108
  /** Timeline gutter styling. */
105
109
  timeline: {
106
110
  axisColor: string;
107
111
  activeColor: string;
108
112
  thickness: number;
109
113
  };
110
- /** In-SVG hover highlight (crosshair rule, dot, and value label). */
114
+ /** In-SVG hover highlight: crosshair rule, dot + value label, and geo feature restyle. */
111
115
  hover: {
112
116
  rule: StrokeStyle;
113
117
  dot: DotStyle;
114
118
  font: FontStyle;
119
+ area: AreaStyle;
120
+ };
121
+ facet: {
122
+ /** Position badge shown in `carousel`/`paginated` facet modes. */
123
+ indicator: {
124
+ background: string;
125
+ color: string;
126
+ fontSize: string;
127
+ padding: string;
128
+ radius: string;
129
+ };
130
+ /** Prev/next buttons shown in `paginated` facet mode. */
131
+ navButton: {
132
+ background: string;
133
+ color: string;
134
+ /** Button diameter (width and height). */
135
+ size: string;
136
+ fontSize: string;
137
+ disabledOpacity: number;
138
+ };
115
139
  };
116
140
  };
117
141
  /** Deep-partial input accepted by `setConfiguration`. */
@@ -1,10 +1,10 @@
1
+ import type { GeoProjection } from 'd3-geo';
1
2
  /**
2
3
  * The projection names svelteplot's `<Plot projection>` accepts as a string
3
4
  * (svelteplot itself doesn't export this as a type — defined here so authors
4
5
  * get autocomplete/type-checking over the full supported set).
5
6
  */
6
7
  export type GeoProjectionName = 'albers-usa' | 'albers' | 'azimuthal-equal-area' | 'azimuthal-equidistant' | 'conic-conformal' | 'conic-equal-area' | 'conic-equidistant' | 'equal-earth' | 'equirectangular' | 'gnomonic' | 'identity' | 'reflect-y' | 'mercator' | 'orthographic' | 'stereographic' | 'transverse-mercator';
7
- import type { GeoProjection } from 'd3-geo';
8
8
  /**
9
9
  * What a custom projection factory (e.g. `argentinaBicontinental` under
10
10
  * `$lib`'s geo projections) must return — just enough of d3's `GeoProjection`
@@ -42,3 +42,35 @@ export type GeoProjectionConfig = GeoProjectionName | {
42
42
  */
43
43
  domain?: GeoJSON.GeoJsonObject | GeoJSON.FeatureCollection | GeoJSON.Feature | 'data';
44
44
  };
45
+ /**
46
+ * `scales` prop for GeoPlot — the geo analog of `AxisBasedScalesConfig`.
47
+ * A map has no x/y/z axis pair, so this only configures the choropleth
48
+ * colour domain (the coordinate system itself is `coordinates.projection`).
49
+ */
50
+ export type GeoScalesConfig = {
51
+ /** Continuous choropleth value domain — mirrors heatmap's `scales.z.domain`. */
52
+ color?: {
53
+ domain?: [number, number];
54
+ };
55
+ };
56
+ export type GeoZoomConfig = {
57
+ min?: number;
58
+ max?: number;
59
+ initial?: {
60
+ x?: number;
61
+ y?: number;
62
+ k?: number;
63
+ };
64
+ };
65
+ /**
66
+ * `coordinates` prop for GeoPlot — the only plot kind with a coordinate
67
+ * system other than implicit cartesian. Bundles the projection (a `GoG`
68
+ * Coordinates concern) and pan/zoom (navigating within that coordinate
69
+ * system), resolved together by `CoordinatesLayout`.
70
+ */
71
+ export type CoordinatesConfig = {
72
+ /** Which map projection to draw with. Defaults to `'equal-earth'`. */
73
+ projection?: GeoProjectionConfig;
74
+ /** `true`/config enables drag-pan + scroll-zoom. Omitted/`false` = static map. */
75
+ zoom?: boolean | GeoZoomConfig;
76
+ };
@@ -0,0 +1,41 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { Accessor } from '../plots/data/common';
3
+ export type Responsive<T> = T | {
4
+ desktop: T;
5
+ mobile: T;
6
+ };
7
+ export type FacetColumns = Responsive<number>;
8
+ export type FacetMode = 'grid' | 'carousel' | 'paginated';
9
+ export type FacetCellContext<TRow extends Record<string, unknown>> = {
10
+ facetValue: string;
11
+ data: TRow[];
12
+ width: number;
13
+ height: number;
14
+ };
15
+ export type FacetCellSnippet<TRow extends Record<string, unknown>> = Snippet<[
16
+ FacetCellContext<TRow>
17
+ ]>;
18
+ export type FacetIndicatorContext = {
19
+ current: number;
20
+ total: number;
21
+ };
22
+ export type FacetIndicatorSnippet = Snippet<[FacetIndicatorContext]>;
23
+ export type FacetNavDirection = 'prev' | 'next';
24
+ export type FacetNavContext = {
25
+ direction: FacetNavDirection;
26
+ disabled: boolean;
27
+ onclick: () => void;
28
+ };
29
+ export type FacetNavSnippet = Snippet<[FacetNavContext]>;
30
+ export type FacetConfig<TRow extends Record<string, unknown>> = {
31
+ by: Accessor<TRow, unknown>;
32
+ columns?: FacetColumns;
33
+ values?: string[];
34
+ gap?: number;
35
+ mode?: Responsive<FacetMode>;
36
+ visible?: number;
37
+ pageSize?: number;
38
+ formatIndicator?: (current: number, total: number) => string;
39
+ indicator?: FacetIndicatorSnippet;
40
+ navButton?: FacetNavSnippet;
41
+ };
@@ -0,0 +1,17 @@
1
+ /** One resolved segment for scoped-marker rendering — see {@link ScopedMarkerGroup}. */
2
+ export type ScopedMarkerSegment<TData> = {
3
+ match: (row: TData) => boolean;
4
+ color: string;
5
+ };
6
+ /**
7
+ * One series' resolved context for rendering its `series`-scoped `'hover'`/
8
+ * `'component'` markers — built by each `Plot.svelte`, consumed by
9
+ * `GeometryLayout`. Keeps `GeometryLayout` itself agnostic of each plot
10
+ * kind's segment style shape (e.g. `fill` vs `stroke.stroke`).
11
+ */
12
+ export type ScopedMarkerGroup<TData> = {
13
+ name: string;
14
+ data: TData[];
15
+ color: string;
16
+ segments: ScopedMarkerSegment<TData>[];
17
+ };
@@ -1,5 +1,64 @@
1
1
  import type { SvelteMap } from 'svelte/reactivity';
2
- import type { LegendDisabledStyle } from '../charts/legend';
2
+ import type { SymbolType, LineStyle } from '../plots/constants';
3
+ import type { StrokeStyle, DotStyle } from '../plots/styling';
4
+ export type LegendSectionType = 'discrete' | 'continuous';
5
+ /**
6
+ * Style applied to whatever a legend interaction has turned "off" — a
7
+ * toggled-off discrete series, or a datapoint/cell/feature outside an active
8
+ * continuous range filter. `opacity` is a blanket convenience: any
9
+ * `*Opacity` field a consumer doesn't set falls back to it, so
10
+ * `{ opacity: 0.1 }` alone is enough to read as "disabled" everywhere.
11
+ */
12
+ export type LegendDisabledStyle = {
13
+ opacity?: number;
14
+ stroke?: StrokeStyle;
15
+ dots?: DotStyle;
16
+ fill?: string;
17
+ fillOpacity?: number;
18
+ };
19
+ export type LegendItem = {
20
+ name: string;
21
+ label?: string;
22
+ color?: string;
23
+ symbol?: SymbolType;
24
+ opacity?: number;
25
+ lineStyle?: LineStyle;
26
+ /** Initial toggled-off state (uncontrolled — the user can still click it back on). */
27
+ disabled?: boolean;
28
+ };
29
+ export type DiscreteLegendSection = {
30
+ type: 'discrete';
31
+ title?: string;
32
+ items: LegendItem[];
33
+ columns?: number;
34
+ /** Enables click-to-toggle on each item. */
35
+ interactive?: boolean;
36
+ /** Style applied to a toggled-off item's series. Falls back to `cfg.legend.disabledOpacity`. */
37
+ disabledStyle?: LegendDisabledStyle;
38
+ };
39
+ export type ContinuousLegendSection = {
40
+ type: 'continuous';
41
+ title?: string;
42
+ columns?: number;
43
+ min: number;
44
+ max: number;
45
+ colorMin?: string;
46
+ colorMax?: string;
47
+ ticks?: number[];
48
+ width?: number;
49
+ format?: (v: number) => string;
50
+ /** Enables drag handles on the bar's edges to narrow the visible range. */
51
+ interactive?: boolean;
52
+ /**
53
+ * How the color ramp responds to a narrowed range: `'rescale'` reprojects
54
+ * it onto the new bounds, `'filter'` keeps the original domain and only
55
+ * excludes out-of-range values. Defaults to `'filter'`.
56
+ */
57
+ mode?: 'rescale' | 'filter';
58
+ /** Style applied to values outside the active range. Falls back to `cfg.legend.disabledOpacity`. */
59
+ disabledStyle?: LegendDisabledStyle;
60
+ };
61
+ export type LegendSection = DiscreteLegendSection | ContinuousLegendSection;
3
62
  /**
4
63
  * Shared legend-interaction state for cross-cutting legend → plot wiring.
5
64
  *
@@ -24,3 +83,8 @@ export type LegendInteractionStore = {
24
83
  disabledStyle: LegendDisabledStyle;
25
84
  } | null;
26
85
  };
86
+ /** Read-only view of which series a legend has toggled off, resolved from {@link BaseChart}'s legend-interaction store. */
87
+ export type LegendPlotContext = {
88
+ disabledSeries: ReadonlySet<string>;
89
+ isDisabled: (name: string) => boolean;
90
+ };
@@ -53,3 +53,14 @@ export type AxisScale<TData = Record<string, unknown>> = {
53
53
  seriesLayout?: 'overlap' | 'grouped' | 'stacked';
54
54
  seriesPadding?: number;
55
55
  };
56
+ /**
57
+ * Per-axis scale overrides, passed as a single `scales` prop to every
58
+ * axis-based plot kind (`GeoPlot` uses `GeoScalesConfig` instead — a map has
59
+ * no x/y/z axis pair). `TData` threads through to {@link AxisScale.sort} on
60
+ * each axis.
61
+ */
62
+ export type AxisBasedScalesConfig<TData = Record<string, unknown>> = {
63
+ x?: AxisScale<TData>;
64
+ y?: AxisScale<TData>;
65
+ z?: AxisScale<TData>;
66
+ };
@@ -0,0 +1,115 @@
1
+ import type { ValueAnchor } from '../plots/constants';
2
+ import type { FontStyle, StrokeStyle, AreaStyle } from '../plots/styling';
3
+ import type { GeoFeature } from '../plots/data/geo';
4
+ /**
5
+ * Controls if and how value labels are rendered on a plot. The high-level
6
+ * `anchor` sets sensible defaults for placement; `fontStyle` (`dx`, `dy`,
7
+ * `textAnchor`, `lineAnchor`, `lineHeight`, `rotate`, `class`, `textClass`,
8
+ * `fill`, …) overrides those defaults field-by-field when provided — mirrors
9
+ * {@link DeltaConfig}'s `fontStyle`/`strokeStyle` split, so label text and
10
+ * connector-line styling never mix into one flat bag of props.
11
+ */
12
+ export type ValuesStyle = {
13
+ show?: boolean;
14
+ anchor?: ValueAnchor;
15
+ format?: (value: number, seriesName: string) => string;
16
+ hoverIsolate?: boolean;
17
+ fontStyle?: FontStyle;
18
+ strokeStyle?: StrokeStyle;
19
+ };
20
+ /**
21
+ * Color overrides for plots that derive their palette from data.
22
+ * Each plot uses only the fields relevant to its kind; unused fields are
23
+ * silently ignored.
24
+ *
25
+ * - `min` / `max` — sequential colour ramp endpoints (heatmap).
26
+ * - `left` / `right` — diverging bar sides (pyramid).
27
+ */
28
+ export type ColorsStyle = {
29
+ min?: string;
30
+ max?: string;
31
+ left?: string;
32
+ right?: string;
33
+ };
34
+ /**
35
+ * Decorative border around the plot's own content box — svelteplot's
36
+ * `Frame` mark, purely cosmetic (drawn from the box geometry, never from
37
+ * data). `true` enables it with svelteplot's own defaults; an object
38
+ * enables it and overrides its look field-by-field. Insets pull the frame
39
+ * in from the content box's own edges, in pixels.
40
+ */
41
+ export type FrameStyle = AreaStyle & {
42
+ inset?: number;
43
+ insetTop?: number;
44
+ insetRight?: number;
45
+ insetBottom?: number;
46
+ insetLeft?: number;
47
+ };
48
+ /** Author-facing `styles.frame` prop — see {@link FrameStyle}. */
49
+ export type FrameProp = boolean | FrameStyle;
50
+ /**
51
+ * Top-level rendering style overrides shared by the non-geo plot kinds.
52
+ * Passed as the `styles` prop. Each plot reads only the fields it cares
53
+ * about.
54
+ */
55
+ export type BasePlotStylesConfig = {
56
+ values?: ValuesStyle;
57
+ colors?: ColorsStyle;
58
+ /** Decorative border around the plot's content box — see {@link FrameStyle}. Available on every plot kind. */
59
+ frame?: FrameProp;
60
+ };
61
+ export type GeoTileLayerConfig = {
62
+ /** XYZ tile URL template, e.g. `'https://tile.openstreetmap.org/{z}/{x}/{y}.png'`. */
63
+ url: string;
64
+ attribution?: string;
65
+ opacity?: number;
66
+ minZoom?: number;
67
+ maxZoom?: number;
68
+ /** Tile edge length in pixels. Defaults to `256`. */
69
+ tileSize?: number;
70
+ };
71
+ /**
72
+ * `styles` prop for GeoPlot — the geo analog of `BasePlotStylesConfig`.
73
+ * Unlike the other plot kinds, GeoPlot's styling needs (base map, choropleth
74
+ * ramp, tile background, click handling) are unlike anything x/y plots need,
75
+ * so this is its own type rather than a reuse of `BasePlotStylesConfig`.
76
+ */
77
+ export type GeoStylesConfig<TProps extends Record<string, unknown> = Record<string, unknown>> = {
78
+ /** Base map fill, used when a feature isn't styled by `segments` or the choropleth ramp. */
79
+ fill?: string;
80
+ fillOpacity?: number;
81
+ stroke?: string;
82
+ strokeWidth?: number;
83
+ /** Continuous choropleth ramp endpoints — used when `value` is provided on data. Mirrors heatmap's `styles.colors`. */
84
+ colors?: ColorsStyle;
85
+ /** Raster XYZ tile basemap under the vector geometry. Mercator-family projections only. */
86
+ tileLayer?: GeoTileLayerConfig;
87
+ /** Fired when a base-map feature is clicked. */
88
+ onFeatureClick?: (feature: GeoFeature<TProps>, event: Event) => void;
89
+ /** Decorative border around the plot's content box — see {@link FrameStyle}. Available on every plot kind. */
90
+ frame?: FrameProp;
91
+ };
92
+ /**
93
+ * `GeoTileLayerConfig`, plus `features` — never author-facing (the public
94
+ * `styles.tileLayer` shape, {@link GeoTileLayerConfig}, doesn't declare it).
95
+ * `GeoPlot` tacks it onto its own internal copy of `styles` so `StylesLayout`
96
+ * can compute the tile layer's auto-fit bounds without needing raw geometry
97
+ * threaded through as a separate prop.
98
+ */
99
+ type GeoTileLayerConfigWithFeatures = GeoTileLayerConfig & {
100
+ features?: {
101
+ geometry: GeoJSON.Geometry;
102
+ }[];
103
+ };
104
+ /**
105
+ * The minimal slice of a plot kind's own `styles` prop `StylesLayout` reads —
106
+ * every concrete `styles` type ({@link BasePlotStylesConfig},
107
+ * {@link GeoStylesConfig}) structurally satisfies this whether or not it
108
+ * declares `tileLayer` at all (a missing optional field type-checks fine).
109
+ */
110
+ export type StylesLayoutConfig = {
111
+ tileLayer?: GeoTileLayerConfigWithFeatures;
112
+ frame?: FrameProp;
113
+ [key: string]: unknown;
114
+ };
115
+ export {};
@@ -0,0 +1,32 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { AxisValue } from './scales';
3
+ import type { Accessor } from '../plots/data/common';
4
+ import type { EasingName, EasingFn } from '../charts/interpolate';
5
+ export type TimeValue = number;
6
+ export type Orientation = 'horizontal' | 'vertical';
7
+ export type TimelineChildContext<TRow extends Record<string, unknown>> = {
8
+ selectedValue: TimeValue;
9
+ data: TRow[];
10
+ width: number;
11
+ height: number;
12
+ };
13
+ export type TimelineChildSnippet<TRow extends Record<string, unknown>> = Snippet<[
14
+ TimelineChildContext<TRow>
15
+ ]>;
16
+ export type TimelineInterpolation<TRow extends Record<string, unknown>> = {
17
+ key?: Accessor<TRow, unknown>;
18
+ value?: Accessor<TRow, AxisValue>;
19
+ create?: (lower: TRow, upper: TRow, x: TimeValue, value: number) => TRow;
20
+ progressEasing?: EasingName | EasingFn;
21
+ segmentEasing?: EasingName | EasingFn;
22
+ };
23
+ export type TimelineConfig<TRow extends Record<string, unknown>> = {
24
+ accessor: Accessor<TRow, TimeValue>;
25
+ progress: number;
26
+ values?: TimeValue[];
27
+ orientation?: Orientation;
28
+ show?: boolean;
29
+ thickness?: number;
30
+ filterMode?: 'exact' | 'upTo';
31
+ interpolate?: boolean | TimelineInterpolation<TRow>;
32
+ };
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { AxisValue } from '../plots/axis';
2
+ import type { AxisValue } from './scales';
3
3
  /**
4
4
  * How the hover highlight finds related points within a facet.
5
5
  * - `'x'` all points sharing the hovered x (default for line / bar).
@@ -7,6 +7,21 @@ import type { AxisValue } from '../plots/axis';
7
7
  * - `'punctual'` exact XY match — one cell at a time (default for heatmap).
8
8
  */
9
9
  export type HoverStrategy = 'x' | 'y' | 'punctual';
10
+ /**
11
+ * Preferred horizontal placement of the floating tooltip relative to the
12
+ * cursor: `'right'`/`'left'` offset it clear of the cursor (so it never
13
+ * covers the hovered point); `'middle'` centers it on the cursor's x, same
14
+ * as the plot's own vertical `'middle'`. Falls back toward the opposite
15
+ * side (via `'middle'`) when the preferred side would overflow the plot's
16
+ * bounds — see {@link resolveTooltipPlacement}. System default: `'right'`.
17
+ */
18
+ export type TooltipAnchorX = 'left' | 'middle' | 'right';
19
+ /**
20
+ * Preferred vertical placement of the floating tooltip relative to the
21
+ * cursor — same fallback behavior as {@link TooltipAnchorX}, along the other
22
+ * axis. System default: `'bottom'`.
23
+ */
24
+ export type TooltipAnchorY = 'top' | 'middle' | 'bottom';
10
25
  /** Author-facing tooltip option on the chart kinds. `true` = enable with defaults. */
11
26
  export type TooltipOptions<TRow extends Record<string, unknown>> = {
12
27
  /** Matching strategy. Defaults to the chart kind's own default. */
@@ -24,6 +39,10 @@ export type TooltipOptions<TRow extends Record<string, unknown>> = {
24
39
  content?: Snippet<[{
25
40
  rows: TRow[];
26
41
  }]>;
42
+ /** Preferred horizontal anchor — see {@link TooltipAnchorX}. */
43
+ anchorX?: TooltipAnchorX;
44
+ /** Preferred vertical anchor — see {@link TooltipAnchorY}. */
45
+ anchorY?: TooltipAnchorY;
27
46
  };
28
47
  /** Either a bare on/off flag or the full option object. */
29
48
  export type TooltipProp<TRow extends Record<string, unknown>> = boolean | TooltipOptions<TRow>;
@@ -0,0 +1,11 @@
1
+ import type { AxisBasedMarkersConfig } from './common';
2
+ import type { GeoMarkersConfig, GeoFeaturesMarkerConfig } from './geo';
3
+ import type { LineMarkersConfig } from './line';
4
+ /**
5
+ * Every marker kind `GeometryLayout`/`BasePlotLayout` can route to — the
6
+ * union of every plot kind's own `markers` prop type, plus
7
+ * `GeoFeaturesMarkerConfig` (built internally, never author-facing). Not
8
+ * used as any `Plot.svelte`'s own `TMarker` — see each kind's own precise
9
+ * type instead.
10
+ */
11
+ export type MarkerConfig = AxisBasedMarkersConfig | LineMarkersConfig | GeoMarkersConfig | GeoFeaturesMarkerConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,45 @@
1
+ import type { AxisValue } from '../layout/scales';
2
+ import type { DotStyle, FontStyle } from '../plots/styling';
3
+ import type { ColorsStyle } from '../layout/styles';
4
+ /**
5
+ * A set of point marks (svelteplot's `Dot`) — usable on any plot kind, axis-based or geo.
6
+ *
7
+ * `x`/`y`/`r`/`value` accept a field key or an accessor function, like `Series.x`/`y`.
8
+ * `GeometryLayout` resolves the shorthand before it reaches `DotMarker.svelte`, which only
9
+ * ever sees functions.
10
+ */
11
+ export type DotMarkerConfig = {
12
+ type: 'dot';
13
+ data: Record<string, unknown>[];
14
+ x: string | ((d: any) => AxisValue);
15
+ y: string | ((d: any) => AxisValue);
16
+ /** Per-row radius, or a constant — overrides `style.dotRadius`. */
17
+ r?: number | string | ((d: any) => number);
18
+ /** Per-row fill, overriding `style.dotFill` — ignored when `value` is set. */
19
+ fill?: (d: any) => string;
20
+ /** Continuous value driving a per-dot color ramp through `style.colors`. */
21
+ value?: string | ((d: any) => number);
22
+ style?: DotStyle & {
23
+ colors?: ColorsStyle;
24
+ };
25
+ };
26
+ /**
27
+ * A text label per row (svelteplot's `Text`) — usable on any plot kind, axis-based or geo.
28
+ *
29
+ * `x`/`y` accept the same field-key-or-function shorthand as `DotMarkerConfig`. `text` is a
30
+ * constant or a per-row accessor.
31
+ */
32
+ export type TextMarkerConfig = {
33
+ type: 'text';
34
+ data: Record<string, unknown>[];
35
+ x: string | ((d: any) => AxisValue);
36
+ y: string | ((d: any) => AxisValue);
37
+ text: string | ((d: any) => string);
38
+ style?: FontStyle;
39
+ };
40
+ /**
41
+ * Every marker kind usable on any plot, axis-based or geo. `AxisBasedMarkersConfig`
42
+ * (`types/markers/common.ts`) and `GeoMarkersConfig` (`types/markers/geo.ts`) both extend
43
+ * this, so `MarkerConfig` (`types/markers/all.ts`) can union the two without a shape collision.
44
+ */
45
+ export type BaseMarkersConfig = DotMarkerConfig | TextMarkerConfig;
@@ -0,0 +1 @@
1
+ export {};