@fundar/data-chart-telling 0.0.24 → 0.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/charts/bar/Chart.svelte +2 -0
- package/dist/charts/heatmap/Chart.svelte +3 -1
- package/dist/charts/heatmap/Chart.svelte.d.ts +1 -2
- package/dist/charts/line/Chart.svelte +2 -0
- package/dist/charts/pyramid/Chart.svelte +3 -1
- 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 +13 -1
- package/dist/configuration/themes/index.d.ts +76 -0
- package/dist/index.d.ts +20 -14
- package/dist/index.js +9 -3
- package/dist/layout/coordinates/CoordinatesLayout.svelte +95 -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/geometry/GeometryLayout.svelte +231 -0
- package/dist/layout/geometry/GeometryLayout.svelte.d.ts +62 -0
- 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/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 +28 -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 +32 -33
- 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 +54 -84
- package/dist/plots/bar/Plot.svelte.d.ts +4 -5
- package/dist/plots/bar/ValueLabels.svelte +1 -1
- package/dist/plots/bar/ValueLabels.svelte.d.ts +1 -1
- 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 +24 -49
- package/dist/plots/heatmap/Plot.svelte.d.ts +4 -5
- package/dist/plots/heatmap/ValueLabels.svelte +2 -2
- package/dist/plots/heatmap/ValueLabels.svelte.d.ts +2 -2
- package/dist/plots/heatmap/buildCellMarkers.d.ts +21 -0
- package/dist/plots/heatmap/buildCellMarkers.js +25 -0
- package/dist/plots/line/Plot.svelte +68 -141
- package/dist/plots/line/Plot.svelte.d.ts +4 -4
- package/dist/plots/line/ValueLabels.svelte +94 -49
- package/dist/plots/line/ValueLabels.svelte.d.ts +6 -1
- package/dist/plots/line/buildLineMarkers.d.ts +15 -0
- package/dist/plots/line/buildLineMarkers.js +57 -0
- package/dist/plots/pyramid/Plot.svelte +41 -117
- package/dist/plots/pyramid/Plot.svelte.d.ts +4 -5
- package/dist/plots/pyramid/ValueLabels.svelte +1 -1
- package/dist/plots/pyramid/ValueLabels.svelte.d.ts +1 -1
- package/dist/plots/pyramid/buildPyramidBarMarkers.d.ts +19 -0
- package/dist/plots/pyramid/buildPyramidBarMarkers.js +32 -0
- package/dist/plots/scatter/Plot.svelte +206 -0
- package/dist/plots/{bar/BarSegments.svelte.d.ts → scatter/Plot.svelte.d.ts} +9 -20
- package/dist/plots/scatter/ValueLabels.svelte +106 -0
- package/dist/{layout/plot/GridLayout.svelte.d.ts → plots/scatter/ValueLabels.svelte.d.ts} +11 -5
- 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 +82 -33
- package/dist/plots/utils/declutter.js +182 -40
- package/dist/plots/utils/geoAccessors.d.ts +1 -1
- package/dist/plots/utils/geoAccessors.js +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 +1 -1
- package/dist/types/charts/props.d.ts +5 -6
- package/dist/types/configuration/styling.d.ts +24 -2
- package/dist/types/{plots/scales/geo.d.ts → layout/coordinates.d.ts} +33 -1
- package/dist/types/layout/geometry.d.ts +17 -0
- package/dist/types/{plots/axis.d.ts → layout/scales.d.ts} +11 -0
- package/dist/types/layout/styles.d.ts +126 -0
- package/dist/types/layout/tooltip.d.ts +20 -1
- package/dist/types/markers/all.d.ts +11 -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 +1 -1
- 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/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/{plots/axis.js → layout/coordinates.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 → markers/all.js} +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Series } from '../../types/plots/data/common';
|
|
2
|
+
import type { BarSegmentStyle } from '../../types/plots/segments/common';
|
|
3
|
+
import type { VisualGroup } from '../../types/plots/segments/config';
|
|
4
|
+
import type { HoverPoint } from '../../types/layout/tooltip';
|
|
5
|
+
import type { BarMarkerConfig } from '../../types/markers/common';
|
|
6
|
+
import type { BarLayout } from './layout.svelte';
|
|
7
|
+
/**
|
|
8
|
+
* Every `'bar'` marker for one BarPlot render: one `role: 'segment'` marker
|
|
9
|
+
* per series (stacked) or per visual segment (grouped/overlap), plus one
|
|
10
|
+
* `role: 'hitArea'` marker per category, so a chart never gets segment
|
|
11
|
+
* markers without their hit areas.
|
|
12
|
+
*
|
|
13
|
+
* `'hitArea'` geometry is left unresolved (just `category` + `data`) —
|
|
14
|
+
* resolving it to pixels needs svelteplot's live scale, only available
|
|
15
|
+
* where the marker actually renders.
|
|
16
|
+
*/
|
|
17
|
+
export declare function buildBarMarkers<TData extends Record<string, unknown>>(args: {
|
|
18
|
+
groupedSeries: VisualGroup<Series<TData>, BarSegmentStyle>[];
|
|
19
|
+
barLayout: BarLayout<TData>;
|
|
20
|
+
isHorizontal: boolean;
|
|
21
|
+
hoverPoints: HoverPoint<TData>[];
|
|
22
|
+
palette: string[];
|
|
23
|
+
disabledFillFor: (seriesName: string) => {
|
|
24
|
+
fill?: string;
|
|
25
|
+
fillOpacity?: number;
|
|
26
|
+
} | undefined;
|
|
27
|
+
active: boolean;
|
|
28
|
+
setHoverMatch: (rows: TData[]) => void;
|
|
29
|
+
clearHoverMatch: () => void;
|
|
30
|
+
}): BarMarkerConfig[];
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { resolveAccessor } from '../utils/accessors';
|
|
2
|
+
import { paletteColor } from '../../utils/color';
|
|
3
|
+
/**
|
|
4
|
+
* Every `'bar'` marker for one BarPlot render: one `role: 'segment'` marker
|
|
5
|
+
* per series (stacked) or per visual segment (grouped/overlap), plus one
|
|
6
|
+
* `role: 'hitArea'` marker per category, so a chart never gets segment
|
|
7
|
+
* markers without their hit areas.
|
|
8
|
+
*
|
|
9
|
+
* `'hitArea'` geometry is left unresolved (just `category` + `data`) —
|
|
10
|
+
* resolving it to pixels needs svelteplot's live scale, only available
|
|
11
|
+
* where the marker actually renders.
|
|
12
|
+
*/
|
|
13
|
+
export function buildBarMarkers(args) {
|
|
14
|
+
const { groupedSeries, barLayout, isHorizontal, hoverPoints, palette, disabledFillFor, active, setHoverMatch, clearHoverMatch } = args;
|
|
15
|
+
const segmentMarkers = [];
|
|
16
|
+
groupedSeries.forEach((group, seriesIndex) => {
|
|
17
|
+
const xFn = resolveAccessor(group.series.x);
|
|
18
|
+
const yFn = resolveAccessor(group.series.y);
|
|
19
|
+
const defaultColor = paletteColor(seriesIndex, palette);
|
|
20
|
+
const disabledFill = disabledFillFor(group.series.name);
|
|
21
|
+
if (barLayout.layout === 'stacked') {
|
|
22
|
+
const stackedBaselineFn = (d) => barLayout.stackedBaseline(xFn(d), seriesIndex);
|
|
23
|
+
const stackedTopFn = (d) => barLayout.stackedBaseline(xFn(d), seriesIndex) + Number(yFn(d));
|
|
24
|
+
const marker = {
|
|
25
|
+
type: 'bar',
|
|
26
|
+
role: 'segment',
|
|
27
|
+
isHorizontal,
|
|
28
|
+
data: group.series.data,
|
|
29
|
+
style: {
|
|
30
|
+
fill: disabledFill?.fill ?? defaultColor,
|
|
31
|
+
fillOpacity: disabledFill?.fillOpacity ?? 1,
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
if (isHorizontal) {
|
|
35
|
+
marker.y = xFn;
|
|
36
|
+
marker.x1 = stackedBaselineFn;
|
|
37
|
+
marker.x2 = stackedTopFn;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
marker.x = xFn;
|
|
41
|
+
marker.y1 = stackedBaselineFn;
|
|
42
|
+
marker.y2 = stackedTopFn;
|
|
43
|
+
}
|
|
44
|
+
segmentMarkers.push(marker);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
for (const seg of group.visualSegments) {
|
|
48
|
+
const marker = {
|
|
49
|
+
type: 'bar',
|
|
50
|
+
role: 'segment',
|
|
51
|
+
isHorizontal,
|
|
52
|
+
data: seg.data,
|
|
53
|
+
style: {
|
|
54
|
+
fill: disabledFill?.fill ?? seg.style.fill ?? defaultColor,
|
|
55
|
+
fillOpacity: disabledFill?.fillOpacity ?? seg.style.fillOpacity ?? 1,
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
if (isHorizontal) {
|
|
59
|
+
marker.y = xFn;
|
|
60
|
+
marker.x1 = barLayout.valueBaseline;
|
|
61
|
+
marker.x2 = yFn;
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
marker.x = xFn;
|
|
65
|
+
marker.y1 = barLayout.valueBaseline;
|
|
66
|
+
marker.y2 = yFn;
|
|
67
|
+
}
|
|
68
|
+
if (barLayout.layout === 'grouped') {
|
|
69
|
+
if (isHorizontal) {
|
|
70
|
+
marker.insetTop = seriesIndex * barLayout.seriesStep + barLayout.seriesGap / 2;
|
|
71
|
+
marker.insetBottom = (barLayout.seriesCount - 1 - seriesIndex) * barLayout.seriesStep + barLayout.seriesGap / 2;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
marker.insetLeft = seriesIndex * barLayout.seriesStep + barLayout.seriesGap / 2;
|
|
75
|
+
marker.insetRight = (barLayout.seriesCount - 1 - seriesIndex) * barLayout.seriesStep + barLayout.seriesGap / 2;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
segmentMarkers.push(marker);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const byCategory = new Map();
|
|
82
|
+
for (const p of hoverPoints) {
|
|
83
|
+
const key = isHorizontal ? p.y : p.x;
|
|
84
|
+
const list = byCategory.get(key);
|
|
85
|
+
if (list)
|
|
86
|
+
list.push(p);
|
|
87
|
+
else
|
|
88
|
+
byCategory.set(key, [p]);
|
|
89
|
+
}
|
|
90
|
+
const hitAreaMarkers = [...byCategory.entries()].map(([category, points]) => ({
|
|
91
|
+
type: 'bar',
|
|
92
|
+
role: 'hitArea',
|
|
93
|
+
isHorizontal,
|
|
94
|
+
category,
|
|
95
|
+
data: points.map((p) => p.row),
|
|
96
|
+
onpointerenter: active ? () => setHoverMatch(points.map((p) => p.row)) : undefined,
|
|
97
|
+
onpointerleave: active ? clearHoverMatch : undefined,
|
|
98
|
+
}));
|
|
99
|
+
return [...segmentMarkers, ...hitAreaMarkers];
|
|
100
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { AxisValue } from '../../types/
|
|
1
|
+
import type { AxisValue, AxisBasedScalesConfig } from '../../types/layout/scales';
|
|
2
2
|
import type { Series } from '../../types/plots/data/common';
|
|
3
|
-
import type { AxisBasedScalesConfig } from '../../types/plots/props';
|
|
4
3
|
import type { BarSegmentStyle } from '../../types/plots/segments/common';
|
|
5
4
|
import type { VisualGroup } from '../../types/plots/segments/config';
|
|
6
5
|
import type { MarginConfig } from '../../types/plots/props';
|
|
@@ -13,7 +13,7 @@ export function createBarLayout(args) {
|
|
|
13
13
|
const cfg = $derived(getConfiguration());
|
|
14
14
|
/**
|
|
15
15
|
* How series sharing the same category are arranged — see
|
|
16
|
-
* {@link import('../../types/
|
|
16
|
+
* {@link import('../../types/layout/scales').AxisScale.seriesLayout}. Read
|
|
17
17
|
* off `scales.z` since it's the grouping axis, not the category axis itself.
|
|
18
18
|
*/
|
|
19
19
|
const layout = $derived(args.scales().z?.seriesLayout ?? 'overlap');
|