@fundar/data-chart-telling 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +121 -17
  2. package/dist/charts/{Chart.svelte → BaseChart.svelte} +2 -0
  3. package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
  4. package/dist/charts/bar/Chart.svelte +5 -5
  5. package/dist/charts/bar/Chart.svelte.d.ts +1 -2
  6. package/dist/charts/heatmap/Chart.svelte +8 -7
  7. package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
  8. package/dist/charts/line/Chart.svelte +5 -5
  9. package/dist/charts/line/Chart.svelte.d.ts +1 -2
  10. package/dist/charts/pyramid/Chart.svelte +7 -6
  11. package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
  12. package/dist/configuration/config.svelte.js +2 -1
  13. package/dist/configuration/themes/index.d.ts +60 -40
  14. package/dist/index.d.ts +27 -13
  15. package/dist/index.js +12 -7
  16. package/dist/layout/facet/FacetLayout.svelte +1 -1
  17. package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
  18. package/dist/layout/geo/GeoLayout.svelte +47 -0
  19. package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
  20. package/dist/layout/geo/resolveProjection.d.ts +10 -0
  21. package/dist/layout/geo/resolveProjection.js +48 -0
  22. package/dist/layout/legend/ContinuousSection.svelte +158 -17
  23. package/dist/layout/legend/DiscreteSection.svelte +56 -4
  24. package/dist/layout/legend/interaction.svelte.d.ts +7 -0
  25. package/dist/layout/legend/interaction.svelte.js +24 -0
  26. package/dist/layout/plot/AxisLayout.svelte +95 -0
  27. package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
  28. package/dist/layout/plot/BasePlotLayout.svelte +302 -0
  29. package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
  30. package/dist/layout/plot/GridLayout.svelte +30 -0
  31. package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
  32. package/dist/layout/plot/RuleLayout.svelte +111 -0
  33. package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
  34. package/dist/layout/plot/margins.d.ts +34 -0
  35. package/dist/layout/plot/margins.js +26 -0
  36. package/dist/layout/timeline/TimelineLayout.svelte +1 -1
  37. package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
  38. package/dist/layout/tooltip/Tooltip.svelte +15 -0
  39. package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
  40. package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
  41. package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
  42. package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
  43. package/dist/layout/tooltip/controller.svelte.js +5 -6
  44. package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
  45. package/dist/layout/tooltip/hover.svelte.js +1 -1
  46. package/dist/layout/tooltip/utils.d.ts +2 -2
  47. package/dist/markers/ContourClipMarker.svelte +77 -0
  48. package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
  49. package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
  50. package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
  51. package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
  52. package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
  53. package/dist/markers/HoverMarker.svelte +136 -0
  54. package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
  55. package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
  56. package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
  57. package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
  58. package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
  59. package/dist/markers/inset/InsetMarker.svelte +170 -0
  60. package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
  61. package/dist/markers/inset/insetLayout.d.ts +25 -0
  62. package/dist/markers/inset/insetLayout.js +39 -0
  63. package/dist/markers/inset/insetProjection.d.ts +8 -0
  64. package/dist/markers/inset/insetProjection.js +39 -0
  65. package/dist/plots/bar/BarSegments.svelte +69 -0
  66. package/dist/plots/bar/BarSegments.svelte.d.ts +40 -0
  67. package/dist/plots/bar/Plot.svelte +140 -74
  68. package/dist/plots/bar/Plot.svelte.d.ts +7 -3
  69. package/dist/plots/bar/ValueLabels.svelte +89 -0
  70. package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
  71. package/dist/plots/bar/hoverPoints.d.ts +15 -0
  72. package/dist/plots/bar/hoverPoints.js +35 -0
  73. package/dist/plots/bar/layout.svelte.d.ts +37 -0
  74. package/dist/plots/bar/layout.svelte.js +132 -0
  75. package/dist/plots/geo/Plot.svelte +577 -0
  76. package/dist/plots/geo/Plot.svelte.d.ts +29 -0
  77. package/dist/plots/geo/TileLayer.svelte +77 -0
  78. package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
  79. package/dist/plots/geo/projections/argentina.d.ts +8 -0
  80. package/dist/plots/geo/projections/argentina.js +35 -0
  81. package/dist/plots/geo/projections/fit.d.ts +8 -0
  82. package/dist/plots/geo/projections/fit.js +14 -0
  83. package/dist/plots/geo/rotate.svelte.d.ts +26 -0
  84. package/dist/plots/geo/rotate.svelte.js +79 -0
  85. package/dist/plots/geo/zoom.svelte.d.ts +32 -0
  86. package/dist/plots/geo/zoom.svelte.js +50 -0
  87. package/dist/plots/heatmap/Plot.svelte +171 -58
  88. package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
  89. package/dist/plots/line/Plot.svelte +67 -30
  90. package/dist/plots/line/Plot.svelte.d.ts +7 -3
  91. package/dist/plots/pyramid/Plot.svelte +88 -35
  92. package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
  93. package/dist/plots/utils/delta.d.ts +1 -1
  94. package/dist/plots/utils/geoAccessors.d.ts +64 -0
  95. package/dist/plots/utils/geoAccessors.js +188 -0
  96. package/dist/plots/utils/geoSegments.d.ts +14 -0
  97. package/dist/plots/utils/geoSegments.js +17 -0
  98. package/dist/plots/utils/legendDisabled.d.ts +15 -0
  99. package/dist/plots/utils/legendDisabled.js +41 -0
  100. package/dist/plots/utils/segments.d.ts +14 -5
  101. package/dist/plots/utils/segments.js +25 -13
  102. package/dist/plots/utils/tiles.d.ts +89 -0
  103. package/dist/plots/utils/tiles.js +159 -0
  104. package/dist/plots/utils/topojson.d.ts +9 -0
  105. package/dist/plots/utils/topojson.js +30 -0
  106. package/dist/types/charts/common.d.ts +2 -1
  107. package/dist/types/charts/legend.d.ts +32 -1
  108. package/dist/types/charts/props.d.ts +9 -6
  109. package/dist/types/configuration/styling.d.ts +13 -5
  110. package/dist/types/layout/legend.d.ts +26 -0
  111. package/dist/types/layout/tooltip.d.ts +14 -21
  112. package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
  113. package/dist/types/markers/geo.d.ts +237 -0
  114. package/dist/types/markers/props.d.ts +11 -0
  115. package/dist/types/markers/props.js +1 -0
  116. package/dist/types/plots/axis.d.ts +55 -0
  117. package/dist/types/plots/axis.js +1 -0
  118. package/dist/types/plots/constants.d.ts +30 -0
  119. package/dist/types/plots/constants.js +1 -0
  120. package/dist/types/plots/data/common.d.ts +40 -0
  121. package/dist/types/plots/data/common.js +1 -0
  122. package/dist/types/plots/data/geo.d.ts +74 -0
  123. package/dist/types/plots/data/geo.js +1 -0
  124. package/dist/types/plots/delta.d.ts +2 -2
  125. package/dist/types/plots/props.d.ts +105 -16
  126. package/dist/types/plots/scales/geo.d.ts +44 -0
  127. package/dist/types/plots/scales/geo.js +1 -0
  128. package/dist/types/plots/segments/common.d.ts +25 -0
  129. package/dist/types/plots/segments/common.js +1 -0
  130. package/dist/types/plots/segments/config.d.ts +51 -0
  131. package/dist/types/plots/segments/config.js +1 -0
  132. package/dist/types/plots/styles/common.d.ts +37 -0
  133. package/dist/types/plots/styles/common.js +1 -0
  134. package/dist/types/plots/styles/geo.d.ts +42 -0
  135. package/dist/types/plots/styles/geo.js +1 -0
  136. package/dist/types/plots/styling.d.ts +45 -0
  137. package/dist/types/plots/styling.js +1 -0
  138. package/dist/utils/grouping.d.ts +2 -1
  139. package/dist/utils/interpolate.d.ts +2 -1
  140. package/package.json +27 -13
  141. package/dist/layout/plot/PlotLayout.svelte +0 -294
  142. package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
  143. package/dist/plots/markers/HoverMarker.svelte +0 -98
  144. package/dist/types/plots/common.d.ts +0 -97
  145. package/dist/types/plots/styles.d.ts +0 -187
  146. /package/dist/types/{plots/common.js → layout/legend.js} +0 -0
  147. /package/dist/types/{plots/markers.js → markers/common.js} +0 -0
  148. /package/dist/types/{plots/styles.js → markers/geo.js} +0 -0
@@ -0,0 +1,30 @@
1
+ export function isTopology(data) {
2
+ return !!data && typeof data === 'object' && data.type === 'Topology';
3
+ }
4
+ /**
5
+ * Converts a TopoJSON `Topology` to GeoJSON via `topojson-client`'s
6
+ * `feature()`, loaded with a dynamic import so the package works perfectly
7
+ * for consumers who never install `topojson-client` — it's an optional peer
8
+ * dependency (see package.json), never statically imported.
9
+ */
10
+ export async function topologyToGeoJson(topology, object) {
11
+ const obj = topology.objects[object];
12
+ if (!obj) {
13
+ throw new Error(`GeoPlot: topology.objects has no key "${object}".`);
14
+ }
15
+ let mod;
16
+ try {
17
+ // @ts-expect-error — topojson-client is an optional peer dependency; its
18
+ // type declarations are intentionally not resolved by our own build
19
+ // (`Topology` above is typed structurally instead), so this import is
20
+ // resolved purely at runtime.
21
+ mod = await import('topojson-client');
22
+ }
23
+ catch {
24
+ throw new Error("GeoPlot: `data` is a TopoJSON Topology, but 'topojson-client' isn't installed. " +
25
+ 'Run `npm install topojson-client` (it\'s an optional peer dependency) or pass GeoJSON directly.');
26
+ }
27
+ const { feature } = mod;
28
+ const collection = feature(topology, obj);
29
+ return (collection.type === 'FeatureCollection' ? collection.features : [collection]);
30
+ }
@@ -1,5 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { Accessor, AxisValue } from '../plots/common';
2
+ import type { AxisValue } from '../plots/axis';
3
+ import type { Accessor } from '../plots/data/common';
3
4
  import type { EasingName, EasingFn } from './interpolate';
4
5
  export type TimeValue = number;
5
6
  export type Orientation = 'horizontal' | 'vertical';
@@ -1,5 +1,20 @@
1
- import type { SymbolType, LineStyle } from '../plots/styles';
1
+ import type { SymbolType, LineStyle } from '../plots/constants';
2
+ import type { StrokeStyle, DotStyle } from '../plots/styling';
2
3
  export type LegendSectionType = 'discrete' | 'continuous';
4
+ /**
5
+ * Style applied to whatever a legend interaction has turned "off" — a
6
+ * toggled-off discrete series, or a datapoint/cell/feature outside an active
7
+ * continuous range filter. `opacity` is a blanket convenience: any
8
+ * `*Opacity` field a consumer doesn't set falls back to it, so
9
+ * `{ opacity: 0.1 }` alone is enough to read as "disabled" everywhere.
10
+ */
11
+ export type LegendDisabledStyle = {
12
+ opacity?: number;
13
+ stroke?: StrokeStyle;
14
+ dots?: DotStyle;
15
+ fill?: string;
16
+ fillOpacity?: number;
17
+ };
3
18
  export type LegendItem = {
4
19
  name: string;
5
20
  label?: string;
@@ -7,12 +22,18 @@ export type LegendItem = {
7
22
  symbol?: SymbolType;
8
23
  opacity?: number;
9
24
  lineStyle?: LineStyle;
25
+ /** Initial toggled-off state (uncontrolled — the user can still click it back on). */
26
+ disabled?: boolean;
10
27
  };
11
28
  export type DiscreteLegendSection = {
12
29
  type: 'discrete';
13
30
  title?: string;
14
31
  items: LegendItem[];
15
32
  columns?: number;
33
+ /** Enables click-to-toggle on each item. */
34
+ interactive?: boolean;
35
+ /** Style applied to a toggled-off item's series. Falls back to `cfg.legend.disabledOpacity`. */
36
+ disabledStyle?: LegendDisabledStyle;
16
37
  };
17
38
  export type ContinuousLegendSection = {
18
39
  type: 'continuous';
@@ -25,5 +46,15 @@ export type ContinuousLegendSection = {
25
46
  ticks?: number[];
26
47
  width?: number;
27
48
  format?: (v: number) => string;
49
+ /** Enables drag handles on the bar's edges to narrow the visible range. */
50
+ interactive?: boolean;
51
+ /**
52
+ * How the color ramp responds to a narrowed range: `'rescale'` reprojects
53
+ * it onto the new bounds, `'filter'` keeps the original domain and only
54
+ * excludes out-of-range values. Defaults to `'filter'`.
55
+ */
56
+ mode?: 'rescale' | 'filter';
57
+ /** Style applied to values outside the active range. Falls back to `cfg.legend.disabledOpacity`. */
58
+ disabledStyle?: LegendDisabledStyle;
28
59
  };
29
60
  export type LegendSection = DiscreteLegendSection | ContinuousLegendSection;
@@ -1,7 +1,10 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { Accessor, AxisValue, ScalesConfig, MarginConfig } from '../plots/common';
3
- import type { PlotStyles, Segments } from '../plots/styles';
4
- import type { Marker } from '../plots/markers';
2
+ import type { AxisValue } from '../plots/axis';
3
+ import type { Accessor } from '../plots/data/common';
4
+ import type { AxisBasedScalesConfig } from '../plots/props';
5
+ import type { BasePlotStyles } from '../plots/styles/common';
6
+ import type { SegmentsConfig, MarginConfig } from '../plots/props';
7
+ import type { Marker } from '../markers/common';
5
8
  import type { TooltipProp } from '../layout/tooltip';
6
9
  import type { LegendSection } from './legend';
7
10
  import type { FacetConfig, TimelineConfig } from './common';
@@ -27,10 +30,10 @@ export type ChartProps<TRow extends Record<string, unknown>, TSegmentStyle exten
27
30
  x: Accessor<TRow, AxisValue>;
28
31
  y: Accessor<TRow, AxisValue>;
29
32
  z?: Accessor<TRow, unknown>;
30
- styles?: PlotStyles;
31
- segments?: Segments<TSegmentStyle>;
33
+ styles?: BasePlotStyles;
34
+ segments?: SegmentsConfig<TSegmentStyle>;
32
35
  markers?: Marker[];
33
- scales?: ScalesConfig;
36
+ scales?: AxisBasedScalesConfig<TRow>;
34
37
  margins?: MarginConfig;
35
38
  facet?: FacetConfig<TRow>;
36
39
  timeline?: TimelineConfig<TRow>;
@@ -1,4 +1,4 @@
1
- import type { StrokeStyle, DotStyle, FontStyle } from '../plots/styles';
1
+ import type { StrokeStyle, DotStyle, FontStyle } from '../plots/styling';
2
2
  export type TextStyle = {
3
3
  /** font-family */
4
4
  font: string;
@@ -37,6 +37,8 @@ export type ChartConfig = {
37
37
  gap: string;
38
38
  /** swatch square size */
39
39
  swatchSize: string;
40
+ /** Fallback opacity for a legend-disabled series/value when a section doesn't set its own `disabledStyle`. */
41
+ disabledOpacity: number;
40
42
  };
41
43
  axis: {
42
44
  color: string;
@@ -57,11 +59,17 @@ export type ChartConfig = {
57
59
  radius: string;
58
60
  border: string;
59
61
  };
62
+ /**
63
+ * Per-side plot margin. `'auto'` (the default) lets svelteplot size that
64
+ * side to fit whatever it actually renders there — tick labels, an axis
65
+ * title, rotated ticks — instead of clipping content or leaving unused
66
+ * space. A number pins that side exactly, opting out of auto-sizing.
67
+ */
60
68
  margins: {
61
- top: number;
62
- right: number;
63
- bottom: number;
64
- left: number;
69
+ top: number | 'auto';
70
+ right: number | 'auto';
71
+ bottom: number | 'auto';
72
+ left: number | 'auto';
65
73
  };
66
74
  /** Discrete categorical palette (grouped series). */
67
75
  palette: string[];
@@ -0,0 +1,26 @@
1
+ import type { SvelteMap } from 'svelte/reactivity';
2
+ import type { LegendDisabledStyle } from '../charts/legend';
3
+ /**
4
+ * Shared legend-interaction state for cross-cutting legend → plot wiring.
5
+ *
6
+ * {@link BaseChart} provides one store via context (mirrors {@link HoverStore});
7
+ * `DiscreteSection`/`ContinuousSection` write to it on click/drag, and every
8
+ * plot kind (line/bar/pyramid/heatmap/geo) reads the same instance to know
9
+ * what to dim. A standalone legend/plot with no provider falls back to its
10
+ * own private store via `createLegendInteraction`.
11
+ */
12
+ export type LegendInteractionStore = {
13
+ /** Legend item name → resolved style to apply. Presence in the map means "disabled". */
14
+ disabledSeries: SvelteMap<string, LegendDisabledStyle>;
15
+ /**
16
+ * The active drag state of the (first) interactive continuous section, or
17
+ * `null` when none is interactive or the user hasn't narrowed it yet (full
18
+ * range — nothing hidden).
19
+ */
20
+ continuousRange: {
21
+ min: number;
22
+ max: number;
23
+ mode: 'rescale' | 'filter';
24
+ disabledStyle: LegendDisabledStyle;
25
+ } | null;
26
+ };
@@ -1,9 +1,9 @@
1
1
  import type { Snippet } from 'svelte';
2
- import type { AxisValue } from '../plots/common';
2
+ import type { AxisValue } from '../plots/axis';
3
3
  /**
4
4
  * How the hover highlight finds related points within a facet.
5
- * - `'x'` all points sharing the hovered x (default for line / bar).
6
- * - `'y'` all points sharing the hovered y (default for pyramid).
5
+ * - `'x'` all points sharing the hovered x (default for line / bar).
6
+ * - `'y'` all points sharing the hovered y (default for pyramid).
7
7
  * - `'punctual'` exact XY match — one cell at a time (default for heatmap).
8
8
  */
9
9
  export type HoverStrategy = 'x' | 'y' | 'punctual';
@@ -27,27 +27,10 @@ export type TooltipOptions<TRow extends Record<string, unknown>> = {
27
27
  };
28
28
  /** Either a bare on/off flag or the full option object. */
29
29
  export type TooltipProp<TRow extends Record<string, unknown>> = boolean | TooltipOptions<TRow>;
30
- /**
31
- * Resolved tooltip config handed from a chart kind down to a plot. Presence of
32
- * this object on a plot is what turns hovering on.
33
- */
34
- export type TooltipRuntime<TRow extends Record<string, unknown>> = {
35
- format: (row: TRow) => string;
36
- /** Identifies the originating facet (`''` when not faceted). */
37
- facetId: string;
38
- /** Strategy resolved by the chart; omitted → PlotLayout falls back to its own default. */
39
- strategy?: HoverStrategy;
40
- /** Whether to broadcast to other facets. */
41
- sync: boolean;
42
- series?: string[];
43
- content?: Snippet<[{
44
- rows: TRow[];
45
- }]>;
46
- };
47
30
  /**
48
31
  * Shared hover state for cross-facet tooltip syncing.
49
32
  *
50
- * {@link Chart} provides one store via context; every faceted plot reads the
33
+ * {@link BaseChart} provides one store via context; every faceted plot reads the
51
34
  * same instance, so a hover detected in one facet (which writes `activeX/Y` and
52
35
  * stamps itself as `source`) is visible to the others. A standalone plot with no
53
36
  * provider falls back to its own {@link createHover} store.
@@ -83,6 +66,16 @@ export type HoverDisplayPoint = {
83
66
  series?: string;
84
67
  /** Resolved series color — used by HoverMarker when dotFill/fill is `'currentColor'`. */
85
68
  color?: string;
69
+ /**
70
+ * Pixel nudge applied on top of the scaled `x`/`y` position — for plot kinds
71
+ * where a series' visual position isn't fully captured by its data value
72
+ * (e.g. BarPlot's 'grouped' layout, where every series shares the same `x`
73
+ * category but is drawn at its own pixel slice within that category's band).
74
+ * Matching (`matchByStrategy`) still compares raw `x`/`y`, so this is
75
+ * display-only and never affects which points highlight together.
76
+ */
77
+ dx?: number;
78
+ dy?: number;
86
79
  };
87
80
  /** A candidate point for hover matching/highlighting — also carries its source row. */
88
81
  export type HoverPoint<T> = HoverDisplayPoint & {
@@ -1,17 +1,6 @@
1
- import type { AxisValue } from './common';
2
- import type { DotStyle, FontStyle, StrokeStyle } from './styles';
1
+ import type { AxisValue } from '../plots/axis';
2
+ import type { DotStyle, FontStyle, StrokeStyle } from '../plots/styling';
3
3
  import type { HoverStrategy, HoverDisplayPoint } from '../layout/tooltip';
4
- /**
5
- * Baseline props every marker component receives when mounted by a plot:
6
- * `data` for the points/values it draws, plus `series`/`seriesColor` when
7
- * mounted per-series via a `CustomComponentMarker`. Marker components extend
8
- * this with whatever else they need (e.g. PeakMarker's `mode`, `label`).
9
- */
10
- export interface MarkerProps<TData = Record<string, unknown>> {
11
- data?: TData[];
12
- series?: string;
13
- seriesColor?: string;
14
- }
15
4
  export type RuleXMarker = {
16
5
  type: 'ruleX';
17
6
  x: AxisValue;
@@ -31,16 +20,12 @@ export type RuleYMarker = {
31
20
  export type HoverMarkerConfig = {
32
21
  type: 'hover';
33
22
  series?: string;
34
- /** Whether to render per segment or for the full series. Defaults to `'series'`. */
35
23
  scope?: 'series' | 'segment';
36
- /** Matching strategy — how related points are found. Defaults to the plot kind's own default. */
37
24
  strategy?: HoverStrategy;
38
- /** Broadcast the hover to other facets. Defaults to `false`. */
39
25
  sync?: boolean;
40
26
  ruleX?: boolean;
41
27
  ruleY?: boolean;
42
28
  showLabels?: boolean;
43
- /** Custom label formatter. Receives the matched point; return the string to display. */
44
29
  format?: (point: HoverDisplayPoint) => string;
45
30
  ruleStyle?: StrokeStyle;
46
31
  dotStyle?: DotStyle;
@@ -52,7 +37,6 @@ export type CustomComponentMarker = {
52
37
  component: any;
53
38
  props?: Record<string, unknown>;
54
39
  data?: any[];
55
- /** Whether to render per segment or for the full series. Defaults to `'series'`. */
56
40
  scope?: 'series' | 'segment';
57
41
  };
58
42
  export type Marker = RuleXMarker | RuleYMarker | HoverMarkerConfig | CustomComponentMarker;
@@ -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 @@
1
+ export {};
@@ -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 {};