@fundar/data-chart-telling 1.16.0 → 1.18.0
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/CHANGELOG.md +56 -0
- package/dist/configuration/ConfigVars.svelte +14 -0
- package/dist/configuration/ConfigVars.svelte.d.ts +3 -0
- package/dist/configuration/config.svelte.d.ts +5 -0
- package/dist/configuration/config.svelte.js +20 -6
- package/dist/configuration/themes/dark.js +1 -1
- package/dist/configuration/themes/editorial.js +1 -1
- package/dist/index.d.ts +12 -4
- package/dist/index.js +4 -1
- package/dist/layout/base/BasePlotLayout.svelte +1 -1
- package/dist/layout/figure/Figure.svelte +5 -12
- package/dist/layout/figure/FigureChrome.svelte +2 -10
- package/dist/layout/geometry/GeometryLayout.svelte +219 -44
- package/dist/layout/hover/HoverDefaults.d.ts +52 -0
- package/dist/layout/hover/HoverDefaults.js +96 -0
- package/dist/layout/hover/HoverLayers.d.ts +35 -0
- package/dist/layout/hover/HoverLayers.js +122 -0
- package/dist/layout/hover/HoverSettings.js +4 -1
- package/dist/layout/hover/HoverShapes.d.ts +44 -0
- package/dist/layout/hover/HoverShapes.js +103 -0
- package/dist/layout/hover/PlotHover.svelte.d.ts +18 -0
- package/dist/layout/hover/PlotHover.svelte.js +54 -1
- package/dist/layout/legend/DisabledStyle.d.ts +1 -1
- package/dist/layout/legend/DisabledStyle.js +1 -1
- package/dist/layout/legend/DiscreteBadgeItem.svelte +1 -1
- package/dist/layout/legend/DiscreteSection.svelte +1 -1
- package/dist/layout/legend/LegendState.svelte.d.ts +14 -2
- package/dist/layout/legend/LegendState.svelte.js +23 -4
- package/dist/layout/legend/LegendText.d.ts +4 -1
- package/dist/layout/legend/LegendText.js +7 -1
- package/dist/layout/margins/PlotMargins.svelte.d.ts +2 -2
- package/dist/layout/margins/PlotMargins.svelte.js +2 -2
- package/dist/layout/plot/Core.svelte +2 -2
- package/dist/layout/plot/Plot.svelte +4 -2
- package/dist/layout/plot/Plot.svelte.d.ts +2 -1
- package/dist/layout/plot/PublicPlotContext.d.ts +6 -0
- package/dist/layout/plot/PublicPlotContext.js +8 -0
- package/dist/layout/scales/ScalesLayout.svelte +1 -1
- package/dist/layout/styles/ValueLabels.d.ts +43 -4
- package/dist/layout/styles/ValueLabels.js +87 -19
- package/dist/layout/timeline/Timeline.svelte +5 -1
- package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -9
- package/dist/layout/tooltip/TooltipState.svelte.js +28 -29
- package/dist/markers/MarkerKinds.d.ts +5 -0
- package/dist/markers/MarkerKinds.js +1 -0
- package/dist/markers/area/AreaMarker.svelte +3 -0
- package/dist/markers/arrow/ArrowMarker.svelte +9 -5
- package/dist/markers/band/BandMarker.svelte +74 -0
- package/dist/markers/band/BandMarker.svelte.d.ts +7 -0
- package/dist/markers/band/Bands.d.ts +16 -0
- package/dist/markers/band/Bands.js +48 -0
- package/dist/markers/bar/BarMarker.svelte +50 -96
- package/dist/markers/bollinger/BollingerMarker.svelte +3 -0
- package/dist/markers/box/BoxMarker.svelte +3 -1
- package/dist/markers/cell/CellMarker.svelte +11 -7
- package/dist/markers/contour/ContourMarker.svelte +3 -0
- package/dist/markers/delaunay/DelaunayLinkMarker.svelte +9 -5
- package/dist/markers/delaunay/DelaunayMeshMarker.svelte +3 -0
- package/dist/markers/density/DensityMarker.svelte +3 -0
- package/dist/markers/difference/DifferenceMarker.svelte +3 -0
- package/dist/markers/dot/DotMarker.svelte +11 -6
- package/dist/markers/geo/GraticuleMarker.svelte +3 -0
- package/dist/markers/geo/SphereMarker.svelte +3 -0
- package/dist/markers/hover/HoverMarker.svelte +7 -249
- package/dist/markers/hover/HoverMarker.svelte.d.ts +4 -27
- package/dist/markers/hull/HullMarker.svelte +3 -0
- package/dist/markers/image/ImageMarker.svelte +3 -0
- package/dist/markers/line/LineMarker.svelte +3 -0
- package/dist/markers/link/LinkMarker.svelte +3 -0
- package/dist/markers/raster/RasterMarker.svelte +3 -0
- package/dist/markers/rect/RectMarker.svelte +25 -17
- package/dist/markers/regression/RegressionMarker.svelte +3 -0
- package/dist/markers/rule/RuleMarker.svelte +15 -5
- package/dist/markers/text/TextFit.d.ts +44 -0
- package/dist/markers/text/TextFit.js +86 -0
- package/dist/markers/text/TextMarker.svelte +186 -90
- package/dist/markers/text/TextMarker.svelte.d.ts +2 -0
- package/dist/markers/tick/TickMarker.svelte +9 -3
- package/dist/markers/trail/TrailMarker.svelte +3 -0
- package/dist/markers/utils/BoxLabel.d.ts +58 -0
- package/dist/markers/utils/BoxLabel.js +175 -0
- package/dist/markers/utils/MarkerEvents.d.ts +23 -0
- package/dist/markers/utils/MarkerEvents.js +44 -0
- package/dist/markers/utils/MarkerLabel.svelte +33 -0
- package/dist/markers/utils/MarkerLabel.svelte.d.ts +10 -0
- package/dist/markers/utils/PointPixel.d.ts +37 -0
- package/dist/markers/utils/PointPixel.js +44 -0
- package/dist/markers/utils/RowStroke.d.ts +9 -21
- package/dist/markers/utils/RowStroke.js +10 -21
- package/dist/markers/utils/RowStyle.d.ts +26 -0
- package/dist/markers/utils/RowStyle.js +55 -0
- package/dist/markers/vector/VectorMarker.svelte +3 -0
- package/dist/markers/voronoi/VoronoiMarker.svelte +9 -5
- package/dist/markers/voronoi/VoronoiMeshMarker.svelte +3 -0
- package/dist/markers/waffle/WaffleMarker.svelte +9 -5
- package/dist/phases/Pipeline.d.ts +10 -8
- package/dist/phases/Pipeline.js +13 -9
- package/dist/phases/context/ContextPhase.d.ts +22 -0
- package/dist/phases/context/ContextPhase.js +23 -0
- package/dist/phases/context/RowContext.d.ts +35 -0
- package/dist/phases/context/RowContext.js +95 -0
- package/dist/phases/data/DataPhase.d.ts +4 -4
- package/dist/phases/data/DataPhase.js +53 -12
- package/dist/phases/hover/HoverPhase.d.ts +6 -7
- package/dist/phases/hover/HoverPhase.js +28 -15
- package/dist/phases/mapping/MappingPhase.d.ts +4 -4
- package/dist/phases/mapping/MappingPhase.js +4 -3
- package/dist/phases/markers/MarkerStyles.d.ts +26 -0
- package/dist/phases/markers/MarkerStyles.js +126 -0
- package/dist/phases/markers/MarkersPhase.d.ts +5 -5
- package/dist/phases/markers/MarkersPhase.js +8 -6
- package/dist/phases/scales/ScalesPhase.d.ts +4 -4
- package/dist/phases/scales/ScalesPhase.js +4 -4
- package/dist/phases/sharedScales/SharedScalesPhase.d.ts +2 -2
- package/dist/phases/sharedScales/SharedScalesPhase.js +2 -2
- package/dist/phases/statistics/MarkerGrouping.d.ts +0 -9
- package/dist/phases/statistics/MarkerGrouping.js +0 -16
- package/dist/phases/statistics/StatisticsPhase.js +1 -1
- package/dist/phases/styles/StylesPhase.d.ts +3 -3
- package/dist/phases/styles/StylesPhase.js +2 -2
- package/dist/phases/tooltip/TooltipPhase.d.ts +4 -4
- package/dist/phases/tooltip/TooltipPhase.js +10 -7
- package/dist/phases/transforms/Transforms.js +3 -1
- package/dist/phases/transforms/TransformsPhase.d.ts +3 -3
- package/dist/phases/transforms/TransformsPhase.js +60 -6
- package/dist/phases/transforms/methods/TreemapTransform.d.ts +28 -0
- package/dist/phases/transforms/methods/TreemapTransform.js +119 -0
- package/dist/plots/correlation/heatmap/defaults.d.ts +2 -2
- package/dist/plots/correlation/heatmap/defaults.js +23 -8
- package/dist/plots/correlation/heatmap/markers.d.ts +2 -10
- package/dist/plots/correlation/heatmap/markers.js +11 -37
- package/dist/plots/correlation/scatter/defaults.d.ts +2 -2
- package/dist/plots/correlation/scatter/defaults.js +9 -3
- package/dist/plots/correlation/scatter/markers.d.ts +3 -3
- package/dist/plots/correlation/scatter/markers.js +6 -5
- package/dist/plots/distribution/box/BoxSummaries.d.ts +17 -8
- package/dist/plots/distribution/box/BoxSummaries.js +90 -40
- package/dist/plots/distribution/box/defaults.d.ts +2 -2
- package/dist/plots/distribution/box/defaults.js +9 -6
- package/dist/plots/distribution/box/markers.d.ts +2 -2
- package/dist/plots/distribution/box/markers.js +3 -3
- package/dist/plots/distribution/density/defaults.d.ts +2 -2
- package/dist/plots/distribution/density/defaults.js +17 -1
- package/dist/plots/distribution/density/markers.d.ts +2 -2
- package/dist/plots/distribution/density/markers.js +4 -4
- package/dist/plots/distribution/histogram/defaults.d.ts +2 -2
- package/dist/plots/distribution/histogram/defaults.js +22 -27
- package/dist/plots/distribution/histogram/markers.d.ts +3 -12
- package/dist/plots/distribution/histogram/markers.js +21 -62
- package/dist/plots/distribution/pyramid/defaults.d.ts +2 -2
- package/dist/plots/distribution/pyramid/defaults.js +7 -4
- package/dist/plots/distribution/pyramid/markers.d.ts +2 -12
- package/dist/plots/distribution/pyramid/markers.js +16 -66
- package/dist/plots/distribution/violin/defaults.d.ts +2 -2
- package/dist/plots/distribution/violin/defaults.js +9 -7
- package/dist/plots/distribution/violin/markers.d.ts +2 -2
- package/dist/plots/distribution/violin/markers.js +4 -4
- package/dist/plots/evolution/area/defaults.d.ts +2 -2
- package/dist/plots/evolution/area/defaults.js +1 -1
- package/dist/plots/evolution/area/markers.d.ts +2 -2
- package/dist/plots/evolution/area/markers.js +4 -4
- package/dist/plots/evolution/line/defaults.d.ts +2 -2
- package/dist/plots/evolution/line/defaults.js +1 -1
- package/dist/plots/evolution/line/markers.d.ts +2 -2
- package/dist/plots/evolution/line/markers.js +3 -3
- package/dist/plots/evolution/slope/defaults.d.ts +2 -2
- package/dist/plots/evolution/slope/defaults.js +8 -4
- package/dist/plots/evolution/slope/markers.d.ts +2 -2
- package/dist/plots/evolution/slope/markers.js +3 -3
- package/dist/plots/evolution/sparkline/defaults.d.ts +2 -2
- package/dist/plots/evolution/sparkline/defaults.js +5 -2
- package/dist/plots/evolution/sparkline/markers.d.ts +2 -2
- package/dist/plots/evolution/sparkline/markers.js +3 -3
- package/dist/plots/map/geo/Core.svelte +3 -3
- package/dist/plots/map/geo/defaults.d.ts +2 -2
- package/dist/plots/map/geo/phases/data.d.ts +1 -1
- package/dist/plots/map/geo/phases/data.js +1 -1
- package/dist/plots/map/geo/phases/hover.d.ts +2 -2
- package/dist/plots/map/geo/phases/hover.js +3 -3
- package/dist/plots/map/geo/phases/markers.d.ts +2 -2
- package/dist/plots/map/geo/phases/markers.js +5 -4
- package/dist/plots/map/geo/phases/scales.d.ts +2 -2
- package/dist/plots/map/geo/phases/scales.js +2 -2
- package/dist/plots/part-of-a-whole/treemap/Plot.svelte +47 -0
- package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +26 -0
- package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +10 -0
- package/dist/plots/part-of-a-whole/treemap/defaults.js +183 -0
- package/dist/plots/ranking/bar/defaults.d.ts +2 -2
- package/dist/plots/ranking/bar/defaults.js +15 -9
- package/dist/plots/ranking/bar/markers.d.ts +4 -14
- package/dist/plots/ranking/bar/markers.js +45 -86
- package/dist/plots/ranking/bullet/defaults.d.ts +2 -2
- package/dist/plots/ranking/bullet/defaults.js +4 -4
- package/dist/plots/ranking/bullet/markers.d.ts +3 -3
- package/dist/plots/ranking/bullet/markers.js +11 -12
- package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +3 -3
- package/dist/plots/ranking/cleveland/ClevelandMarkers.js +28 -23
- package/dist/plots/ranking/cleveland/defaults.d.ts +2 -2
- package/dist/plots/ranking/cleveland/defaults.js +7 -4
- package/dist/plots/ranking/dumbbell/defaults.d.ts +2 -2
- package/dist/plots/ranking/forest/defaults.d.ts +2 -2
- package/dist/plots/ranking/lollipop/defaults.d.ts +2 -2
- package/dist/types/configuration/styling.d.ts +31 -2
- package/dist/types/layout/context.d.ts +21 -0
- package/dist/types/layout/context.js +1 -0
- package/dist/types/layout/hover.d.ts +3 -0
- package/dist/types/layout/legend.d.ts +8 -1
- package/dist/types/layout/mapping.d.ts +12 -3
- package/dist/types/layout/scales.d.ts +6 -0
- package/dist/types/layout/styles/values.d.ts +8 -2
- package/dist/types/layout/tooltip.d.ts +11 -4
- package/dist/types/markers/axis/arrow.d.ts +2 -8
- package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
- package/dist/types/markers/axis/band.d.ts +24 -0
- package/dist/types/markers/axis/band.js +1 -0
- package/dist/types/markers/axis/bar.d.ts +6 -10
- package/dist/types/markers/axis/cell.d.ts +5 -5
- package/dist/types/markers/axis/delaunayLink.d.ts +2 -2
- package/dist/types/markers/axis/hover.d.ts +60 -15
- package/dist/types/markers/axis/rect.d.ts +4 -8
- package/dist/types/markers/axis/rule.d.ts +2 -16
- package/dist/types/markers/axis/tick.d.ts +2 -2
- package/dist/types/markers/axis/voronoi.d.ts +2 -2
- package/dist/types/markers/axis/waffle.d.ts +4 -3
- package/dist/types/markers/basic/dot.d.ts +2 -2
- package/dist/types/markers/basic/text.d.ts +56 -14
- package/dist/types/markers/channels/commonMarkerConfig.d.ts +8 -1
- package/dist/types/markers/channels/commonMarkerConfigWithArea.d.ts +1 -2
- package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +10 -0
- package/dist/types/markers/channels/commonMarkerConfigWithLabel.js +1 -0
- package/dist/types/markers/channels/commonMarkerEvents.d.ts +17 -0
- package/dist/types/markers/channels/commonMarkerEvents.js +13 -0
- package/dist/types/markers/common.d.ts +1 -0
- package/dist/types/markers/common.js +1 -0
- package/dist/types/markers/geo/contour.d.ts +2 -1
- package/dist/types/markers/geo/graticule.d.ts +2 -1
- package/dist/types/markers/geo/link.d.ts +2 -1
- package/dist/types/markers/geo/sphere.d.ts +2 -1
- package/dist/types/markers/geo/vector.d.ts +2 -1
- package/dist/types/phases/context/phase.d.ts +7 -0
- package/dist/types/phases/context/phase.js +1 -0
- package/dist/types/phases/data/phase.d.ts +7 -2
- package/dist/types/phases/hover/phase.d.ts +10 -5
- package/dist/types/phases/index.d.ts +2 -1
- package/dist/types/phases/kind.d.ts +11 -8
- package/dist/types/phases/mapping/phase.d.ts +2 -2
- package/dist/types/phases/markers/phase.d.ts +3 -3
- package/dist/types/phases/scales/phase.d.ts +4 -4
- package/dist/types/phases/stage.d.ts +3 -3
- package/dist/types/phases/state.d.ts +8 -1
- package/dist/types/phases/statistics/phase.d.ts +2 -1
- package/dist/types/phases/styles/phase.d.ts +3 -2
- package/dist/types/phases/transforms/phase.d.ts +13 -2
- package/dist/types/plots/constants.d.ts +17 -19
- package/dist/types/plots/correlation/heatmap/props.d.ts +3 -3
- package/dist/types/plots/correlation/heatmap/state.d.ts +2 -2
- package/dist/types/plots/correlation/scatter/props.d.ts +3 -3
- package/dist/types/plots/correlation/scatter/state.d.ts +2 -2
- package/dist/types/plots/data/common.d.ts +19 -6
- package/dist/types/plots/data/geo.d.ts +1 -1
- package/dist/types/plots/distribution/box/props.d.ts +25 -3
- package/dist/types/plots/distribution/box/state.d.ts +6 -17
- package/dist/types/plots/distribution/density/props.d.ts +3 -11
- package/dist/types/plots/distribution/density/state.d.ts +2 -2
- package/dist/types/plots/distribution/histogram/props.d.ts +16 -11
- package/dist/types/plots/distribution/histogram/state.d.ts +2 -2
- package/dist/types/plots/distribution/pyramid/props.d.ts +3 -3
- package/dist/types/plots/distribution/pyramid/state.d.ts +2 -2
- package/dist/types/plots/distribution/violin/props.d.ts +4 -3
- package/dist/types/plots/distribution/violin/state.d.ts +2 -2
- package/dist/types/plots/evolution/area/props.d.ts +3 -3
- package/dist/types/plots/evolution/area/state.d.ts +2 -2
- package/dist/types/plots/evolution/line/props.d.ts +3 -3
- package/dist/types/plots/evolution/line/state.d.ts +2 -2
- package/dist/types/plots/evolution/slope/state.d.ts +2 -2
- package/dist/types/plots/evolution/sparkline/state.d.ts +2 -2
- package/dist/types/plots/map/geo/state.d.ts +1 -1
- package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +29 -0
- package/dist/types/plots/part-of-a-whole/treemap/props.js +1 -0
- package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +6 -0
- package/dist/types/plots/part-of-a-whole/treemap/state.js +1 -0
- package/dist/types/plots/props.d.ts +10 -4
- package/dist/types/plots/ranking/bar/props.d.ts +3 -3
- package/dist/types/plots/ranking/bar/state.d.ts +2 -2
- package/dist/types/plots/ranking/bullet/state.d.ts +2 -2
- package/dist/types/plots/ranking/cleveland/props.d.ts +3 -3
- package/dist/types/plots/ranking/cleveland/state.d.ts +2 -2
- package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -3
- package/dist/types/plots/ranking/dumbbell/state.d.ts +2 -2
- package/dist/types/plots/ranking/forest/props.d.ts +3 -3
- package/dist/types/plots/ranking/forest/state.d.ts +2 -2
- package/dist/types/plots/ranking/lollipop/props.d.ts +3 -3
- package/dist/types/plots/ranking/lollipop/state.d.ts +2 -2
- package/dist/types/plots/styling.d.ts +24 -0
- package/dist/types/transforms/index.d.ts +3 -1
- package/dist/types/transforms/treemap.d.ts +32 -0
- package/dist/types/transforms/treemap.js +5 -0
- package/dist/utils/color/ColorTones.d.ts +19 -0
- package/dist/utils/color/ColorTones.js +64 -0
- package/dist/utils/color/CssColor.d.ts +14 -5
- package/dist/utils/color/CssColor.js +69 -27
- package/dist/utils/color/index.d.ts +4 -0
- package/dist/utils/color/index.js +4 -0
- package/dist/utils/grouping.d.ts +18 -1
- package/dist/utils/grouping.js +31 -0
- package/docs/concepts.md +3 -2
- package/docs/legend.md +8 -5
- package/docs/markers.md +110 -28
- package/docs/plots/evolution/line.md +1 -1
- package/docs/plots/evolution/slope.md +1 -1
- package/docs/plots/part-of-a-whole/treemap.md +103 -0
- package/docs/plots/ranking/bar.md +2 -1
- package/docs/plots/ranking/cleveland.md +1 -1
- package/docs/plots.md +21 -20
- package/docs/scales.md +3 -0
- package/docs/state.md +34 -1
- package/docs/styles-and-segments.md +20 -19
- package/docs/theming.md +6 -12
- package/docs/tooltip-and-hover.md +81 -3
- package/docs/transforms-and-statistics.md +17 -16
- package/examples/LineDates.svelte +1 -1
- package/examples/ResponsiveLine.svelte +3 -1
- package/examples/Treemap.svelte +13 -0
- package/examples/TreemapHover.svelte +25 -0
- package/examples/ValueLabels.svelte +1 -1
- package/examples/datasets/economic-activity.ts +40 -0
- package/examples/datasets/index.ts +1 -0
- package/llms-full.txt +11 -9
- package/llms.txt +4 -1
- package/package.json +3 -1
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { HoverShapeStyle } from '../../types/markers/common';
|
|
2
|
+
import type { PlotStylesConfig } from '../../types/configuration/styling';
|
|
3
|
+
type Row = Record<string, unknown>;
|
|
4
|
+
type Role = 'active' | 'other';
|
|
5
|
+
/** What a hover marker sets for the shapes linked to the hover. */
|
|
6
|
+
type ShapeRule = {
|
|
7
|
+
active?: HoverShapeStyle;
|
|
8
|
+
others?: HoverShapeStyle;
|
|
9
|
+
series?: string;
|
|
10
|
+
};
|
|
11
|
+
/** What the plot tells about each row the shapes draw. */
|
|
12
|
+
export type HoverShapesReach = {
|
|
13
|
+
/** How the hover reaches a row - see `PlotHover.roleOf`. */
|
|
14
|
+
roleOf: (row: Row, series?: string) => Role | null;
|
|
15
|
+
/** Whether the legend dims the row's series, which then keeps its own fill and opacities. */
|
|
16
|
+
dimmed: (row: Row) => boolean;
|
|
17
|
+
cfg: PlotStylesConfig;
|
|
18
|
+
};
|
|
19
|
+
/** One part of a marker: its rows that the hover styles alike, keyed by how. */
|
|
20
|
+
export type HoverShapesPart<T> = {
|
|
21
|
+
key: string;
|
|
22
|
+
marker: T;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* The look the plot's hover markers give the shapes of every marker linked to the hover (`hover: true` or
|
|
26
|
+
* `'style'`): the hovered ones take `active`, the others `others`, each over the shape's own style. A shape
|
|
27
|
+
* the legend dims keeps its own fill and opacities; one the hover cannot reach (hidden, omitted) is untouched.
|
|
28
|
+
*/
|
|
29
|
+
export declare class HoverShapes {
|
|
30
|
+
#private;
|
|
31
|
+
constructor(markers: readonly ({
|
|
32
|
+
type: string;
|
|
33
|
+
} & ShapeRule)[]);
|
|
34
|
+
/** Whether any hover marker restyles shapes. */
|
|
35
|
+
get any(): boolean;
|
|
36
|
+
/** Whether `marker`'s shapes take the hover's styles. */
|
|
37
|
+
static links(marker: object): boolean;
|
|
38
|
+
/**
|
|
39
|
+
* `marker` in parts, each drawing the rows the hover styles alike - the shapes it does not style first, the
|
|
40
|
+
* hovered ones last, so their outline is on top. A marker the hover does not style is one part, as it is.
|
|
41
|
+
*/
|
|
42
|
+
split<T extends object>(marker: T, rows: readonly unknown[], reach: HoverShapesReach): HoverShapesPart<T>[];
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { MarkerStyles } from '../../phases/markers/MarkerStyles';
|
|
2
|
+
import { SERIES_KEY } from '../../phases/transforms/TransformsPhase';
|
|
3
|
+
/**
|
|
4
|
+
* The look the plot's hover markers give the shapes of every marker linked to the hover (`hover: true` or
|
|
5
|
+
* `'style'`): the hovered ones take `active`, the others `others`, each over the shape's own style. A shape
|
|
6
|
+
* the legend dims keeps its own fill and opacities; one the hover cannot reach (hidden, omitted) is untouched.
|
|
7
|
+
*/
|
|
8
|
+
export class HoverShapes {
|
|
9
|
+
/** What the legend owns on a dimmed shape. */
|
|
10
|
+
static #LEGEND_KEYS = ['fill', 'fillOpacity', 'strokeOpacity'];
|
|
11
|
+
/** A shape style's field as a `dot` marker names it. */
|
|
12
|
+
static #DOT_KEYS = {
|
|
13
|
+
fill: 'dotFill',
|
|
14
|
+
fillOpacity: 'dotFillOpacity',
|
|
15
|
+
stroke: 'dotStroke',
|
|
16
|
+
strokeWidth: 'dotStrokeWidth',
|
|
17
|
+
strokeOpacity: 'dotStrokeOpacity',
|
|
18
|
+
strokeDasharray: 'dotStrokeDasharray'
|
|
19
|
+
};
|
|
20
|
+
#rules;
|
|
21
|
+
constructor(markers) {
|
|
22
|
+
this.#rules = markers.filter((m) => m.type === 'hover' && !!(m.active || m.others));
|
|
23
|
+
}
|
|
24
|
+
/** Whether any hover marker restyles shapes. */
|
|
25
|
+
get any() {
|
|
26
|
+
return this.#rules.length > 0;
|
|
27
|
+
}
|
|
28
|
+
/** Whether `marker`'s shapes take the hover's styles. */
|
|
29
|
+
static links(marker) {
|
|
30
|
+
const hover = marker.hover;
|
|
31
|
+
return hover === true || hover === 'style';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* `marker` in parts, each drawing the rows the hover styles alike - the shapes it does not style first, the
|
|
35
|
+
* hovered ones last, so their outline is on top. A marker the hover does not style is one part, as it is.
|
|
36
|
+
*/
|
|
37
|
+
split(marker, rows, reach) {
|
|
38
|
+
const whole = [{ key: '', marker }];
|
|
39
|
+
if (!this.any || !HoverShapes.links(marker))
|
|
40
|
+
return whole;
|
|
41
|
+
const data = (marker.data ?? rows);
|
|
42
|
+
const buckets = new Map();
|
|
43
|
+
for (const row of data) {
|
|
44
|
+
const key = this.#signature(row, reach);
|
|
45
|
+
const bucket = buckets.get(key) ?? buckets.set(key, []).get(key);
|
|
46
|
+
bucket.push(row);
|
|
47
|
+
}
|
|
48
|
+
if (buckets.size === 1 && buckets.has(''))
|
|
49
|
+
return whole;
|
|
50
|
+
const plain = (key) => !key.includes('a');
|
|
51
|
+
return [...buckets.entries()]
|
|
52
|
+
.sort(([a], [b]) => Number(plain(b)) - Number(plain(a)))
|
|
53
|
+
.map(([key, part]) => ({
|
|
54
|
+
key,
|
|
55
|
+
marker: key === '' ? { ...marker, data: part } : this.#restyled(marker, part, key, reach)
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* How the hover styles `row`: for each rule, `a` (active), `o` (other) or `-` (not at all), and `~` when the
|
|
60
|
+
* legend dims it. `''` while no rule styles it.
|
|
61
|
+
*/
|
|
62
|
+
#signature(row, reach) {
|
|
63
|
+
const own = row[SERIES_KEY];
|
|
64
|
+
const roles = this.#rules.map((rule) => {
|
|
65
|
+
if (rule.series !== undefined && own !== rule.series)
|
|
66
|
+
return '-';
|
|
67
|
+
const role = reach.roleOf(row, rule.series);
|
|
68
|
+
if (role === 'active')
|
|
69
|
+
return rule.active ? 'a' : '-';
|
|
70
|
+
if (role === 'other')
|
|
71
|
+
return rule.others ? 'o' : '-';
|
|
72
|
+
return '-';
|
|
73
|
+
});
|
|
74
|
+
if (roles.every((role) => role === '-'))
|
|
75
|
+
return '';
|
|
76
|
+
return roles.join('') + (reach.dimmed(row) ? '~' : '');
|
|
77
|
+
}
|
|
78
|
+
/** `marker` over `rows`, with the styles `key` stands for over its own. */
|
|
79
|
+
#restyled(marker, rows, key, reach) {
|
|
80
|
+
const dimmed = key.endsWith('~');
|
|
81
|
+
const styles = this.#rules.reduce((merged, rule, i) => {
|
|
82
|
+
const role = key[i];
|
|
83
|
+
const style = role === 'a' ? rule.active : role === 'o' ? rule.others : undefined;
|
|
84
|
+
return {
|
|
85
|
+
...merged,
|
|
86
|
+
...HoverShapes.#named(HoverShapes.#defined(style, dimmed), marker)
|
|
87
|
+
};
|
|
88
|
+
}, { ...marker.styles });
|
|
89
|
+
return MarkerStyles.restyle({ ...marker, data: rows, styles }, { cfg: reach.cfg, rows });
|
|
90
|
+
}
|
|
91
|
+
/** `style` as `marker` names its fields: a `dot` marker's are its `dot` ones (`dotFill`...). */
|
|
92
|
+
static #named(style, marker) {
|
|
93
|
+
if (marker.type !== 'dot')
|
|
94
|
+
return style;
|
|
95
|
+
const keys = HoverShapes.#DOT_KEYS;
|
|
96
|
+
return Object.fromEntries(Object.entries(style).map(([name, value]) => [keys[name] ?? name, value]));
|
|
97
|
+
}
|
|
98
|
+
/** `style`'s set values, without what the legend owns on a dimmed shape. */
|
|
99
|
+
static #defined(style, dimmed) {
|
|
100
|
+
return Object.fromEntries(Object.entries(style ?? {}).filter(([name, value]) => value !== undefined &&
|
|
101
|
+
!(dimmed && HoverShapes.#LEGEND_KEYS.includes(name))));
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HoverState } from './HoverState.svelte';
|
|
2
2
|
import type { AxisValue } from '../../types/layout/mapping';
|
|
3
3
|
import type { HoverPoint } from '../../types/layout/hover';
|
|
4
|
+
import type { HoverLook } from '../../types/markers/common';
|
|
4
5
|
import type { HoverConfig } from '../../types/plots/props';
|
|
5
6
|
/** What a plot's hover is built from, each read reactively. */
|
|
6
7
|
export type PlotHoverInputs<T extends Record<string, unknown>> = {
|
|
@@ -23,6 +24,12 @@ export declare class PlotHover<T extends Record<string, unknown>> {
|
|
|
23
24
|
#private;
|
|
24
25
|
readonly state: HoverState;
|
|
25
26
|
constructor(inputs: PlotHoverInputs<T>);
|
|
27
|
+
/**
|
|
28
|
+
* How the hover reaches `row`: `'active'` while it is matched, `'other'` while it can be hovered but is not,
|
|
29
|
+
* `null` while nothing is hovered here or it is no row the hover can reach (one the legend hides). A row is
|
|
30
|
+
* found by identity, else by its x, y and `series`. `series` narrows the active rows to that series.
|
|
31
|
+
*/
|
|
32
|
+
roleOf(row: T, series?: string): 'active' | 'other' | null;
|
|
26
33
|
/** The matched points the tooltip reads: only the tooltip's `series`, when it names some. */
|
|
27
34
|
readonly matchedRows: HoverPoint<T>[];
|
|
28
35
|
/** The points the hover marker highlights. */
|
|
@@ -33,6 +40,7 @@ export declare class PlotHover<T extends Record<string, unknown>> {
|
|
|
33
40
|
series: string | undefined;
|
|
34
41
|
color: string | undefined;
|
|
35
42
|
areaInset: import("../../types/layout/hover").BandSlice | undefined;
|
|
43
|
+
context: import("../..").PlotRowContext | undefined;
|
|
36
44
|
row: T;
|
|
37
45
|
}[];
|
|
38
46
|
/**
|
|
@@ -40,10 +48,20 @@ export declare class PlotHover<T extends Record<string, unknown>> {
|
|
|
40
48
|
* among ties, the one at the hovered x and y. Crosshair rules sit on it.
|
|
41
49
|
*/
|
|
42
50
|
readonly activePoint: HoverPoint<T> | null;
|
|
51
|
+
/**
|
|
52
|
+
* The plot kind's own hover under the strategy in force - the figure's, which a composer or a scrolly step can
|
|
53
|
+
* change while the plot is shown - for an author's `hover` marker to be laid over.
|
|
54
|
+
*/
|
|
55
|
+
get look(): HoverLook;
|
|
43
56
|
/** Whether a crosshair rule runs across x - the strategy's, unless the config turns them off. */
|
|
44
57
|
get impliesCrosshairX(): boolean;
|
|
45
58
|
/** Whether a crosshair rule runs across y. */
|
|
46
59
|
get impliesCrosshairY(): boolean;
|
|
60
|
+
/** The pointer's position in the plot's box, while it is over this plot. */
|
|
61
|
+
get cursor(): {
|
|
62
|
+
x: number;
|
|
63
|
+
y: number;
|
|
64
|
+
} | null;
|
|
47
65
|
/** Whether the tooltip shows: under the cursor in the owning plot, in every synced one. */
|
|
48
66
|
get showTooltip(): boolean;
|
|
49
67
|
/** Where the tooltip sits: the cursor, else the hovered point, else the owning plot's cursor carried over. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SERIES_KEY } from '../../phases/transforms/TransformsPhase';
|
|
1
2
|
import { HoverState } from './HoverState.svelte';
|
|
2
3
|
/**
|
|
3
4
|
* One plot's hover: the figure's {@link HoverState} (or its own, outside a
|
|
@@ -46,6 +47,46 @@ export class PlotHover {
|
|
|
46
47
|
return [];
|
|
47
48
|
return this.state.match(this.#inputs.hover().points);
|
|
48
49
|
});
|
|
50
|
+
/** A row's place, as a key: its x, y and series. */
|
|
51
|
+
static #keyOf(x, y, series) {
|
|
52
|
+
const plain = (value) => (value instanceof Date ? +value : value);
|
|
53
|
+
return JSON.stringify([plain(x), plain(y), series ?? null]);
|
|
54
|
+
}
|
|
55
|
+
// The rows the hover can reach, and the matched ones: by identity, and by their place. Built whole
|
|
56
|
+
// inside this derivation and never changed after it, so they have nothing to react to.
|
|
57
|
+
#reach = $derived.by(() => {
|
|
58
|
+
const points = this.#inputs.hover().points;
|
|
59
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
60
|
+
const matched = new Set(this.#matched);
|
|
61
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
62
|
+
const byRow = new Map(points.map((p) => [p.row, p]));
|
|
63
|
+
// eslint-disable-next-line svelte/prefer-svelte-reactivity
|
|
64
|
+
const byPlace = new Map(points.map((p) => [PlotHover.#keyOf(p.x, p.y, p.series), p]));
|
|
65
|
+
return { matched, byRow, byPlace };
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* How the hover reaches `row`: `'active'` while it is matched, `'other'` while it can be hovered but is not,
|
|
69
|
+
* `null` while nothing is hovered here or it is no row the hover can reach (one the legend hides). A row is
|
|
70
|
+
* found by identity, else by its x, y and `series`. `series` narrows the active rows to that series.
|
|
71
|
+
*/
|
|
72
|
+
roleOf(row, series) {
|
|
73
|
+
const { matched, byRow, byPlace } = this.#reach;
|
|
74
|
+
if (matched.size === 0)
|
|
75
|
+
return null;
|
|
76
|
+
const point = byRow.get(row) ?? this.#placed(byPlace, row);
|
|
77
|
+
if (!point)
|
|
78
|
+
return null;
|
|
79
|
+
return matched.has(point) && (series === undefined || point.series === series)
|
|
80
|
+
? 'active'
|
|
81
|
+
: 'other';
|
|
82
|
+
}
|
|
83
|
+
/** The point at `row`'s place: of its own series, else of none (a heatmap's cell). */
|
|
84
|
+
#placed(byPlace, row) {
|
|
85
|
+
const x = this.#inputs.getX()(row);
|
|
86
|
+
const y = this.#inputs.getY()(row);
|
|
87
|
+
const series = row[SERIES_KEY];
|
|
88
|
+
return (byPlace.get(PlotHover.#keyOf(x, y, series)) ?? byPlace.get(PlotHover.#keyOf(x, y, undefined)));
|
|
89
|
+
}
|
|
49
90
|
/** The matched points the tooltip reads: only the tooltip's `series`, when it names some. */
|
|
50
91
|
matchedRows = $derived.by(() => {
|
|
51
92
|
const series = this.#inputs.hover().tooltip?.series;
|
|
@@ -54,13 +95,14 @@ export class PlotHover {
|
|
|
54
95
|
return this.#matched.filter((p) => p.series != null && series.includes(p.series));
|
|
55
96
|
});
|
|
56
97
|
/** The points the hover marker highlights. */
|
|
57
|
-
points = $derived(this.#matched.map(({ x, y, label, series, color, areaInset, row }) => ({
|
|
98
|
+
points = $derived(this.#matched.map(({ x, y, label, series, color, areaInset, context, row }) => ({
|
|
58
99
|
x,
|
|
59
100
|
y,
|
|
60
101
|
label,
|
|
61
102
|
series,
|
|
62
103
|
color,
|
|
63
104
|
areaInset,
|
|
105
|
+
context,
|
|
64
106
|
row
|
|
65
107
|
})));
|
|
66
108
|
/**
|
|
@@ -79,6 +121,13 @@ export class PlotHover {
|
|
|
79
121
|
return (candidates.find((p) => HoverState.same(p.x, activeX) && HoverState.same(p.y, activeY)) ??
|
|
80
122
|
candidates[0]);
|
|
81
123
|
});
|
|
124
|
+
/**
|
|
125
|
+
* The plot kind's own hover under the strategy in force - the figure's, which a composer or a scrolly step can
|
|
126
|
+
* change while the plot is shown - for an author's `hover` marker to be laid over.
|
|
127
|
+
*/
|
|
128
|
+
get look() {
|
|
129
|
+
return this.#inputs.hover().look?.(this.state.strategy) ?? {};
|
|
130
|
+
}
|
|
82
131
|
/** Whether a crosshair rule runs across x - the strategy's, unless the config turns them off. */
|
|
83
132
|
get impliesCrosshairX() {
|
|
84
133
|
return this.#inputs.hover().crosshair !== false && this.state.crosshairX;
|
|
@@ -87,6 +136,10 @@ export class PlotHover {
|
|
|
87
136
|
get impliesCrosshairY() {
|
|
88
137
|
return this.#inputs.hover().crosshair !== false && this.state.crosshairY;
|
|
89
138
|
}
|
|
139
|
+
/** The pointer's position in the plot's box, while it is over this plot. */
|
|
140
|
+
get cursor() {
|
|
141
|
+
return this.#cursor;
|
|
142
|
+
}
|
|
90
143
|
/** Whether the tooltip shows: under the cursor in the owning plot, in every synced one. */
|
|
91
144
|
get showTooltip() {
|
|
92
145
|
if (this.matchedRows.length === 0)
|
|
@@ -6,7 +6,7 @@ import type { DotStyle, StrokeStyle } from '../../types/plots/styling';
|
|
|
6
6
|
* a call site slots it in as one more `??` layer ahead of its own style chain.
|
|
7
7
|
*/
|
|
8
8
|
export declare class DisabledStyle {
|
|
9
|
-
/** The style `action` draws a mark with - `'hide'` and `'
|
|
9
|
+
/** The style `action` draws a mark with - `'hide'`, `'omit'` and `'rescale'` are fully transparent. */
|
|
10
10
|
static of(action: LegendDisabledAction | undefined, fallbackOpacity: number): LegendDisabledStyle | undefined;
|
|
11
11
|
/** The style a legend item draws with while off - it stays visible, so it can be turned back on. */
|
|
12
12
|
static ofItem(action: LegendDisabledAction | undefined, fallbackOpacity: number): LegendDisabledStyle | undefined;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* a call site slots it in as one more `??` layer ahead of its own style chain.
|
|
5
5
|
*/
|
|
6
6
|
export class DisabledStyle {
|
|
7
|
-
/** The style `action` draws a mark with - `'hide'` and `'
|
|
7
|
+
/** The style `action` draws a mark with - `'hide'`, `'omit'` and `'rescale'` are fully transparent. */
|
|
8
8
|
static of(action, fallbackOpacity) {
|
|
9
9
|
if (!action)
|
|
10
10
|
return undefined;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
/**
|
|
9
9
|
* The `interactive.legendStyle: 'badge'` item look: a pill with the series
|
|
10
10
|
* color, symbol icon, label, and a toggle icon - an eye (crossed out when
|
|
11
|
-
* `disabled`) for `'dim'` and `'hide'`, or a plus/cross pair for `'omit'`.
|
|
11
|
+
* `disabled`) for `'dim'` and `'hide'`, or a plus/cross pair for `'omit'` and `'rescale'`.
|
|
12
12
|
*/
|
|
13
13
|
let {
|
|
14
14
|
item,
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
{#snippet discreteItem(item: LegendItem, i: number)}
|
|
162
162
|
{@const action = interaction.actionOf(item.name)}
|
|
163
163
|
{@const isDisabled = action != null}
|
|
164
|
-
{@const omitMode = (action ?? disabledAction).mode
|
|
164
|
+
{@const omitMode = ['omit', 'rescale'].includes((action ?? disabledAction).mode)}
|
|
165
165
|
{@const disabledStyle = DisabledStyle.ofItem(action, cfg.legend.disabledOpacity)}
|
|
166
166
|
{@const color =
|
|
167
167
|
disabledStyle?.fill ??
|
|
@@ -31,6 +31,8 @@ export declare class LegendState {
|
|
|
31
31
|
}): boolean;
|
|
32
32
|
/** Whether `series` is turned off. */
|
|
33
33
|
isOff(series: string): boolean;
|
|
34
|
+
/** Whether `series` is out of the hover: turned off any way but `'dim'`, which leaves it drawn and hoverable. */
|
|
35
|
+
isUnhoverable(series: string): boolean;
|
|
34
36
|
/** What turning `series` off does, while it is off. */
|
|
35
37
|
actionOf(series: string): LegendDisabledAction | undefined;
|
|
36
38
|
turnOff(series: string, action: LegendDisabledAction): void;
|
|
@@ -48,12 +50,22 @@ export declare class LegendState {
|
|
|
48
50
|
* off any other way, is left alone.
|
|
49
51
|
*/
|
|
50
52
|
setOff(targets: Map<string, LegendDisabledAction>): void;
|
|
51
|
-
/** Whether any series is off with `'omit'` - which
|
|
53
|
+
/** Whether any series is off with `'omit'` or `'rescale'` - which change the plot's own rows, not just how they draw. */
|
|
52
54
|
get omits(): boolean;
|
|
53
|
-
/** `series` without those turned off with `'omit'`. */
|
|
55
|
+
/** `series` without those turned off with `'omit'` or `'rescale'`. */
|
|
54
56
|
withoutOmitted<S extends {
|
|
55
57
|
name: string;
|
|
56
58
|
}>(series: S[]): S[];
|
|
59
|
+
/**
|
|
60
|
+
* The series of `series` taken out of the plot's rows, and how: `'omit'` or `'rescale'` - one mode for every
|
|
61
|
+
* series of a plot, as its legend sets it. `undefined` while none is.
|
|
62
|
+
*/
|
|
63
|
+
removed<S extends {
|
|
64
|
+
name: string;
|
|
65
|
+
}>(series: S[]): {
|
|
66
|
+
mode: 'omit' | 'rescale';
|
|
67
|
+
series: S[];
|
|
68
|
+
} | undefined;
|
|
57
69
|
/**
|
|
58
70
|
* Records what the plot `source` draws, replacing what it recorded before.
|
|
59
71
|
* A series or mark that is off keeps its entry, in its place, even when
|
|
@@ -52,6 +52,11 @@ export class LegendState {
|
|
|
52
52
|
isOff(series) {
|
|
53
53
|
return this.disabled.has(series);
|
|
54
54
|
}
|
|
55
|
+
/** Whether `series` is out of the hover: turned off any way but `'dim'`, which leaves it drawn and hoverable. */
|
|
56
|
+
isUnhoverable(series) {
|
|
57
|
+
const action = this.disabled.get(series);
|
|
58
|
+
return action !== undefined && action.mode !== 'dim';
|
|
59
|
+
}
|
|
55
60
|
/** What turning `series` off does, while it is off. */
|
|
56
61
|
actionOf(series) {
|
|
57
62
|
return this.disabled.get(series);
|
|
@@ -119,13 +124,27 @@ export class LegendState {
|
|
|
119
124
|
this.#managed = new SvelteMap(targets);
|
|
120
125
|
});
|
|
121
126
|
}
|
|
122
|
-
/** Whether any series is off with `'omit'` - which
|
|
127
|
+
/** Whether any series is off with `'omit'` or `'rescale'` - which change the plot's own rows, not just how they draw. */
|
|
123
128
|
get omits() {
|
|
124
|
-
return [...this.disabled.values()].some(
|
|
129
|
+
return [...this.disabled.values()].some(LegendState.#removes);
|
|
125
130
|
}
|
|
126
|
-
/** `series` without those turned off with `'omit'`. */
|
|
131
|
+
/** `series` without those turned off with `'omit'` or `'rescale'`. */
|
|
127
132
|
withoutOmitted(series) {
|
|
128
|
-
return series.filter((s) => this.actionOf(s.name)
|
|
133
|
+
return series.filter((s) => !LegendState.#removes(this.actionOf(s.name)));
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The series of `series` taken out of the plot's rows, and how: `'omit'` or `'rescale'` - one mode for every
|
|
137
|
+
* series of a plot, as its legend sets it. `undefined` while none is.
|
|
138
|
+
*/
|
|
139
|
+
removed(series) {
|
|
140
|
+
const off = series.filter((s) => LegendState.#removes(this.actionOf(s.name)));
|
|
141
|
+
if (!off.length)
|
|
142
|
+
return undefined;
|
|
143
|
+
return { mode: this.actionOf(off[0].name).mode, series: off };
|
|
144
|
+
}
|
|
145
|
+
/** Whether `action` takes a series out of the plot's rows. */
|
|
146
|
+
static #removes(action) {
|
|
147
|
+
return action?.mode === 'omit' || action?.mode === 'rescale';
|
|
129
148
|
}
|
|
130
149
|
/**
|
|
131
150
|
* Records what the plot `source` draws, replacing what it recorded before.
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { PlotStylesConfig } from '../../types/configuration/styling';
|
|
2
2
|
/** How a legend shows the names it reads off the data. */
|
|
3
3
|
export declare class LegendText {
|
|
4
|
+
#private;
|
|
4
5
|
/** `name` as the legend shows it: as words, unless `legend.pretty` is off. */
|
|
5
6
|
static of(name: string, cfg: Pick<PlotStylesConfig, 'legend'>): string;
|
|
6
7
|
/**
|
|
7
8
|
* A field or category name as words: `_` and camel-case humps split it,
|
|
8
9
|
* all lowercase but the first letter - `gdp_per_capita` and `gdpPerCapita`
|
|
9
|
-
* both read "Gdp per capita". All-caps words (acronyms) keep their case.
|
|
10
|
+
* both read "Gdp per capita". All-caps words (acronyms) keep their case. The
|
|
11
|
+
* levels of a series grouped by several (`'Americas.Argentina'`) are made
|
|
12
|
+
* words each.
|
|
10
13
|
*/
|
|
11
14
|
static humanize(name: string): string;
|
|
12
15
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Grouping } from '../../utils/grouping';
|
|
1
2
|
/** How a legend shows the names it reads off the data. */
|
|
2
3
|
export class LegendText {
|
|
3
4
|
/** `name` as the legend shows it: as words, unless `legend.pretty` is off. */
|
|
@@ -7,9 +8,14 @@ export class LegendText {
|
|
|
7
8
|
/**
|
|
8
9
|
* A field or category name as words: `_` and camel-case humps split it,
|
|
9
10
|
* all lowercase but the first letter - `gdp_per_capita` and `gdpPerCapita`
|
|
10
|
-
* both read "Gdp per capita". All-caps words (acronyms) keep their case.
|
|
11
|
+
* both read "Gdp per capita". All-caps words (acronyms) keep their case. The
|
|
12
|
+
* levels of a series grouped by several (`'Americas.Argentina'`) are made
|
|
13
|
+
* words each.
|
|
11
14
|
*/
|
|
12
15
|
static humanize(name) {
|
|
16
|
+
return name.split(Grouping.SEPARATOR).map(LegendText.#words).join(Grouping.SEPARATOR);
|
|
17
|
+
}
|
|
18
|
+
static #words(name) {
|
|
13
19
|
const words = name
|
|
14
20
|
.replace(/_+/g, ' ')
|
|
15
21
|
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
|
|
@@ -56,7 +56,7 @@ export declare class PlotMargins {
|
|
|
56
56
|
/**
|
|
57
57
|
* Measures `el`'s rendered box once its readings settle - again whenever
|
|
58
58
|
* the plot's area or `deps` change - and reports how far it reaches past
|
|
59
|
-
* that area: to `
|
|
59
|
+
* that area: to `onoverflow`, and, when `grow` holds, into the room the
|
|
60
60
|
* margins grow by. The area is where svelteplot draws the marks (see
|
|
61
61
|
* {@link follow}), not the {@link contentBox}'s estimate: an `'auto'` side
|
|
62
62
|
* is only its estimate until svelteplot sizes its axes, and what a label
|
|
@@ -64,7 +64,7 @@ export declare class PlotMargins {
|
|
|
64
64
|
*/
|
|
65
65
|
watch(el: () => SVGGraphicsElement | undefined, options: {
|
|
66
66
|
grow?: () => boolean;
|
|
67
|
-
|
|
67
|
+
onoverflow?: (overflow: Margins) => void;
|
|
68
68
|
deps?: () => unknown;
|
|
69
69
|
}): void;
|
|
70
70
|
/** Grows the labels' room to fit what reached `overflow` px past the content box. */
|
|
@@ -57,7 +57,7 @@ export class PlotMargins {
|
|
|
57
57
|
/**
|
|
58
58
|
* Measures `el`'s rendered box once its readings settle - again whenever
|
|
59
59
|
* the plot's area or `deps` change - and reports how far it reaches past
|
|
60
|
-
* that area: to `
|
|
60
|
+
* that area: to `onoverflow`, and, when `grow` holds, into the room the
|
|
61
61
|
* margins grow by. The area is where svelteplot draws the marks (see
|
|
62
62
|
* {@link follow}), not the {@link contentBox}'s estimate: an `'auto'` side
|
|
63
63
|
* is only its estimate until svelteplot sizes its axes, and what a label
|
|
@@ -92,7 +92,7 @@ export class PlotMargins {
|
|
|
92
92
|
frame = requestAnimationFrame(measure);
|
|
93
93
|
return;
|
|
94
94
|
}
|
|
95
|
-
options.
|
|
95
|
+
options.onoverflow?.(overflow);
|
|
96
96
|
if (options.grow?.())
|
|
97
97
|
this.reportOverflow(overflow);
|
|
98
98
|
};
|
|
@@ -47,12 +47,12 @@
|
|
|
47
47
|
|
|
48
48
|
const cfg = $derived(getConfiguration());
|
|
49
49
|
const interaction = PlotInteraction.current(() => cfg);
|
|
50
|
-
const
|
|
50
|
+
const env = $derived({ cfg, interaction, range: interaction.legend?.range });
|
|
51
51
|
|
|
52
52
|
const plotState = $derived(
|
|
53
53
|
pipeline!.run(
|
|
54
54
|
{ ...rest, width, height, styles, segments, markers, scales, margins },
|
|
55
|
-
|
|
55
|
+
env,
|
|
56
56
|
panelState
|
|
57
57
|
)
|
|
58
58
|
);
|
|
@@ -74,7 +74,8 @@
|
|
|
74
74
|
slice?: (cell: PlotCellContext<TRow, TScales>) => TCore;
|
|
75
75
|
cell?: PlotCellSnippet<TRow, TScales>;
|
|
76
76
|
margins?: MarginConfig;
|
|
77
|
-
tooltip
|
|
77
|
+
/** The plot's `tooltip`, whose `format` gets whatever context its kind gives. */
|
|
78
|
+
tooltip?: TooltipProp<TRow, never>;
|
|
78
79
|
/** The rows `timeline` and `facet` slice. Defaults to `core.data`. */
|
|
79
80
|
data?: TRow[];
|
|
80
81
|
width?: number;
|
|
@@ -89,7 +90,8 @@
|
|
|
89
90
|
const pipeline = $derived(defaults ? Pipeline.of(defaults()) : undefined);
|
|
90
91
|
const hoverSettings = $derived(
|
|
91
92
|
new HoverSettings(
|
|
92
|
-
|
|
93
|
+
// A kind's own context reaches `format` as the hover phase gives it.
|
|
94
|
+
tooltip as TooltipProp<TRow> | undefined,
|
|
93
95
|
markers ?? core?.markers,
|
|
94
96
|
pipeline?.hoverStrategy(core ?? {}, cfg) ?? 'x'
|
|
95
97
|
)
|
|
@@ -14,7 +14,8 @@ declare function $$render<TRow extends Record<string, unknown>, TScales extends
|
|
|
14
14
|
slice?: (cell: PlotCellContext<TRow, TScales>) => TCore;
|
|
15
15
|
cell?: PlotCellSnippet<TRow, TScales>;
|
|
16
16
|
margins?: MarginConfig;
|
|
17
|
-
tooltip
|
|
17
|
+
/** The plot's `tooltip`, whose `format` gets whatever context its kind gives. */
|
|
18
|
+
tooltip?: TooltipProp<TRow, never>;
|
|
18
19
|
/** The rows `timeline` and `facet` slice. Defaults to `core.data`. */
|
|
19
20
|
data?: TRow[];
|
|
20
21
|
width?: number;
|
|
@@ -7,6 +7,7 @@ import type { PlotHover } from '../hover/PlotHover.svelte';
|
|
|
7
7
|
import type { Margins } from '../margins/Margins';
|
|
8
8
|
import type { PlotAxes } from '../../phases/data/PlotAxes';
|
|
9
9
|
import type { AxisValue } from '../../types/layout/mapping';
|
|
10
|
+
import type { PlotRowContext } from '../../types/layout/context';
|
|
10
11
|
import type { HoverPoint, HoverStrategy } from '../../types/layout/hover';
|
|
11
12
|
import type { PlayerControl, TimeInput, TimelineStep } from '../../types/layout/timeline';
|
|
12
13
|
import type { LegendDisabledAction, LegendEntry, LegendRange } from '../../types/layout/legend';
|
|
@@ -126,6 +127,11 @@ export declare class PublicPlotContext<T extends Record<string, unknown> = Recor
|
|
|
126
127
|
get axes(): PlotAxes | undefined;
|
|
127
128
|
/** The rows the plot draws and hovers over. */
|
|
128
129
|
get data(): T[];
|
|
130
|
+
/**
|
|
131
|
+
* What the plot knows of one of the rows it draws (or a copy of it, as a mark's accessor gets it): its series,
|
|
132
|
+
* where it sits, the value it shows and whatever the plot kind works out for it - see {@link PlotRowContext}.
|
|
133
|
+
*/
|
|
134
|
+
contextOf<TContext extends PlotRowContext<T> = PlotRowContext<T>>(row: unknown): TContext;
|
|
129
135
|
/** The color a series is drawn in, by its name - `undefined` for a plot with no series (a map). */
|
|
130
136
|
get colorForSeries(): ((name: string) => string) | undefined;
|
|
131
137
|
get width(): number;
|
|
@@ -2,6 +2,7 @@ import { usePlot as usePlotFromSvelteplot } from 'svelteplot';
|
|
|
2
2
|
import { HoverState } from '../hover/HoverState.svelte';
|
|
3
3
|
import { LegendState } from '../legend/LegendState.svelte';
|
|
4
4
|
import { PlotContext } from './PlotContext';
|
|
5
|
+
import { RowContext } from '../../phases/context/RowContext';
|
|
5
6
|
import { TimelineState } from '../timeline/TimelineState.svelte';
|
|
6
7
|
/** What the pointer is over, shared by every plot in a figure. Read-only. */
|
|
7
8
|
export class PublicHover {
|
|
@@ -231,6 +232,13 @@ export class PublicPlotContext {
|
|
|
231
232
|
get data() {
|
|
232
233
|
return this.#context.data;
|
|
233
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* What the plot knows of one of the rows it draws (or a copy of it, as a mark's accessor gets it): its series,
|
|
237
|
+
* where it sits, the value it shows and whatever the plot kind works out for it - see {@link PlotRowContext}.
|
|
238
|
+
*/
|
|
239
|
+
contextOf(row) {
|
|
240
|
+
return RowContext.of(row);
|
|
241
|
+
}
|
|
234
242
|
/** The color a series is drawn in, by its name - `undefined` for a plot with no series (a map). */
|
|
235
243
|
get colorForSeries() {
|
|
236
244
|
return this.#context.colorForSeries;
|