@fundar/data-chart-telling 0.0.13 → 0.0.15

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 (141) hide show
  1. package/README.md +121 -17
  2. package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
  3. package/dist/charts/bar/Chart.svelte +5 -5
  4. package/dist/charts/bar/Chart.svelte.d.ts +1 -2
  5. package/dist/charts/heatmap/Chart.svelte +8 -7
  6. package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
  7. package/dist/charts/line/Chart.svelte +5 -5
  8. package/dist/charts/line/Chart.svelte.d.ts +1 -2
  9. package/dist/charts/pyramid/Chart.svelte +7 -6
  10. package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
  11. package/dist/configuration/config.svelte.js +1 -1
  12. package/dist/configuration/themes/index.d.ts +56 -40
  13. package/dist/index.d.ts +26 -12
  14. package/dist/index.js +12 -7
  15. package/dist/layout/facet/FacetLayout.svelte +1 -1
  16. package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
  17. package/dist/layout/geo/GeoLayout.svelte +47 -0
  18. package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
  19. package/dist/layout/geo/resolveProjection.d.ts +10 -0
  20. package/dist/layout/geo/resolveProjection.js +48 -0
  21. package/dist/layout/legend/DiscreteSection.svelte +1 -1
  22. package/dist/layout/plot/AxisLayout.svelte +95 -0
  23. package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
  24. package/dist/layout/plot/BasePlotLayout.svelte +302 -0
  25. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
  26. package/dist/layout/plot/GridLayout.svelte +30 -0
  27. package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
  28. package/dist/layout/plot/RuleLayout.svelte +111 -0
  29. package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
  30. package/dist/layout/plot/margins.d.ts +34 -0
  31. package/dist/layout/plot/margins.js +26 -0
  32. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  33. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
  34. package/dist/layout/tooltip/Tooltip.svelte +15 -0
  35. package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
  36. package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
  37. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
  38. package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
  39. package/dist/layout/tooltip/controller.svelte.js +5 -6
  40. package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
  41. package/dist/layout/tooltip/hover.svelte.js +1 -1
  42. package/dist/layout/tooltip/utils.d.ts +2 -2
  43. package/dist/markers/ContourClipMarker.svelte +77 -0
  44. package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
  45. package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
  46. package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
  47. package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
  48. package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
  49. package/dist/markers/HoverMarker.svelte +136 -0
  50. package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
  51. package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
  52. package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
  53. package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
  54. package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
  55. package/dist/markers/inset/InsetMarker.svelte +170 -0
  56. package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
  57. package/dist/markers/inset/insetLayout.d.ts +25 -0
  58. package/dist/markers/inset/insetLayout.js +39 -0
  59. package/dist/markers/inset/insetProjection.d.ts +8 -0
  60. package/dist/markers/inset/insetProjection.js +39 -0
  61. package/dist/plots/bar/BarSegments.svelte +66 -0
  62. package/dist/plots/bar/BarSegments.svelte.d.ts +36 -0
  63. package/dist/plots/bar/Plot.svelte +132 -76
  64. package/dist/plots/bar/Plot.svelte.d.ts +7 -3
  65. package/dist/plots/bar/ValueLabels.svelte +89 -0
  66. package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
  67. package/dist/plots/bar/hoverPoints.d.ts +15 -0
  68. package/dist/plots/bar/hoverPoints.js +35 -0
  69. package/dist/plots/bar/layout.svelte.d.ts +37 -0
  70. package/dist/plots/bar/layout.svelte.js +132 -0
  71. package/dist/plots/geo/Plot.svelte +548 -0
  72. package/dist/plots/geo/Plot.svelte.d.ts +29 -0
  73. package/dist/plots/geo/TileLayer.svelte +77 -0
  74. package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
  75. package/dist/plots/geo/projections/argentina.d.ts +8 -0
  76. package/dist/plots/geo/projections/argentina.js +35 -0
  77. package/dist/plots/geo/projections/fit.d.ts +8 -0
  78. package/dist/plots/geo/projections/fit.js +14 -0
  79. package/dist/plots/geo/rotate.svelte.d.ts +26 -0
  80. package/dist/plots/geo/rotate.svelte.js +79 -0
  81. package/dist/plots/geo/zoom.svelte.d.ts +32 -0
  82. package/dist/plots/geo/zoom.svelte.js +50 -0
  83. package/dist/plots/heatmap/Plot.svelte +129 -47
  84. package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
  85. package/dist/plots/line/Plot.svelte +44 -16
  86. package/dist/plots/line/Plot.svelte.d.ts +7 -3
  87. package/dist/plots/pyramid/Plot.svelte +70 -25
  88. package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
  89. package/dist/plots/utils/delta.d.ts +1 -1
  90. package/dist/plots/utils/geoAccessors.d.ts +64 -0
  91. package/dist/plots/utils/geoAccessors.js +188 -0
  92. package/dist/plots/utils/geoSegments.d.ts +14 -0
  93. package/dist/plots/utils/geoSegments.js +17 -0
  94. package/dist/plots/utils/segments.d.ts +14 -5
  95. package/dist/plots/utils/segments.js +25 -13
  96. package/dist/plots/utils/tiles.d.ts +89 -0
  97. package/dist/plots/utils/tiles.js +159 -0
  98. package/dist/plots/utils/topojson.d.ts +9 -0
  99. package/dist/plots/utils/topojson.js +30 -0
  100. package/dist/types/charts/common.d.ts +2 -1
  101. package/dist/types/charts/legend.d.ts +1 -1
  102. package/dist/types/charts/props.d.ts +9 -6
  103. package/dist/types/configuration/styling.d.ts +11 -5
  104. package/dist/types/layout/tooltip.d.ts +14 -21
  105. package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
  106. package/dist/types/markers/geo.d.ts +237 -0
  107. package/dist/types/markers/props.d.ts +11 -0
  108. package/dist/types/plots/axis.d.ts +55 -0
  109. package/dist/types/plots/axis.js +1 -0
  110. package/dist/types/plots/constants.d.ts +30 -0
  111. package/dist/types/plots/constants.js +1 -0
  112. package/dist/types/plots/data/common.d.ts +40 -0
  113. package/dist/types/plots/data/common.js +1 -0
  114. package/dist/types/plots/data/geo.d.ts +74 -0
  115. package/dist/types/plots/data/geo.js +1 -0
  116. package/dist/types/plots/delta.d.ts +2 -2
  117. package/dist/types/plots/props.d.ts +105 -16
  118. package/dist/types/plots/scales/geo.d.ts +44 -0
  119. package/dist/types/plots/scales/geo.js +1 -0
  120. package/dist/types/plots/segments/common.d.ts +25 -0
  121. package/dist/types/plots/segments/common.js +1 -0
  122. package/dist/types/plots/segments/config.d.ts +51 -0
  123. package/dist/types/plots/segments/config.js +1 -0
  124. package/dist/types/plots/styles/common.d.ts +37 -0
  125. package/dist/types/plots/styles/common.js +1 -0
  126. package/dist/types/plots/styles/geo.d.ts +42 -0
  127. package/dist/types/plots/styles/geo.js +1 -0
  128. package/dist/types/plots/styling.d.ts +45 -0
  129. package/dist/types/plots/styling.js +1 -0
  130. package/dist/utils/grouping.d.ts +2 -1
  131. package/dist/utils/interpolate.d.ts +2 -1
  132. package/package.json +27 -13
  133. package/dist/layout/plot/PlotLayout.svelte +0 -237
  134. package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
  135. package/dist/plots/markers/HoverMarker.svelte +0 -98
  136. package/dist/types/plots/common.d.ts +0 -100
  137. package/dist/types/plots/styles.d.ts +0 -187
  138. /package/dist/charts/{Chart.svelte → BaseChart.svelte} +0 -0
  139. /package/dist/types/{plots → markers}/common.js +0 -0
  140. /package/dist/types/{plots/markers.js → markers/geo.js} +0 -0
  141. /package/dist/types/{plots/styles.js → markers/props.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
  ---
@@ -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> & {
@@ -66,7 +66,7 @@ export const DEFAULT_CONFIG = {
66
66
  radius: '0.375rem',
67
67
  border: 'none',
68
68
  },
69
- margins: { top: 30, right: 50, bottom: 30, left: 40 },
69
+ margins: { top: 'auto', right: 'auto', bottom: 'auto', left: 'auto' },
70
70
  palette: ['#4f46e5', '#e6580d', '#16a34a', '#dc2626', '#0891b2', '#9333ea', '#ca8a04', '#db2777'],
71
71
  continuous: { min: '#e0e7ff', max: '#4f46e5', labelColor: '#111827' },
72
72
  line: { strokeWidth: 3, dotRadius: 4 },
@@ -69,10 +69,10 @@ export declare const THEMES: {
69
69
  border?: string | undefined;
70
70
  } | undefined;
71
71
  margins?: {
72
- top?: number | undefined;
73
- right?: number | undefined;
74
- bottom?: number | undefined;
75
- left?: number | undefined;
72
+ top?: number | "auto" | undefined;
73
+ right?: number | "auto" | undefined;
74
+ bottom?: number | "auto" | undefined;
75
+ left?: number | "auto" | undefined;
76
76
  } | undefined;
77
77
  palette?: string[] | undefined;
78
78
  continuous?: {
@@ -95,8 +95,8 @@ export declare const THEMES: {
95
95
  strokeWidth?: number | undefined;
96
96
  strokeOpacity?: number | undefined;
97
97
  strokeDasharray?: (string | import("../..").LineStyle) | undefined;
98
- strokeLinecap?: import("../../types/plots/styles").LineCap | undefined;
99
- strokeLinejoin?: import("../../types/plots/styles").LineJoin | undefined;
98
+ strokeLinecap?: import("../..").LineCap | undefined;
99
+ strokeLinejoin?: import("../..").LineJoin | undefined;
100
100
  } | undefined;
101
101
  dot?: {
102
102
  dotRadius?: number | undefined;
@@ -111,15 +111,19 @@ export declare const THEMES: {
111
111
  font?: {
112
112
  fill?: string | undefined;
113
113
  fontSize?: number | undefined;
114
- fontWeight?: "normal" | "bold" | undefined;
115
- fontStyle?: "normal" | "italic" | undefined;
116
- textAnchor?: "start" | "middle" | "end" | undefined;
117
- lineAnchor?: "top" | "middle" | "bottom" | undefined;
114
+ fontWeight?: import("../..").FontWeight | undefined;
115
+ fontStyle?: import("../..").FontStyleKeyword | undefined;
116
+ textAnchor?: import("../..").TextAnchor | undefined;
117
+ lineAnchor?: import("../..").LineAnchor | undefined;
118
+ lineHeight?: number | undefined;
119
+ rotate?: number | undefined;
118
120
  stroke?: string | undefined;
119
121
  strokeWidth?: number | undefined;
120
122
  paintOrder?: string | undefined;
121
123
  dx?: number | undefined;
122
124
  dy?: number | undefined;
125
+ class?: string | undefined;
126
+ textClass?: string | undefined;
123
127
  } | undefined;
124
128
  } | undefined;
125
129
  };
@@ -187,10 +191,10 @@ export declare const THEMES: {
187
191
  border?: string | undefined;
188
192
  } | undefined;
189
193
  margins?: {
190
- top?: number | undefined;
191
- right?: number | undefined;
192
- bottom?: number | undefined;
193
- left?: number | undefined;
194
+ top?: number | "auto" | undefined;
195
+ right?: number | "auto" | undefined;
196
+ bottom?: number | "auto" | undefined;
197
+ left?: number | "auto" | undefined;
194
198
  } | undefined;
195
199
  palette?: string[] | undefined;
196
200
  continuous?: {
@@ -213,8 +217,8 @@ export declare const THEMES: {
213
217
  strokeWidth?: number | undefined;
214
218
  strokeOpacity?: number | undefined;
215
219
  strokeDasharray?: (string | import("../..").LineStyle) | undefined;
216
- strokeLinecap?: import("../../types/plots/styles").LineCap | undefined;
217
- strokeLinejoin?: import("../../types/plots/styles").LineJoin | undefined;
220
+ strokeLinecap?: import("../..").LineCap | undefined;
221
+ strokeLinejoin?: import("../..").LineJoin | undefined;
218
222
  } | undefined;
219
223
  dot?: {
220
224
  dotRadius?: number | undefined;
@@ -229,15 +233,19 @@ export declare const THEMES: {
229
233
  font?: {
230
234
  fill?: string | undefined;
231
235
  fontSize?: number | undefined;
232
- fontWeight?: "normal" | "bold" | undefined;
233
- fontStyle?: "normal" | "italic" | undefined;
234
- textAnchor?: "start" | "middle" | "end" | undefined;
235
- lineAnchor?: "top" | "middle" | "bottom" | undefined;
236
+ fontWeight?: import("../..").FontWeight | undefined;
237
+ fontStyle?: import("../..").FontStyleKeyword | undefined;
238
+ textAnchor?: import("../..").TextAnchor | undefined;
239
+ lineAnchor?: import("../..").LineAnchor | undefined;
240
+ lineHeight?: number | undefined;
241
+ rotate?: number | undefined;
236
242
  stroke?: string | undefined;
237
243
  strokeWidth?: number | undefined;
238
244
  paintOrder?: string | undefined;
239
245
  dx?: number | undefined;
240
246
  dy?: number | undefined;
247
+ class?: string | undefined;
248
+ textClass?: string | undefined;
241
249
  } | undefined;
242
250
  } | undefined;
243
251
  };
@@ -305,10 +313,10 @@ export declare const THEMES: {
305
313
  border?: string | undefined;
306
314
  } | undefined;
307
315
  margins?: {
308
- top?: number | undefined;
309
- right?: number | undefined;
310
- bottom?: number | undefined;
311
- left?: number | undefined;
316
+ top?: number | "auto" | undefined;
317
+ right?: number | "auto" | undefined;
318
+ bottom?: number | "auto" | undefined;
319
+ left?: number | "auto" | undefined;
312
320
  } | undefined;
313
321
  palette?: string[] | undefined;
314
322
  continuous?: {
@@ -331,8 +339,8 @@ export declare const THEMES: {
331
339
  strokeWidth?: number | undefined;
332
340
  strokeOpacity?: number | undefined;
333
341
  strokeDasharray?: (string | import("../..").LineStyle) | undefined;
334
- strokeLinecap?: import("../../types/plots/styles").LineCap | undefined;
335
- strokeLinejoin?: import("../../types/plots/styles").LineJoin | undefined;
342
+ strokeLinecap?: import("../..").LineCap | undefined;
343
+ strokeLinejoin?: import("../..").LineJoin | undefined;
336
344
  } | undefined;
337
345
  dot?: {
338
346
  dotRadius?: number | undefined;
@@ -347,15 +355,19 @@ export declare const THEMES: {
347
355
  font?: {
348
356
  fill?: string | undefined;
349
357
  fontSize?: number | undefined;
350
- fontWeight?: "normal" | "bold" | undefined;
351
- fontStyle?: "normal" | "italic" | undefined;
352
- textAnchor?: "start" | "middle" | "end" | undefined;
353
- lineAnchor?: "top" | "middle" | "bottom" | undefined;
358
+ fontWeight?: import("../..").FontWeight | undefined;
359
+ fontStyle?: import("../..").FontStyleKeyword | undefined;
360
+ textAnchor?: import("../..").TextAnchor | undefined;
361
+ lineAnchor?: import("../..").LineAnchor | undefined;
362
+ lineHeight?: number | undefined;
363
+ rotate?: number | undefined;
354
364
  stroke?: string | undefined;
355
365
  strokeWidth?: number | undefined;
356
366
  paintOrder?: string | undefined;
357
367
  dx?: number | undefined;
358
368
  dy?: number | undefined;
369
+ class?: string | undefined;
370
+ textClass?: string | undefined;
359
371
  } | undefined;
360
372
  } | undefined;
361
373
  };
@@ -423,10 +435,10 @@ export declare const THEMES: {
423
435
  border?: string | undefined;
424
436
  } | undefined;
425
437
  margins?: {
426
- top?: number | undefined;
427
- right?: number | undefined;
428
- bottom?: number | undefined;
429
- left?: number | undefined;
438
+ top?: number | "auto" | undefined;
439
+ right?: number | "auto" | undefined;
440
+ bottom?: number | "auto" | undefined;
441
+ left?: number | "auto" | undefined;
430
442
  } | undefined;
431
443
  palette?: string[] | undefined;
432
444
  continuous?: {
@@ -449,8 +461,8 @@ export declare const THEMES: {
449
461
  strokeWidth?: number | undefined;
450
462
  strokeOpacity?: number | undefined;
451
463
  strokeDasharray?: (string | import("../..").LineStyle) | undefined;
452
- strokeLinecap?: import("../../types/plots/styles").LineCap | undefined;
453
- strokeLinejoin?: import("../../types/plots/styles").LineJoin | undefined;
464
+ strokeLinecap?: import("../..").LineCap | undefined;
465
+ strokeLinejoin?: import("../..").LineJoin | undefined;
454
466
  } | undefined;
455
467
  dot?: {
456
468
  dotRadius?: number | undefined;
@@ -465,15 +477,19 @@ export declare const THEMES: {
465
477
  font?: {
466
478
  fill?: string | undefined;
467
479
  fontSize?: number | undefined;
468
- fontWeight?: "normal" | "bold" | undefined;
469
- fontStyle?: "normal" | "italic" | undefined;
470
- textAnchor?: "start" | "middle" | "end" | undefined;
471
- lineAnchor?: "top" | "middle" | "bottom" | undefined;
480
+ fontWeight?: import("../..").FontWeight | undefined;
481
+ fontStyle?: import("../..").FontStyleKeyword | undefined;
482
+ textAnchor?: import("../..").TextAnchor | undefined;
483
+ lineAnchor?: import("../..").LineAnchor | undefined;
484
+ lineHeight?: number | undefined;
485
+ rotate?: number | undefined;
472
486
  stroke?: string | undefined;
473
487
  strokeWidth?: number | undefined;
474
488
  paintOrder?: string | undefined;
475
489
  dx?: number | undefined;
476
490
  dy?: number | undefined;
491
+ class?: string | undefined;
492
+ textClass?: string | undefined;
477
493
  } | undefined;
478
494
  } | undefined;
479
495
  };