@fundar/data-chart-telling 0.0.25 → 0.0.27
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/dist/charts/BaseChart.svelte +18 -10
- package/dist/charts/BaseChart.svelte.d.ts +4 -2
- package/dist/charts/bar/Chart.svelte +2 -0
- package/dist/charts/heatmap/Chart.svelte +5 -3
- package/dist/charts/heatmap/Chart.svelte.d.ts +1 -2
- package/dist/charts/line/Chart.svelte +2 -0
- package/dist/charts/pyramid/Chart.svelte +5 -3
- package/dist/charts/pyramid/Chart.svelte.d.ts +1 -2
- package/dist/charts/scatter/Chart.svelte +95 -0
- package/dist/charts/scatter/Chart.svelte.d.ts +28 -0
- package/dist/configuration/config.svelte.js +28 -0
- package/dist/configuration/themes/dark.js +4 -0
- package/dist/configuration/themes/index.d.ts +112 -0
- package/dist/index.d.ts +26 -16
- package/dist/index.js +11 -3
- package/dist/layout/coordinates/CoordinatesLayout.svelte +93 -0
- package/dist/layout/{plot/RuleLayout.svelte.d.ts → coordinates/CoordinatesLayout.svelte.d.ts} +13 -16
- package/dist/layout/coordinates/margins.d.ts +16 -0
- package/dist/layout/coordinates/margins.js +11 -0
- package/dist/{plots/geo → layout/coordinates}/projections/argentina.d.ts +1 -1
- package/dist/layout/{geo → coordinates}/resolveProjection.d.ts +1 -1
- package/dist/layout/coordinates/resolveProjection.js +24 -0
- package/dist/{plots/geo → layout/coordinates}/zoom.svelte.d.ts +1 -1
- package/dist/layout/facet/FacetIndicator.svelte +31 -0
- package/dist/layout/facet/FacetIndicator.svelte.d.ts +8 -0
- package/dist/layout/facet/FacetLayout.svelte +249 -24
- package/dist/layout/facet/FacetLayout.svelte.d.ts +7 -1
- package/dist/layout/geometry/GeometryLayout.svelte +231 -0
- package/dist/layout/geometry/GeometryLayout.svelte.d.ts +62 -0
- package/dist/layout/legend/ContinuousSection.svelte +1 -1
- package/dist/layout/legend/ContinuousSection.svelte.d.ts +1 -1
- package/dist/layout/legend/DiscreteSection.svelte +1 -1
- package/dist/layout/legend/DiscreteSection.svelte.d.ts +1 -1
- package/dist/layout/legend/LegendLayout.svelte +1 -1
- package/dist/layout/legend/LegendLayout.svelte.d.ts +1 -1
- package/dist/layout/legend/interaction.svelte.d.ts +9 -1
- package/dist/layout/legend/interaction.svelte.js +9 -1
- package/dist/layout/plot/BasePlotLayout.svelte +142 -155
- package/dist/layout/plot/BasePlotLayout.svelte.d.ts +61 -51
- package/dist/layout/plot/margins.d.ts +0 -16
- package/dist/layout/plot/margins.js +0 -11
- package/dist/layout/{plot/AxisLayout.svelte → scales/ScalesLayout.svelte} +23 -16
- package/dist/layout/{plot/AxisLayout.svelte.d.ts → scales/ScalesLayout.svelte.d.ts} +4 -5
- package/dist/layout/scales/buildScale.d.ts +8 -0
- package/dist/layout/scales/buildScale.js +43 -0
- package/dist/layout/styles/StylesLayout.svelte +75 -0
- package/dist/layout/styles/StylesLayout.svelte.d.ts +15 -0
- package/dist/{plots/geo → layout/styles}/TileLayer.svelte +2 -2
- package/dist/{plots/geo → layout/styles}/TileLayer.svelte.d.ts +1 -1
- package/dist/layout/timeline/Timeline.svelte +1 -1
- package/dist/layout/timeline/Timeline.svelte.d.ts +1 -1
- package/dist/layout/timeline/TimelineLayout.svelte +1 -1
- package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
- package/dist/layout/tooltip/Tooltip.svelte +16 -20
- package/dist/layout/tooltip/Tooltip.svelte.d.ts +5 -0
- package/dist/layout/tooltip/TooltipLayout.svelte +7 -1
- package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +4 -0
- package/dist/layout/tooltip/controller.svelte.d.ts +4 -5
- package/dist/layout/tooltip/controller.svelte.js +42 -16
- package/dist/layout/tooltip/resolveTooltipPlacement.d.ts +24 -0
- package/dist/layout/tooltip/resolveTooltipPlacement.js +49 -0
- package/dist/layout/tooltip/utils.d.ts +27 -19
- package/dist/layout/tooltip/utils.js +16 -15
- package/dist/markers/BarMarker.svelte +92 -0
- package/dist/markers/BarMarker.svelte.d.ts +7 -0
- package/dist/markers/CellMarker.svelte +21 -0
- package/dist/markers/CellMarker.svelte.d.ts +7 -0
- package/dist/markers/ContourMarker.svelte +28 -0
- package/dist/markers/ContourMarker.svelte.d.ts +7 -0
- package/dist/markers/DeltaMarker.svelte +32 -39
- package/dist/markers/DeltaMarker.svelte.d.ts +4 -5
- package/dist/markers/DotMarker.svelte +35 -6
- package/dist/markers/DotMarker.svelte.d.ts +11 -2
- package/dist/markers/GeoFeaturesMarker.svelte +19 -0
- package/dist/markers/GeoFeaturesMarker.svelte.d.ts +7 -0
- package/dist/markers/GeoHoverMarker.svelte +25 -0
- package/dist/markers/GeoHoverMarker.svelte.d.ts +9 -0
- package/dist/markers/GraticuleMarker.svelte +18 -0
- package/dist/markers/GraticuleMarker.svelte.d.ts +7 -0
- package/dist/markers/HoverMarker.svelte +34 -35
- package/dist/markers/HoverMarker.svelte.d.ts +15 -9
- package/dist/markers/LineMarker.svelte +19 -0
- package/dist/markers/LineMarker.svelte.d.ts +7 -0
- package/dist/markers/LinkMarker.svelte +42 -0
- package/dist/markers/LinkMarker.svelte.d.ts +7 -0
- package/dist/markers/RuleMarker.svelte +24 -0
- package/dist/markers/RuleMarker.svelte.d.ts +10 -0
- package/dist/markers/SphereMarker.svelte +15 -0
- package/dist/markers/SphereMarker.svelte.d.ts +7 -0
- package/dist/markers/TextMarker.svelte +1 -1
- package/dist/markers/TextMarker.svelte.d.ts +1 -1
- package/dist/markers/VectorMarker.svelte +20 -0
- package/dist/markers/VectorMarker.svelte.d.ts +7 -0
- package/dist/markers/inset/InsetMarker.svelte +38 -45
- package/dist/markers/inset/InsetMarker.svelte.d.ts +6 -2
- package/dist/plots/bar/Plot.svelte +96 -87
- package/dist/plots/bar/Plot.svelte.d.ts +4 -5
- package/dist/plots/bar/ValueLabels.svelte +70 -24
- package/dist/plots/bar/ValueLabels.svelte.d.ts +11 -2
- package/dist/plots/bar/buildBarMarkers.d.ts +30 -0
- package/dist/plots/bar/buildBarMarkers.js +100 -0
- package/dist/plots/bar/layout.svelte.d.ts +1 -2
- package/dist/plots/bar/layout.svelte.js +1 -1
- package/dist/plots/geo/Plot.svelte +113 -387
- package/dist/plots/geo/Plot.svelte.d.ts +5 -4
- package/dist/plots/geo/buildGeoMarkers.d.ts +33 -0
- package/dist/plots/geo/buildGeoMarkers.js +47 -0
- package/dist/plots/heatmap/Plot.svelte +27 -52
- package/dist/plots/heatmap/Plot.svelte.d.ts +4 -5
- package/dist/plots/heatmap/ValueLabels.svelte +5 -5
- package/dist/plots/heatmap/ValueLabels.svelte.d.ts +3 -3
- package/dist/plots/heatmap/buildCellMarkers.d.ts +21 -0
- package/dist/plots/heatmap/buildCellMarkers.js +25 -0
- package/dist/plots/line/Plot.svelte +73 -141
- package/dist/plots/line/Plot.svelte.d.ts +4 -4
- package/dist/plots/line/ValueLabels.svelte +84 -85
- package/dist/plots/line/ValueLabels.svelte.d.ts +10 -1
- package/dist/plots/line/buildLineMarkers.d.ts +15 -0
- package/dist/plots/line/buildLineMarkers.js +57 -0
- package/dist/plots/pyramid/Plot.svelte +80 -121
- package/dist/plots/pyramid/Plot.svelte.d.ts +4 -5
- package/dist/plots/pyramid/ValueLabels.svelte +71 -25
- package/dist/plots/pyramid/ValueLabels.svelte.d.ts +11 -2
- package/dist/plots/pyramid/buildPyramidBarMarkers.d.ts +19 -0
- package/dist/plots/pyramid/buildPyramidBarMarkers.js +32 -0
- package/dist/plots/scatter/Plot.svelte +242 -0
- package/dist/{layout/plot/GridLayout.svelte.d.ts → plots/scatter/Plot.svelte.d.ts} +9 -7
- package/dist/plots/scatter/ValueLabels.svelte +149 -0
- package/dist/plots/{bar/BarSegments.svelte.d.ts → scatter/ValueLabels.svelte.d.ts} +17 -15
- package/dist/plots/scatter/buildScatterMarkers.d.ts +11 -0
- package/dist/plots/scatter/buildScatterMarkers.js +37 -0
- package/dist/plots/scatter/resolveRadiusPaddedDomain.d.ts +10 -0
- package/dist/plots/scatter/resolveRadiusPaddedDomain.js +23 -0
- package/dist/plots/utils/declutter.d.ts +55 -37
- package/dist/plots/utils/declutter.js +79 -64
- package/dist/plots/utils/geoAccessors.d.ts +1 -1
- package/dist/plots/utils/geoAccessors.js +1 -1
- package/dist/plots/utils/labelOverflow.svelte.d.ts +51 -0
- package/dist/plots/utils/labelOverflow.svelte.js +116 -0
- package/dist/plots/utils/legendDisabled.d.ts +1 -1
- package/dist/plots/utils/segments.d.ts +17 -10
- package/dist/plots/utils/segments.js +26 -16
- package/dist/types/charts/common.d.ts +3 -50
- package/dist/types/charts/props.d.ts +8 -8
- package/dist/types/configuration/styling.d.ts +26 -2
- package/dist/types/{plots/scales/geo.d.ts → layout/coordinates.d.ts} +33 -1
- package/dist/types/layout/facet.d.ts +41 -0
- package/dist/types/layout/geometry.d.ts +17 -0
- package/dist/types/layout/legend.d.ts +65 -1
- package/dist/types/{plots/axis.d.ts → layout/scales.d.ts} +11 -0
- package/dist/types/layout/styles.d.ts +115 -0
- package/dist/types/layout/timeline.d.ts +32 -0
- package/dist/types/layout/tooltip.d.ts +20 -1
- package/dist/types/markers/all.d.ts +11 -0
- package/dist/types/markers/all.js +1 -0
- package/dist/types/markers/base.d.ts +45 -0
- package/dist/types/markers/base.js +1 -0
- package/dist/types/markers/common.d.ts +64 -16
- package/dist/types/markers/geo.d.ts +75 -100
- package/dist/types/markers/line.d.ts +34 -0
- package/dist/types/markers/line.js +1 -0
- package/dist/types/markers/props.d.ts +1 -1
- package/dist/types/plots/data/common.d.ts +1 -1
- package/dist/types/plots/data/scatter.d.ts +13 -0
- package/dist/types/plots/data/scatter.js +1 -0
- package/dist/types/plots/props.d.ts +46 -74
- package/dist/types/plots/segments/common.d.ts +6 -12
- package/dist/types/plots/segments/config.d.ts +1 -1
- package/dist/types/plots/styling.d.ts +10 -0
- package/dist/{plots/utils → utils}/delta.d.ts +2 -2
- package/dist/{plots/utils → utils}/delta.js +1 -1
- package/dist/utils/edgeAwareAnchor.d.ts +37 -0
- package/dist/utils/edgeAwareAnchor.js +65 -0
- package/dist/utils/grouping.d.ts +1 -1
- package/dist/utils/interpolate.d.ts +2 -2
- package/package.json +3 -1
- package/dist/layout/geo/GeoLayout.svelte +0 -51
- package/dist/layout/geo/GeoLayout.svelte.d.ts +0 -24
- package/dist/layout/geo/resolveProjection.js +0 -48
- package/dist/layout/plot/GridLayout.svelte +0 -30
- package/dist/layout/plot/RuleLayout.svelte +0 -111
- package/dist/plots/bar/BarSegments.svelte +0 -69
- package/dist/types/charts/legend.d.ts +0 -60
- package/dist/types/plots/delta.d.ts +0 -19
- package/dist/types/plots/styles/common.d.ts +0 -52
- package/dist/types/plots/styles/geo.d.ts +0 -42
- /package/dist/{plots/geo → layout/coordinates}/projections/argentina.js +0 -0
- /package/dist/{plots/geo → layout/coordinates}/projections/fit.d.ts +0 -0
- /package/dist/{plots/geo → layout/coordinates}/projections/fit.js +0 -0
- /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.d.ts +0 -0
- /package/dist/{plots/geo → layout/coordinates}/rotate.svelte.js +0 -0
- /package/dist/{plots/geo → layout/coordinates}/zoom.svelte.js +0 -0
- /package/dist/types/{charts/legend.js → layout/coordinates.js} +0 -0
- /package/dist/types/{plots/axis.js → layout/facet.js} +0 -0
- /package/dist/types/{plots/delta.js → layout/geometry.js} +0 -0
- /package/dist/types/{plots/scales/geo.js → layout/scales.js} +0 -0
- /package/dist/types/{plots/styles/common.js → layout/styles.js} +0 -0
- /package/dist/types/{plots/styles/geo.js → layout/timeline.js} +0 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
<script lang="ts" generics="TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData">
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
4
|
+
import BarMarker from '../../markers/BarMarker.svelte';
|
|
5
|
+
import LineMarker from '../../markers/LineMarker.svelte';
|
|
6
|
+
import CellMarker from '../../markers/CellMarker.svelte';
|
|
7
|
+
import DotMarker from '../../markers/DotMarker.svelte';
|
|
8
|
+
import TextMarker from '../../markers/TextMarker.svelte';
|
|
9
|
+
import RuleMarker from '../../markers/RuleMarker.svelte';
|
|
10
|
+
import HoverMarker from '../../markers/HoverMarker.svelte';
|
|
11
|
+
import GeoHoverMarker from '../../markers/GeoHoverMarker.svelte';
|
|
12
|
+
import DeltaMarker from '../../markers/DeltaMarker.svelte';
|
|
13
|
+
import GeoFeaturesMarker from '../../markers/GeoFeaturesMarker.svelte';
|
|
14
|
+
import GraticuleMarker from '../../markers/GraticuleMarker.svelte';
|
|
15
|
+
import SphereMarker from '../../markers/SphereMarker.svelte';
|
|
16
|
+
import VectorMarker from '../../markers/VectorMarker.svelte';
|
|
17
|
+
import LinkMarker from '../../markers/LinkMarker.svelte';
|
|
18
|
+
import ContourMarker from '../../markers/ContourMarker.svelte';
|
|
19
|
+
import ContourClipMarker from '../../markers/ContourClipMarker.svelte';
|
|
20
|
+
import InsetMarker from '../../markers/inset/InsetMarker.svelte';
|
|
21
|
+
import { getConfiguration } from '../../configuration/config.svelte';
|
|
22
|
+
import { resolveAccessor } from '../../plots/utils/accessors';
|
|
23
|
+
import type { Series } from '../../types/plots/data/common';
|
|
24
|
+
import type { HoverMarkerConfig, CustomComponentMarkerConfig } from '../../types/markers/common';
|
|
25
|
+
import type { MarkerConfig } from '../../types/markers/all';
|
|
26
|
+
import type { HoverPoint, TooltipAnchorX, TooltipAnchorY } from '../../types/layout/tooltip';
|
|
27
|
+
import type { ScopedMarkerGroup } from '../../types/layout/geometry';
|
|
28
|
+
import type { GeoFeature } from '../../types/plots/data/geo';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Renders every marker in `markers`, in array order, each delegated to the
|
|
32
|
+
* component that draws it. Owns only routing, plus the few extra props a
|
|
33
|
+
* marker kind needs beyond its own config (hover-controller state for
|
|
34
|
+
* `hover`; per-series data/color for a `series`-scoped `hover`/`component`).
|
|
35
|
+
* `children` (value labels) renders last, on top of everything here.
|
|
36
|
+
*
|
|
37
|
+
* A marker scoped to one `series` renders once per matching entry in
|
|
38
|
+
* `scopedGroups` instead of the plain loop, since it needs that series'
|
|
39
|
+
* own data/color and resolved segments. `width`/`height`/`numericMargins`/
|
|
40
|
+
* `geoAllFeatures` are `GeoPlot`-only context an `inset` marker needs
|
|
41
|
+
* beyond its own config; `data` is `BasePlotLayout`'s own rows, forwarded
|
|
42
|
+
* for `contour`'s clip and unscoped `geo-component`'s fallback data —
|
|
43
|
+
* both reachable only through `GeoMarkersConfig`, so `data` is always
|
|
44
|
+
* `GeoFeature`-shaped there despite the generic `TData` bound.
|
|
45
|
+
*/
|
|
46
|
+
let {
|
|
47
|
+
width,
|
|
48
|
+
height,
|
|
49
|
+
markers = [],
|
|
50
|
+
seriesData = [],
|
|
51
|
+
scopedGroups = [],
|
|
52
|
+
matchedPoints,
|
|
53
|
+
activePoint,
|
|
54
|
+
impliesCrosshairX,
|
|
55
|
+
impliesCrosshairY,
|
|
56
|
+
numericMargins,
|
|
57
|
+
data = [],
|
|
58
|
+
geoAllFeatures = [],
|
|
59
|
+
tooltipAnchorX,
|
|
60
|
+
tooltipAnchorY,
|
|
61
|
+
children,
|
|
62
|
+
}: {
|
|
63
|
+
/** The plot's own outer width/height — `inset` marker only, to size its content box. */
|
|
64
|
+
width?: number;
|
|
65
|
+
height?: number;
|
|
66
|
+
markers?: MarkerConfig[];
|
|
67
|
+
/** All resolved series, forwarded to unscoped `component`/`delta` markers. Independently generic over `TSeries` (defaults to `TData`). */
|
|
68
|
+
seriesData?: Series<TSeries>[];
|
|
69
|
+
/** One entry per series that can own a `series`-scoped marker. Same `TSeries` as `seriesData`. */
|
|
70
|
+
scopedGroups?: ScopedMarkerGroup<TSeries>[];
|
|
71
|
+
matchedPoints: HoverPoint<TData>[];
|
|
72
|
+
/** The specific matched point actually under the cursor. */
|
|
73
|
+
activePoint: HoverPoint<TData> | null;
|
|
74
|
+
impliesCrosshairX: boolean;
|
|
75
|
+
impliesCrosshairY: boolean;
|
|
76
|
+
/** The plot's own resolved margins — `inset` marker only, to place its content box. */
|
|
77
|
+
numericMargins?: { top: number; right: number; bottom: number; left: number };
|
|
78
|
+
/** `BasePlotLayout`'s own rows — `contour` (clip) and unscoped `geo-component` fallback data. */
|
|
79
|
+
data?: TData[];
|
|
80
|
+
/** `GeoPlot`'s own untouched, tagged features — `inset` marker only (shows a part the main map may exclude). */
|
|
81
|
+
geoAllFeatures?: (GeoFeature<Record<string, unknown>> & { __id: string })[];
|
|
82
|
+
/** The plot's own top-level `tooltip.anchorX`/`anchorY` — `inset` marker only, as the fallback its own tooltip inherits when unset. */
|
|
83
|
+
tooltipAnchorX?: TooltipAnchorX;
|
|
84
|
+
tooltipAnchorY?: TooltipAnchorY;
|
|
85
|
+
/** Rendered last, on top of every marker — typically value labels. Optional; a plot kind may have nothing extra to add. */
|
|
86
|
+
children?: Snippet;
|
|
87
|
+
} = $props();
|
|
88
|
+
|
|
89
|
+
const cfg = $derived(getConfiguration());
|
|
90
|
+
|
|
91
|
+
const geometryMarkers = $derived(
|
|
92
|
+
markers.filter(
|
|
93
|
+
(marker) => !((marker.type === 'hover' || marker.type === 'component') && 'series' in marker && marker.series),
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const scopedMarkersByName = $derived.by(() => {
|
|
98
|
+
const map = new SvelteMap<string, (HoverMarkerConfig | CustomComponentMarkerConfig)[]>();
|
|
99
|
+
for (const marker of markers) {
|
|
100
|
+
if ((marker.type === 'hover' || marker.type === 'component') && 'series' in marker && marker.series) {
|
|
101
|
+
if (!map.has(marker.series)) map.set(marker.series, []);
|
|
102
|
+
map.get(marker.series)!.push(marker);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return map;
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
function markerKey(marker: MarkerConfig, i: number): string {
|
|
109
|
+
if (marker.type === 'rule') return `rule-${marker.axis}-${marker.value}`;
|
|
110
|
+
if (marker.type === 'bar') return `bar-${marker.role}-${i}`;
|
|
111
|
+
return `${marker.type}-${i}`;
|
|
112
|
+
}
|
|
113
|
+
</script>
|
|
114
|
+
|
|
115
|
+
{#each geometryMarkers as marker, i (markerKey(marker, i))}
|
|
116
|
+
{#if marker.type === 'bar'}
|
|
117
|
+
<BarMarker {marker} />
|
|
118
|
+
{:else if marker.type === 'line'}
|
|
119
|
+
<LineMarker {marker} />
|
|
120
|
+
{:else if marker.type === 'cell'}
|
|
121
|
+
<CellMarker {marker} />
|
|
122
|
+
{:else if marker.type === 'dot'}
|
|
123
|
+
<DotMarker
|
|
124
|
+
data={marker.data}
|
|
125
|
+
x={resolveAccessor(marker.x)}
|
|
126
|
+
y={resolveAccessor(marker.y)}
|
|
127
|
+
r={typeof marker.r === 'number' || marker.r == null ? marker.r : resolveAccessor(marker.r)}
|
|
128
|
+
fill={marker.fill}
|
|
129
|
+
value={marker.value ? resolveAccessor(marker.value) : undefined}
|
|
130
|
+
style={marker.style}
|
|
131
|
+
/>
|
|
132
|
+
{:else if marker.type === 'text'}
|
|
133
|
+
<TextMarker
|
|
134
|
+
data={marker.data}
|
|
135
|
+
x={resolveAccessor(marker.x)}
|
|
136
|
+
y={resolveAccessor(marker.y)}
|
|
137
|
+
text={marker.text}
|
|
138
|
+
style={marker.style}
|
|
139
|
+
/>
|
|
140
|
+
{:else if marker.type === 'rule'}
|
|
141
|
+
<RuleMarker axis={marker.axis} value={marker.value} style={marker.style} />
|
|
142
|
+
{:else if marker.type === 'geo'}
|
|
143
|
+
<GeoFeaturesMarker {marker} />
|
|
144
|
+
{:else if marker.type === 'graticule'}
|
|
145
|
+
<GraticuleMarker {marker} />
|
|
146
|
+
{:else if marker.type === 'sphere'}
|
|
147
|
+
<SphereMarker {marker} />
|
|
148
|
+
{:else if marker.type === 'vector'}
|
|
149
|
+
<VectorMarker {marker} />
|
|
150
|
+
{:else if marker.type === 'link'}
|
|
151
|
+
<LinkMarker {marker} />
|
|
152
|
+
{:else if marker.type === 'contour'}
|
|
153
|
+
<!-- 'contour' only exists in GeoMarkersConfig, so `data` is always GeoFeature-shaped here despite the generic TData bound. -->
|
|
154
|
+
<ContourClipMarker mode={marker.clip} features={data as unknown as GeoFeature<Record<string, unknown>>[]}>
|
|
155
|
+
<ContourMarker {marker} />
|
|
156
|
+
</ContourClipMarker>
|
|
157
|
+
{:else if marker.type === 'inset'}
|
|
158
|
+
<InsetMarker
|
|
159
|
+
{marker}
|
|
160
|
+
features={geoAllFeatures}
|
|
161
|
+
width={Math.max(0, (width ?? 0) - (numericMargins?.left ?? 0) - (numericMargins?.right ?? 0))}
|
|
162
|
+
height={Math.max(0, (height ?? 0) - (numericMargins?.top ?? 0) - (numericMargins?.bottom ?? 0))}
|
|
163
|
+
left={numericMargins?.left ?? 0}
|
|
164
|
+
top={numericMargins?.top ?? 0}
|
|
165
|
+
defaultFill={cfg.palette[0]}
|
|
166
|
+
{tooltipAnchorX}
|
|
167
|
+
{tooltipAnchorY}
|
|
168
|
+
/>
|
|
169
|
+
{:else if marker.type === 'component'}
|
|
170
|
+
<marker.component {...marker.props} data={marker.data ?? seriesData} />
|
|
171
|
+
{:else if marker.type === 'geo-component'}
|
|
172
|
+
<marker.component {...marker.props} data={marker.data ?? data} />
|
|
173
|
+
{:else if marker.type === 'hover'}
|
|
174
|
+
<HoverMarker {marker} data={matchedPoints} {activePoint} {impliesCrosshairX} {impliesCrosshairY} />
|
|
175
|
+
{:else if marker.type === 'geo-hover'}
|
|
176
|
+
<GeoHoverMarker {marker} data={matchedPoints} />
|
|
177
|
+
{:else if marker.type === 'delta'}
|
|
178
|
+
<DeltaMarker {marker} data={seriesData} />
|
|
179
|
+
{/if}
|
|
180
|
+
{/each}
|
|
181
|
+
|
|
182
|
+
{#each scopedGroups as group (group.name)}
|
|
183
|
+
{#each scopedMarkersByName.get(group.name) ?? [] as marker, i (`${group.name}-${marker.type}-${i}`)}
|
|
184
|
+
{#if marker.type === 'hover'}
|
|
185
|
+
{@const seriesPoints = matchedPoints.filter((p) => p.series === group.name)}
|
|
186
|
+
{#if marker.scope === 'segment'}
|
|
187
|
+
{#each group.segments as seg, segIdx (`${group.name}-hover-segment-${segIdx}`)}
|
|
188
|
+
<!-- p.row (TData) is always a superset of TSeries in practice, not provable across two independent generics. -->
|
|
189
|
+
{@const segPoints = seriesPoints.filter((p) => seg.match(p.row as unknown as TSeries))}
|
|
190
|
+
{#if segPoints.length > 0}
|
|
191
|
+
<HoverMarker
|
|
192
|
+
{marker}
|
|
193
|
+
data={segPoints}
|
|
194
|
+
activePoint={segPoints[0] ?? null}
|
|
195
|
+
{impliesCrosshairX}
|
|
196
|
+
{impliesCrosshairY}
|
|
197
|
+
seriesColor={seg.color}
|
|
198
|
+
/>
|
|
199
|
+
{/if}
|
|
200
|
+
{/each}
|
|
201
|
+
{:else}
|
|
202
|
+
<HoverMarker
|
|
203
|
+
{marker}
|
|
204
|
+
data={seriesPoints}
|
|
205
|
+
activePoint={seriesPoints[0] ?? null}
|
|
206
|
+
{impliesCrosshairX}
|
|
207
|
+
{impliesCrosshairY}
|
|
208
|
+
seriesColor={group.segments[0]?.color ?? group.color}
|
|
209
|
+
/>
|
|
210
|
+
{/if}
|
|
211
|
+
{:else if marker.type === 'component'}
|
|
212
|
+
{#if marker.scope === 'segment'}
|
|
213
|
+
{#each group.segments as seg, segIdx (`${group.name}-component-segment-${segIdx}`)}
|
|
214
|
+
{@const segmentData = group.data.filter((row) => seg.match(row))}
|
|
215
|
+
{#if segmentData.length > 0}
|
|
216
|
+
<marker.component {...marker.props} series={group.name} data={segmentData} seriesColor={seg.color} />
|
|
217
|
+
{/if}
|
|
218
|
+
{/each}
|
|
219
|
+
{:else}
|
|
220
|
+
<marker.component
|
|
221
|
+
{...marker.props}
|
|
222
|
+
series={group.name}
|
|
223
|
+
data={group.data}
|
|
224
|
+
seriesColor={group.segments[0]?.color ?? group.color}
|
|
225
|
+
/>
|
|
226
|
+
{/if}
|
|
227
|
+
{/if}
|
|
228
|
+
{/each}
|
|
229
|
+
{/each}
|
|
230
|
+
|
|
231
|
+
{@render children?.()}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { Series } from '../../types/plots/data/common';
|
|
3
|
+
import type { MarkerConfig } from '../../types/markers/all';
|
|
4
|
+
import type { HoverPoint, TooltipAnchorX, TooltipAnchorY } from '../../types/layout/tooltip';
|
|
5
|
+
import type { ScopedMarkerGroup } from '../../types/layout/geometry';
|
|
6
|
+
import type { GeoFeature } from '../../types/plots/data/geo';
|
|
7
|
+
declare function $$render<TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData>(): {
|
|
8
|
+
props: {
|
|
9
|
+
/** The plot's own outer width/height — `inset` marker only, to size its content box. */
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
markers?: MarkerConfig[];
|
|
13
|
+
/** All resolved series, forwarded to unscoped `component`/`delta` markers. Independently generic over `TSeries` (defaults to `TData`). */
|
|
14
|
+
seriesData?: Series<TSeries>[];
|
|
15
|
+
/** One entry per series that can own a `series`-scoped marker. Same `TSeries` as `seriesData`. */
|
|
16
|
+
scopedGroups?: ScopedMarkerGroup<TSeries>[];
|
|
17
|
+
matchedPoints: HoverPoint<TData>[];
|
|
18
|
+
/** The specific matched point actually under the cursor. */
|
|
19
|
+
activePoint: HoverPoint<TData> | null;
|
|
20
|
+
impliesCrosshairX: boolean;
|
|
21
|
+
impliesCrosshairY: boolean;
|
|
22
|
+
/** The plot's own resolved margins — `inset` marker only, to place its content box. */
|
|
23
|
+
numericMargins?: {
|
|
24
|
+
top: number;
|
|
25
|
+
right: number;
|
|
26
|
+
bottom: number;
|
|
27
|
+
left: number;
|
|
28
|
+
};
|
|
29
|
+
/** `BasePlotLayout`'s own rows — `contour` (clip) and unscoped `geo-component` fallback data. */
|
|
30
|
+
data?: TData[];
|
|
31
|
+
/** `GeoPlot`'s own untouched, tagged features — `inset` marker only (shows a part the main map may exclude). */
|
|
32
|
+
geoAllFeatures?: (GeoFeature<Record<string, unknown>> & {
|
|
33
|
+
__id: string;
|
|
34
|
+
})[];
|
|
35
|
+
/** The plot's own top-level `tooltip.anchorX`/`anchorY` — `inset` marker only, as the fallback its own tooltip inherits when unset. */
|
|
36
|
+
tooltipAnchorX?: TooltipAnchorX;
|
|
37
|
+
tooltipAnchorY?: TooltipAnchorY;
|
|
38
|
+
/** Rendered last, on top of every marker — typically value labels. Optional; a plot kind may have nothing extra to add. */
|
|
39
|
+
children?: Snippet;
|
|
40
|
+
};
|
|
41
|
+
exports: {};
|
|
42
|
+
bindings: "";
|
|
43
|
+
slots: {};
|
|
44
|
+
events: {};
|
|
45
|
+
};
|
|
46
|
+
declare class __sveltets_Render<TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData> {
|
|
47
|
+
props(): ReturnType<typeof $$render<TData, TSeries>>['props'];
|
|
48
|
+
events(): ReturnType<typeof $$render<TData, TSeries>>['events'];
|
|
49
|
+
slots(): ReturnType<typeof $$render<TData, TSeries>>['slots'];
|
|
50
|
+
bindings(): "";
|
|
51
|
+
exports(): {};
|
|
52
|
+
}
|
|
53
|
+
interface $$IsomorphicComponent {
|
|
54
|
+
new <TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData, TSeries>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData, TSeries>['props']>, ReturnType<__sveltets_Render<TData, TSeries>['events']>, ReturnType<__sveltets_Render<TData, TSeries>['slots']>> & {
|
|
55
|
+
$$bindings?: ReturnType<__sveltets_Render<TData, TSeries>['bindings']>;
|
|
56
|
+
} & ReturnType<__sveltets_Render<TData, TSeries>['exports']>;
|
|
57
|
+
<TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData>(internal: unknown, props: ReturnType<__sveltets_Render<TData, TSeries>['props']> & {}): ReturnType<__sveltets_Render<TData, TSeries>['exports']>;
|
|
58
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
59
|
+
}
|
|
60
|
+
declare const GeometryLayout: $$IsomorphicComponent;
|
|
61
|
+
type GeometryLayout<TData extends Record<string, unknown>, TSeries extends Record<string, unknown> = TData> = InstanceType<typeof GeometryLayout<TData, TSeries>>;
|
|
62
|
+
export default GeometryLayout;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { untrack } from 'svelte';
|
|
3
|
-
import type { ContinuousLegendSection } from '../../types/
|
|
3
|
+
import type { ContinuousLegendSection } from '../../types/layout/legend';
|
|
4
4
|
import { makeColorScale } from '../../utils/color';
|
|
5
5
|
import { getConfiguration } from '../../configuration/config.svelte';
|
|
6
6
|
import { getLegendInteraction, createLegendInteraction } from './interaction.svelte';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { getConfiguration } from '../../configuration/config.svelte';
|
|
4
4
|
import { paletteColor } from '../../utils/color';
|
|
5
5
|
import { getLegendInteraction, createLegendInteraction } from './interaction.svelte';
|
|
6
|
-
import type { DiscreteLegendSection, LegendItem } from '../../types/
|
|
6
|
+
import type { DiscreteLegendSection, LegendItem } from '../../types/layout/legend';
|
|
7
7
|
import type { LineStyle } from '../../types/plots/constants';
|
|
8
8
|
|
|
9
9
|
let { section }: { section: DiscreteLegendSection } = $props();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import type { LegendSection } from '../../types/
|
|
2
|
+
import type { LegendSection } from '../../types/layout/legend';
|
|
3
3
|
import DiscreteSection from './DiscreteSection.svelte';
|
|
4
4
|
import ContinuousSection from './ContinuousSection.svelte';
|
|
5
5
|
|
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
import type { LegendInteractionStore } from '../../types/layout/legend';
|
|
2
2
|
/** Create + register the shared legend-interaction store. Call during component init. */
|
|
3
3
|
export declare function provideLegendInteraction(): LegendInteractionStore;
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Read the shared legend-interaction store, or `null` when there is no provider.
|
|
6
|
+
*
|
|
7
|
+
* Only resolves correctly when called during a real descendant component's
|
|
8
|
+
* own `<script>` instantiation, not from inside a `{@render}`ed snippet body
|
|
9
|
+
* — snippets run in their author's scope rather than as a fresh component
|
|
10
|
+
* instance. `BaseChart`'s `plot` snippet gets the same data via its `legend`
|
|
11
|
+
* context field instead, which works from either scope.
|
|
12
|
+
*/
|
|
5
13
|
export declare function getLegendInteraction(): LegendInteractionStore | null;
|
|
6
14
|
/** A private legend-interaction store for a legend/plot used outside of a {@link BaseChart}. */
|
|
7
15
|
export declare function createLegendInteraction(): LegendInteractionStore;
|
|
@@ -13,7 +13,15 @@ export function provideLegendInteraction() {
|
|
|
13
13
|
setContext(LEGEND_INTERACTION_KEY, store);
|
|
14
14
|
return store;
|
|
15
15
|
}
|
|
16
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Read the shared legend-interaction store, or `null` when there is no provider.
|
|
18
|
+
*
|
|
19
|
+
* Only resolves correctly when called during a real descendant component's
|
|
20
|
+
* own `<script>` instantiation, not from inside a `{@render}`ed snippet body
|
|
21
|
+
* — snippets run in their author's scope rather than as a fresh component
|
|
22
|
+
* instance. `BaseChart`'s `plot` snippet gets the same data via its `legend`
|
|
23
|
+
* context field instead, which works from either scope.
|
|
24
|
+
*/
|
|
17
25
|
export function getLegendInteraction() {
|
|
18
26
|
return getContext(LEGEND_INTERACTION_KEY) ?? null;
|
|
19
27
|
}
|