@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.
- package/README.md +121 -17
- package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
- package/dist/charts/bar/Chart.svelte +5 -5
- package/dist/charts/bar/Chart.svelte.d.ts +1 -2
- package/dist/charts/heatmap/Chart.svelte +8 -7
- package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
- package/dist/charts/line/Chart.svelte +5 -5
- package/dist/charts/line/Chart.svelte.d.ts +1 -2
- package/dist/charts/pyramid/Chart.svelte +7 -6
- package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
- package/dist/configuration/config.svelte.js +1 -1
- package/dist/configuration/themes/index.d.ts +56 -40
- package/dist/index.d.ts +26 -12
- package/dist/index.js +12 -7
- package/dist/layout/facet/FacetLayout.svelte +1 -1
- package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
- package/dist/layout/geo/GeoLayout.svelte +47 -0
- package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
- package/dist/layout/geo/resolveProjection.d.ts +10 -0
- package/dist/layout/geo/resolveProjection.js +48 -0
- package/dist/layout/legend/DiscreteSection.svelte +1 -1
- package/dist/layout/plot/AxisLayout.svelte +95 -0
- package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
- package/dist/layout/plot/BasePlotLayout.svelte +302 -0
- package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
- package/dist/layout/plot/GridLayout.svelte +30 -0
- package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
- package/dist/layout/plot/RuleLayout.svelte +111 -0
- package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
- package/dist/layout/plot/margins.d.ts +34 -0
- package/dist/layout/plot/margins.js +26 -0
- package/dist/layout/timeline/TimelineLayout.svelte +1 -1
- package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
- package/dist/layout/tooltip/Tooltip.svelte +15 -0
- package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
- package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
- package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
- package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
- package/dist/layout/tooltip/controller.svelte.js +5 -6
- package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
- package/dist/layout/tooltip/hover.svelte.js +1 -1
- package/dist/layout/tooltip/utils.d.ts +2 -2
- package/dist/markers/ContourClipMarker.svelte +77 -0
- package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
- package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
- package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
- package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
- package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
- package/dist/markers/HoverMarker.svelte +136 -0
- package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
- package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
- package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
- package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
- package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
- package/dist/markers/inset/InsetMarker.svelte +170 -0
- package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
- package/dist/markers/inset/insetLayout.d.ts +25 -0
- package/dist/markers/inset/insetLayout.js +39 -0
- package/dist/markers/inset/insetProjection.d.ts +8 -0
- package/dist/markers/inset/insetProjection.js +39 -0
- package/dist/plots/bar/BarSegments.svelte +66 -0
- package/dist/plots/bar/BarSegments.svelte.d.ts +36 -0
- package/dist/plots/bar/Plot.svelte +132 -76
- package/dist/plots/bar/Plot.svelte.d.ts +7 -3
- package/dist/plots/bar/ValueLabels.svelte +89 -0
- package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
- package/dist/plots/bar/hoverPoints.d.ts +15 -0
- package/dist/plots/bar/hoverPoints.js +35 -0
- package/dist/plots/bar/layout.svelte.d.ts +37 -0
- package/dist/plots/bar/layout.svelte.js +132 -0
- package/dist/plots/geo/Plot.svelte +548 -0
- package/dist/plots/geo/Plot.svelte.d.ts +29 -0
- package/dist/plots/geo/TileLayer.svelte +77 -0
- package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
- package/dist/plots/geo/projections/argentina.d.ts +8 -0
- package/dist/plots/geo/projections/argentina.js +35 -0
- package/dist/plots/geo/projections/fit.d.ts +8 -0
- package/dist/plots/geo/projections/fit.js +14 -0
- package/dist/plots/geo/rotate.svelte.d.ts +26 -0
- package/dist/plots/geo/rotate.svelte.js +79 -0
- package/dist/plots/geo/zoom.svelte.d.ts +32 -0
- package/dist/plots/geo/zoom.svelte.js +50 -0
- package/dist/plots/heatmap/Plot.svelte +129 -47
- package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
- package/dist/plots/line/Plot.svelte +44 -16
- package/dist/plots/line/Plot.svelte.d.ts +7 -3
- package/dist/plots/pyramid/Plot.svelte +70 -25
- package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
- package/dist/plots/utils/delta.d.ts +1 -1
- package/dist/plots/utils/geoAccessors.d.ts +64 -0
- package/dist/plots/utils/geoAccessors.js +188 -0
- package/dist/plots/utils/geoSegments.d.ts +14 -0
- package/dist/plots/utils/geoSegments.js +17 -0
- package/dist/plots/utils/segments.d.ts +14 -5
- package/dist/plots/utils/segments.js +25 -13
- package/dist/plots/utils/tiles.d.ts +89 -0
- package/dist/plots/utils/tiles.js +159 -0
- package/dist/plots/utils/topojson.d.ts +9 -0
- package/dist/plots/utils/topojson.js +30 -0
- package/dist/types/charts/common.d.ts +2 -1
- package/dist/types/charts/legend.d.ts +1 -1
- package/dist/types/charts/props.d.ts +9 -6
- package/dist/types/configuration/styling.d.ts +11 -5
- package/dist/types/layout/tooltip.d.ts +14 -21
- package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
- package/dist/types/markers/geo.d.ts +237 -0
- package/dist/types/markers/props.d.ts +11 -0
- package/dist/types/plots/axis.d.ts +55 -0
- package/dist/types/plots/axis.js +1 -0
- package/dist/types/plots/constants.d.ts +30 -0
- package/dist/types/plots/constants.js +1 -0
- package/dist/types/plots/data/common.d.ts +40 -0
- package/dist/types/plots/data/common.js +1 -0
- package/dist/types/plots/data/geo.d.ts +74 -0
- package/dist/types/plots/data/geo.js +1 -0
- package/dist/types/plots/delta.d.ts +2 -2
- package/dist/types/plots/props.d.ts +105 -16
- package/dist/types/plots/scales/geo.d.ts +44 -0
- package/dist/types/plots/scales/geo.js +1 -0
- package/dist/types/plots/segments/common.d.ts +25 -0
- package/dist/types/plots/segments/common.js +1 -0
- package/dist/types/plots/segments/config.d.ts +51 -0
- package/dist/types/plots/segments/config.js +1 -0
- package/dist/types/plots/styles/common.d.ts +37 -0
- package/dist/types/plots/styles/common.js +1 -0
- package/dist/types/plots/styles/geo.d.ts +42 -0
- package/dist/types/plots/styles/geo.js +1 -0
- package/dist/types/plots/styling.d.ts +45 -0
- package/dist/types/plots/styling.js +1 -0
- package/dist/utils/grouping.d.ts +2 -1
- package/dist/utils/interpolate.d.ts +2 -1
- package/package.json +27 -13
- package/dist/layout/plot/PlotLayout.svelte +0 -237
- package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
- package/dist/plots/markers/HoverMarker.svelte +0 -98
- package/dist/types/plots/common.d.ts +0 -100
- package/dist/types/plots/styles.d.ts +0 -187
- /package/dist/charts/{Chart.svelte → BaseChart.svelte} +0 -0
- /package/dist/types/{plots → markers}/common.js +0 -0
- /package/dist/types/{plots/markers.js → markers/geo.js} +0 -0
- /package/dist/types/{plots/styles.js → markers/props.js} +0 -0
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Accessor } from '../plots/data/common';
|
|
3
|
+
import type { ColorsStyle } from '../plots/styles/common';
|
|
4
|
+
import type { DotStyle, FontStyle, StrokeStyle } from '../plots/styling';
|
|
5
|
+
import type { HoverDisplayPoint } from '../layout/tooltip';
|
|
6
|
+
import type { GeoFeature, GeoJsonInput } from '../plots/data/geo';
|
|
7
|
+
import type { GeoSegmentStyle } from '../plots/segments/common';
|
|
8
|
+
import type { GeoProjectionName } from '../plots/scales/geo';
|
|
9
|
+
/** Longitude/latitude gridlines — svelteplot's `Graticule`. */
|
|
10
|
+
export type GeoGraticuleMarker = {
|
|
11
|
+
type: 'graticule';
|
|
12
|
+
step?: number;
|
|
13
|
+
stepX?: number;
|
|
14
|
+
stepY?: number;
|
|
15
|
+
style?: StrokeStyle;
|
|
16
|
+
/**
|
|
17
|
+
* Renders behind the base map's own fill/stroke instead of on top of it
|
|
18
|
+
* (markers otherwise always draw over the base map, regardless of their
|
|
19
|
+
* position in the `markers` array). Useful for a graticule meant to read
|
|
20
|
+
* as a faint background reference frame rather than an overlay obscuring
|
|
21
|
+
* the geometry above it.
|
|
22
|
+
*/
|
|
23
|
+
behind?: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** The outer globe outline (for orthographic-type projections) — svelteplot's `Sphere`. */
|
|
26
|
+
export type GeoSphereMarker = {
|
|
27
|
+
type: 'sphere';
|
|
28
|
+
style?: StrokeStyle & {
|
|
29
|
+
fill?: string;
|
|
30
|
+
fillOpacity?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Renders behind the base map's own fill/stroke instead of on top of it —
|
|
34
|
+
* needed any time `style.fill` is set, since a filled sphere otherwise
|
|
35
|
+
* covers every feature drawn under it (the sphere is the full globe
|
|
36
|
+
* outline, larger than any geometry on it). Off by default so an
|
|
37
|
+
* unfilled/stroke-only sphere (the common case, tracing just the globe's
|
|
38
|
+
* edge) keeps drawing on top where it stays visible over ocean fills.
|
|
39
|
+
*/
|
|
40
|
+
behind?: boolean;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Point markers by longitude/latitude, sized/colored by value —
|
|
44
|
+
* svelteplot's `Dot`. https://svelteplot.dev/examples/dot/weather
|
|
45
|
+
*/
|
|
46
|
+
export type GeoDotMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
|
|
47
|
+
type: 'dot';
|
|
48
|
+
data: TRow[];
|
|
49
|
+
x: Accessor<TRow, number>;
|
|
50
|
+
y: Accessor<TRow, number>;
|
|
51
|
+
r?: Accessor<TRow, number> | number;
|
|
52
|
+
/** Continuous value used to color each dot through a ramp — see `style.colors`. */
|
|
53
|
+
value?: Accessor<TRow, number>;
|
|
54
|
+
style?: DotStyle & {
|
|
55
|
+
colors?: ColorsStyle;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Arrows/spikes at points — svelteplot's `Vector`.
|
|
60
|
+
* https://svelteplot.dev/examples/vector/shift-map
|
|
61
|
+
*/
|
|
62
|
+
export type GeoVectorMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
|
|
63
|
+
type: 'vector';
|
|
64
|
+
data: TRow[];
|
|
65
|
+
x: Accessor<TRow, number>;
|
|
66
|
+
y: Accessor<TRow, number>;
|
|
67
|
+
length?: Accessor<TRow, number> | number;
|
|
68
|
+
rotate?: Accessor<TRow, number> | number;
|
|
69
|
+
shape?: 'arrow' | 'spike' | 'arrow-filled';
|
|
70
|
+
anchor?: 'start' | 'middle' | 'end';
|
|
71
|
+
style?: {
|
|
72
|
+
fill?: string;
|
|
73
|
+
stroke?: string;
|
|
74
|
+
strokeWidth?: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Geodesic-aware lines between point pairs — svelteplot's `Link` (its
|
|
79
|
+
* `curve: 'auto'` traces a great-circle arc on a geographic projection).
|
|
80
|
+
* https://svelteplot.dev/examples/link/spherical-link
|
|
81
|
+
*/
|
|
82
|
+
export type GeoLinkMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
|
|
83
|
+
type: 'link';
|
|
84
|
+
data: TRow[];
|
|
85
|
+
x1: Accessor<TRow, number>;
|
|
86
|
+
y1: Accessor<TRow, number>;
|
|
87
|
+
x2: Accessor<TRow, number>;
|
|
88
|
+
y2: Accessor<TRow, number>;
|
|
89
|
+
curve?: 'auto' | 'linear';
|
|
90
|
+
style?: StrokeStyle;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Marching-squares contours from a scalar field — svelteplot's `Contour`.
|
|
94
|
+
* https://svelteplot.dev/examples/contour/weather
|
|
95
|
+
*
|
|
96
|
+
* Two input modes: pass `data` (+ `x`/`y`/`value` row accessors) to
|
|
97
|
+
* spatially interpolate a scatter of samples, or omit `data` and pass
|
|
98
|
+
* `value` as an `(x, y) => number` sampling function.
|
|
99
|
+
*/
|
|
100
|
+
export type GeoContourMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
|
|
101
|
+
type: 'contour';
|
|
102
|
+
data?: TRow[];
|
|
103
|
+
x?: Accessor<TRow, number>;
|
|
104
|
+
y?: Accessor<TRow, number>;
|
|
105
|
+
value?: Accessor<TRow, number> | ((x: number, y: number) => number);
|
|
106
|
+
thresholds?: number | number[];
|
|
107
|
+
fill?: 'value' | string;
|
|
108
|
+
stroke?: 'value' | string;
|
|
109
|
+
blur?: number;
|
|
110
|
+
interpolate?: 'none' | 'nearest' | 'barycentric' | 'random-walk';
|
|
111
|
+
style?: {
|
|
112
|
+
strokeWidth?: number;
|
|
113
|
+
fillOpacity?: number;
|
|
114
|
+
strokeOpacity?: number;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Masks the contour to just the base map's landmass (`'land'`) or just
|
|
118
|
+
* its water (`'ocean'`) — e.g. a temperature contour that should only
|
|
119
|
+
* shade land, leaving the ocean bare (or the reverse).
|
|
120
|
+
*/
|
|
121
|
+
clip?: 'land' | 'ocean';
|
|
122
|
+
/**
|
|
123
|
+
* Renders behind the base map's own fill/stroke instead of on top of it —
|
|
124
|
+
* lets a filled contour read as background shading with the base map's
|
|
125
|
+
* feature borders drawn crisply over it, rather than the contour
|
|
126
|
+
* obscuring them.
|
|
127
|
+
*/
|
|
128
|
+
behind?: boolean;
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* The in-map hover highlight. `strategy` chooses which candidate point set
|
|
132
|
+
* drives matching: `'nearest-feature'` (base-map feature centroids —
|
|
133
|
+
* choropleth-style hover) or `'nearest-point'` (a `dot` marker's own rows).
|
|
134
|
+
*/
|
|
135
|
+
export type GeoHoverMarkerConfig = {
|
|
136
|
+
type: 'hover';
|
|
137
|
+
strategy?: 'nearest-feature' | 'nearest-point';
|
|
138
|
+
showLabels?: boolean;
|
|
139
|
+
format?: (point: HoverDisplayPoint) => string;
|
|
140
|
+
dotStyle?: DotStyle;
|
|
141
|
+
fontStyle?: FontStyle;
|
|
142
|
+
};
|
|
143
|
+
/** Mounts an arbitrary Svelte component as a mark — the geo analog of `CustomComponentMarker` (no `series` concept here). */
|
|
144
|
+
export type GeoCustomComponentMarker = {
|
|
145
|
+
type: 'component';
|
|
146
|
+
component: any;
|
|
147
|
+
props?: Record<string, unknown>;
|
|
148
|
+
data?: any[];
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Which edge of the plot frame an inset is anchored to, and where along that
|
|
152
|
+
* edge — a `side-anchor` pair joined by `-`, in either word order (so
|
|
153
|
+
* `'bottom-right'` and `'right-bottom'` are the same corner). `side` is
|
|
154
|
+
* `top`/`bottom`/`left`/`right`; `anchor` is the same four plus `middle`
|
|
155
|
+
* (e.g. `'right-middle'` centers the inset vertically along the right edge).
|
|
156
|
+
*/
|
|
157
|
+
export type GeoInsetLocation = 'top-left' | 'left-top' | 'top-middle' | 'middle-top' | 'top-right' | 'right-top' | 'middle-left' | 'left-middle' | 'middle-middle' | 'middle-right' | 'right-middle' | 'bottom-left' | 'left-bottom' | 'bottom-middle' | 'middle-bottom' | 'bottom-right' | 'right-bottom';
|
|
158
|
+
/**
|
|
159
|
+
* Named projections an `inset` marker can use for its own independently-fit
|
|
160
|
+
* mini-map — everything `GeoProjectionName` offers except `'identity'`/
|
|
161
|
+
* `'reflect-y'`, which have no scale/translate of their own to fit (see
|
|
162
|
+
* `GeoProjectionConfig.domain`'s doc comment) and so can't auto-fit the way
|
|
163
|
+
* every inset needs to.
|
|
164
|
+
*/
|
|
165
|
+
export type GeoInsetProjectionName = Exclude<GeoProjectionName, 'identity' | 'reflect-y'>;
|
|
166
|
+
/**
|
|
167
|
+
* Independent hover tooltip scoped to just one `inset` marker's own rendered
|
|
168
|
+
* features. Matched by nearest projected centroid within the inset's own
|
|
169
|
+
* local mini-projection/box — entirely decoupled from the plot's own
|
|
170
|
+
* top-level `tooltip`, which only ever matches the main map's own features
|
|
171
|
+
* (an inset draws in its own coordinate space, at its own scale, so the
|
|
172
|
+
* main map's hover has no way to reach it). No `facetId`/`sync`/`strategy`
|
|
173
|
+
* here, unlike the top-level `TooltipConfig` — an inset never broadcasts
|
|
174
|
+
* its hover to other facets and always matches punctually.
|
|
175
|
+
*/
|
|
176
|
+
export type GeoInsetTooltipConfig = {
|
|
177
|
+
/** Tooltip text for the nearest feature (by centroid) to the cursor, within this inset. */
|
|
178
|
+
format: (feature: GeoFeature<Record<string, unknown>>) => string;
|
|
179
|
+
/** Custom tooltip body; replaces `format` when given. */
|
|
180
|
+
content?: Snippet<[{
|
|
181
|
+
rows: GeoFeature<Record<string, unknown>>[];
|
|
182
|
+
}]>;
|
|
183
|
+
};
|
|
184
|
+
/** Projection config for an `inset` marker — like `GeoProjectionConfig`, minus `inset`/`domain` (insets always auto-fit to their own content) and custom factories (which can't guarantee `fitExtent`). */
|
|
185
|
+
export type GeoInsetProjectionConfig = GeoInsetProjectionName | {
|
|
186
|
+
type?: GeoInsetProjectionName;
|
|
187
|
+
rotate?: [number, number] | [number, number, number];
|
|
188
|
+
center?: [number, number];
|
|
189
|
+
parallels?: [number, number];
|
|
190
|
+
clip?: boolean | null | number | 'frame';
|
|
191
|
+
};
|
|
192
|
+
/**
|
|
193
|
+
* A small, independently-projected map panel anchored to a corner/edge of
|
|
194
|
+
* the plot — for showing a region at a different, more legible scale than
|
|
195
|
+
* the main map (a disjoint territory, a dense metro area, etc.), the way
|
|
196
|
+
* national mapping agencies commonly draw insets for exactly this reason.
|
|
197
|
+
*
|
|
198
|
+
* What it shows is either a filtered subset of the plot's own `data` (via
|
|
199
|
+
* `features`, matched the same way `segments` keys are) or a wholly
|
|
200
|
+
* separate dataset (`data`, which takes precedence over `features` when
|
|
201
|
+
* both are given) — the inset's own mini-projection is fit to whichever one
|
|
202
|
+
* applies, independently of the main map's projection/zoom.
|
|
203
|
+
*/
|
|
204
|
+
export type GeoInsetMarker<TProps extends Record<string, unknown> = Record<string, unknown>> = {
|
|
205
|
+
type: 'inset';
|
|
206
|
+
location: GeoInsetLocation;
|
|
207
|
+
/** Feature ids (matching the plot's own `featureId`) to filter from the plot's own `data`. Ignored when `data` is set. */
|
|
208
|
+
features?: string[];
|
|
209
|
+
/**
|
|
210
|
+
* Narrows each `features`-matched feature down to just the geometry parts
|
|
211
|
+
* that pass this predicate (each polygon of a `MultiPolygon`, each line of
|
|
212
|
+
* a `MultiLineString`) — same `(part, feature)` signature as
|
|
213
|
+
* `GeoDataProps.excludeParts`, so the same predicate can be passed to both
|
|
214
|
+
* to split one feature's geometry between the main map and this inset
|
|
215
|
+
* without preprocessing the source data. Omitted → every part of each
|
|
216
|
+
* matched feature renders, as before. Ignored when `data` is set.
|
|
217
|
+
*/
|
|
218
|
+
featurePartsFilter?: (part: {
|
|
219
|
+
centroid: [number, number];
|
|
220
|
+
geometry: GeoJSON.Geometry;
|
|
221
|
+
}, feature: GeoFeature<TProps> & {
|
|
222
|
+
__id: string;
|
|
223
|
+
}) => boolean;
|
|
224
|
+
/** A separate GeoJSON dataset rendered inside the inset instead of a filtered subset of the plot's own `data`. TopoJSON isn't supported here. */
|
|
225
|
+
data?: GeoJsonInput<TProps>;
|
|
226
|
+
/** Projection for just this inset, independently fit to whatever it ends up showing. Defaults to `'mercator'`. */
|
|
227
|
+
projection?: GeoInsetProjectionConfig;
|
|
228
|
+
/** Inset box size as a fraction of the plot's own width/height. Defaults to `0.26`/`0.22`. */
|
|
229
|
+
width?: number;
|
|
230
|
+
height?: number;
|
|
231
|
+
/** Gap between the inset box and the plot's own edge, in pixels. Defaults to `8`. */
|
|
232
|
+
margin?: number;
|
|
233
|
+
style?: GeoSegmentStyle;
|
|
234
|
+
/** Independent hover tooltip for just this inset's own rendered features — see `GeoInsetTooltipConfig`. */
|
|
235
|
+
tooltip?: GeoInsetTooltipConfig;
|
|
236
|
+
};
|
|
237
|
+
export type GeoMarker = GeoGraticuleMarker | GeoSphereMarker | GeoDotMarker | GeoVectorMarker | GeoLinkMarker | GeoContourMarker | GeoHoverMarkerConfig | GeoCustomComponentMarker | GeoInsetMarker;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baseline props every marker component receives when mounted by a plot:
|
|
3
|
+
* `data` for the points/values it draws, plus `series`/`seriesColor` when
|
|
4
|
+
* mounted per-series via a `CustomComponentMarker`. Marker components extend
|
|
5
|
+
* this with whatever else they need (e.g. PeakMarker's `mode`, `label`).
|
|
6
|
+
*/
|
|
7
|
+
export interface MarkerProps<TData = Record<string, unknown>> {
|
|
8
|
+
data?: TData[];
|
|
9
|
+
series?: string;
|
|
10
|
+
seriesColor?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type AxisValue = number | string | Date;
|
|
2
|
+
/**
|
|
3
|
+
* Author-facing scale overrides for a plot axis. Mirrors svelteplot's
|
|
4
|
+
* `ScaleOptions` + `XScaleOptions` in full — `type`, `padding`, `domain`,
|
|
5
|
+
* `nice`, `reverse`, `label`, `tickFormat`, `labelAnchor`, etc.
|
|
6
|
+
*
|
|
7
|
+
* Used for both `x` and `y` entries in `ScalesConfig`. X-specific
|
|
8
|
+
* fields (`labelAnchor`, `tickRotate`) are accepted on `y` too; svelteplot
|
|
9
|
+
* silently ignores any inapplicable options.
|
|
10
|
+
*
|
|
11
|
+
* `TData` is the plot's own row type — it's what {@link AxisScale.sort}
|
|
12
|
+
* receives, so ordering isn't limited to comparing this axis's own value.
|
|
13
|
+
*/
|
|
14
|
+
export type AxisScale<TData = Record<string, unknown>> = {
|
|
15
|
+
type?: 'auto' | 'linear' | 'pow' | 'sqrt' | 'log' | 'symlog' | 'time' | 'utc' | 'point' | 'ordinal' | 'sequential' | 'band' | 'categorical' | 'cyclical' | 'threshold' | 'quantile-cont' | 'quantile' | 'quantize' | 'diverging' | 'diverging-log' | 'diverging-pow' | 'diverging-sqrt' | 'diverging-symlog';
|
|
16
|
+
domain?: (number | string | boolean | Date | null)[];
|
|
17
|
+
range?: (number | string | boolean | Date | null)[];
|
|
18
|
+
reverse?: boolean;
|
|
19
|
+
label?: string | false;
|
|
20
|
+
labelAnchor?: 'auto' | 'left' | 'center' | 'right' | 'bottom' | 'middle' | 'top';
|
|
21
|
+
labelOrientation?: 'horizontal' | 'vertical';
|
|
22
|
+
labelPosition?: 'top' | 'middle';
|
|
23
|
+
titleFontSize?: number;
|
|
24
|
+
interval?: string | number;
|
|
25
|
+
clamp?: boolean;
|
|
26
|
+
nice?: boolean;
|
|
27
|
+
zero?: boolean;
|
|
28
|
+
round?: boolean;
|
|
29
|
+
percent?: boolean;
|
|
30
|
+
align?: number;
|
|
31
|
+
base?: number;
|
|
32
|
+
constant?: number;
|
|
33
|
+
sort?: (a: TData, b: TData) => number;
|
|
34
|
+
grid?: boolean | {
|
|
35
|
+
stroke?: string;
|
|
36
|
+
strokeWidth?: number;
|
|
37
|
+
strokeOpacity?: number;
|
|
38
|
+
strokeDasharray?: string;
|
|
39
|
+
};
|
|
40
|
+
padding?: number;
|
|
41
|
+
paddingInner?: number;
|
|
42
|
+
paddingOuter?: number;
|
|
43
|
+
insetLeft?: number;
|
|
44
|
+
insetRight?: number;
|
|
45
|
+
insetTop?: number;
|
|
46
|
+
insetBottom?: number;
|
|
47
|
+
ticks?: (number | string | boolean | Date | null)[];
|
|
48
|
+
tickSpacing?: number;
|
|
49
|
+
tickSize?: number;
|
|
50
|
+
tickPadding?: number;
|
|
51
|
+
tickRotate?: number;
|
|
52
|
+
tickFormat?: false | Intl.NumberFormatOptions | Intl.DateTimeFormatOptions | ((d: unknown, index: number, ticks: unknown[]) => string | string[]);
|
|
53
|
+
seriesLayout?: 'overlap' | 'grouped' | 'stacked';
|
|
54
|
+
seriesPadding?: number;
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified positional anchor for value labels across all plot kinds.
|
|
3
|
+
*
|
|
4
|
+
* - `'outside'` — beyond the tip of the mark (above a vertical bar, to the
|
|
5
|
+
* far end of a horizontal bar or line). This is the only value with no
|
|
6
|
+
* direct svelteplot equivalent; the plot computes dx/dy internally.
|
|
7
|
+
* - `'start'` — at the tip of the mark, just inside (top of a bar, far end
|
|
8
|
+
* of a pyramid bar from zero, right of a line's last point).
|
|
9
|
+
* - `'middle'` — centred on the mark.
|
|
10
|
+
* - `'end'` — at the baseline/zero end of the mark.
|
|
11
|
+
*/
|
|
12
|
+
export type ValueAnchor = 'outside' | 'start' | 'middle' | 'end';
|
|
13
|
+
export type SymbolType = 'circle' | 'square' | 'triangle' | 'line';
|
|
14
|
+
export type LineStyle = 'solid' | 'dashed' | 'dotted' | 'dashdot';
|
|
15
|
+
export type LineCap = 'butt' | 'round' | 'square';
|
|
16
|
+
export type LineJoin = 'arcs' | 'bevel' | 'miter' | 'miter-clip' | 'round';
|
|
17
|
+
/** `font-weight` keyword accepted by any text styling. */
|
|
18
|
+
export type FontWeight = 'normal' | 'bold';
|
|
19
|
+
/** `font-style` keyword accepted by any text styling. */
|
|
20
|
+
export type FontStyleKeyword = 'normal' | 'italic';
|
|
21
|
+
/**
|
|
22
|
+
* Horizontal text anchor. `'outside'` is only meaningful where the consuming
|
|
23
|
+
* mark resolves it per-point from a signed x value (currently `HoverMarker`
|
|
24
|
+
* only) — it anchors the label away from zero: `'start'` (extending right)
|
|
25
|
+
* for a positive x, `'end'` (extending left) for negative. Elsewhere it's
|
|
26
|
+
* treated the same as `'start'`.
|
|
27
|
+
*/
|
|
28
|
+
export type TextAnchor = 'start' | 'middle' | 'end' | 'outside';
|
|
29
|
+
/** Vertical text anchor. */
|
|
30
|
+
export type LineAnchor = 'top' | 'middle' | 'bottom';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { AxisValue } from '../axis';
|
|
2
|
+
/**
|
|
3
|
+
* A field key or accessor function. Mirrors the shorthand used across plots
|
|
4
|
+
* so chart-level encodings (`x`, `y`, `z`, facet, timeline) feel consistent
|
|
5
|
+
* with the plot-level series definitions.
|
|
6
|
+
*/
|
|
7
|
+
export type Accessor<TRow extends Record<string, unknown>, V> = keyof TRow | ((d: TRow) => V);
|
|
8
|
+
/**
|
|
9
|
+
* A plot series: a name, x/y accessors and the rows it draws. Shared as-is by
|
|
10
|
+
* every mark (line, bar, …) — none of them need anything beyond this shape;
|
|
11
|
+
* visual styling lives separately in `segments`.
|
|
12
|
+
*/
|
|
13
|
+
export type Series<T extends Record<string, unknown> = Record<string, unknown>> = {
|
|
14
|
+
name: string;
|
|
15
|
+
x: Accessor<T, AxisValue>;
|
|
16
|
+
y: Accessor<T, AxisValue>;
|
|
17
|
+
z?: Accessor<T, unknown>;
|
|
18
|
+
data: T[];
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Pre-built series. Mutually exclusive with {@link DataProps} — takes
|
|
22
|
+
* precedence when both could apply.
|
|
23
|
+
*/
|
|
24
|
+
export type SeriesProps<T extends Record<string, unknown>> = {
|
|
25
|
+
series: Series<T>[];
|
|
26
|
+
data?: never;
|
|
27
|
+
x?: never;
|
|
28
|
+
y?: never;
|
|
29
|
+
z?: never;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Flat rows to group into series, as an alternative to {@link SeriesProps}.
|
|
33
|
+
*/
|
|
34
|
+
export type DataProps<T extends Record<string, unknown>> = {
|
|
35
|
+
series?: never;
|
|
36
|
+
data: T[];
|
|
37
|
+
x: Accessor<T, AxisValue>;
|
|
38
|
+
y: Accessor<T, AxisValue>;
|
|
39
|
+
z?: Accessor<T, unknown>;
|
|
40
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { Accessor } from './common';
|
|
2
|
+
/**
|
|
3
|
+
* One GeoJSON feature, generically typed over its `properties`. Intersected
|
|
4
|
+
* with `Record<string, unknown>` so it satisfies the same generic bound
|
|
5
|
+
* every other row type in this package does (e.g. `TooltipConfig<TRow
|
|
6
|
+
* extends Record<string, unknown>>`) — GeoJSON's own `Feature` type has no
|
|
7
|
+
* index signature on its own.
|
|
8
|
+
*/
|
|
9
|
+
export type GeoFeature<TProps extends Record<string, unknown> = Record<string, unknown>> = GeoJSON.Feature<GeoJSON.Geometry, TProps> & Record<string, unknown>;
|
|
10
|
+
export type GeoJsonInput<TProps extends Record<string, unknown>> = GeoJSON.FeatureCollection<GeoJSON.Geometry, TProps> | GeoFeature<TProps>[];
|
|
11
|
+
/**
|
|
12
|
+
* Minimal structural shape of a TopoJSON `Topology` object. Deliberately not
|
|
13
|
+
* imported from `topojson-client`'s own types, so referencing it never forces
|
|
14
|
+
* module resolution of that (optional peer) package at typecheck time for
|
|
15
|
+
* consumers who haven't installed it — see `$lib/plots/utils/topojson`.
|
|
16
|
+
*/
|
|
17
|
+
export type Topology = {
|
|
18
|
+
type: 'Topology';
|
|
19
|
+
objects: Record<string, unknown>;
|
|
20
|
+
arcs: unknown[][];
|
|
21
|
+
transform?: {
|
|
22
|
+
scale: [number, number];
|
|
23
|
+
translate: [number, number];
|
|
24
|
+
};
|
|
25
|
+
bbox?: number[];
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Data contract for GeoPlot — the geo analog of {@link DataProps}/{@link SeriesProps}
|
|
29
|
+
* (`$lib/types/plots/data/common`). There's no x/y/z axis pair for geographic data:
|
|
30
|
+
* `data` IS the map.
|
|
31
|
+
*/
|
|
32
|
+
export type GeoDataProps<TProps extends Record<string, unknown> = Record<string, unknown>> = {
|
|
33
|
+
/**
|
|
34
|
+
* GeoJSON is always accepted. A TopoJSON `Topology` is also accepted, but
|
|
35
|
+
* only converted at runtime if `topojson-client` is installed (an optional
|
|
36
|
+
* peer dependency) — see `object`.
|
|
37
|
+
*/
|
|
38
|
+
data: GeoJsonInput<TProps> | Topology;
|
|
39
|
+
/**
|
|
40
|
+
* Required when `data` is a `Topology` — the key under `topology.objects`
|
|
41
|
+
* to convert via topojson-client's `feature()`. Ignored for GeoJSON input.
|
|
42
|
+
*/
|
|
43
|
+
object?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves each feature's stable id — used as the `segments` lookup key
|
|
46
|
+
* (e.g. `segments.argentina`) and for hover/click identification. Defaults
|
|
47
|
+
* to `feature.id ?? feature.properties?.id ?? feature.properties?.name`.
|
|
48
|
+
*/
|
|
49
|
+
featureId?: Accessor<GeoFeature<TProps>, string>;
|
|
50
|
+
/**
|
|
51
|
+
* Optional continuous value accessor for choropleth coloring (mirrors
|
|
52
|
+
* heatmap's `z`). A feature with no `value` (or when omitted entirely)
|
|
53
|
+
* falls back to `styles.fill`/`segments`.
|
|
54
|
+
*/
|
|
55
|
+
value?: (feature: GeoFeature<TProps>) => number | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Excludes matching parts of a feature's geometry from the map's own
|
|
58
|
+
* rendering and hover/click matching — e.g. so a separate `inset` marker
|
|
59
|
+
* (via its own `featurePartsFilter`) can take over showing that part
|
|
60
|
+
* elsewhere without it being drawn twice. Runs once per disjoint part of
|
|
61
|
+
* each feature's geometry (each polygon of a `MultiPolygon`, each line of
|
|
62
|
+
* a `MultiLineString`; any other geometry type is a single part). Return
|
|
63
|
+
* `true` to exclude that part — excluding every part of a feature drops
|
|
64
|
+
* it entirely, which also covers omitting a whole feature from the map.
|
|
65
|
+
* `segments` styling is unaffected (still keyed by whole-feature
|
|
66
|
+
* `featureId`, applied to whatever geometry remains).
|
|
67
|
+
*/
|
|
68
|
+
excludeParts?: (part: {
|
|
69
|
+
centroid: [number, number];
|
|
70
|
+
geometry: GeoJSON.Geometry;
|
|
71
|
+
}, feature: GeoFeature<TProps> & {
|
|
72
|
+
__id: string;
|
|
73
|
+
}) => boolean;
|
|
74
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AxisValue } from './
|
|
2
|
-
import type { StrokeStyle, FontStyle, DotStyle } from './
|
|
1
|
+
import type { AxisValue } from './axis';
|
|
2
|
+
import type { StrokeStyle, FontStyle, DotStyle } from './styling';
|
|
3
3
|
export type DeltaTarget = {
|
|
4
4
|
type: 'series';
|
|
5
5
|
series: string;
|
|
@@ -1,23 +1,112 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
1
|
+
import type { TooltipOptions } from '../layout/tooltip';
|
|
2
|
+
import type { Segment } from './segments/config';
|
|
3
|
+
import type { AxisScale } from './axis';
|
|
4
|
+
import type { GeoProjectionConfig } from './scales/geo';
|
|
5
|
+
/** The `styles` prop accepted by every plot kind — its own
|
|
6
|
+
* styles shape ({@link BasePlotStyles}, `GeoStyles`, …). */
|
|
7
|
+
export type StylesConfig<TStyles extends object> = TStyles;
|
|
8
|
+
/** The `markers` prop accepted by every plot kind — a list of that
|
|
9
|
+
* kind's own marker union ({@link Marker}, `GeoMarker`, …). */
|
|
10
|
+
export type MarkersConfig<TMarker> = TMarker[];
|
|
5
11
|
/**
|
|
6
|
-
*
|
|
7
|
-
* …). The `TSegmentStyle` parameter lets each plot narrow `segments` to its
|
|
8
|
-
* own style shape ({@link BarSegmentStyle}, {@link LineSegmentStyle}, etc.)
|
|
9
|
-
* while keeping everything else shared.
|
|
12
|
+
* The `segments` prop accepted by every plot kind.
|
|
10
13
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
14
|
+
* A record mapping series names (or `'default'` for all series) to lists of
|
|
15
|
+
* {@link Segment}s. Segments in a named key apply only to that series;
|
|
16
|
+
* segments under `'default'` apply to every series.
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* segments: {
|
|
20
|
+
* female: [{ style: { stroke: { stroke: 'tomato' } } }], // catch-all for female
|
|
21
|
+
* male: [{ style: { stroke: { stroke: 'steelblue' } } }], // catch-all for male
|
|
22
|
+
* default: [{ areas: [{ x: { from: 2012, to: 2014 } }], style: { dots: { dotSymbol: 'circle' } } }],
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* Within each resolved series list, catch-alls (no `areas`) are evaluated last
|
|
27
|
+
* so that area-specific segments always override them, regardless of position.
|
|
28
|
+
* Area-specific segments also inherit any style key absent from their own style
|
|
29
|
+
* by merging the catch-all as a baseline — the area's own style wins on conflict.
|
|
30
|
+
* This lets you set a series colour once in a catch-all and add per-range dots
|
|
31
|
+
* or dash patterns without repeating the colour on every area segment.
|
|
32
|
+
*/
|
|
33
|
+
export type SegmentsConfig<TStyle> = Record<string, Segment<TStyle>[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Partial margin override — only the sides you specify are overridden; the
|
|
36
|
+
* rest come from the theme (which itself defaults every side to `'auto'`).
|
|
37
|
+
* `'auto'` sizes that side to fit its rendered content (tick labels, axis
|
|
38
|
+
* title, rotated ticks); a number pins it exactly.
|
|
39
|
+
*/
|
|
40
|
+
export type MarginConfig = Partial<{
|
|
41
|
+
top: number | 'auto';
|
|
42
|
+
right: number | 'auto';
|
|
43
|
+
bottom: number | 'auto';
|
|
44
|
+
left: number | 'auto';
|
|
45
|
+
}>;
|
|
46
|
+
/**
|
|
47
|
+
* The `tooltip` prop a plot actually receives — the chart's resolved form of
|
|
48
|
+
* the author-facing {@link TooltipOptions} (which a chart accepts as a bare
|
|
49
|
+
* `boolean` or the full object via `TooltipProp`): `format`/`sync` become
|
|
50
|
+
* required once resolved, and `facetId` identifies the originating facet
|
|
51
|
+
* (`''` when not faceted). Presence of this object on a plot is what turns
|
|
52
|
+
* hovering on.
|
|
53
|
+
*/
|
|
54
|
+
export type TooltipConfig<TRow extends Record<string, unknown>> = Omit<TooltipOptions<TRow>, 'format' | 'sync'> & {
|
|
55
|
+
format: (row: TRow) => string;
|
|
56
|
+
sync: boolean;
|
|
57
|
+
facetId: string;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Per-axis scale overrides, passed as a single `scales` prop to every
|
|
61
|
+
* axis-based plot kind (`GeoPlot` uses {@link GeoScalesConfig} instead — a
|
|
62
|
+
* map has no x/y/z axis pair). `TData` threads through to
|
|
63
|
+
* {@link AxisScale.sort} on each axis.
|
|
64
|
+
*/
|
|
65
|
+
export type AxisBasedScalesConfig<TData = Record<string, unknown>> = {
|
|
66
|
+
x?: AxisScale<TData>;
|
|
67
|
+
y?: AxisScale<TData>;
|
|
68
|
+
z?: AxisScale<TData>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* `scales` prop for GeoPlot — the geo analog of {@link AxisBasedScalesConfig}.
|
|
72
|
+
* A map has no x/y/z axis pair, so this configures the projection and the
|
|
73
|
+
* choropleth colour domain instead.
|
|
74
|
+
*/
|
|
75
|
+
export type GeoScalesConfig = {
|
|
76
|
+
/** Which map projection to draw with. Defaults to `'equal-earth'`. */
|
|
77
|
+
projection?: GeoProjectionConfig;
|
|
78
|
+
/** Continuous choropleth value domain — mirrors heatmap's `scales.z.domain`. */
|
|
79
|
+
color?: {
|
|
80
|
+
domain?: [number, number];
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* The `scales` prop accepted by every plot kind — either flavor of scale
|
|
85
|
+
* config a plot kind can have ({@link AxisBasedScalesConfig} for the
|
|
86
|
+
* axis-based kinds, {@link GeoScalesConfig} for `GeoPlot`). Each concrete
|
|
87
|
+
* `Plot.svelte` narrows `BasePlotProps`'s `TScales` to exactly the one
|
|
88
|
+
* that applies to it, rather than accepting this whole union.
|
|
89
|
+
*/
|
|
90
|
+
export type ScalesConfig<TData = Record<string, unknown>> = AxisBasedScalesConfig<TData> | GeoScalesConfig;
|
|
91
|
+
/**
|
|
92
|
+
* The shared "prop bag" every plot component accepts, parameterized over
|
|
93
|
+
* everything that varies by plot kind: `TDataContract` is the kind's own
|
|
94
|
+
* data shape ({@link SeriesProps}`|`{@link DataProps} for the axis-based
|
|
95
|
+
* kinds, `GeoDataProps` for `GeoPlot`), `TRow` is what `tooltip` resolves
|
|
96
|
+
* against, and `TStyles`/`TSegmentStyle`/`TMarker`/`TScales` are that kind's
|
|
97
|
+
* own segment/style/marker/scale shapes. Each `Plot.svelte` instantiates
|
|
98
|
+
* this directly with its own concrete arguments rather than going through a
|
|
99
|
+
* shared per-kind alias — segments/styles/markers already diverge in shape
|
|
100
|
+
* across kinds today (or will soon), so a shared alias would just be an
|
|
101
|
+
* extra layer to keep in sync.
|
|
13
102
|
*/
|
|
14
|
-
export type
|
|
103
|
+
export type BasePlotProps<TDataContract, TRow extends Record<string, unknown>, TStyles extends object, TSegmentStyle extends object, TMarker, TScales extends ScalesConfig<TRow>> = TDataContract & {
|
|
15
104
|
width: number;
|
|
16
105
|
height: number;
|
|
17
|
-
styles?:
|
|
18
|
-
segments?:
|
|
19
|
-
markers?:
|
|
20
|
-
scales?:
|
|
106
|
+
styles?: StylesConfig<TStyles>;
|
|
107
|
+
segments?: SegmentsConfig<TSegmentStyle>;
|
|
108
|
+
markers?: MarkersConfig<TMarker>;
|
|
109
|
+
scales?: TScales;
|
|
21
110
|
margins?: MarginConfig;
|
|
22
|
-
tooltip?:
|
|
111
|
+
tooltip?: TooltipConfig<TRow>;
|
|
23
112
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The projection names svelteplot's `<Plot projection>` accepts as a string
|
|
3
|
+
* (svelteplot itself doesn't export this as a type — defined here so authors
|
|
4
|
+
* get autocomplete/type-checking over the full supported set).
|
|
5
|
+
*/
|
|
6
|
+
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
|
+
/**
|
|
9
|
+
* What a custom projection factory (e.g. `argentinaBicontinental` under
|
|
10
|
+
* `$lib`'s geo projections) must return — just enough of d3's `GeoProjection`
|
|
11
|
+
* for svelteplot to stream marks through it and invert pointer coordinates
|
|
12
|
+
* back to lon/lat. Deliberately narrower than importing `GeoProjection`
|
|
13
|
+
* itself, since a hand-tuned custom projection may not implement its full
|
|
14
|
+
* surface (e.g. no single `scale`/`translate` describing it).
|
|
15
|
+
*/
|
|
16
|
+
export type GeoCustomProjection = Pick<GeoProjection, 'stream'> & Partial<Pick<GeoProjection, 'invert'>>;
|
|
17
|
+
/**
|
|
18
|
+
* A custom projection factory, usable as `scales.projection.type` alongside
|
|
19
|
+
* (instead of) a `GeoProjectionName`. svelteplot calls this with the plot's
|
|
20
|
+
* inner width/height (already net of margins/insets) and expects a
|
|
21
|
+
* ready-to-use projection back.
|
|
22
|
+
*/
|
|
23
|
+
export type GeoCustomProjectionFactory = (opts: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}) => GeoCustomProjection;
|
|
27
|
+
export type GeoProjectionConfig = GeoProjectionName | {
|
|
28
|
+
type?: GeoProjectionName | GeoCustomProjectionFactory;
|
|
29
|
+
rotate?: [number, number] | [number, number, number];
|
|
30
|
+
center?: [number, number] | [number, number, number];
|
|
31
|
+
parallels?: [number, number] | [number, number, number];
|
|
32
|
+
inset?: number;
|
|
33
|
+
clip?: boolean | null | number | 'frame';
|
|
34
|
+
/**
|
|
35
|
+
* Fits the projection's scale/translate to this GeoJSON object's extent
|
|
36
|
+
* instead of the projection's own default (whole-world-sized) framing,
|
|
37
|
+
* regardless of which named projection is active. Also what makes
|
|
38
|
+
* `'identity'`/`'reflect-y'` (which otherwise have no scale/translate of
|
|
39
|
+
* their own — they pass lon/lat through as-is) size themselves to fill
|
|
40
|
+
* the plot. Pass `'data'` to fit to whatever was already given to the
|
|
41
|
+
* plot's own `data` prop, instead of repeating it here.
|
|
42
|
+
*/
|
|
43
|
+
domain?: GeoJSON.GeoJsonObject | GeoJSON.FeatureCollection | GeoJSON.Feature | 'data';
|
|
44
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|