@fundar/data-chart-telling 0.0.14 → 0.0.16

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 (148) hide show
  1. package/README.md +121 -17
  2. package/dist/charts/{Chart.svelte → BaseChart.svelte} +2 -0
  3. package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
  4. package/dist/charts/bar/Chart.svelte +5 -5
  5. package/dist/charts/bar/Chart.svelte.d.ts +1 -2
  6. package/dist/charts/heatmap/Chart.svelte +8 -7
  7. package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
  8. package/dist/charts/line/Chart.svelte +5 -5
  9. package/dist/charts/line/Chart.svelte.d.ts +1 -2
  10. package/dist/charts/pyramid/Chart.svelte +7 -6
  11. package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
  12. package/dist/configuration/config.svelte.js +2 -1
  13. package/dist/configuration/themes/index.d.ts +60 -40
  14. package/dist/index.d.ts +27 -13
  15. package/dist/index.js +12 -7
  16. package/dist/layout/facet/FacetLayout.svelte +1 -1
  17. package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
  18. package/dist/layout/geo/GeoLayout.svelte +47 -0
  19. package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
  20. package/dist/layout/geo/resolveProjection.d.ts +10 -0
  21. package/dist/layout/geo/resolveProjection.js +48 -0
  22. package/dist/layout/legend/ContinuousSection.svelte +158 -17
  23. package/dist/layout/legend/DiscreteSection.svelte +56 -4
  24. package/dist/layout/legend/interaction.svelte.d.ts +7 -0
  25. package/dist/layout/legend/interaction.svelte.js +24 -0
  26. package/dist/layout/plot/AxisLayout.svelte +95 -0
  27. package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
  28. package/dist/layout/plot/BasePlotLayout.svelte +302 -0
  29. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
  30. package/dist/layout/plot/GridLayout.svelte +30 -0
  31. package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
  32. package/dist/layout/plot/RuleLayout.svelte +111 -0
  33. package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
  34. package/dist/layout/plot/margins.d.ts +34 -0
  35. package/dist/layout/plot/margins.js +26 -0
  36. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  37. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
  38. package/dist/layout/tooltip/Tooltip.svelte +15 -0
  39. package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
  40. package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
  41. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
  42. package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
  43. package/dist/layout/tooltip/controller.svelte.js +5 -6
  44. package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
  45. package/dist/layout/tooltip/hover.svelte.js +1 -1
  46. package/dist/layout/tooltip/utils.d.ts +2 -2
  47. package/dist/markers/ContourClipMarker.svelte +77 -0
  48. package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
  49. package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
  50. package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
  51. package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
  52. package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
  53. package/dist/markers/HoverMarker.svelte +136 -0
  54. package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
  55. package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
  56. package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
  57. package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
  58. package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
  59. package/dist/markers/inset/InsetMarker.svelte +170 -0
  60. package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
  61. package/dist/markers/inset/insetLayout.d.ts +25 -0
  62. package/dist/markers/inset/insetLayout.js +39 -0
  63. package/dist/markers/inset/insetProjection.d.ts +8 -0
  64. package/dist/markers/inset/insetProjection.js +39 -0
  65. package/dist/plots/bar/BarSegments.svelte +69 -0
  66. package/dist/plots/bar/BarSegments.svelte.d.ts +40 -0
  67. package/dist/plots/bar/Plot.svelte +140 -74
  68. package/dist/plots/bar/Plot.svelte.d.ts +7 -3
  69. package/dist/plots/bar/ValueLabels.svelte +89 -0
  70. package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
  71. package/dist/plots/bar/hoverPoints.d.ts +15 -0
  72. package/dist/plots/bar/hoverPoints.js +35 -0
  73. package/dist/plots/bar/layout.svelte.d.ts +37 -0
  74. package/dist/plots/bar/layout.svelte.js +132 -0
  75. package/dist/plots/geo/Plot.svelte +577 -0
  76. package/dist/plots/geo/Plot.svelte.d.ts +29 -0
  77. package/dist/plots/geo/TileLayer.svelte +77 -0
  78. package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
  79. package/dist/plots/geo/projections/argentina.d.ts +8 -0
  80. package/dist/plots/geo/projections/argentina.js +35 -0
  81. package/dist/plots/geo/projections/fit.d.ts +8 -0
  82. package/dist/plots/geo/projections/fit.js +14 -0
  83. package/dist/plots/geo/rotate.svelte.d.ts +26 -0
  84. package/dist/plots/geo/rotate.svelte.js +79 -0
  85. package/dist/plots/geo/zoom.svelte.d.ts +32 -0
  86. package/dist/plots/geo/zoom.svelte.js +50 -0
  87. package/dist/plots/heatmap/Plot.svelte +171 -58
  88. package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
  89. package/dist/plots/line/Plot.svelte +67 -30
  90. package/dist/plots/line/Plot.svelte.d.ts +7 -3
  91. package/dist/plots/pyramid/Plot.svelte +88 -35
  92. package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
  93. package/dist/plots/utils/delta.d.ts +1 -1
  94. package/dist/plots/utils/geoAccessors.d.ts +64 -0
  95. package/dist/plots/utils/geoAccessors.js +188 -0
  96. package/dist/plots/utils/geoSegments.d.ts +14 -0
  97. package/dist/plots/utils/geoSegments.js +17 -0
  98. package/dist/plots/utils/legendDisabled.d.ts +15 -0
  99. package/dist/plots/utils/legendDisabled.js +41 -0
  100. package/dist/plots/utils/segments.d.ts +14 -5
  101. package/dist/plots/utils/segments.js +25 -13
  102. package/dist/plots/utils/tiles.d.ts +89 -0
  103. package/dist/plots/utils/tiles.js +159 -0
  104. package/dist/plots/utils/topojson.d.ts +9 -0
  105. package/dist/plots/utils/topojson.js +30 -0
  106. package/dist/types/charts/common.d.ts +2 -1
  107. package/dist/types/charts/legend.d.ts +32 -1
  108. package/dist/types/charts/props.d.ts +9 -6
  109. package/dist/types/configuration/styling.d.ts +13 -5
  110. package/dist/types/layout/legend.d.ts +26 -0
  111. package/dist/types/layout/tooltip.d.ts +14 -21
  112. package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
  113. package/dist/types/markers/geo.d.ts +237 -0
  114. package/dist/types/markers/props.d.ts +11 -0
  115. package/dist/types/markers/props.js +1 -0
  116. package/dist/types/plots/axis.d.ts +55 -0
  117. package/dist/types/plots/axis.js +1 -0
  118. package/dist/types/plots/constants.d.ts +30 -0
  119. package/dist/types/plots/constants.js +1 -0
  120. package/dist/types/plots/data/common.d.ts +40 -0
  121. package/dist/types/plots/data/common.js +1 -0
  122. package/dist/types/plots/data/geo.d.ts +74 -0
  123. package/dist/types/plots/data/geo.js +1 -0
  124. package/dist/types/plots/delta.d.ts +2 -2
  125. package/dist/types/plots/props.d.ts +105 -16
  126. package/dist/types/plots/scales/geo.d.ts +44 -0
  127. package/dist/types/plots/scales/geo.js +1 -0
  128. package/dist/types/plots/segments/common.d.ts +25 -0
  129. package/dist/types/plots/segments/common.js +1 -0
  130. package/dist/types/plots/segments/config.d.ts +51 -0
  131. package/dist/types/plots/segments/config.js +1 -0
  132. package/dist/types/plots/styles/common.d.ts +37 -0
  133. package/dist/types/plots/styles/common.js +1 -0
  134. package/dist/types/plots/styles/geo.d.ts +42 -0
  135. package/dist/types/plots/styles/geo.js +1 -0
  136. package/dist/types/plots/styling.d.ts +45 -0
  137. package/dist/types/plots/styling.js +1 -0
  138. package/dist/utils/grouping.d.ts +2 -1
  139. package/dist/utils/interpolate.d.ts +2 -1
  140. package/package.json +27 -13
  141. package/dist/layout/plot/PlotLayout.svelte +0 -294
  142. package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
  143. package/dist/plots/markers/HoverMarker.svelte +0 -98
  144. package/dist/types/plots/common.d.ts +0 -97
  145. package/dist/types/plots/styles.d.ts +0 -187
  146. /package/dist/types/{plots/common.js → layout/legend.js} +0 -0
  147. /package/dist/types/{plots/markers.js → markers/common.js} +0 -0
  148. /package/dist/types/{plots/styles.js → markers/geo.js} +0 -0
package/README.md CHANGED
@@ -98,12 +98,13 @@ pnpm build-storybook
98
98
  | `HeatmapPlot` | `$lib/plots/heatmap/Plot.svelte` | Grid of colour-coded cells. |
99
99
  | `LinePlot` | `$lib/plots/line/Plot.svelte` | Line chart. Supports multiple series and per-series range segments with independent stroke styles. |
100
100
  | `PyramidPlot` | `$lib/plots/pyramid/Plot.svelte` | Diverging horizontal bar chart; each series is mirrored left or right of a shared zero baseline. |
101
+ | `GeoPlot` | `$lib/plots/geo/Plot.svelte` | Geographic map rendered from GeoJSON/TopoJSON with optional choropleth styling and interactive markers. |
101
102
 
102
103
  All components accept explicit `width` and `height` in pixels (svelteplot does not auto-size).
103
104
 
104
105
  ---
105
106
 
106
- ### Plot props
107
+ ### Plot props (BarPlot, LinePlot, HeatmapPlot, PyramidPlot)
107
108
 
108
109
  Plots accept either `series` (pre-built `Series[]`) or the `data` + `x`/`y`/`z` flat-rows path — these are mutually exclusive.
109
110
 
@@ -116,14 +117,34 @@ Plots accept either `series` (pre-built `Series[]`) or the `data` + `x`/`y`/`z`
116
117
  | `x` | `Accessor` | — | ✅ | ✅ | ✅ | ✅ |
117
118
  | `y` | `Accessor` | — | ✅ | ✅ | ✅ | ✅ |
118
119
  | `z` | `Accessor` | — | ✅ | ✅ | ✅ | ✅ |
119
- | `segments` | `Segments<TStyle>` | `[]` | ✅ | ✅ | ✅ | ✅ |
120
+ | `segments` | `SegmentsConfig<TStyle>` | `[]` | ✅ | ✅ | ✅ | ✅ |
120
121
  | `markers` | `Marker[]` | `[]` | ✅ | ✅ | ✅ | ✅ |
121
- | `scales` | `ScalesConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
122
+ | `scales` | `AxisBasedScalesConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
122
123
  | `margins` | `MarginConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
123
- | `tooltip` | `TooltipRuntime` | | ✅ | ✅ | ✅ | ✅ |
124
- | `styles` | `PlotStyles` | | ✅ | ✅ | ✅ | ✅ |
125
-
126
- #### `PlotStyles` sub-properties (plots)
124
+ | `tooltip` | `TooltipConfig` | | ✅ | ✅ | ✅ | ✅ |
125
+ | `styles` | `BasePlotStyles` | | ✅ | ✅ | ✅ | ✅ |
126
+
127
+ #### GeoPlot props
128
+
129
+ Unlike x/y plots, `GeoPlot` uses GeoJSON/TopoJSON as its data source (no x/y/z axes). It accepts either a `FeatureCollection`, a `Feature[]`, or a TopoJSON `Topology` (with the `object` key to specify which named object to extract).
130
+
131
+ | Prop | Type | Default | Description |
132
+ | ---- | ---- | ------- | ----------- |
133
+ | `width` | `number` | — | Plot width in pixels. |
134
+ | `height` | `number` | — | Plot height in pixels. |
135
+ | `data` | `FeatureCollection \| Feature[] \| Topology` | — | GeoJSON (FeatureCollection or Feature array) or TopoJSON Topology. |
136
+ | `object` | `string` | — | Required when `data` is a TopoJSON Topology — the key under `topology.objects` to extract. |
137
+ | `featureId` | `Accessor<GeoFeature, string>` | `feature.id ?? feature.properties?.id ?? feature.properties?.name` | Resolver for each feature's stable id (used for `segments` lookup and hover identification). |
138
+ | `value` | `(feature: GeoFeature) => number \| undefined` | — | Optional continuous accessor for choropleth colouring (mirrors heatmap's `z`). |
139
+ | `excludeParts` | `(part: GeoGeometry, feature: GeoFeature) => boolean` | — | Excludes matching geometry parts from rendering/hover (e.g. for inset markers). Return `true` to exclude. |
140
+ | `segments` | `SegmentsConfig<GeoSegmentStyle>` | `[]` | Per-feature styling (keyed by `featureId`). |
141
+ | `markers` | `GeoMarker[]` | `[]` | Array of markers: `graticule`, `sphere`, `dot`, `vector`, `link`, `contour`, `inset`, or custom `component`. |
142
+ | `scales` | `GeoScalesConfig` | `{}` | Projection and colour scale config. |
143
+ | `margins` | `MarginConfig` | `{}` | Top/right/bottom/left margin overrides. |
144
+ | `tooltip` | `TooltipConfig<GeoFeature>` | — | Hover/click tooltip configuration. |
145
+ | `styles` | `GeoStyles<TProps>` | — | Base map fill, choropleth ramp, tile layer, zoom, and click handlers. |
146
+
147
+ #### `BasePlotStyles` sub-properties (BarPlot, LinePlot, HeatmapPlot, PyramidPlot)
127
148
 
128
149
  | Sub-prop | Type | BarPlot default | HeatmapPlot default | LinePlot default | PyramidPlot default |
129
150
  | -------- | ---- | --------------- | ------------------- | ---------------- | ------------------- |
@@ -142,6 +163,54 @@ Plots accept either `series` (pre-built `Series[]`) or the `data` + `x`/`y`/`z`
142
163
  | `styles.colors.left` | `string` | — | — | — | palette index 0 |
143
164
  | `styles.colors.right` | `string` | — | — | — | palette index 1 |
144
165
 
166
+ #### `GeoStyles` sub-properties (GeoPlot)
167
+
168
+ | Sub-prop | Type | Default | Description |
169
+ | -------- | ---- | ------- | ----------- |
170
+ | `styles.fill` | `string` | palette[0] | Base map fill for features not styled by `segments` or choropleth. |
171
+ | `styles.fillOpacity` | `number` | `1` | Base map fill opacity. |
172
+ | `styles.stroke` | `string` | cfg `axis.color` | Base map feature stroke colour. |
173
+ | `styles.strokeWidth` | `number` | `0.5` | Base map feature stroke width. |
174
+ | `styles.colors.min` | `string` | cfg `continuous.min` | Choropleth ramp minimum colour (when `value` is provided). |
175
+ | `styles.colors.max` | `string` | cfg `continuous.max` | Choropleth ramp maximum colour (when `value` is provided). |
176
+ | `styles.tileLayer` | `GeoTileLayerConfig` | — | XYZ raster basemap config (URL, opacity, zoom range). Mercator-family projections only. |
177
+ | `styles.zoom` | `boolean \| GeoZoomConfig` | `false` | Enable/configure drag-pan + scroll-zoom (`false` = static map). |
178
+ | `styles.onFeatureClick` | `(feature: GeoFeature, event: Event) => void` | — | Click handler for base-map features. |
179
+
180
+ #### Scales: `AxisBasedScalesConfig` (x/y plots) vs `GeoScalesConfig` (GeoPlot)
181
+
182
+ X/Y plots use `AxisBasedScalesConfig` with `x`, `y`, `z` axis configurations. GeoPlot uses `GeoScalesConfig` with projection and colour settings instead. `ScalesConfig` is the union of both (`AxisBasedScalesConfig | GeoScalesConfig`) — each plot kind's own `scales` prop narrows to whichever one applies to it.
183
+
184
+ | Prop | AxisBasedScalesConfig (BarPlot, LinePlot, HeatmapPlot, PyramidPlot) | GeoScalesConfig (GeoPlot) |
185
+ | ---- | ------- | ------- |
186
+ | `x` | ✅ (AxisScale) | ❌ |
187
+ | `y` | ✅ (AxisScale) | ❌ |
188
+ | `z` | ✅ (AxisScale) | ❌ |
189
+ | `projection` | ❌ | ✅ (GeoProjectionConfig) |
190
+ | `color` | ❌ | ✅ (`{ domain?: [number, number] }`) |
191
+
192
+ #### Props distribution across all plot kinds
193
+
194
+ | Prop | BarPlot | HeatmapPlot | LinePlot | PyramidPlot | GeoPlot | Notes |
195
+ | ---- | ------- | ----------- | -------- | ----------- | ------- | ----- |
196
+ | `width` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots. |
197
+ | `height` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots. |
198
+ | `segments` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots; GeoPlot uses `SegmentsConfig<GeoSegmentStyle>`, others use their own `SegmentStyle` type. |
199
+ | `markers` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots; GeoPlot uses `GeoMarker[]`, others use `Marker[]`. |
200
+ | `margins` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots. |
201
+ | `tooltip` | ✅ | ✅ | ✅ | ✅ | ✅ | Common to all plots; row type varies per plot. |
202
+ | `styles` | ✅ | ✅ | ✅ | ✅ | ✅ | Common; type is `BasePlotStyles` for x/y plots, `GeoStyles<TProps>` for GeoPlot. |
203
+ | `scales` | ✅ | ✅ | ✅ | ✅ | ✅ | Common; type is `AxisBasedScalesConfig<TData>` for x/y plots, `GeoScalesConfig` for GeoPlot. |
204
+ | `series` | ✅ | ✅ | ✅ | ✅ | ❌ | X/Y plots only (mutually exclusive with `data`/`x`/`y`/`z`). |
205
+ | `data` | ✅ (TData[]) | ✅ (TData[]) | ✅ (TData[]) | ✅ (TData[]) | ✅ (FeatureCollection \| Feature[] \| Topology) | Common; data shape differs — x/y plots use flat rows, GeoPlot uses geo features. |
206
+ | `x` | ✅ | ✅ | ✅ | ✅ | ❌ | X/Y plots only. |
207
+ | `y` | ✅ | ✅ | ✅ | ✅ | ❌ | X/Y plots only. |
208
+ | `z` | ✅ | ✅ | ✅ | ✅ | ❌ | X/Y plots only (used as series selector in bar/line/pyramid, value accessor in heatmap). |
209
+ | `object` | ❌ | ❌ | ❌ | ❌ | ✅ (optional) | GeoPlot only; required when `data` is a TopoJSON Topology. |
210
+ | `featureId` | ❌ | ❌ | ❌ | ❌ | ✅ (optional) | GeoPlot only; resolves feature identity for `segments` lookup and hover. |
211
+ | `value` | ❌ | ❌ | ❌ | ❌ | ✅ (optional) | GeoPlot only; drives choropleth colouring (analogous to heatmap's `z`). |
212
+ | `excludeParts` | ❌ | ❌ | ❌ | ❌ | ✅ (optional) | GeoPlot only; filters geometry parts from rendering. |
213
+
145
214
  ---
146
215
 
147
216
  ### Chart props
@@ -160,14 +229,14 @@ Plots accept either `series` (pre-built `Series[]`) or the `data` + `x`/`y`/`z`
160
229
  | `header` | `Snippet` | | ✅ | ✅ | ✅ | ✅ |
161
230
  | `footer` | `Snippet` | | ✅ | ✅ | ✅ | ✅ |
162
231
  | `legend` | `LegendSection[]` | | ✅ | ✅ | ✅ | ✅ |
163
- | `segments` | `Segments<TStyle>` | `[]` | ✅ | ✅ | ✅ | ✅ |
232
+ | `segments` | `SegmentsConfig<TStyle>` | `[]` | ✅ | ✅ | ✅ | ✅ |
164
233
  | `markers` | `Marker[]` | `[]` | ✅ | ✅ | ✅ | ✅ |
165
- | `scales` | `ScalesConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
234
+ | `scales` | `AxisBasedScalesConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
166
235
  | `margins` | `MarginConfig` | `{}` | ✅ | ✅ | ✅ | ✅ |
167
236
  | `facet` | `FacetConfig` | | ✅ | ✅ | ✅ | ✅ |
168
237
  | `timeline` | `TimelineConfig` | | ✅ | ✅ | ✅ | ✅ |
169
238
  | `tooltip` | `TooltipProp` | | ✅ | ✅ | ✅ | ✅ |
170
- | `styles` | `PlotStyles` | | ✅ | ✅ | ✅ | ✅ |
239
+ | `styles` | `BasePlotStyles` | | ✅ | ✅ | ✅ | ✅ |
171
240
 
172
241
  `header` and `footer` are Svelte 5 snippets that replace the string props when richer markup is needed (custom styles, logos, links, etc.). When `header` is provided it takes full precedence over `title`/`subtitle`; when `footer` is provided it takes full precedence over `caption`. Use the natural snippet syntax:
173
242
 
@@ -186,7 +255,7 @@ Plots accept either `series` (pre-built `Series[]`) or the `data` + `x`/`y`/`z`
186
255
  </LineChart>
187
256
  ```
188
257
 
189
- See the [PlotStyles sub-properties table](#plotstyles-sub-properties-plots) above — charts accept the same `styles` shape and pass it through to their underlying plot.
258
+ See the [BasePlotStyles sub-properties table](#baseplotstyles-sub-properties-barplot-lineplot-heatmapplot-pyramidplot) above — charts accept the same `styles` shape and pass it through to their underlying plot.
190
259
 
191
260
  ---
192
261
 
@@ -194,12 +263,22 @@ See the [PlotStyles sub-properties table](#plotstyles-sub-properties-plots) abov
194
263
 
195
264
  The `segments` prop separates data ranges from visual styling. Every plot kind shares the same underlying types; the style shape (`TStyle`) differs per mark.
196
265
 
197
- | Plot | `segments` type |
198
- | ---- | --------------- |
199
- | `LinePlot` / `LineChart` | `Segments<LineSegmentStyle>` |
200
- | `BarPlot` / `BarChart` | `Segments<BarSegmentStyle>` |
201
- | `PyramidPlot` / `PyramidChart` | `Segments<BarSegmentStyle>` |
202
- | `HeatmapPlot` / `HeatmapChart` | `Segments<CellSegmentStyle>` (`'default'` key only) |
266
+ | Plot | `segments` type | Key structure | Lookup |
267
+ | ---- | --------------- | ------------- | ------ |
268
+ | `LinePlot` / `LineChart` | `SegmentsConfig<LineSegmentStyle>` | Named keys (series names) or `'default'` | By series name (`z` accessor or series index). |
269
+ | `BarPlot` / `BarChart` | `SegmentsConfig<BarSegmentStyle>` | Named keys (series names) or `'default'` | By series name (`z` accessor or series index). |
270
+ | `PyramidPlot` / `PyramidChart` | `SegmentsConfig<BarSegmentStyle>` | Named keys (series names) or `'default'` | By series name (`z` accessor or series index). |
271
+ | `HeatmapPlot` / `HeatmapChart` | `SegmentsConfig<CellSegmentStyle>` | `'default'` key only | All cells (can be restricted by `areas` coordinates). |
272
+ | `GeoPlot` | `SegmentsConfig<GeoSegmentStyle>` | Named keys (feature ids) or `'default'` | By feature id (`featureId` accessor or derived from properties). |
273
+
274
+ **Segment styles by plot:**
275
+
276
+ | SegmentStyle type | Supports | Plot(s) |
277
+ | --- | --- | --- |
278
+ | `LineSegmentStyle` | `stroke` (line), `dots` (endpoint markers) | `LinePlot` / `LineChart` |
279
+ | `BarSegmentStyle` | `fill`, `fillOpacity` | `BarPlot` / `BarChart`, `PyramidPlot` / `PyramidChart` |
280
+ | `CellSegmentStyle` | `fill`, `fillOpacity`, `stroke`, `strokeWidth` | `HeatmapPlot` / `HeatmapChart` |
281
+ | `GeoSegmentStyle` | `fill`, `fillOpacity`, `stroke`, `strokeWidth` | `GeoPlot` |
203
282
 
204
283
  #### Core types
205
284
 
@@ -291,6 +370,31 @@ Having multiple groups lets you organise segments by concern — for example one
291
370
  />
292
371
  ```
293
372
 
373
+ **GeoPlot — per-feature styling and catch-all fallback (note: GeoPlot keys are feature ids, not series names):**
374
+
375
+ ```svelte
376
+ <GeoPlot
377
+ {width} {height}
378
+ data={COUNTRIES_GEOJSON}
379
+ value={(f) => f.properties?.population}
380
+ segments={[
381
+ {
382
+ // Catch-all baseline (always evaluated last)
383
+ default: [
384
+ { style: { fillOpacity: 0.7, stroke: '#94a3b8' } },
385
+ ],
386
+ // Per-feature overrides (matched by feature id)
387
+ argentina: [
388
+ { style: { fill: '#3b82f6', fillOpacity: 0.9 } },
389
+ ],
390
+ brazil: [
391
+ { style: { fill: '#ef4444', fillOpacity: 0.9 } },
392
+ ],
393
+ },
394
+ ]}
395
+ />
396
+ ```
397
+
294
398
  Omitting `segments` (or passing `[]`) renders every mark in its default palette colour.
295
399
 
296
400
  ---
@@ -5,6 +5,7 @@
5
5
  import LegendLayout from '../layout/legend/LegendLayout.svelte';
6
6
  import { getConfiguration } from '../configuration/config.svelte';
7
7
  import { provideHover } from '../layout/tooltip/hover.svelte';
8
+ import { provideLegendInteraction } from '../layout/legend/interaction.svelte';
8
9
  import type { Snippet } from 'svelte';
9
10
  import type { LegendSection } from '../types/charts/legend';
10
11
  import type { HoverStrategy } from '../types/layout/tooltip';
@@ -59,6 +60,7 @@
59
60
  const cfg = $derived(getConfiguration());
60
61
 
61
62
  const hoverStore = provideHover();
63
+ provideLegendInteraction();
62
64
  $effect(() => {
63
65
  hoverStore.strategy = hover?.strategy ?? 'x';
64
66
  hoverStore.sync = hover?.sync ?? false;
@@ -40,6 +40,6 @@ interface $$IsomorphicComponent {
40
40
  <TRow extends Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<TRow>['props']> & {}): ReturnType<__sveltets_Render<TRow>['exports']>;
41
41
  z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
42
42
  }
43
- declare const Chart: $$IsomorphicComponent;
44
- type Chart<TRow extends Record<string, unknown>> = InstanceType<typeof Chart<TRow>>;
45
- export default Chart;
43
+ declare const BaseChart: $$IsomorphicComponent;
44
+ type BaseChart<TRow extends Record<string, unknown>> = InstanceType<typeof BaseChart<TRow>>;
45
+ export default BaseChart;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
- import Chart from '../Chart.svelte';
2
+ import BaseChart from '../BaseChart.svelte';
3
3
  import BarPlot from '../../plots/bar/Plot.svelte';
4
4
  import {
5
5
  resolveTooltip,
@@ -9,12 +9,12 @@
9
9
  } from '../../layout/tooltip/utils';
10
10
  import { resolveAccessor } from '../../plots/utils/accessors';
11
11
  import { resolveTimelineInterpolation } from '../../utils/interpolate';
12
- import type { BarSegmentStyle } from '../../types/plots/styles';
12
+ import type { BarSegmentStyle } from '../../types/plots/segments/common';
13
13
  import type { ChartProps } from '../../types/charts/props';
14
14
 
15
15
  /**
16
16
  * High-level bar chart. Groups flat rows by `z` into one series per group
17
- * and delegates all chrome to {@link Chart}. Styling lives entirely in
17
+ * and delegates all chrome to {@link BaseChart}. Styling lives entirely in
18
18
  * `segments` — there's no separate colour shorthand, so a series' look is
19
19
  * always defined in one place.
20
20
  */
@@ -66,7 +66,7 @@
66
66
  );
67
67
  </script>
68
68
 
69
- <Chart
69
+ <BaseChart
70
70
  {width}
71
71
  {height}
72
72
  {title}
@@ -105,4 +105,4 @@
105
105
  : undefined}
106
106
  />
107
107
  {/snippet}
108
- </Chart>
108
+ </BaseChart>
@@ -1,5 +1,4 @@
1
- import Chart from '../Chart.svelte';
2
- import type { BarSegmentStyle } from '../../types/plots/styles';
1
+ import type { BarSegmentStyle } from '../../types/plots/segments/common';
3
2
  import type { ChartProps } from '../../types/charts/props';
4
3
  declare function $$render<TRow extends Record<string, unknown>>(): {
5
4
  props: ChartProps<TRow, BarSegmentStyle>;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
- import Chart from '../Chart.svelte';
2
+ import BaseChart from '../BaseChart.svelte';
3
3
  import HeatmapPlot from '../../plots/heatmap/Plot.svelte';
4
4
  import {
5
5
  resolveTooltip,
@@ -8,13 +8,14 @@
8
8
  hasHoverMarker
9
9
  } from '../../layout/tooltip/utils';
10
10
  import { resolveAccessor } from '../../plots/utils/accessors';
11
- import type { Accessor, ScalesConfig } from '../../types/plots/common';
12
- import type { CellSegmentStyle } from '../../types/plots/styles';
11
+ import type { Accessor } from '../../types/plots/data/common';
12
+ import type { AxisBasedScalesConfig } from '../../types/plots/props';
13
+ import type { CellSegmentStyle } from '../../types/plots/segments/common';
13
14
  import type { ChartProps } from '../../types/charts/props';
14
15
 
15
16
  /**
16
17
  * High-level heatmap. Proves the chart chrome (container/legend/timeline/facet)
17
- * is plot-agnostic: it reuses {@link Chart} exactly like {@link LineChart}, only
18
+ * is plot-agnostic: it reuses {@link BaseChart} exactly like {@link LineChart}, only
18
19
  * swapping the leaf for {@link HeatmapPlot}. The colour domain is computed once
19
20
  * over the full dataset so cells stay comparable across timeline steps/facets —
20
21
  * it is passed via `scales.z.domain` and can be overridden by the caller.
@@ -53,7 +54,7 @@
53
54
  const vals = data.map((d) => Number(getZ(d)));
54
55
  return vals.length ? [Math.min(...vals, 0), Math.max(...vals)] : [0, 1];
55
56
  });
56
- const mergedScales = $derived<ScalesConfig>({
57
+ const mergedScales = $derived<AxisBasedScalesConfig<TRow>>({
57
58
  ...scales,
58
59
  z: { domain: fullDomain, ...(scales.z ?? {}) },
59
60
  });
@@ -69,7 +70,7 @@
69
70
  });
70
71
  </script>
71
72
 
72
- <Chart
73
+ <BaseChart
73
74
  {width}
74
75
  {height}
75
76
  {title}
@@ -108,4 +109,4 @@
108
109
  : undefined}
109
110
  />
110
111
  {/snippet}
111
- </Chart>
112
+ </BaseChart>
@@ -1,6 +1,5 @@
1
- import Chart from '../Chart.svelte';
2
- import type { Accessor } from '../../types/plots/common';
3
- import type { CellSegmentStyle } from '../../types/plots/styles';
1
+ import type { Accessor } from '../../types/plots/data/common';
2
+ import type { CellSegmentStyle } from '../../types/plots/segments/common';
4
3
  import type { ChartProps } from '../../types/charts/props';
5
4
  declare function $$render<TRow extends Record<string, unknown>>(): {
6
5
  props: ChartProps<TRow, CellSegmentStyle> & {
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
- import Chart from '../Chart.svelte';
2
+ import BaseChart from '../BaseChart.svelte';
3
3
  import LinePlot from '../../plots/line/Plot.svelte';
4
4
  import {
5
5
  resolveTooltip,
@@ -9,14 +9,14 @@
9
9
  } from '../../layout/tooltip/utils';
10
10
  import { resolveAccessor } from '../../plots/utils/accessors';
11
11
  import { resolveTimelineInterpolation } from '../../utils/interpolate';
12
- import type { LineSegmentStyle } from '../../types/plots/styles';
12
+ import type { LineSegmentStyle } from '../../types/plots/segments/common';
13
13
  import type { ChartProps } from '../../types/charts/props';
14
14
 
15
15
  /**
16
16
  * High-level line chart. It takes flat rows plus `x`/`y`/`z` encodings, groups
17
17
  * by `z` into one line per group, and hands the result to {@link LinePlot}.
18
18
  * Everything chrome-related (title, legend, timeline, facets) is delegated to
19
- * {@link Chart}; this component only owns the flat-data → line-series adaption.
19
+ * {@link BaseChart}; this component only owns the flat-data → line-series adaption.
20
20
  */
21
21
  let {
22
22
  width,
@@ -68,7 +68,7 @@
68
68
  });
69
69
  </script>
70
70
 
71
- <Chart
71
+ <BaseChart
72
72
  {width}
73
73
  {height}
74
74
  {title}
@@ -107,4 +107,4 @@
107
107
  : undefined}
108
108
  />
109
109
  {/snippet}
110
- </Chart>
110
+ </BaseChart>
@@ -1,5 +1,4 @@
1
- import Chart from '../Chart.svelte';
2
- import type { LineSegmentStyle } from '../../types/plots/styles';
1
+ import type { LineSegmentStyle } from '../../types/plots/segments/common';
3
2
  import type { ChartProps } from '../../types/charts/props';
4
3
  declare function $$render<TRow extends Record<string, unknown>>(): {
5
4
  props: ChartProps<TRow, LineSegmentStyle>;
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" generics="TRow extends Record<string, unknown>">
2
- import Chart from '../Chart.svelte';
2
+ import BaseChart from '../BaseChart.svelte';
3
3
  import PyramidPlot from '../../plots/pyramid/Plot.svelte';
4
4
  import {
5
5
  resolveTooltip,
@@ -9,8 +9,9 @@
9
9
  } from '../../layout/tooltip/utils';
10
10
  import { resolveAccessor } from '../../plots/utils/accessors';
11
11
  import { resolveTimelineInterpolation } from '../../utils/interpolate';
12
- import type { Accessor, AxisValue } from '../../types/plots/common';
13
- import type { BarSegmentStyle } from '../../types/plots/styles';
12
+ import type { AxisValue } from '../../types/plots/axis';
13
+ import type { Accessor } from '../../types/plots/data/common';
14
+ import type { BarSegmentStyle } from '../../types/plots/segments/common';
14
15
  import type { ChartProps } from '../../types/charts/props';
15
16
 
16
17
  /**
@@ -19,7 +20,7 @@
19
20
  * into series and assigns left/right sides automatically from the
20
21
  * alphabetical order of `z` values. Pass `scales.z.reverse: true` to flip
21
22
  * which side goes first. Delegates all chrome (title, legend, timeline,
22
- * facets) to {@link Chart}.
23
+ * facets) to {@link BaseChart}.
23
24
  */
24
25
  let {
25
26
  width,
@@ -89,7 +90,7 @@
89
90
  );
90
91
  </script>
91
92
 
92
- <Chart
93
+ <BaseChart
93
94
  {width}
94
95
  {height}
95
96
  {title}
@@ -128,4 +129,4 @@
128
129
  : undefined}
129
130
  />
130
131
  {/snippet}
131
- </Chart>
132
+ </BaseChart>
@@ -1,6 +1,5 @@
1
- import Chart from '../Chart.svelte';
2
- import type { Accessor } from '../../types/plots/common';
3
- import type { BarSegmentStyle } from '../../types/plots/styles';
1
+ import type { Accessor } from '../../types/plots/data/common';
2
+ import type { BarSegmentStyle } from '../../types/plots/segments/common';
4
3
  import type { ChartProps } from '../../types/charts/props';
5
4
  declare function $$render<TRow extends Record<string, unknown>>(): {
6
5
  props: ChartProps<TRow, BarSegmentStyle> & {
@@ -46,6 +46,7 @@ export const DEFAULT_CONFIG = {
46
46
  titleWeight: 500,
47
47
  gap: '0.5rem 2rem',
48
48
  swatchSize: '1.25rem',
49
+ disabledOpacity: 0.12,
49
50
  },
50
51
  axis: {
51
52
  color: 'currentColor',
@@ -66,7 +67,7 @@ export const DEFAULT_CONFIG = {
66
67
  radius: '0.375rem',
67
68
  border: 'none',
68
69
  },
69
- margins: { top: 30, right: 50, bottom: 30, left: 40 },
70
+ margins: { top: 'auto', right: 'auto', bottom: 'auto', left: 'auto' },
70
71
  palette: ['#4f46e5', '#e6580d', '#16a34a', '#dc2626', '#0891b2', '#9333ea', '#ca8a04', '#db2777'],
71
72
  continuous: { min: '#e0e7ff', max: '#4f46e5', labelColor: '#111827' },
72
73
  line: { strokeWidth: 3, dotRadius: 4 },