@fundar/data-chart-telling 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +121 -17
- package/dist/charts/{Chart.svelte.d.ts → BaseChart.svelte.d.ts} +3 -3
- package/dist/charts/bar/Chart.svelte +5 -5
- package/dist/charts/bar/Chart.svelte.d.ts +1 -2
- package/dist/charts/heatmap/Chart.svelte +8 -7
- package/dist/charts/heatmap/Chart.svelte.d.ts +2 -3
- package/dist/charts/line/Chart.svelte +5 -5
- package/dist/charts/line/Chart.svelte.d.ts +1 -2
- package/dist/charts/pyramid/Chart.svelte +7 -6
- package/dist/charts/pyramid/Chart.svelte.d.ts +2 -3
- package/dist/configuration/config.svelte.js +1 -1
- package/dist/configuration/themes/index.d.ts +56 -40
- package/dist/index.d.ts +26 -12
- package/dist/index.js +12 -7
- package/dist/layout/facet/FacetLayout.svelte +1 -1
- package/dist/layout/facet/FacetLayout.svelte.d.ts +1 -1
- package/dist/layout/geo/GeoLayout.svelte +47 -0
- package/dist/layout/geo/GeoLayout.svelte.d.ts +22 -0
- package/dist/layout/geo/resolveProjection.d.ts +10 -0
- package/dist/layout/geo/resolveProjection.js +48 -0
- package/dist/layout/legend/DiscreteSection.svelte +1 -1
- package/dist/layout/plot/AxisLayout.svelte +95 -0
- package/dist/layout/plot/AxisLayout.svelte.d.ts +39 -0
- package/dist/layout/plot/BasePlotLayout.svelte +302 -0
- package/dist/layout/plot/BasePlotLayout.svelte.d.ts +95 -0
- package/dist/layout/plot/GridLayout.svelte +30 -0
- package/dist/layout/plot/GridLayout.svelte.d.ts +27 -0
- package/dist/layout/plot/RuleLayout.svelte +111 -0
- package/dist/layout/plot/RuleLayout.svelte.d.ts +40 -0
- package/dist/layout/plot/margins.d.ts +34 -0
- package/dist/layout/plot/margins.js +26 -0
- package/dist/layout/timeline/TimelineLayout.svelte +1 -1
- package/dist/layout/timeline/TimelineLayout.svelte.d.ts +1 -1
- package/dist/layout/tooltip/Tooltip.svelte +15 -0
- package/dist/layout/tooltip/Tooltip.svelte.d.ts +7 -0
- package/dist/layout/tooltip/TooltipLayout.svelte +45 -0
- package/dist/layout/tooltip/TooltipLayout.svelte.d.ts +41 -0
- package/dist/layout/tooltip/controller.svelte.d.ts +4 -3
- package/dist/layout/tooltip/controller.svelte.js +5 -6
- package/dist/layout/tooltip/hover.svelte.d.ts +1 -1
- package/dist/layout/tooltip/hover.svelte.js +1 -1
- package/dist/layout/tooltip/utils.d.ts +2 -2
- package/dist/markers/ContourClipMarker.svelte +77 -0
- package/dist/markers/ContourClipMarker.svelte.d.ts +10 -0
- package/dist/{plots/markers → markers}/DeltaMarker.svelte +4 -4
- package/dist/{plots/markers → markers}/DeltaMarker.svelte.d.ts +3 -3
- package/dist/{plots/markers → markers}/DotMarker.svelte +3 -3
- package/dist/{plots/markers → markers}/DotMarker.svelte.d.ts +3 -3
- package/dist/markers/HoverMarker.svelte +136 -0
- package/dist/{plots/markers → markers}/HoverMarker.svelte.d.ts +4 -4
- package/dist/{plots/markers → markers}/PeakMarker.svelte +2 -2
- package/dist/{plots/markers → markers}/PeakMarker.svelte.d.ts +2 -2
- package/dist/{plots/markers → markers}/TextMarker.svelte +11 -4
- package/dist/{plots/markers → markers}/TextMarker.svelte.d.ts +3 -3
- package/dist/markers/inset/InsetMarker.svelte +170 -0
- package/dist/markers/inset/InsetMarker.svelte.d.ts +51 -0
- package/dist/markers/inset/insetLayout.d.ts +25 -0
- package/dist/markers/inset/insetLayout.js +39 -0
- package/dist/markers/inset/insetProjection.d.ts +8 -0
- package/dist/markers/inset/insetProjection.js +39 -0
- package/dist/plots/bar/BarSegments.svelte +66 -0
- package/dist/plots/bar/BarSegments.svelte.d.ts +36 -0
- package/dist/plots/bar/Plot.svelte +132 -76
- package/dist/plots/bar/Plot.svelte.d.ts +7 -3
- package/dist/plots/bar/ValueLabels.svelte +89 -0
- package/dist/plots/bar/ValueLabels.svelte.d.ts +39 -0
- package/dist/plots/bar/hoverPoints.d.ts +15 -0
- package/dist/plots/bar/hoverPoints.js +35 -0
- package/dist/plots/bar/layout.svelte.d.ts +37 -0
- package/dist/plots/bar/layout.svelte.js +132 -0
- package/dist/plots/geo/Plot.svelte +548 -0
- package/dist/plots/geo/Plot.svelte.d.ts +29 -0
- package/dist/plots/geo/TileLayer.svelte +77 -0
- package/dist/plots/geo/TileLayer.svelte.d.ts +11 -0
- package/dist/plots/geo/projections/argentina.d.ts +8 -0
- package/dist/plots/geo/projections/argentina.js +35 -0
- package/dist/plots/geo/projections/fit.d.ts +8 -0
- package/dist/plots/geo/projections/fit.js +14 -0
- package/dist/plots/geo/rotate.svelte.d.ts +26 -0
- package/dist/plots/geo/rotate.svelte.js +79 -0
- package/dist/plots/geo/zoom.svelte.d.ts +32 -0
- package/dist/plots/geo/zoom.svelte.js +50 -0
- package/dist/plots/heatmap/Plot.svelte +129 -47
- package/dist/plots/heatmap/Plot.svelte.d.ts +7 -3
- package/dist/plots/line/Plot.svelte +44 -16
- package/dist/plots/line/Plot.svelte.d.ts +7 -3
- package/dist/plots/pyramid/Plot.svelte +70 -25
- package/dist/plots/pyramid/Plot.svelte.d.ts +7 -3
- package/dist/plots/utils/delta.d.ts +1 -1
- package/dist/plots/utils/geoAccessors.d.ts +64 -0
- package/dist/plots/utils/geoAccessors.js +188 -0
- package/dist/plots/utils/geoSegments.d.ts +14 -0
- package/dist/plots/utils/geoSegments.js +17 -0
- package/dist/plots/utils/segments.d.ts +14 -5
- package/dist/plots/utils/segments.js +25 -13
- package/dist/plots/utils/tiles.d.ts +89 -0
- package/dist/plots/utils/tiles.js +159 -0
- package/dist/plots/utils/topojson.d.ts +9 -0
- package/dist/plots/utils/topojson.js +30 -0
- package/dist/types/charts/common.d.ts +2 -1
- package/dist/types/charts/legend.d.ts +1 -1
- package/dist/types/charts/props.d.ts +9 -6
- package/dist/types/configuration/styling.d.ts +11 -5
- package/dist/types/layout/tooltip.d.ts +14 -21
- package/dist/types/{plots/markers.d.ts → markers/common.d.ts} +2 -18
- package/dist/types/markers/geo.d.ts +237 -0
- package/dist/types/markers/props.d.ts +11 -0
- package/dist/types/plots/axis.d.ts +55 -0
- package/dist/types/plots/axis.js +1 -0
- package/dist/types/plots/constants.d.ts +30 -0
- package/dist/types/plots/constants.js +1 -0
- package/dist/types/plots/data/common.d.ts +40 -0
- package/dist/types/plots/data/common.js +1 -0
- package/dist/types/plots/data/geo.d.ts +74 -0
- package/dist/types/plots/data/geo.js +1 -0
- package/dist/types/plots/delta.d.ts +2 -2
- package/dist/types/plots/props.d.ts +105 -16
- package/dist/types/plots/scales/geo.d.ts +44 -0
- package/dist/types/plots/scales/geo.js +1 -0
- package/dist/types/plots/segments/common.d.ts +25 -0
- package/dist/types/plots/segments/common.js +1 -0
- package/dist/types/plots/segments/config.d.ts +51 -0
- package/dist/types/plots/segments/config.js +1 -0
- package/dist/types/plots/styles/common.d.ts +37 -0
- package/dist/types/plots/styles/common.js +1 -0
- package/dist/types/plots/styles/geo.d.ts +42 -0
- package/dist/types/plots/styles/geo.js +1 -0
- package/dist/types/plots/styling.d.ts +45 -0
- package/dist/types/plots/styling.js +1 -0
- package/dist/utils/grouping.d.ts +2 -1
- package/dist/utils/interpolate.d.ts +2 -1
- package/package.json +27 -13
- package/dist/layout/plot/PlotLayout.svelte +0 -237
- package/dist/layout/plot/PlotLayout.svelte.d.ts +0 -70
- package/dist/plots/markers/HoverMarker.svelte +0 -98
- package/dist/types/plots/common.d.ts +0 -100
- package/dist/types/plots/styles.d.ts +0 -187
- /package/dist/charts/{Chart.svelte → BaseChart.svelte} +0 -0
- /package/dist/types/{plots → markers}/common.js +0 -0
- /package/dist/types/{plots/markers.js → markers/geo.js} +0 -0
- /package/dist/types/{plots/styles.js → markers/props.js} +0 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StrokeStyle, DotStyle } from '../styling';
|
|
2
|
+
/** Per-segment styling for a line: its stroke and/or its endpoint dots. */
|
|
3
|
+
export type LineSegmentStyle = {
|
|
4
|
+
stroke?: StrokeStyle;
|
|
5
|
+
dots?: DotStyle;
|
|
6
|
+
};
|
|
7
|
+
/** Per-segment styling for a bar-shaped mark: its fill. Shared by `BarPlot` and `PyramidPlot`. */
|
|
8
|
+
export type BarSegmentStyle = {
|
|
9
|
+
fill?: string;
|
|
10
|
+
fillOpacity?: number;
|
|
11
|
+
};
|
|
12
|
+
/** Per-cell styling override for a heatmap cell. */
|
|
13
|
+
export type CellSegmentStyle = {
|
|
14
|
+
fill?: string;
|
|
15
|
+
fillOpacity?: number;
|
|
16
|
+
stroke?: string;
|
|
17
|
+
strokeWidth?: number;
|
|
18
|
+
};
|
|
19
|
+
/** Per-feature styling override for `GeoPlot` — the geo analog of `CellSegmentStyle`. */
|
|
20
|
+
export type GeoSegmentStyle = {
|
|
21
|
+
fill?: string;
|
|
22
|
+
fillOpacity?: number;
|
|
23
|
+
stroke?: string;
|
|
24
|
+
strokeWidth?: number;
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AxisValue } from '../axis';
|
|
2
|
+
import type { Series } from '../data/common';
|
|
3
|
+
import type { LineSegmentStyle } from './common';
|
|
4
|
+
/** A half-open interval on one axis. Both bounds are inclusive; omit either to leave that end open. */
|
|
5
|
+
export type Range = {
|
|
6
|
+
from?: AxisValue;
|
|
7
|
+
to?: AxisValue;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A 2-D rectangular area on the plot, addressed by optional x and y intervals.
|
|
11
|
+
* Omitting an interval leaves that axis unrestricted (matches all values).
|
|
12
|
+
*
|
|
13
|
+
* - For line/bar/pyramid plots only the `x` interval is used (the series' primary
|
|
14
|
+
* axis); `y` is evaluated but filters by the series' value axis.
|
|
15
|
+
* - For heatmaps both `x` (column) and `y` (row) are used to address cells.
|
|
16
|
+
*/
|
|
17
|
+
export type Area = {
|
|
18
|
+
x?: Range;
|
|
19
|
+
y?: Range;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* One styled rule for a plot. A data point (or cell) is styled when it falls
|
|
23
|
+
* inside **any** of the listed `areas`. Omitting `areas` (or passing an empty
|
|
24
|
+
* array) makes the segment a catch-all that matches every data point — useful
|
|
25
|
+
* as a baseline style. `TStyle` is the per-mark shape ({@link LineSegmentStyle},
|
|
26
|
+
* {@link BarSegmentStyle}, {@link CellSegmentStyle}, …).
|
|
27
|
+
*
|
|
28
|
+
* Catch-alls are evaluated last so that area-specific segments always take
|
|
29
|
+
* priority, regardless of their position in the list. A catch-all placed first
|
|
30
|
+
* therefore acts as a fallback baseline that area-specific segments override.
|
|
31
|
+
*/
|
|
32
|
+
export type Segment<TStyle> = {
|
|
33
|
+
areas?: Area[];
|
|
34
|
+
style?: TStyle;
|
|
35
|
+
};
|
|
36
|
+
/** One contiguous, styled slice of a series' data — ready to draw as its own mark. */
|
|
37
|
+
export type VisualSegment<T extends Record<string, unknown>, TStyle = LineSegmentStyle> = {
|
|
38
|
+
data: T[];
|
|
39
|
+
style: TStyle;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A series split into its styled visual segments. `S` is the full series
|
|
43
|
+
* type Series<T> — its row type is read off `S['data']`
|
|
44
|
+
* rather than taken as a separate parameter, since TypeScript can't reliably
|
|
45
|
+
* infer a type parameter that only appears inside another parameter's
|
|
46
|
+
* constraint.
|
|
47
|
+
*/
|
|
48
|
+
export type VisualGroup<S extends Series<any>, TStyle = LineSegmentStyle> = {
|
|
49
|
+
series: S;
|
|
50
|
+
visualSegments: VisualSegment<S['data'][number], TStyle>[];
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ValueAnchor } from '../constants';
|
|
2
|
+
import type { FontStyle } from '../styling';
|
|
3
|
+
/**
|
|
4
|
+
* Controls if and how value labels are rendered on a plot. The high-level
|
|
5
|
+
* `anchor` sets sensible defaults for placement; the inherited {@link FontStyle}
|
|
6
|
+
* fields (`dx`, `dy`, `textAnchor`, `lineAnchor`, `lineHeight`, `rotate`,
|
|
7
|
+
* `class`, `textClass`, `fill`, …) override those defaults when provided.
|
|
8
|
+
*/
|
|
9
|
+
export type ValuesStyle = FontStyle & {
|
|
10
|
+
show?: boolean;
|
|
11
|
+
anchor?: ValueAnchor;
|
|
12
|
+
/** Called with the numeric value and the series name. Return a string to render. */
|
|
13
|
+
format?: (value: number, seriesName: string) => string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Color overrides for plots that derive their palette from data.
|
|
17
|
+
* Each plot uses only the fields relevant to its kind; unused fields are
|
|
18
|
+
* silently ignored.
|
|
19
|
+
*
|
|
20
|
+
* - `min` / `max` — sequential colour ramp endpoints (heatmap).
|
|
21
|
+
* - `left` / `right` — diverging bar sides (pyramid).
|
|
22
|
+
*/
|
|
23
|
+
export type ColorsStyle = {
|
|
24
|
+
min?: string;
|
|
25
|
+
max?: string;
|
|
26
|
+
left?: string;
|
|
27
|
+
right?: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Top-level rendering style overrides shared by the non-geo plot kinds.
|
|
31
|
+
* Passed as the `styles` prop. Each plot reads only the fields it cares
|
|
32
|
+
* about.
|
|
33
|
+
*/
|
|
34
|
+
export type BasePlotStyles = {
|
|
35
|
+
values?: ValuesStyle;
|
|
36
|
+
colors?: ColorsStyle;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ColorsStyle } from './common';
|
|
2
|
+
import type { GeoFeature } from '../data/geo';
|
|
3
|
+
export type GeoTileLayerConfig = {
|
|
4
|
+
/** XYZ tile URL template, e.g. `'https://tile.openstreetmap.org/{z}/{x}/{y}.png'`. */
|
|
5
|
+
url: string;
|
|
6
|
+
attribution?: string;
|
|
7
|
+
opacity?: number;
|
|
8
|
+
minZoom?: number;
|
|
9
|
+
maxZoom?: number;
|
|
10
|
+
/** Tile edge length in pixels. Defaults to `256`. */
|
|
11
|
+
tileSize?: number;
|
|
12
|
+
};
|
|
13
|
+
export type GeoZoomConfig = {
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
initial?: {
|
|
17
|
+
x?: number;
|
|
18
|
+
y?: number;
|
|
19
|
+
k?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* `styles` prop for GeoPlot — the geo analog of `BasePlotStyles`. Unlike the
|
|
24
|
+
* other plot kinds, GeoPlot's styling needs (base map, choropleth ramp, tile
|
|
25
|
+
* background, zoom, click handling) are unlike anything x/y plots need, so
|
|
26
|
+
* this is its own type rather than a reuse of `BasePlotStyles`.
|
|
27
|
+
*/
|
|
28
|
+
export type GeoStyles<TProps extends Record<string, unknown> = Record<string, unknown>> = {
|
|
29
|
+
/** Base map fill, used when a feature isn't styled by `segments` or the choropleth ramp. */
|
|
30
|
+
fill?: string;
|
|
31
|
+
fillOpacity?: number;
|
|
32
|
+
stroke?: string;
|
|
33
|
+
strokeWidth?: number;
|
|
34
|
+
/** Continuous choropleth ramp endpoints — used when `value` is provided on data. Mirrors heatmap's `styles.colors`. */
|
|
35
|
+
colors?: ColorsStyle;
|
|
36
|
+
/** Raster XYZ tile basemap under the vector geometry. Mercator-family projections only. */
|
|
37
|
+
tileLayer?: GeoTileLayerConfig;
|
|
38
|
+
/** `true`/config enables drag-pan + scroll-zoom. Omitted/`false` = static map. */
|
|
39
|
+
zoom?: boolean | GeoZoomConfig;
|
|
40
|
+
/** Fired when a base-map feature is clicked. */
|
|
41
|
+
onFeatureClick?: (feature: GeoFeature<TProps>, event: Event) => void;
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { FontWeight, FontStyleKeyword, TextAnchor, LineAnchor, LineStyle, LineCap, LineJoin, SymbolType } from './constants';
|
|
2
|
+
/** Text/label styling for any text mark — a marker's label, an annotation, a value label. */
|
|
3
|
+
export type FontStyle = {
|
|
4
|
+
fill?: string;
|
|
5
|
+
fontSize?: number;
|
|
6
|
+
fontWeight?: FontWeight;
|
|
7
|
+
fontStyle?: FontStyleKeyword;
|
|
8
|
+
textAnchor?: TextAnchor;
|
|
9
|
+
lineAnchor?: LineAnchor;
|
|
10
|
+
lineHeight?: number;
|
|
11
|
+
rotate?: number;
|
|
12
|
+
stroke?: string;
|
|
13
|
+
strokeWidth?: number;
|
|
14
|
+
paintOrder?: string;
|
|
15
|
+
dx?: number;
|
|
16
|
+
dy?: number;
|
|
17
|
+
class?: string;
|
|
18
|
+
textClass?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Stroke styling for any line-ish mark — a line, a rule, a marker's connector. */
|
|
21
|
+
export type StrokeStyle = {
|
|
22
|
+
stroke?: string;
|
|
23
|
+
strokeWidth?: number;
|
|
24
|
+
strokeOpacity?: number;
|
|
25
|
+
strokeDasharray?: string | LineStyle;
|
|
26
|
+
strokeLinecap?: LineCap;
|
|
27
|
+
strokeLinejoin?: LineJoin;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Dot styling for any point mark — a line's endpoint dots, a marker's dot.
|
|
31
|
+
* Carries its own `dotStroke*` fields rather than nesting a {@link StrokeStyle},
|
|
32
|
+
* because a dot's outline is a distinct style from the stroke of the line (or
|
|
33
|
+
* other mark) it sits next to — e.g. a `LineSegmentStyle` styles its
|
|
34
|
+
* line's stroke and its dots' outline independently.
|
|
35
|
+
*/
|
|
36
|
+
export type DotStyle = {
|
|
37
|
+
dotRadius?: number;
|
|
38
|
+
dotFill?: string;
|
|
39
|
+
dotFillOpacity?: number;
|
|
40
|
+
dotSymbol?: SymbolType;
|
|
41
|
+
dotStroke?: string;
|
|
42
|
+
dotStrokeWidth?: number;
|
|
43
|
+
dotStrokeOpacity?: number;
|
|
44
|
+
dotStrokeDasharray?: string | LineStyle;
|
|
45
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/utils/grouping.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AxisValue } from '../types/plots/axis';
|
|
2
|
+
import type { Series, Accessor } from '../types/plots/data/common';
|
|
2
3
|
/**
|
|
3
4
|
* Splits rows into ordered groups keyed by the stringified accessor value.
|
|
4
5
|
* Insertion order of first appearance is preserved, which keeps colours stable
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { EasingName, EasingFn } from '../types/charts/interpolate';
|
|
2
2
|
import type { TimeValue, TimelineInterpolation } from '../types/charts/common';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AxisValue } from '../types/plots/axis';
|
|
4
|
+
import type { Accessor } from '../types/plots/data/common';
|
|
4
5
|
export declare function resolveEasing(easing?: EasingName | EasingFn): EasingFn;
|
|
5
6
|
/**
|
|
6
7
|
* Brackets a continuous target position `x` within one key-group's sorted
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fundar/data-chart-telling",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -18,46 +18,60 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"@types/geojson": "^7946.0.16",
|
|
22
|
+
"d3-geo": "^3.1.1",
|
|
23
|
+
"d3-interpolate": "^3.0.1",
|
|
24
|
+
"d3-selection": "^3.0.0",
|
|
25
|
+
"d3-zoom": "^3.0.0"
|
|
22
26
|
},
|
|
23
27
|
"peerDependencies": {
|
|
24
28
|
"svelte": "^5.0.0",
|
|
25
|
-
"svelteplot": "^0.14.0"
|
|
29
|
+
"svelteplot": "^0.14.0",
|
|
30
|
+
"topojson-client": "^3.1.0"
|
|
31
|
+
},
|
|
32
|
+
"peerDependenciesMeta": {
|
|
33
|
+
"topojson-client": {
|
|
34
|
+
"optional": true
|
|
35
|
+
}
|
|
26
36
|
},
|
|
27
37
|
"devDependencies": {
|
|
38
|
+
"@chromatic-com/storybook": "^5.2.1",
|
|
28
39
|
"@eslint/compat": "^2.0.4",
|
|
29
40
|
"@eslint/js": "^10.0.1",
|
|
41
|
+
"@storybook/addon-a11y": "^10.4.1",
|
|
42
|
+
"@storybook/addon-docs": "^10.4.1",
|
|
43
|
+
"@storybook/addon-svelte-csf": "^5.1.2",
|
|
44
|
+
"@storybook/addon-vitest": "^10.4.1",
|
|
45
|
+
"@storybook/svelte-vite": "^10.4.1",
|
|
30
46
|
"@sveltejs/package": "^2.5.7",
|
|
31
47
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
48
|
+
"@types/d3-geo": "^3.1.0",
|
|
32
49
|
"@types/d3-interpolate": "^3.0.4",
|
|
50
|
+
"@types/d3-selection": "^3.0.11",
|
|
51
|
+
"@types/d3-zoom": "^3.0.8",
|
|
33
52
|
"@types/node": "^22",
|
|
34
53
|
"@vitest/browser": "^4.1.7",
|
|
35
54
|
"@vitest/browser-playwright": "^4.1.7",
|
|
55
|
+
"@vitest/coverage-v8": "4.1.7",
|
|
36
56
|
"eslint": "^10.2.0",
|
|
37
57
|
"eslint-config-prettier": "^10.1.8",
|
|
58
|
+
"eslint-plugin-storybook": "^10.4.1",
|
|
38
59
|
"eslint-plugin-svelte": "^3.17.0",
|
|
39
60
|
"globals": "^17.4.0",
|
|
40
61
|
"playwright": "^1.60.0",
|
|
41
62
|
"prettier": "^3.8.1",
|
|
42
63
|
"prettier-plugin-svelte": "^3.5.1",
|
|
43
64
|
"publint": "^0.3.18",
|
|
65
|
+
"storybook": "^10.4.1",
|
|
44
66
|
"svelte": "^5.55.2",
|
|
45
67
|
"svelte-check": "^4.4.6",
|
|
46
68
|
"svelteplot": "^0.14.0",
|
|
69
|
+
"topojson-client": "^3.1.0",
|
|
47
70
|
"typescript": "^6.0.2",
|
|
48
71
|
"typescript-eslint": "^8.58.1",
|
|
49
72
|
"vite": "^8.0.7",
|
|
50
73
|
"vitest": "^4.1.3",
|
|
51
|
-
"vitest-browser-svelte": "^2.1.1"
|
|
52
|
-
"storybook": "^10.4.1",
|
|
53
|
-
"@storybook/svelte-vite": "^10.4.1",
|
|
54
|
-
"@storybook/addon-svelte-csf": "^5.1.2",
|
|
55
|
-
"@chromatic-com/storybook": "^5.2.1",
|
|
56
|
-
"@storybook/addon-vitest": "^10.4.1",
|
|
57
|
-
"@storybook/addon-a11y": "^10.4.1",
|
|
58
|
-
"@storybook/addon-docs": "^10.4.1",
|
|
59
|
-
"eslint-plugin-storybook": "^10.4.1",
|
|
60
|
-
"@vitest/coverage-v8": "4.1.7"
|
|
74
|
+
"vitest-browser-svelte": "^2.1.1"
|
|
61
75
|
},
|
|
62
76
|
"keywords": [
|
|
63
77
|
"svelte"
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import type { ComponentProps, Snippet } from 'svelte';
|
|
3
|
-
import { Plot, Pointer, RuleX, RuleY, AxisX, AxisY } from 'svelteplot';
|
|
4
|
-
import { getConfiguration } from '../../configuration/config.svelte';
|
|
5
|
-
import { getHover, createHover } from '../tooltip/hover.svelte';
|
|
6
|
-
import { createHoverController } from '../tooltip/controller.svelte';
|
|
7
|
-
import { hasHoverMarker, findHoverMarker } from '../tooltip/utils';
|
|
8
|
-
import HoverMarker from '../../plots/markers/HoverMarker.svelte';
|
|
9
|
-
import Tooltip from '../tooltip/Tooltip.svelte';
|
|
10
|
-
import type { AxisValue, Series, ScalesConfig, MarginConfig } from '../../types/plots/common';
|
|
11
|
-
import type { Marker } from '../../types/plots/markers';
|
|
12
|
-
import type { HoverStrategy, HoverDisplayPoint, HoverPoint, TooltipRuntime } from '../../types/layout/tooltip';
|
|
13
|
-
|
|
14
|
-
type SveltePlotProps = ComponentProps<typeof Plot>;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Shared chrome around every plot kind's svelteplot markup: the pointer-event
|
|
18
|
-
* wrapper, the hover/tooltip state machine, the `<Plot>` element itself plus
|
|
19
|
-
* standalone markers (`ruleX`/`ruleY`/un-scoped `component`) and the floating
|
|
20
|
-
* tooltip. A plot kind only supplies its data/accessors and its marks
|
|
21
|
-
* (`<Line>`/`<BarY>`/`<Cell>`, …) through `children`.
|
|
22
|
-
*/
|
|
23
|
-
let {
|
|
24
|
-
width,
|
|
25
|
-
height,
|
|
26
|
-
x,
|
|
27
|
-
y,
|
|
28
|
-
data,
|
|
29
|
-
getX,
|
|
30
|
-
getY,
|
|
31
|
-
matchY,
|
|
32
|
-
hoverPoints,
|
|
33
|
-
label,
|
|
34
|
-
tooltip = undefined,
|
|
35
|
-
markers = [],
|
|
36
|
-
seriesData = [],
|
|
37
|
-
showHoverLabels = true,
|
|
38
|
-
scales,
|
|
39
|
-
margins,
|
|
40
|
-
defaultStrategy = 'x',
|
|
41
|
-
children,
|
|
42
|
-
}: {
|
|
43
|
-
width: number;
|
|
44
|
-
height: number;
|
|
45
|
-
x?: SveltePlotProps['x'];
|
|
46
|
-
y?: SveltePlotProps['y'];
|
|
47
|
-
/** Flat rows fed to svelteplot's `<Pointer>` for nearest-point matching. */
|
|
48
|
-
data: TData[];
|
|
49
|
-
getX: (d: TData) => AxisValue;
|
|
50
|
-
getY: (d: TData) => AxisValue;
|
|
51
|
-
/** Pointer's `y` channel — only needed when matching must be 2D (e.g. a heatmap grid). */
|
|
52
|
-
matchY?: (d: TData) => AxisValue;
|
|
53
|
-
hoverPoints: HoverPoint<TData>[];
|
|
54
|
-
label: (row: TData) => string;
|
|
55
|
-
tooltip?: TooltipRuntime<TData>;
|
|
56
|
-
markers?: Marker[];
|
|
57
|
-
/** All resolved series, forwarded to unscoped component markers (e.g. DeltaMarker). */
|
|
58
|
-
seriesData?: Series<TData>[];
|
|
59
|
-
/** Scale config forwarded from the plot. */
|
|
60
|
-
scales?: ScalesConfig;
|
|
61
|
-
/** Partial margin override — merged on top of the theme before tickRotate adjustment. */
|
|
62
|
-
margins?: MarginConfig;
|
|
63
|
-
showHoverLabels?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* The plot kind's default hover strategy when none is set on the tooltip or
|
|
66
|
-
* hover marker. Line/bar → `'x'`, pyramid → `'y'`, heatmap → `'punctual'`.
|
|
67
|
-
*/
|
|
68
|
-
defaultStrategy?: HoverStrategy;
|
|
69
|
-
/**
|
|
70
|
-
* `matchedPoints` carries only display info (+ `series`), not `row` — a
|
|
71
|
-
* per-series-scoped `HoverMarker` never needs the source row, just enough
|
|
72
|
-
* to filter and place dots/labels, which sidesteps forcing a concrete
|
|
73
|
-
* `TData` resolution through this snippet's type for every plot kind.
|
|
74
|
-
* `impliesRuleX`/`impliesRuleY` tell the plot kind whether the active
|
|
75
|
-
* strategy implies a crosshair rule on each axis by default.
|
|
76
|
-
*/
|
|
77
|
-
children: Snippet<
|
|
78
|
-
[{
|
|
79
|
-
matchedPoints: HoverDisplayPoint[];
|
|
80
|
-
ruleX: AxisValue | null;
|
|
81
|
-
ruleY: AxisValue | null;
|
|
82
|
-
impliesRuleX: boolean;
|
|
83
|
-
impliesRuleY: boolean;
|
|
84
|
-
}]
|
|
85
|
-
>;
|
|
86
|
-
} = $props();
|
|
87
|
-
|
|
88
|
-
const cfg = $derived(getConfiguration());
|
|
89
|
-
|
|
90
|
-
const computedMargins = $derived.by(() => {
|
|
91
|
-
const base = { ...cfg.margins, ...margins };
|
|
92
|
-
const xRotate = scales?.x?.tickRotate;
|
|
93
|
-
if (!xRotate) return base;
|
|
94
|
-
const rad = Math.abs(xRotate) * Math.PI / 180;
|
|
95
|
-
return {
|
|
96
|
-
...base,
|
|
97
|
-
bottom: base.bottom + Math.ceil(Math.sin(rad) * 20),
|
|
98
|
-
};
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
// ── Hover / tooltip ───────────────────────────────────────────────────────
|
|
102
|
-
const hoverActive = $derived(tooltip != null || hasHoverMarker(markers));
|
|
103
|
-
|
|
104
|
-
const sharedHover = getHover();
|
|
105
|
-
const localHover = createHover();
|
|
106
|
-
const hover = $derived(sharedHover ?? localHover);
|
|
107
|
-
|
|
108
|
-
$effect(() => {
|
|
109
|
-
if (sharedHover) return;
|
|
110
|
-
const hoverMarker = findHoverMarker(markers);
|
|
111
|
-
localHover.strategy = tooltip?.strategy ?? hoverMarker?.strategy ?? defaultStrategy;
|
|
112
|
-
localHover.sync = tooltip?.sync ?? hoverMarker?.sync ?? false;
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
const ctrl = createHoverController<TData>({
|
|
116
|
-
hover: () => hover,
|
|
117
|
-
facetId: () => tooltip?.facetId ?? '',
|
|
118
|
-
points: () => hoverPoints,
|
|
119
|
-
getX: () => getX,
|
|
120
|
-
getY: () => getY,
|
|
121
|
-
label: () => label,
|
|
122
|
-
format: () => tooltip?.format ?? label,
|
|
123
|
-
seriesFilter: () => tooltip?.series,
|
|
124
|
-
width: () => width,
|
|
125
|
-
height: () => height,
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const topLevelMarkers = $derived(
|
|
129
|
-
markers.filter(
|
|
130
|
-
(marker) =>
|
|
131
|
-
marker.type === 'ruleX' ||
|
|
132
|
-
marker.type === 'ruleY' ||
|
|
133
|
-
(marker.type === 'component' && !marker.series),
|
|
134
|
-
),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
/** The unscoped (no `series`) hover marker, if any. */
|
|
138
|
-
const unscopedHoverMarker = $derived(
|
|
139
|
-
markers.find((m) => m.type === 'hover' && !m.series) as
|
|
140
|
-
| Extract<Marker, { type: 'hover' }>
|
|
141
|
-
| undefined,
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Gate ruleX display: shows when the strategy implies it (default) or the
|
|
146
|
-
* marker explicitly requests it (`ruleX: true`), and is never suppressed
|
|
147
|
-
* unless the marker explicitly disables it (`ruleX: false`).
|
|
148
|
-
*/
|
|
149
|
-
const showRuleX = $derived(
|
|
150
|
-
unscopedHoverMarker != null &&
|
|
151
|
-
unscopedHoverMarker.ruleX !== false &&
|
|
152
|
-
(ctrl.impliesRuleX || unscopedHoverMarker.ruleX === true),
|
|
153
|
-
);
|
|
154
|
-
const showRuleY = $derived(
|
|
155
|
-
unscopedHoverMarker != null &&
|
|
156
|
-
unscopedHoverMarker.ruleY !== false &&
|
|
157
|
-
(ctrl.impliesRuleY || unscopedHoverMarker.ruleY === true),
|
|
158
|
-
);
|
|
159
|
-
</script>
|
|
160
|
-
|
|
161
|
-
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
162
|
-
<div
|
|
163
|
-
class="dct-plot"
|
|
164
|
-
style:color={cfg.axis.color}
|
|
165
|
-
onpointermove={hoverActive ? ctrl.onMove : undefined}
|
|
166
|
-
onpointerleave={hoverActive ? ctrl.onLeave : undefined}
|
|
167
|
-
>
|
|
168
|
-
<Plot {width} {height} margin={computedMargins} {x} {y}>
|
|
169
|
-
<AxisX tickSize={scales?.x?.tickSize ?? cfg.axis.xTickSize} tickPadding={scales?.x?.tickPadding ?? cfg.axis.xTickPadding} tickFontSize={cfg.axis.fontSize} titleFontSize={scales?.x?.titleFontSize ?? cfg.axis.titleFontSize} />
|
|
170
|
-
<AxisY tickSize={scales?.y?.tickSize ?? cfg.axis.yTickSize} tickPadding={scales?.y?.tickPadding ?? cfg.axis.yTickPadding} tickFontSize={cfg.axis.fontSize} titleFontSize={scales?.y?.titleFontSize ?? cfg.axis.titleFontSize} />
|
|
171
|
-
{@render children({
|
|
172
|
-
matchedPoints: ctrl.points,
|
|
173
|
-
ruleX: ctrl.ruleX,
|
|
174
|
-
ruleY: ctrl.ruleY,
|
|
175
|
-
impliesRuleX: ctrl.impliesRuleX,
|
|
176
|
-
impliesRuleY: ctrl.impliesRuleY,
|
|
177
|
-
})}
|
|
178
|
-
|
|
179
|
-
{#each topLevelMarkers as marker, i (marker.type === 'ruleX' ? `${marker.type}-${marker.x}` : marker.type === 'ruleY' ? `${marker.type}-${marker.y}` : `${marker.type}-${i}`)}
|
|
180
|
-
{#if marker.type === 'ruleX'}
|
|
181
|
-
<RuleX
|
|
182
|
-
data={[{ xValue: marker.x }]}
|
|
183
|
-
x={(d) => d.xValue}
|
|
184
|
-
stroke={marker.style?.stroke ?? 'currentColor'}
|
|
185
|
-
strokeWidth={marker.style?.strokeWidth ?? 1}
|
|
186
|
-
strokeOpacity={marker.style?.strokeOpacity ?? 1}
|
|
187
|
-
strokeDasharray={marker.style?.strokeDasharray}
|
|
188
|
-
/>
|
|
189
|
-
{:else if marker.type === 'ruleY'}
|
|
190
|
-
<RuleY
|
|
191
|
-
data={[{ yValue: marker.y }]}
|
|
192
|
-
y={(d) => d.yValue}
|
|
193
|
-
stroke={marker.style?.stroke ?? 'currentColor'}
|
|
194
|
-
strokeWidth={marker.style?.strokeWidth ?? 1}
|
|
195
|
-
strokeOpacity={marker.style?.strokeOpacity ?? 1}
|
|
196
|
-
strokeDasharray={marker.style?.strokeDasharray}
|
|
197
|
-
/>
|
|
198
|
-
{:else if marker.type === 'component'}
|
|
199
|
-
<marker.component {...marker.props} data={marker.data ?? seriesData} />
|
|
200
|
-
{/if}
|
|
201
|
-
{/each}
|
|
202
|
-
|
|
203
|
-
{#if hoverActive}
|
|
204
|
-
<Pointer {data} x={getX} y={matchY} maxDistance={400} onupdate={ctrl.onPointer} />
|
|
205
|
-
{/if}
|
|
206
|
-
|
|
207
|
-
{#if unscopedHoverMarker}
|
|
208
|
-
<HoverMarker
|
|
209
|
-
data={ctrl.points}
|
|
210
|
-
ruleX={showRuleX ? ctrl.ruleX : null}
|
|
211
|
-
ruleY={showRuleY ? ctrl.ruleY : null}
|
|
212
|
-
showLabels={unscopedHoverMarker.showLabels ?? showHoverLabels}
|
|
213
|
-
format={unscopedHoverMarker.format}
|
|
214
|
-
ruleStyle={unscopedHoverMarker.ruleStyle}
|
|
215
|
-
dotStyle={unscopedHoverMarker.dotStyle}
|
|
216
|
-
fontStyle={unscopedHoverMarker.fontStyle}
|
|
217
|
-
/>
|
|
218
|
-
{/if}
|
|
219
|
-
</Plot>
|
|
220
|
-
|
|
221
|
-
{#if tooltip && ctrl.showTooltip && ctrl.tooltipPosition}
|
|
222
|
-
<Tooltip x={ctrl.tooltipPosition?.x ?? 0} y={ctrl.tooltipPosition?.y ?? 0} bounds={{ width, height }}>
|
|
223
|
-
{#if tooltip.content}
|
|
224
|
-
{@render tooltip.content({ rows: ctrl.matchedRows.map((p) => p.row) })}
|
|
225
|
-
{:else}
|
|
226
|
-
{ctrl.tooltipText}
|
|
227
|
-
{/if}
|
|
228
|
-
</Tooltip>
|
|
229
|
-
{/if}
|
|
230
|
-
</div>
|
|
231
|
-
|
|
232
|
-
<style>
|
|
233
|
-
.dct-plot {
|
|
234
|
-
position: relative;
|
|
235
|
-
line-height: 0;
|
|
236
|
-
}
|
|
237
|
-
</style>
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import type { Snippet } from 'svelte';
|
|
2
|
-
import type { AxisValue, Series, ScalesConfig, MarginConfig } from '../../types/plots/common';
|
|
3
|
-
import type { Marker } from '../../types/plots/markers';
|
|
4
|
-
import type { HoverStrategy, HoverDisplayPoint, HoverPoint, TooltipRuntime } from '../../types/layout/tooltip';
|
|
5
|
-
declare function $$render<TData extends Record<string, unknown>>(): {
|
|
6
|
-
props: {
|
|
7
|
-
width: number;
|
|
8
|
-
height: number;
|
|
9
|
-
x?: false | Partial<import("svelteplot/types/scale.js").XScaleOptions> | import("svelteplot/types/data.js").RawValue[] | undefined;
|
|
10
|
-
y?: false | import("svelteplot/types/data.js").RawValue[] | Partial<import("svelteplot/types/scale.js").YScaleOptions> | undefined;
|
|
11
|
-
/** Flat rows fed to svelteplot's `<Pointer>` for nearest-point matching. */
|
|
12
|
-
data: TData[];
|
|
13
|
-
getX: (d: TData) => AxisValue;
|
|
14
|
-
getY: (d: TData) => AxisValue;
|
|
15
|
-
/** Pointer's `y` channel — only needed when matching must be 2D (e.g. a heatmap grid). */
|
|
16
|
-
matchY?: (d: TData) => AxisValue;
|
|
17
|
-
hoverPoints: HoverPoint<TData>[];
|
|
18
|
-
label: (row: TData) => string;
|
|
19
|
-
tooltip?: TooltipRuntime<TData>;
|
|
20
|
-
markers?: Marker[];
|
|
21
|
-
/** All resolved series, forwarded to unscoped component markers (e.g. DeltaMarker). */
|
|
22
|
-
seriesData?: Series<TData>[];
|
|
23
|
-
/** Scale config forwarded from the plot. */
|
|
24
|
-
scales?: ScalesConfig;
|
|
25
|
-
/** Partial margin override — merged on top of the theme before tickRotate adjustment. */
|
|
26
|
-
margins?: MarginConfig;
|
|
27
|
-
showHoverLabels?: boolean;
|
|
28
|
-
/**
|
|
29
|
-
* The plot kind's default hover strategy when none is set on the tooltip or
|
|
30
|
-
* hover marker. Line/bar → `'x'`, pyramid → `'y'`, heatmap → `'punctual'`.
|
|
31
|
-
*/
|
|
32
|
-
defaultStrategy?: HoverStrategy;
|
|
33
|
-
/**
|
|
34
|
-
* `matchedPoints` carries only display info (+ `series`), not `row` — a
|
|
35
|
-
* per-series-scoped `HoverMarker` never needs the source row, just enough
|
|
36
|
-
* to filter and place dots/labels, which sidesteps forcing a concrete
|
|
37
|
-
* `TData` resolution through this snippet's type for every plot kind.
|
|
38
|
-
* `impliesRuleX`/`impliesRuleY` tell the plot kind whether the active
|
|
39
|
-
* strategy implies a crosshair rule on each axis by default.
|
|
40
|
-
*/
|
|
41
|
-
children: Snippet<[{
|
|
42
|
-
matchedPoints: HoverDisplayPoint[];
|
|
43
|
-
ruleX: AxisValue | null;
|
|
44
|
-
ruleY: AxisValue | null;
|
|
45
|
-
impliesRuleX: boolean;
|
|
46
|
-
impliesRuleY: boolean;
|
|
47
|
-
}]>;
|
|
48
|
-
};
|
|
49
|
-
exports: {};
|
|
50
|
-
bindings: "";
|
|
51
|
-
slots: {};
|
|
52
|
-
events: {};
|
|
53
|
-
};
|
|
54
|
-
declare class __sveltets_Render<TData extends Record<string, unknown>> {
|
|
55
|
-
props(): ReturnType<typeof $$render<TData>>['props'];
|
|
56
|
-
events(): ReturnType<typeof $$render<TData>>['events'];
|
|
57
|
-
slots(): ReturnType<typeof $$render<TData>>['slots'];
|
|
58
|
-
bindings(): "";
|
|
59
|
-
exports(): {};
|
|
60
|
-
}
|
|
61
|
-
interface $$IsomorphicComponent {
|
|
62
|
-
new <TData extends Record<string, unknown>>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TData>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TData>['props']>, ReturnType<__sveltets_Render<TData>['events']>, ReturnType<__sveltets_Render<TData>['slots']>> & {
|
|
63
|
-
$$bindings?: ReturnType<__sveltets_Render<TData>['bindings']>;
|
|
64
|
-
} & ReturnType<__sveltets_Render<TData>['exports']>;
|
|
65
|
-
<TData extends Record<string, unknown>>(internal: unknown, props: ReturnType<__sveltets_Render<TData>['props']> & {}): ReturnType<__sveltets_Render<TData>['exports']>;
|
|
66
|
-
z_$$bindings?: ReturnType<__sveltets_Render<any>['bindings']>;
|
|
67
|
-
}
|
|
68
|
-
declare const PlotLayout: $$IsomorphicComponent;
|
|
69
|
-
type PlotLayout<TData extends Record<string, unknown>> = InstanceType<typeof PlotLayout<TData>>;
|
|
70
|
-
export default PlotLayout;
|