@fundar/data-chart-telling 0.0.24 → 0.0.26

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 (170) hide show
  1. package/dist/charts/bar/Chart.svelte +2 -0
  2. package/dist/charts/heatmap/Chart.svelte +3 -1
  3. package/dist/charts/heatmap/Chart.svelte.d.ts +1 -2
  4. package/dist/charts/line/Chart.svelte +2 -0
  5. package/dist/charts/pyramid/Chart.svelte +3 -1
  6. package/dist/charts/pyramid/Chart.svelte.d.ts +1 -2
  7. package/dist/charts/scatter/Chart.svelte +95 -0
  8. package/dist/charts/scatter/Chart.svelte.d.ts +28 -0
  9. package/dist/configuration/config.svelte.js +13 -1
  10. package/dist/configuration/themes/index.d.ts +76 -0
  11. package/dist/index.d.ts +20 -14
  12. package/dist/index.js +9 -3
  13. package/dist/layout/coordinates/CoordinatesLayout.svelte +95 -0
  14. package/dist/layout/{plot/RuleLayout.svelte.d.ts → coordinates/CoordinatesLayout.svelte.d.ts} +13 -16
  15. package/dist/layout/coordinates/margins.d.ts +16 -0
  16. package/dist/layout/coordinates/margins.js +11 -0
  17. package/dist/{plots/geo → layout/coordinates}/projections/argentina.d.ts +1 -1
  18. package/dist/layout/{geo → coordinates}/resolveProjection.d.ts +1 -1
  19. package/dist/layout/coordinates/resolveProjection.js +24 -0
  20. package/dist/{plots/geo → layout/coordinates}/zoom.svelte.d.ts +1 -1
  21. package/dist/layout/geometry/GeometryLayout.svelte +231 -0
  22. package/dist/layout/geometry/GeometryLayout.svelte.d.ts +62 -0
  23. package/dist/layout/plot/BasePlotLayout.svelte +142 -155
  24. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +61 -51
  25. package/dist/layout/plot/margins.d.ts +0 -16
  26. package/dist/layout/plot/margins.js +0 -11
  27. package/dist/layout/{plot/AxisLayout.svelte → scales/ScalesLayout.svelte} +23 -16
  28. package/dist/layout/{plot/AxisLayout.svelte.d.ts → scales/ScalesLayout.svelte.d.ts} +4 -5
  29. package/dist/layout/scales/buildScale.d.ts +8 -0
  30. package/dist/layout/scales/buildScale.js +43 -0
  31. package/dist/layout/styles/StylesLayout.svelte +75 -0
  32. package/dist/layout/styles/StylesLayout.svelte.d.ts +15 -0
  33. package/dist/{plots/geo → layout/styles}/TileLayer.svelte +2 -2
  34. package/dist/{plots/geo → layout/styles}/TileLayer.svelte.d.ts +1 -1
  35. package/dist/layout/tooltip/Tooltip.svelte +16 -20
  36. package/dist/layout/tooltip/Tooltip.svelte.d.ts +5 -0
  37. package/dist/layout/tooltip/TooltipLayout.svelte +7 -1
  38. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +4 -0
  39. package/dist/layout/tooltip/controller.svelte.d.ts +4 -5
  40. package/dist/layout/tooltip/controller.svelte.js +28 -16
  41. package/dist/layout/tooltip/resolveTooltipPlacement.d.ts +24 -0
  42. package/dist/layout/tooltip/resolveTooltipPlacement.js +49 -0
  43. package/dist/layout/tooltip/utils.d.ts +27 -19
  44. package/dist/layout/tooltip/utils.js +16 -15
  45. package/dist/markers/BarMarker.svelte +92 -0
  46. package/dist/markers/BarMarker.svelte.d.ts +7 -0
  47. package/dist/markers/CellMarker.svelte +21 -0
  48. package/dist/markers/CellMarker.svelte.d.ts +7 -0
  49. package/dist/markers/ContourMarker.svelte +28 -0
  50. package/dist/markers/ContourMarker.svelte.d.ts +7 -0
  51. package/dist/markers/DeltaMarker.svelte +32 -39
  52. package/dist/markers/DeltaMarker.svelte.d.ts +4 -5
  53. package/dist/markers/DotMarker.svelte +35 -6
  54. package/dist/markers/DotMarker.svelte.d.ts +11 -2
  55. package/dist/markers/GeoFeaturesMarker.svelte +19 -0
  56. package/dist/markers/GeoFeaturesMarker.svelte.d.ts +7 -0
  57. package/dist/markers/GeoHoverMarker.svelte +25 -0
  58. package/dist/markers/GeoHoverMarker.svelte.d.ts +9 -0
  59. package/dist/markers/GraticuleMarker.svelte +18 -0
  60. package/dist/markers/GraticuleMarker.svelte.d.ts +7 -0
  61. package/dist/markers/HoverMarker.svelte +32 -33
  62. package/dist/markers/HoverMarker.svelte.d.ts +15 -9
  63. package/dist/markers/LineMarker.svelte +19 -0
  64. package/dist/markers/LineMarker.svelte.d.ts +7 -0
  65. package/dist/markers/LinkMarker.svelte +42 -0
  66. package/dist/markers/LinkMarker.svelte.d.ts +7 -0
  67. package/dist/markers/RuleMarker.svelte +24 -0
  68. package/dist/markers/RuleMarker.svelte.d.ts +10 -0
  69. package/dist/markers/SphereMarker.svelte +15 -0
  70. package/dist/markers/SphereMarker.svelte.d.ts +7 -0
  71. package/dist/markers/TextMarker.svelte +1 -1
  72. package/dist/markers/TextMarker.svelte.d.ts +1 -1
  73. package/dist/markers/VectorMarker.svelte +20 -0
  74. package/dist/markers/VectorMarker.svelte.d.ts +7 -0
  75. package/dist/markers/inset/InsetMarker.svelte +38 -45
  76. package/dist/markers/inset/InsetMarker.svelte.d.ts +6 -2
  77. package/dist/plots/bar/Plot.svelte +54 -84
  78. package/dist/plots/bar/Plot.svelte.d.ts +4 -5
  79. package/dist/plots/bar/ValueLabels.svelte +1 -1
  80. package/dist/plots/bar/ValueLabels.svelte.d.ts +1 -1
  81. package/dist/plots/bar/buildBarMarkers.d.ts +30 -0
  82. package/dist/plots/bar/buildBarMarkers.js +100 -0
  83. package/dist/plots/bar/layout.svelte.d.ts +1 -2
  84. package/dist/plots/bar/layout.svelte.js +1 -1
  85. package/dist/plots/geo/Plot.svelte +113 -387
  86. package/dist/plots/geo/Plot.svelte.d.ts +5 -4
  87. package/dist/plots/geo/buildGeoMarkers.d.ts +33 -0
  88. package/dist/plots/geo/buildGeoMarkers.js +47 -0
  89. package/dist/plots/heatmap/Plot.svelte +24 -49
  90. package/dist/plots/heatmap/Plot.svelte.d.ts +4 -5
  91. package/dist/plots/heatmap/ValueLabels.svelte +2 -2
  92. package/dist/plots/heatmap/ValueLabels.svelte.d.ts +2 -2
  93. package/dist/plots/heatmap/buildCellMarkers.d.ts +21 -0
  94. package/dist/plots/heatmap/buildCellMarkers.js +25 -0
  95. package/dist/plots/line/Plot.svelte +68 -141
  96. package/dist/plots/line/Plot.svelte.d.ts +4 -4
  97. package/dist/plots/line/ValueLabels.svelte +94 -49
  98. package/dist/plots/line/ValueLabels.svelte.d.ts +6 -1
  99. package/dist/plots/line/buildLineMarkers.d.ts +15 -0
  100. package/dist/plots/line/buildLineMarkers.js +57 -0
  101. package/dist/plots/pyramid/Plot.svelte +41 -117
  102. package/dist/plots/pyramid/Plot.svelte.d.ts +4 -5
  103. package/dist/plots/pyramid/ValueLabels.svelte +1 -1
  104. package/dist/plots/pyramid/ValueLabels.svelte.d.ts +1 -1
  105. package/dist/plots/pyramid/buildPyramidBarMarkers.d.ts +19 -0
  106. package/dist/plots/pyramid/buildPyramidBarMarkers.js +32 -0
  107. package/dist/plots/scatter/Plot.svelte +206 -0
  108. package/dist/plots/{bar/BarSegments.svelte.d.ts → scatter/Plot.svelte.d.ts} +9 -20
  109. package/dist/plots/scatter/ValueLabels.svelte +106 -0
  110. package/dist/{layout/plot/GridLayout.svelte.d.ts → plots/scatter/ValueLabels.svelte.d.ts} +11 -5
  111. package/dist/plots/scatter/buildScatterMarkers.d.ts +11 -0
  112. package/dist/plots/scatter/buildScatterMarkers.js +37 -0
  113. package/dist/plots/scatter/resolveRadiusPaddedDomain.d.ts +10 -0
  114. package/dist/plots/scatter/resolveRadiusPaddedDomain.js +23 -0
  115. package/dist/plots/utils/declutter.d.ts +82 -33
  116. package/dist/plots/utils/declutter.js +182 -40
  117. package/dist/plots/utils/geoAccessors.d.ts +1 -1
  118. package/dist/plots/utils/geoAccessors.js +1 -1
  119. package/dist/plots/utils/segments.d.ts +17 -10
  120. package/dist/plots/utils/segments.js +26 -16
  121. package/dist/types/charts/common.d.ts +1 -1
  122. package/dist/types/charts/props.d.ts +5 -6
  123. package/dist/types/configuration/styling.d.ts +24 -2
  124. package/dist/types/{plots/scales/geo.d.ts → layout/coordinates.d.ts} +33 -1
  125. package/dist/types/layout/geometry.d.ts +17 -0
  126. package/dist/types/{plots/axis.d.ts → layout/scales.d.ts} +11 -0
  127. package/dist/types/layout/styles.d.ts +126 -0
  128. package/dist/types/layout/tooltip.d.ts +20 -1
  129. package/dist/types/markers/all.d.ts +11 -0
  130. package/dist/types/markers/base.d.ts +45 -0
  131. package/dist/types/markers/base.js +1 -0
  132. package/dist/types/markers/common.d.ts +64 -16
  133. package/dist/types/markers/geo.d.ts +75 -100
  134. package/dist/types/markers/line.d.ts +34 -0
  135. package/dist/types/markers/line.js +1 -0
  136. package/dist/types/markers/props.d.ts +1 -1
  137. package/dist/types/plots/data/common.d.ts +1 -1
  138. package/dist/types/plots/data/scatter.d.ts +13 -0
  139. package/dist/types/plots/data/scatter.js +1 -0
  140. package/dist/types/plots/props.d.ts +46 -74
  141. package/dist/types/plots/segments/common.d.ts +6 -12
  142. package/dist/types/plots/segments/config.d.ts +1 -1
  143. package/dist/types/plots/styling.d.ts +10 -0
  144. package/dist/{plots/utils → utils}/delta.d.ts +2 -2
  145. package/dist/{plots/utils → utils}/delta.js +1 -1
  146. package/dist/utils/edgeAwareAnchor.d.ts +37 -0
  147. package/dist/utils/edgeAwareAnchor.js +65 -0
  148. package/dist/utils/grouping.d.ts +1 -1
  149. package/dist/utils/interpolate.d.ts +1 -1
  150. package/package.json +3 -1
  151. package/dist/layout/geo/GeoLayout.svelte +0 -51
  152. package/dist/layout/geo/GeoLayout.svelte.d.ts +0 -24
  153. package/dist/layout/geo/resolveProjection.js +0 -48
  154. package/dist/layout/plot/GridLayout.svelte +0 -30
  155. package/dist/layout/plot/RuleLayout.svelte +0 -111
  156. package/dist/plots/bar/BarSegments.svelte +0 -69
  157. package/dist/types/plots/delta.d.ts +0 -19
  158. package/dist/types/plots/styles/common.d.ts +0 -52
  159. package/dist/types/plots/styles/geo.d.ts +0 -42
  160. /package/dist/{plots/geo → layout/coordinates}/projections/argentina.js +0 -0
  161. /package/dist/{plots/geo → layout/coordinates}/projections/fit.d.ts +0 -0
  162. /package/dist/{plots/geo → layout/coordinates}/projections/fit.js +0 -0
  163. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.d.ts +0 -0
  164. /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.js +0 -0
  165. /package/dist/{plots/geo → layout/coordinates}/zoom.svelte.js +0 -0
  166. /package/dist/types/{plots/axis.js → layout/coordinates.js} +0 -0
  167. /package/dist/types/{plots/delta.js → layout/geometry.js} +0 -0
  168. /package/dist/types/{plots/scales/geo.js → layout/scales.js} +0 -0
  169. /package/dist/types/{plots/styles/common.js → layout/styles.js} +0 -0
  170. /package/dist/types/{plots/styles/geo.js → markers/all.js} +0 -0
@@ -0,0 +1,126 @@
1
+ import type { ValueAnchor } from '../plots/constants';
2
+ import type { FontStyle, StrokeStyle, AreaStyle } from '../plots/styling';
3
+ import type { GeoFeature } from '../plots/data/geo';
4
+ /**
5
+ * Controls if and how value labels are rendered on a plot. The high-level
6
+ * `anchor` sets sensible defaults for placement; `fontStyle` (`dx`, `dy`,
7
+ * `textAnchor`, `lineAnchor`, `lineHeight`, `rotate`, `class`, `textClass`,
8
+ * `fill`, …) overrides those defaults field-by-field when provided — mirrors
9
+ * {@link DeltaConfig}'s `fontStyle`/`strokeStyle` split, so label text and
10
+ * connector-line styling never mix into one flat bag of props.
11
+ */
12
+ export type ValuesStyle = {
13
+ show?: boolean;
14
+ anchor?: ValueAnchor;
15
+ /** Called with the numeric value and the series name. Return a string to render. */
16
+ format?: (value: number, seriesName: string) => string;
17
+ /** Text styling for the label itself. */
18
+ fontStyle?: FontStyle;
19
+ /**
20
+ * Style for the leader line drawn from a label displaced to clear an
21
+ * overlap with another series' label, back to its real data point.
22
+ * Labels only ever move when they'd otherwise collide — this is a no-op
23
+ * style until that happens. Falls back to a neutral grey, thin, solid
24
+ * stroke — deliberately not the series' own colour or stroke width, since
25
+ * matching the data line reads as more data rather than as a leader,
26
+ * right where several lines are already converging. Unset fields keep
27
+ * that fallback.
28
+ */
29
+ strokeStyle?: StrokeStyle;
30
+ };
31
+ /**
32
+ * Color overrides for plots that derive their palette from data.
33
+ * Each plot uses only the fields relevant to its kind; unused fields are
34
+ * silently ignored.
35
+ *
36
+ * - `min` / `max` — sequential colour ramp endpoints (heatmap).
37
+ * - `left` / `right` — diverging bar sides (pyramid).
38
+ */
39
+ export type ColorsStyle = {
40
+ min?: string;
41
+ max?: string;
42
+ left?: string;
43
+ right?: string;
44
+ };
45
+ /**
46
+ * Decorative border around the plot's own content box — svelteplot's
47
+ * `Frame` mark, purely cosmetic (drawn from the box geometry, never from
48
+ * data). `true` enables it with svelteplot's own defaults; an object
49
+ * enables it and overrides its look field-by-field. Insets pull the frame
50
+ * in from the content box's own edges, in pixels.
51
+ */
52
+ export type FrameStyle = AreaStyle & {
53
+ inset?: number;
54
+ insetTop?: number;
55
+ insetRight?: number;
56
+ insetBottom?: number;
57
+ insetLeft?: number;
58
+ };
59
+ /** Author-facing `styles.frame` prop — see {@link FrameStyle}. */
60
+ export type FrameProp = boolean | FrameStyle;
61
+ /**
62
+ * Top-level rendering style overrides shared by the non-geo plot kinds.
63
+ * Passed as the `styles` prop. Each plot reads only the fields it cares
64
+ * about.
65
+ */
66
+ export type BasePlotStylesConfig = {
67
+ values?: ValuesStyle;
68
+ colors?: ColorsStyle;
69
+ /** Decorative border around the plot's content box — see {@link FrameStyle}. Available on every plot kind. */
70
+ frame?: FrameProp;
71
+ };
72
+ export type GeoTileLayerConfig = {
73
+ /** XYZ tile URL template, e.g. `'https://tile.openstreetmap.org/{z}/{x}/{y}.png'`. */
74
+ url: string;
75
+ attribution?: string;
76
+ opacity?: number;
77
+ minZoom?: number;
78
+ maxZoom?: number;
79
+ /** Tile edge length in pixels. Defaults to `256`. */
80
+ tileSize?: number;
81
+ };
82
+ /**
83
+ * `styles` prop for GeoPlot — the geo analog of `BasePlotStylesConfig`.
84
+ * Unlike the other plot kinds, GeoPlot's styling needs (base map, choropleth
85
+ * ramp, tile background, click handling) are unlike anything x/y plots need,
86
+ * so this is its own type rather than a reuse of `BasePlotStylesConfig`.
87
+ */
88
+ export type GeoStylesConfig<TProps extends Record<string, unknown> = Record<string, unknown>> = {
89
+ /** Base map fill, used when a feature isn't styled by `segments` or the choropleth ramp. */
90
+ fill?: string;
91
+ fillOpacity?: number;
92
+ stroke?: string;
93
+ strokeWidth?: number;
94
+ /** Continuous choropleth ramp endpoints — used when `value` is provided on data. Mirrors heatmap's `styles.colors`. */
95
+ colors?: ColorsStyle;
96
+ /** Raster XYZ tile basemap under the vector geometry. Mercator-family projections only. */
97
+ tileLayer?: GeoTileLayerConfig;
98
+ /** Fired when a base-map feature is clicked. */
99
+ onFeatureClick?: (feature: GeoFeature<TProps>, event: Event) => void;
100
+ /** Decorative border around the plot's content box — see {@link FrameStyle}. Available on every plot kind. */
101
+ frame?: FrameProp;
102
+ };
103
+ /**
104
+ * `GeoTileLayerConfig`, plus `features` — never author-facing (the public
105
+ * `styles.tileLayer` shape, {@link GeoTileLayerConfig}, doesn't declare it).
106
+ * `GeoPlot` tacks it onto its own internal copy of `styles` so `StylesLayout`
107
+ * can compute the tile layer's auto-fit bounds without needing raw geometry
108
+ * threaded through as a separate prop.
109
+ */
110
+ type GeoTileLayerConfigWithFeatures = GeoTileLayerConfig & {
111
+ features?: {
112
+ geometry: GeoJSON.Geometry;
113
+ }[];
114
+ };
115
+ /**
116
+ * The minimal slice of a plot kind's own `styles` prop `StylesLayout` reads —
117
+ * every concrete `styles` type ({@link BasePlotStylesConfig},
118
+ * {@link GeoStylesConfig}) structurally satisfies this whether or not it
119
+ * declares `tileLayer` at all (a missing optional field type-checks fine).
120
+ */
121
+ export type StylesLayoutConfig = {
122
+ tileLayer?: GeoTileLayerConfigWithFeatures;
123
+ frame?: FrameProp;
124
+ [key: string]: unknown;
125
+ };
126
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { AxisValue } from '../plots/axis';
2
+ import type { AxisValue } from './scales';
3
3
  /**
4
4
  * How the hover highlight finds related points within a facet.
5
5
  * - `'x'` all points sharing the hovered x (default for line / bar).
@@ -7,6 +7,21 @@ import type { AxisValue } from '../plots/axis';
7
7
  * - `'punctual'` exact XY match — one cell at a time (default for heatmap).
8
8
  */
9
9
  export type HoverStrategy = 'x' | 'y' | 'punctual';
10
+ /**
11
+ * Preferred horizontal placement of the floating tooltip relative to the
12
+ * cursor: `'right'`/`'left'` offset it clear of the cursor (so it never
13
+ * covers the hovered point); `'middle'` centers it on the cursor's x, same
14
+ * as the plot's own vertical `'middle'`. Falls back toward the opposite
15
+ * side (via `'middle'`) when the preferred side would overflow the plot's
16
+ * bounds — see {@link resolveTooltipPlacement}. System default: `'right'`.
17
+ */
18
+ export type TooltipAnchorX = 'left' | 'middle' | 'right';
19
+ /**
20
+ * Preferred vertical placement of the floating tooltip relative to the
21
+ * cursor — same fallback behavior as {@link TooltipAnchorX}, along the other
22
+ * axis. System default: `'bottom'`.
23
+ */
24
+ export type TooltipAnchorY = 'top' | 'middle' | 'bottom';
10
25
  /** Author-facing tooltip option on the chart kinds. `true` = enable with defaults. */
11
26
  export type TooltipOptions<TRow extends Record<string, unknown>> = {
12
27
  /** Matching strategy. Defaults to the chart kind's own default. */
@@ -24,6 +39,10 @@ export type TooltipOptions<TRow extends Record<string, unknown>> = {
24
39
  content?: Snippet<[{
25
40
  rows: TRow[];
26
41
  }]>;
42
+ /** Preferred horizontal anchor — see {@link TooltipAnchorX}. */
43
+ anchorX?: TooltipAnchorX;
44
+ /** Preferred vertical anchor — see {@link TooltipAnchorY}. */
45
+ anchorY?: TooltipAnchorY;
27
46
  };
28
47
  /** Either a bare on/off flag or the full option object. */
29
48
  export type TooltipProp<TRow extends Record<string, unknown>> = boolean | TooltipOptions<TRow>;
@@ -0,0 +1,11 @@
1
+ import type { AxisBasedMarkersConfig } from './common';
2
+ import type { GeoMarkersConfig, GeoFeaturesMarkerConfig } from './geo';
3
+ import type { LineMarkersConfig } from './line';
4
+ /**
5
+ * Every marker kind `GeometryLayout`/`BasePlotLayout` can route to — the
6
+ * union of every plot kind's own `markers` prop type, plus
7
+ * `GeoFeaturesMarkerConfig` (built internally, never author-facing). Not
8
+ * used as any `Plot.svelte`'s own `TMarker` — see each kind's own precise
9
+ * type instead.
10
+ */
11
+ export type MarkerConfig = AxisBasedMarkersConfig | LineMarkersConfig | GeoMarkersConfig | GeoFeaturesMarkerConfig;
@@ -0,0 +1,45 @@
1
+ import type { AxisValue } from '../layout/scales';
2
+ import type { DotStyle, FontStyle } from '../plots/styling';
3
+ import type { ColorsStyle } from '../layout/styles';
4
+ /**
5
+ * A set of point marks (svelteplot's `Dot`) — usable on any plot kind, axis-based or geo.
6
+ *
7
+ * `x`/`y`/`r`/`value` accept a field key or an accessor function, like `Series.x`/`y`.
8
+ * `GeometryLayout` resolves the shorthand before it reaches `DotMarker.svelte`, which only
9
+ * ever sees functions.
10
+ */
11
+ export type DotMarkerConfig = {
12
+ type: 'dot';
13
+ data: Record<string, unknown>[];
14
+ x: string | ((d: any) => AxisValue);
15
+ y: string | ((d: any) => AxisValue);
16
+ /** Per-row radius, or a constant — overrides `style.dotRadius`. */
17
+ r?: number | string | ((d: any) => number);
18
+ /** Per-row fill, overriding `style.dotFill` — ignored when `value` is set. */
19
+ fill?: (d: any) => string;
20
+ /** Continuous value driving a per-dot color ramp through `style.colors`. */
21
+ value?: string | ((d: any) => number);
22
+ style?: DotStyle & {
23
+ colors?: ColorsStyle;
24
+ };
25
+ };
26
+ /**
27
+ * A text label per row (svelteplot's `Text`) — usable on any plot kind, axis-based or geo.
28
+ *
29
+ * `x`/`y` accept the same field-key-or-function shorthand as `DotMarkerConfig`. `text` is a
30
+ * constant or a per-row accessor.
31
+ */
32
+ export type TextMarkerConfig = {
33
+ type: 'text';
34
+ data: Record<string, unknown>[];
35
+ x: string | ((d: any) => AxisValue);
36
+ y: string | ((d: any) => AxisValue);
37
+ text: string | ((d: any) => string);
38
+ style?: FontStyle;
39
+ };
40
+ /**
41
+ * Every marker kind usable on any plot, axis-based or geo. `AxisBasedMarkersConfig`
42
+ * (`types/markers/common.ts`) and `GeoMarkersConfig` (`types/markers/geo.ts`) both extend
43
+ * this, so `MarkerConfig` (`types/markers/all.ts`) can union the two without a shape collision.
44
+ */
45
+ export type BaseMarkersConfig = DotMarkerConfig | TextMarkerConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,21 +1,18 @@
1
- import type { AxisValue } from '../plots/axis';
2
- import type { DotStyle, FontStyle, StrokeStyle } from '../plots/styling';
1
+ import type { AxisValue } from '../layout/scales';
2
+ import type { FontStyle, StrokeStyle, DotStyle, AreaStyle } from '../plots/styling';
3
3
  import type { HoverStrategy, HoverDisplayPoint } from '../layout/tooltip';
4
- export type RuleXMarker = {
5
- type: 'ruleX';
6
- x: AxisValue;
7
- style?: StrokeStyle;
8
- };
9
- export type RuleYMarker = {
10
- type: 'ruleY';
11
- y: AxisValue;
4
+ import type { BaseMarkersConfig } from './base';
5
+ export type { DotMarkerConfig } from './base';
6
+ export type RuleMarkerConfig = {
7
+ type: 'rule';
8
+ axis: 'x' | 'y';
9
+ value: AxisValue;
12
10
  style?: StrokeStyle;
13
11
  };
14
12
  /**
15
- * The in-SVG hover highlight (crosshair + dot + label), opt-in via `markers`
16
- * so it can be combined freely with or used entirely without — the HTML
17
- * tooltip. Omitting `series` mounts it unscoped (all series); scoping it to
18
- * one series follows the same targeting fields as {@link CustomComponentMarker}.
13
+ * In-SVG hover highlight (crosshair + dot + label). Omitting `series`
14
+ * applies it to all series; scoping follows the same fields as
15
+ * {@link CustomComponentMarkerConfig}.
19
16
  */
20
17
  export type HoverMarkerConfig = {
21
18
  type: 'hover';
@@ -31,7 +28,51 @@ export type HoverMarkerConfig = {
31
28
  dotStyle?: DotStyle;
32
29
  fontStyle?: FontStyle;
33
30
  };
34
- export type CustomComponentMarker = {
31
+ /** A single line-segment stroke. Endpoint dots are a separate `'dot'` marker rather than a field here. */
32
+ export type LineMarkerConfig = {
33
+ type: 'line';
34
+ data: Record<string, unknown>[];
35
+ x: (d: any) => AxisValue;
36
+ y: (d: any) => AxisValue;
37
+ style?: StrokeStyle;
38
+ };
39
+ /**
40
+ * A single bar mark. `role: 'segment'` is a visible bar
41
+ * (`x`/`y`/`x1`/`x2`/`y1`/`y2` map to svelteplot's `<BarX>`/`<BarY>` per
42
+ * `isHorizontal`); `role: 'hitArea'` is an invisible per-category hit region
43
+ * for hover, resolved against the live scale at render time.
44
+ */
45
+ export type BarMarkerConfig = {
46
+ type: 'bar';
47
+ role: 'segment' | 'hitArea';
48
+ isHorizontal: boolean;
49
+ data: Record<string, unknown>[];
50
+ x?: (d: any) => AxisValue;
51
+ y?: (d: any) => AxisValue;
52
+ x1?: number | ((d: any) => number);
53
+ x2?: number | ((d: any) => number);
54
+ y1?: number | ((d: any) => number);
55
+ y2?: number | ((d: any) => number);
56
+ insetTop?: number;
57
+ insetBottom?: number;
58
+ insetLeft?: number;
59
+ insetRight?: number;
60
+ style?: AreaStyle;
61
+ category?: AxisValue;
62
+ onpointerenter?: () => void;
63
+ onpointerleave?: () => void;
64
+ };
65
+ /** A single heatmap cell mark. `fill` stays a per-row accessor; the rest of the style is constant per call. */
66
+ export type CellMarkerConfig = {
67
+ type: 'cell';
68
+ data: Record<string, unknown>[];
69
+ x: (d: any) => AxisValue;
70
+ y: (d: any) => AxisValue;
71
+ fill: (d: any) => string;
72
+ style?: AreaStyle;
73
+ inset?: number;
74
+ };
75
+ export type CustomComponentMarkerConfig = {
35
76
  type: 'component';
36
77
  series?: string;
37
78
  component: any;
@@ -39,4 +80,11 @@ export type CustomComponentMarker = {
39
80
  data?: any[];
40
81
  scope?: 'series' | 'segment';
41
82
  };
42
- export type Marker = RuleXMarker | RuleYMarker | HoverMarkerConfig | CustomComponentMarker;
83
+ /**
84
+ * Every marker kind any axis-based plot can render: {@link BaseMarkersConfig}
85
+ * plus every axis-based-only kind. `BarPlot`/`HeatmapPlot`/`PyramidPlot` use
86
+ * this directly as their `markers` prop type; `LinePlot`'s own
87
+ * `LineMarkersConfig` (`types/markers/line.ts`) unions it with the line-only
88
+ * `delta` annotation instead.
89
+ */
90
+ export type AxisBasedMarkersConfig = BaseMarkersConfig | RuleMarkerConfig | HoverMarkerConfig | LineMarkerConfig | BarMarkerConfig | CellMarkerConfig | CustomComponentMarkerConfig;
@@ -1,65 +1,36 @@
1
1
  import type { Snippet } from 'svelte';
2
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';
3
+ import type { AreaStyle, StrokeStyle } from '../plots/styling';
6
4
  import type { GeoFeature, GeoJsonInput } from '../plots/data/geo';
7
5
  import type { GeoSegmentStyle } from '../plots/segments/common';
8
- import type { GeoProjectionName } from '../plots/scales/geo';
6
+ import type { GeoProjectionName } from '../layout/coordinates';
7
+ import type { TooltipAnchorX, TooltipAnchorY } from '../layout/tooltip';
8
+ import type { BaseMarkersConfig } from './base';
9
9
  /** Longitude/latitude gridlines — svelteplot's `Graticule`. */
10
- export type GeoGraticuleMarker = {
10
+ export type GeoGraticuleMarkerConfig = {
11
11
  type: 'graticule';
12
12
  step?: number;
13
13
  stepX?: number;
14
14
  stepY?: number;
15
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
- */
16
+ /** Renders behind the base map's own fill/stroke instead of on top of it (markers otherwise draw over the base map). */
23
17
  behind?: boolean;
24
18
  };
25
19
  /** The outer globe outline (for orthographic-type projections) — svelteplot's `Sphere`. */
26
- export type GeoSphereMarker = {
20
+ export type GeoSphereMarkerConfig = {
27
21
  type: 'sphere';
28
22
  style?: StrokeStyle & {
29
23
  fill?: string;
30
24
  fillOpacity?: number;
31
25
  };
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
- */
26
+ /** Renders behind the base map's own fill/stroke instead of on top of it — needed when `style.fill` is set. */
40
27
  behind?: boolean;
41
28
  };
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
29
  /**
59
30
  * Arrows/spikes at points — svelteplot's `Vector`.
60
31
  * https://svelteplot.dev/examples/vector/shift-map
61
32
  */
62
- export type GeoVectorMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
33
+ export type GeoVectorMarkerConfig<TRow extends Record<string, unknown> = Record<string, unknown>> = {
63
34
  type: 'vector';
64
35
  data: TRow[];
65
36
  x: Accessor<TRow, number>;
@@ -79,7 +50,7 @@ export type GeoVectorMarker<TRow extends Record<string, unknown> = Record<string
79
50
  * `curve: 'auto'` traces a great-circle arc on a geographic projection).
80
51
  * https://svelteplot.dev/examples/link/spherical-link
81
52
  */
82
- export type GeoLinkMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
53
+ export type GeoLinkMarkerConfig<TRow extends Record<string, unknown> = Record<string, unknown>> = {
83
54
  type: 'link';
84
55
  data: TRow[];
85
56
  x1: Accessor<TRow, number>;
@@ -97,7 +68,7 @@ export type GeoLinkMarker<TRow extends Record<string, unknown> = Record<string,
97
68
  * spatially interpolate a scatter of samples, or omit `data` and pass
98
69
  * `value` as an `(x, y) => number` sampling function.
99
70
  */
100
- export type GeoContourMarker<TRow extends Record<string, unknown> = Record<string, unknown>> = {
71
+ export type GeoContourMarkerConfig<TRow extends Record<string, unknown> = Record<string, unknown>> = {
101
72
  type: 'contour';
102
73
  data?: TRow[];
103
74
  x?: Accessor<TRow, number>;
@@ -113,65 +84,48 @@ export type GeoContourMarker<TRow extends Record<string, unknown> = Record<strin
113
84
  fillOpacity?: number;
114
85
  strokeOpacity?: number;
115
86
  };
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
- */
87
+ /** Masks the contour to just the base map's landmass (`'land'`) or water (`'ocean'`). */
121
88
  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
- */
89
+ /** Renders behind the base map's own fill/stroke instead of on top of it. */
128
90
  behind?: boolean;
129
91
  };
130
92
  /**
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).
93
+ * The in-map hover highlight restyles the hovered feature's own shape.
94
+ * Its own `type: 'geo-hover'` tag (rather than the axis-based `'hover'`)
95
+ * keeps it unambiguous: both configs are all-optional, so an author writing
96
+ * `{ type: 'hover' }` for a `GeoPlot` would otherwise be structurally
97
+ * indistinguishable from the axis-based marker.
134
98
  */
135
99
  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;
100
+ type: 'geo-hover';
101
+ style?: AreaStyle;
142
102
  };
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';
103
+ /**
104
+ * Mounts an arbitrary Svelte component as a mark — the geo analog of
105
+ * `CustomComponentMarkerConfig` (no `series` concept here). Its own
106
+ * `type: 'geo-component'` tag (rather than the axis-based `'component'`)
107
+ * keeps the two unambiguous at `GeometryLayout`'s dispatch — same reasoning
108
+ * as `GeoHoverMarkerConfig`'s `'geo-hover'` tag.
109
+ */
110
+ export type GeoCustomComponentMarkerConfig = {
111
+ type: 'geo-component';
146
112
  component: any;
147
113
  props?: Record<string, unknown>;
148
114
  data?: any[];
149
115
  };
150
116
  /**
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).
117
+ * Which edge of the plot frame an inset is anchored to, and where along it
118
+ * — a `side-anchor` pair in either word order (`'bottom-right'` ==
119
+ * `'right-bottom'`). `side` is `top`/`bottom`/`left`/`right`; `anchor` is
120
+ * the same four plus `middle`.
156
121
  */
157
122
  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
- */
123
+ /** Named projections an `inset` marker can use, minus `'identity'`/`'reflect-y'`, which have no scale/translate to auto-fit. */
165
124
  export type GeoInsetProjectionName = Exclude<GeoProjectionName, 'identity' | 'reflect-y'>;
166
125
  /**
167
126
  * 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.
127
+ * features, matched by nearest projected centroid within the inset's own
128
+ * local mini-projection. Decoupled from the plot's own top-level `tooltip`.
175
129
  */
176
130
  export type GeoInsetTooltipConfig = {
177
131
  /** Tooltip text for the nearest feature (by centroid) to the cursor, within this inset. */
@@ -180,6 +134,13 @@ export type GeoInsetTooltipConfig = {
180
134
  content?: Snippet<[{
181
135
  rows: GeoFeature<Record<string, unknown>>[];
182
136
  }]>;
137
+ /**
138
+ * Preferred anchor for this inset's own tooltip. Unset falls back to the
139
+ * plot's own top-level `tooltip.anchorX`/`anchorY` when explicitly set
140
+ * there, then to the system default — see {@link TooltipAnchorX}.
141
+ */
142
+ anchorX?: TooltipAnchorX;
143
+ anchorY?: TooltipAnchorY;
183
144
  };
184
145
  /** 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
146
  export type GeoInsetProjectionConfig = GeoInsetProjectionName | {
@@ -191,29 +152,21 @@ export type GeoInsetProjectionConfig = GeoInsetProjectionName | {
191
152
  };
192
153
  /**
193
154
  * 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.
155
+ * the plot, showing a region at a different scale than the main map. Shows
156
+ * either a filtered subset of the plot's own `data` (via `features`) or a
157
+ * wholly separate dataset (`data`, which takes precedence when both are
158
+ * given).
203
159
  */
204
- export type GeoInsetMarker<TProps extends Record<string, unknown> = Record<string, unknown>> = {
160
+ export type GeoInsetMarkerConfig<TProps extends Record<string, unknown> = Record<string, unknown>> = {
205
161
  type: 'inset';
206
162
  location: GeoInsetLocation;
207
163
  /** Feature ids (matching the plot's own `featureId`) to filter from the plot's own `data`. Ignored when `data` is set. */
208
164
  features?: string[];
209
165
  /**
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.
166
+ * Narrows each `features`-matched feature to just the geometry parts that
167
+ * pass this predicate same signature as `GeoDataProps.excludeParts`, so
168
+ * one feature's geometry can be split between the main map and this inset.
169
+ * Ignored when `data` is set.
217
170
  */
218
171
  featurePartsFilter?: (part: {
219
172
  centroid: [number, number];
@@ -234,4 +187,26 @@ export type GeoInsetMarker<TProps extends Record<string, unknown> = Record<strin
234
187
  /** Independent hover tooltip for just this inset's own rendered features — see `GeoInsetTooltipConfig`. */
235
188
  tooltip?: GeoInsetTooltipConfig;
236
189
  };
237
- export type GeoMarker = GeoGraticuleMarker | GeoSphereMarker | GeoDotMarker | GeoVectorMarker | GeoLinkMarker | GeoContourMarker | GeoHoverMarkerConfig | GeoCustomComponentMarker | GeoInsetMarker;
190
+ /**
191
+ * `GeoPlot`'s own `markers` prop type — unions {@link BaseMarkersConfig} with
192
+ * every geo-only kind. Independent of `AxisBasedMarkersConfig`
193
+ * (`types/markers/common.ts`): geo has no axis to `rule` against, and its
194
+ * `hover`/`component` variants differ in shape from the axis-based kinds'.
195
+ */
196
+ export type GeoMarkersConfig = BaseMarkersConfig | GeoGraticuleMarkerConfig | GeoSphereMarkerConfig | GeoVectorMarkerConfig | GeoLinkMarkerConfig | GeoContourMarkerConfig | GeoHoverMarkerConfig | GeoCustomComponentMarkerConfig | GeoInsetMarkerConfig;
197
+ /**
198
+ * The base choropleth/base-map mark — one per distinct resolved feature
199
+ * style. Never author-facing: `buildGeoMarkers` builds it from `GeoPlot`'s
200
+ * own `styleGroups`.
201
+ */
202
+ export type GeoFeaturesMarkerConfig = {
203
+ type: 'geo';
204
+ data: Record<string, unknown>[];
205
+ fill: (d: any) => string;
206
+ fillOpacity?: number;
207
+ stroke?: string;
208
+ strokeWidth?: number;
209
+ onclick?: (e: Event, d: any) => void;
210
+ onpointerenter?: (e: Event, d: any) => void;
211
+ onpointerleave?: (e: Event) => void;
212
+ };
@@ -0,0 +1,34 @@
1
+ import type { AxisValue } from '../layout/scales';
2
+ import type { StrokeStyle, FontStyle, DotStyle } from '../plots/styling';
3
+ import type { AxisBasedMarkersConfig } from './common';
4
+ /** Which endpoint a delta measures from/to: a named series, or a fixed axis value (defaults to `0`). */
5
+ export type DeltaTarget = {
6
+ type: 'series';
7
+ series: string;
8
+ } | {
9
+ type: 'axis';
10
+ value?: number;
11
+ };
12
+ /** How far apart two points are on a line chart: a given x (or y), or a series' distance from a fixed axis value. */
13
+ export type DeltaConfig = {
14
+ axis: 'x' | 'y';
15
+ at: AxisValue;
16
+ from: DeltaTarget;
17
+ to?: DeltaTarget;
18
+ formatDiff?: (diff: number) => string;
19
+ strokeStyle?: StrokeStyle;
20
+ fontStyle?: FontStyle;
21
+ dotStyle?: DotStyle;
22
+ };
23
+ /**
24
+ * A delta annotation between two points on a line chart, resolved against
25
+ * series data (`utils/delta.ts`). `xDomain`/`yDomain` optionally clamp
26
+ * the varying endpoint to the plot's own axis range.
27
+ */
28
+ export type DeltaMarkerConfig = {
29
+ type: 'delta';
30
+ xDomain?: (number | string | Date)[];
31
+ yDomain?: (number | string | Date)[];
32
+ } & DeltaConfig;
33
+ /** `LinePlot`'s own `markers` prop type — every {@link AxisBasedMarkersConfig} kind plus the line-only `'delta'` annotation. */
34
+ export type LineMarkersConfig = AxisBasedMarkersConfig | DeltaMarkerConfig;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Baseline props every marker component receives when mounted by a plot:
3
3
  * `data` for the points/values it draws, plus `series`/`seriesColor` when
4
- * mounted per-series via a `CustomComponentMarker`. Marker components extend
4
+ * mounted per-series via a `CustomComponentMarkerConfig`. Marker components extend
5
5
  * this with whatever else they need (e.g. PeakMarker's `mode`, `label`).
6
6
  */
7
7
  export interface MarkerProps<TData = Record<string, unknown>> {
@@ -1,4 +1,4 @@
1
- import type { AxisValue } from '../axis';
1
+ import type { AxisValue } from '../../layout/scales';
2
2
  /**
3
3
  * A field key or accessor function. Mirrors the shorthand used across plots
4
4
  * so chart-level encodings (`x`, `y`, `z`, facet, timeline) feel consistent