@fundar/data-chart-telling 1.17.0 → 1.19.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 +59 -0
- package/README.md +2 -1
- package/dist/configuration/config.svelte.js +4 -3
- package/dist/index.d.ts +10 -3
- package/dist/index.js +4 -1
- package/dist/layout/coordinates/CoordinatesLayout.svelte +3 -1
- package/dist/layout/geometry/GeometryLayout.svelte +222 -53
- package/dist/layout/geometry/ScaleFreeContext.d.ts +31 -0
- package/dist/layout/geometry/ScaleFreeContext.js +65 -0
- package/dist/layout/geometry/ScaleFreeMarks.svelte +14 -0
- package/dist/layout/geometry/ScaleFreeMarks.svelte.d.ts +7 -0
- package/dist/layout/geometry/ScaleGate.svelte.d.ts +8 -0
- package/dist/layout/geometry/ScaleGate.svelte.js +95 -0
- package/dist/layout/geometry/ScaleGateMarks.svelte +15 -0
- package/dist/layout/geometry/ScaleGateMarks.svelte.d.ts +7 -0
- 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.d.ts +1 -3
- package/dist/layout/hover/HoverSettings.js +3 -2
- package/dist/layout/hover/HoverShapes.d.ts +56 -0
- package/dist/layout/hover/HoverShapes.js +163 -0
- package/dist/layout/hover/PlotHover.svelte.d.ts +18 -0
- package/dist/layout/hover/PlotHover.svelte.js +54 -1
- package/dist/layout/legend/LegendState.svelte.d.ts +2 -0
- package/dist/layout/legend/LegendState.svelte.js +5 -0
- package/dist/layout/margins/Box.d.ts +4 -0
- package/dist/layout/margins/Box.js +14 -0
- package/dist/layout/margins/PlotMargins.svelte.js +26 -1
- package/dist/layout/plot/{Plot.svelte.d.ts → AbstractPlot.svelte.d.ts} +3 -3
- package/dist/layout/plot/Core.svelte +2 -2
- package/dist/layout/plot/PublicPlotContext.d.ts +6 -0
- package/dist/layout/plot/PublicPlotContext.js +8 -0
- package/dist/layout/styles/ValueLabels.d.ts +118 -59
- package/dist/layout/styles/ValueLabels.js +313 -146
- 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 +84 -1
- package/dist/markers/MarkerKinds.js +150 -23
- package/dist/markers/area/AreaMarker.svelte +1 -1
- 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 +29 -70
- package/dist/markers/bollinger/BollingerMarker.svelte +1 -1
- package/dist/markers/box/BoxMarker.svelte +1 -1
- package/dist/markers/dot/DotRadius.d.ts +11 -0
- package/dist/markers/dot/DotRadius.js +21 -0
- package/dist/markers/hover/HoverMarker.svelte +7 -265
- package/dist/markers/hover/HoverMarker.svelte.d.ts +4 -27
- package/dist/markers/labels/CurveLabel.svelte +56 -0
- package/dist/markers/labels/CurveLabel.svelte.d.ts +9 -0
- package/dist/markers/labels/LabelMerge.d.ts +11 -0
- package/dist/markers/labels/LabelMerge.js +87 -0
- package/dist/markers/labels/MarkerLabel.svelte +36 -0
- package/dist/markers/labels/MarkerLabel.svelte.d.ts +10 -0
- package/dist/markers/labels/MarkerLabels.d.ts +52 -0
- package/dist/markers/labels/MarkerLabels.js +97 -0
- package/dist/markers/labels/geometry/BoxGeometry.d.ts +8 -0
- package/dist/markers/labels/geometry/BoxGeometry.js +101 -0
- package/dist/markers/labels/geometry/CurveGeometry.d.ts +34 -0
- package/dist/markers/labels/geometry/CurveGeometry.js +193 -0
- package/dist/markers/labels/geometry/PointGeometry.d.ts +9 -0
- package/dist/markers/labels/geometry/PointGeometry.js +22 -0
- package/dist/markers/labels/layouts/BoxLayout.d.ts +10 -0
- package/dist/markers/labels/layouts/BoxLayout.js +49 -0
- package/dist/markers/labels/layouts/PathLayout.d.ts +11 -0
- package/dist/markers/labels/layouts/PathLayout.js +91 -0
- package/dist/markers/labels/layouts/PointLayout.d.ts +19 -0
- package/dist/markers/labels/layouts/PointLayout.js +94 -0
- package/dist/markers/regression/RegressionMarker.svelte +1 -1
- package/dist/markers/text/Covering.d.ts +13 -0
- package/dist/markers/text/Covering.js +29 -0
- package/dist/markers/text/Declutter.d.ts +24 -3
- package/dist/markers/text/Declutter.js +46 -3
- package/dist/markers/text/TextMarker.svelte +90 -17
- package/dist/markers/text/TextMarker.svelte.d.ts +1 -1
- package/dist/markers/tick/TickMarker.svelte +1 -1
- package/dist/markers/utils/MarkerChannels.d.ts +1 -1
- package/dist/markers/utils/MarkerChannels.js +3 -2
- package/dist/markers/utils/PointPixel.d.ts +37 -0
- package/dist/markers/utils/PointPixel.js +44 -0
- package/dist/markers/violin/ViolinMarker.svelte +1 -1
- package/dist/markers/waffle/WaffleMarker.svelte +1 -1
- package/dist/phases/Pipeline.d.ts +7 -7
- package/dist/phases/Pipeline.js +12 -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 +37 -0
- package/dist/phases/context/RowContext.js +97 -0
- package/dist/phases/data/DataPhase.d.ts +4 -4
- package/dist/phases/data/DataPhase.js +7 -7
- package/dist/phases/hover/HoverPhase.d.ts +6 -7
- package/dist/phases/hover/HoverPhase.js +28 -23
- package/dist/phases/mapping/MappingPhase.d.ts +4 -4
- package/dist/phases/mapping/MappingPhase.js +2 -2
- package/dist/phases/markers/MarkerStyles.d.ts +8 -0
- package/dist/phases/markers/MarkerStyles.js +24 -6
- package/dist/phases/markers/MarkersPhase.d.ts +6 -7
- package/dist/phases/markers/MarkersPhase.js +18 -12
- 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 +5 -48
- package/dist/phases/statistics/MarkerInheritance.d.ts +11 -0
- package/dist/phases/statistics/MarkerInheritance.js +25 -0
- package/dist/phases/statistics/MarkerOrientation.d.ts +26 -0
- package/dist/phases/statistics/MarkerOrientation.js +29 -0
- package/dist/phases/statistics/StatisticsPhase.js +15 -15
- 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/TransformsPhase.d.ts +3 -3
- package/dist/phases/transforms/TransformsPhase.js +7 -5
- package/dist/plots/correlation/heatmap/Plot.svelte +2 -2
- package/dist/plots/correlation/heatmap/Plot.svelte.d.ts +0 -1
- package/dist/plots/correlation/heatmap/defaults.d.ts +2 -2
- package/dist/plots/correlation/heatmap/defaults.js +35 -7
- package/dist/plots/correlation/heatmap/markers.d.ts +2 -8
- package/dist/plots/correlation/heatmap/markers.js +8 -11
- package/dist/plots/correlation/scatter/Plot.svelte +2 -2
- package/dist/plots/correlation/scatter/Plot.svelte.d.ts +0 -1
- package/dist/plots/correlation/scatter/defaults.d.ts +2 -2
- package/dist/plots/correlation/scatter/defaults.js +18 -6
- package/dist/plots/correlation/scatter/markers.d.ts +2 -11
- package/dist/plots/correlation/scatter/markers.js +24 -30
- package/dist/plots/distribution/box/BoxSummaries.d.ts +22 -8
- package/dist/plots/distribution/box/BoxSummaries.js +99 -40
- package/dist/plots/distribution/box/Plot.svelte +2 -2
- package/dist/plots/distribution/box/Plot.svelte.d.ts +0 -1
- package/dist/plots/distribution/box/defaults.d.ts +2 -2
- package/dist/plots/distribution/box/defaults.js +20 -6
- package/dist/plots/distribution/box/markers.d.ts +2 -2
- package/dist/plots/distribution/box/markers.js +13 -4
- package/dist/plots/distribution/density/Plot.svelte +2 -2
- package/dist/plots/distribution/density/Plot.svelte.d.ts +0 -1
- package/dist/plots/distribution/density/defaults.d.ts +2 -2
- package/dist/plots/distribution/density/defaults.js +33 -1
- package/dist/plots/distribution/density/markers.d.ts +2 -2
- package/dist/plots/distribution/density/markers.js +9 -5
- package/dist/plots/distribution/histogram/Plot.svelte +2 -2
- package/dist/plots/distribution/histogram/Plot.svelte.d.ts +0 -1
- package/dist/plots/distribution/histogram/defaults.d.ts +2 -2
- package/dist/plots/distribution/histogram/defaults.js +36 -36
- package/dist/plots/distribution/histogram/markers.d.ts +2 -2
- package/dist/plots/distribution/histogram/markers.js +7 -6
- package/dist/plots/distribution/pyramid/Plot.svelte +2 -2
- package/dist/plots/distribution/pyramid/Plot.svelte.d.ts +0 -1
- package/dist/plots/distribution/pyramid/defaults.d.ts +2 -2
- package/dist/plots/distribution/pyramid/defaults.js +13 -3
- package/dist/plots/distribution/pyramid/markers.d.ts +2 -10
- package/dist/plots/distribution/pyramid/markers.js +9 -18
- package/dist/plots/distribution/violin/Plot.svelte +2 -2
- package/dist/plots/distribution/violin/Plot.svelte.d.ts +0 -1
- package/dist/plots/distribution/violin/defaults.d.ts +2 -2
- package/dist/plots/distribution/violin/defaults.js +20 -7
- package/dist/plots/distribution/violin/markers.d.ts +2 -2
- package/dist/plots/distribution/violin/markers.js +30 -6
- package/dist/plots/evolution/area/Plot.svelte +2 -2
- package/dist/plots/evolution/area/Plot.svelte.d.ts +0 -1
- package/dist/plots/evolution/area/defaults.d.ts +2 -2
- package/dist/plots/evolution/area/defaults.js +5 -8
- package/dist/plots/evolution/area/markers.d.ts +2 -2
- package/dist/plots/evolution/area/markers.js +7 -5
- package/dist/plots/evolution/line/Plot.svelte +2 -2
- package/dist/plots/evolution/line/Plot.svelte.d.ts +0 -1
- package/dist/plots/evolution/line/defaults.d.ts +2 -2
- package/dist/plots/evolution/line/defaults.js +5 -7
- package/dist/plots/evolution/line/markers.d.ts +2 -2
- package/dist/plots/evolution/line/markers.js +6 -4
- package/dist/plots/evolution/slope/Plot.svelte +2 -2
- package/dist/plots/evolution/slope/Plot.svelte.d.ts +0 -1
- package/dist/plots/evolution/slope/defaults.d.ts +2 -2
- package/dist/plots/evolution/slope/defaults.js +11 -6
- package/dist/plots/evolution/slope/markers.d.ts +6 -5
- package/dist/plots/evolution/slope/markers.js +19 -12
- package/dist/plots/evolution/sparkline/Plot.svelte +2 -2
- package/dist/plots/evolution/sparkline/Plot.svelte.d.ts +0 -1
- 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 +6 -4
- package/dist/plots/generic/Plot.svelte +42 -0
- package/dist/plots/generic/Plot.svelte.d.ts +25 -0
- package/dist/plots/generic/defaults.d.ts +4 -0
- package/dist/plots/generic/defaults.js +7 -0
- package/dist/plots/map/geo/Core.svelte +3 -3
- package/dist/plots/map/geo/Plot.svelte +2 -2
- package/dist/plots/map/geo/Plot.svelte.d.ts +0 -1
- 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 +3 -3
- 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 +2 -2
- package/dist/plots/part-of-a-whole/treemap/Plot.svelte.d.ts +0 -1
- package/dist/plots/part-of-a-whole/treemap/defaults.d.ts +2 -2
- package/dist/plots/part-of-a-whole/treemap/defaults.js +38 -22
- package/dist/plots/ranking/bar/Plot.svelte +2 -2
- package/dist/plots/ranking/bar/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/bar/defaults.d.ts +2 -2
- package/dist/plots/ranking/bar/defaults.js +26 -10
- package/dist/plots/ranking/bar/markers.d.ts +3 -3
- package/dist/plots/ranking/bar/markers.js +17 -33
- package/dist/plots/ranking/bullet/Plot.svelte +2 -2
- package/dist/plots/ranking/bullet/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/bullet/defaults.d.ts +2 -2
- package/dist/plots/ranking/bullet/defaults.js +24 -4
- package/dist/plots/ranking/bullet/markers.d.ts +3 -3
- package/dist/plots/ranking/bullet/markers.js +16 -10
- package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +4 -11
- package/dist/plots/ranking/cleveland/ClevelandMarkers.js +73 -54
- package/dist/plots/ranking/cleveland/Plot.svelte +2 -2
- package/dist/plots/ranking/cleveland/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/cleveland/defaults.d.ts +2 -2
- package/dist/plots/ranking/cleveland/defaults.js +39 -5
- package/dist/plots/ranking/dumbbell/Plot.svelte +2 -2
- package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/dumbbell/defaults.d.ts +2 -2
- package/dist/plots/ranking/forest/Plot.svelte +2 -2
- package/dist/plots/ranking/forest/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/forest/defaults.d.ts +2 -2
- package/dist/plots/ranking/lollipop/Plot.svelte +2 -2
- package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/lollipop/defaults.d.ts +2 -2
- package/dist/types/configuration/styling.d.ts +4 -0
- package/dist/types/layout/context.d.ts +23 -0
- package/dist/types/layout/context.js +1 -0
- package/dist/types/layout/hover.d.ts +3 -0
- package/dist/types/layout/styles/bullet.d.ts +4 -1
- package/dist/types/layout/styles/values.d.ts +59 -13
- package/dist/types/layout/tooltip.d.ts +5 -10
- package/dist/types/markers/axis/area.d.ts +5 -1
- 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 +7 -4
- package/dist/types/markers/axis/bollinger.d.ts +2 -1
- package/dist/types/markers/axis/box.d.ts +2 -1
- package/dist/types/markers/axis/cell.d.ts +4 -1
- package/dist/types/markers/axis/hover.d.ts +60 -15
- package/dist/types/markers/axis/line.d.ts +4 -1
- package/dist/types/markers/axis/rect.d.ts +4 -1
- package/dist/types/markers/axis/regression.d.ts +2 -1
- package/dist/types/markers/axis/tick.d.ts +2 -1
- package/dist/types/markers/axis/trail.d.ts +4 -1
- package/dist/types/markers/axis/violin.d.ts +2 -1
- package/dist/types/markers/axis/waffle.d.ts +5 -1
- package/dist/types/markers/basic/dot.d.ts +4 -1
- package/dist/types/markers/basic/text.d.ts +25 -21
- package/dist/types/markers/channels/commonMarkerConfig.d.ts +6 -2
- package/dist/types/markers/channels/commonMarkerConfigWithLabel.d.ts +5 -9
- package/dist/types/markers/channels/commonMarkerConfigWithOrientation.d.ts +5 -0
- package/dist/types/markers/channels/commonMarkerConfigWithOrientation.js +1 -0
- package/dist/types/markers/common.d.ts +1 -0
- package/dist/types/markers/common.js +1 -0
- package/dist/types/markers/labels/box.d.ts +57 -0
- package/dist/types/markers/labels/box.js +1 -0
- package/dist/types/markers/labels/common.d.ts +15 -0
- package/dist/types/markers/labels/common.js +1 -0
- package/dist/types/markers/labels/path.d.ts +52 -0
- package/dist/types/markers/labels/path.js +1 -0
- package/dist/types/markers/labels/point.d.ts +40 -0
- package/dist/types/markers/labels/point.js +1 -0
- package/dist/types/markers/traits.d.ts +10 -0
- 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 +2 -2
- package/dist/types/phases/hover/phase.d.ts +10 -7
- 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 -10
- 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 +1 -1
- package/dist/types/phases/statistics/phase.d.ts +8 -3
- package/dist/types/phases/styles/phase.d.ts +18 -5
- package/dist/types/phases/transforms/phase.d.ts +4 -2
- package/dist/types/plots/constants.d.ts +3 -17
- package/dist/types/plots/correlation/heatmap/props.d.ts +3 -2
- package/dist/types/plots/correlation/heatmap/state.d.ts +2 -2
- package/dist/types/plots/correlation/scatter/props.d.ts +3 -2
- package/dist/types/plots/correlation/scatter/state.d.ts +2 -2
- package/dist/types/plots/distribution/box/props.d.ts +28 -2
- package/dist/types/plots/distribution/box/state.d.ts +6 -17
- package/dist/types/plots/distribution/density/props.d.ts +2 -1
- package/dist/types/plots/distribution/density/state.d.ts +2 -2
- package/dist/types/plots/distribution/histogram/props.d.ts +16 -2
- package/dist/types/plots/distribution/histogram/state.d.ts +2 -2
- package/dist/types/plots/distribution/pyramid/props.d.ts +3 -2
- package/dist/types/plots/distribution/pyramid/state.d.ts +2 -2
- package/dist/types/plots/distribution/violin/props.d.ts +6 -2
- package/dist/types/plots/distribution/violin/state.d.ts +2 -2
- package/dist/types/plots/evolution/area/props.d.ts +3 -2
- package/dist/types/plots/evolution/area/state.d.ts +2 -2
- package/dist/types/plots/evolution/line/props.d.ts +3 -2
- 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/generic/props.d.ts +16 -0
- package/dist/types/plots/generic/props.js +1 -0
- package/dist/types/plots/generic/state.d.ts +4 -0
- package/dist/types/plots/generic/state.js +1 -0
- package/dist/types/plots/map/geo/state.d.ts +1 -1
- package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +18 -6
- package/dist/types/plots/part-of-a-whole/treemap/state.d.ts +2 -2
- package/dist/types/plots/props.d.ts +3 -0
- package/dist/types/plots/ranking/bar/props.d.ts +3 -2
- 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 -2
- package/dist/types/plots/ranking/cleveland/state.d.ts +2 -2
- package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -2
- package/dist/types/plots/ranking/dumbbell/state.d.ts +2 -2
- package/dist/types/plots/ranking/forest/props.d.ts +5 -2
- package/dist/types/plots/ranking/forest/state.d.ts +2 -2
- package/dist/types/plots/ranking/lollipop/props.d.ts +3 -2
- package/dist/types/plots/ranking/lollipop/state.d.ts +2 -2
- package/docs/architecture.md +9 -9
- package/docs/markers.md +36 -6
- 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 +36 -2
- package/docs/plots/ranking/bar.md +1 -0
- package/docs/plots/ranking/cleveland.md +1 -1
- package/docs/state.md +33 -0
- package/docs/styles-and-segments.md +2 -15
- package/docs/theming.md +2 -1
- package/docs/tooltip-and-hover.md +81 -3
- package/docs/value-labels.md +159 -0
- package/examples/BarValues.svelte +1 -1
- package/examples/LineDates.svelte +1 -1
- package/examples/ResponsiveLine.svelte +3 -1
- package/examples/TreemapHover.svelte +25 -0
- package/examples/ValueLabels.svelte +1 -1
- package/llms-full.txt +9 -7
- package/llms.txt +3 -1
- package/package.json +3 -1
- package/dist/markers/utils/BoxLabel.d.ts +0 -58
- package/dist/markers/utils/BoxLabel.js +0 -175
- package/dist/markers/utils/MarkerLabel.svelte +0 -33
- package/dist/markers/utils/MarkerLabel.svelte.d.ts +0 -10
- /package/dist/layout/plot/{Plot.svelte → AbstractPlot.svelte} +0 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { MarkerStyles } from '../../phases/markers/MarkerStyles';
|
|
2
|
+
import { SERIES_KEY } from '../../phases/transforms/TransformsPhase';
|
|
3
|
+
import { RowStyle } from '../../markers/utils/RowStyle';
|
|
4
|
+
/**
|
|
5
|
+
* The look the plot's hover markers give the shapes of every marker linked to the hover (`hover: true` or
|
|
6
|
+
* `'style'`): the hovered ones take `active`, the others `others`, each over the shape's own style. A shape
|
|
7
|
+
* the legend dims keeps its own fill and opacities; one the hover cannot reach (hidden, omitted) is untouched.
|
|
8
|
+
*
|
|
9
|
+
* The marker stays one marker over all its rows, whatever is hovered: each style the hover sets is a function of
|
|
10
|
+
* the row that asks the hover how it reaches it. Moving the pointer then only draws the marker's shapes again in
|
|
11
|
+
* their new look - their rows and options do not change, so svelteplot never works the plot's scales out again
|
|
12
|
+
* (it does so from every mark's data and options, and a style with no scale is never read for them).
|
|
13
|
+
*/
|
|
14
|
+
export class HoverShapes {
|
|
15
|
+
/** What the legend owns on a dimmed shape. */
|
|
16
|
+
static #LEGEND_KEYS = new Set(['fill', 'fillOpacity', 'strokeOpacity']);
|
|
17
|
+
/** The fields that draw a shape's outline. */
|
|
18
|
+
static #OUTLINE_KEYS = [
|
|
19
|
+
'stroke',
|
|
20
|
+
'strokeWidth',
|
|
21
|
+
'strokeOpacity',
|
|
22
|
+
'strokeDasharray'
|
|
23
|
+
];
|
|
24
|
+
/** The fields that hold an opacity, fully opaque unless set. */
|
|
25
|
+
static #OPACITY_KEYS = new Set(['fillOpacity', 'strokeOpacity']);
|
|
26
|
+
/** The fields that hold a color: a string is the field of the rows it names, else the color itself. */
|
|
27
|
+
static #COLOR_KEYS = new Set(['fill', 'stroke']);
|
|
28
|
+
/** A shape style's field as a `dot` marker names it. */
|
|
29
|
+
static #DOT_KEYS = {
|
|
30
|
+
fill: 'dotFill',
|
|
31
|
+
fillOpacity: 'dotFillOpacity',
|
|
32
|
+
stroke: 'dotStroke',
|
|
33
|
+
strokeWidth: 'dotStrokeWidth',
|
|
34
|
+
strokeOpacity: 'dotStrokeOpacity',
|
|
35
|
+
strokeDasharray: 'dotStrokeDasharray'
|
|
36
|
+
};
|
|
37
|
+
#rules;
|
|
38
|
+
/** The fields any rule sets, in either role. */
|
|
39
|
+
#fields;
|
|
40
|
+
constructor(markers) {
|
|
41
|
+
this.#rules = markers.filter((m) => m.type === 'hover' && !!(m.active || m.others));
|
|
42
|
+
this.#fields = [
|
|
43
|
+
...new Set(this.#rules.flatMap((rule) => [rule.active, rule.others].flatMap((style) => Object.entries(style ?? {})
|
|
44
|
+
.filter(([, value]) => value !== undefined)
|
|
45
|
+
.map(([name]) => name))))
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
/** Whether any hover marker restyles shapes. */
|
|
49
|
+
get any() {
|
|
50
|
+
return this.#rules.length > 0;
|
|
51
|
+
}
|
|
52
|
+
/** Whether `marker`'s shapes take the hover's styles. */
|
|
53
|
+
static links(marker) {
|
|
54
|
+
const hover = marker.hover;
|
|
55
|
+
return hover === true || hover === 'style';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* `marker` with each style the hover sets as a function of the row: the hovered rows take `active`, the others
|
|
59
|
+
* `others`, and while nothing is hovered every row its own style. A marker the hover does not style is returned
|
|
60
|
+
* as it is. `rows` are what the marker draws without `data` of its own.
|
|
61
|
+
*
|
|
62
|
+
* The outline `active` sets is not the shape's own: {@link outline} draws it over every shape, whole.
|
|
63
|
+
*/
|
|
64
|
+
styled(marker, rows, reach) {
|
|
65
|
+
return this.#styled(marker, rows, reach, false);
|
|
66
|
+
}
|
|
67
|
+
/** {@link styled}, with `active`'s outline on the shapes themselves when `outlined`. */
|
|
68
|
+
#styled(marker, rows, reach, outlined) {
|
|
69
|
+
if (!this.any || !HoverShapes.links(marker))
|
|
70
|
+
return marker;
|
|
71
|
+
const own = { ...marker.styles };
|
|
72
|
+
const data = (marker.data ?? rows);
|
|
73
|
+
const isDot = marker.type === 'dot';
|
|
74
|
+
const styles = { ...own };
|
|
75
|
+
for (const field of this.#fields) {
|
|
76
|
+
const name = isDot ? HoverShapes.#DOT_KEYS[field] : field;
|
|
77
|
+
const base = HoverShapes.#reader(field, own[name], data);
|
|
78
|
+
styles[name] = (row, index) => {
|
|
79
|
+
const value = this.#hovered(field, row, index, reach, outlined);
|
|
80
|
+
return value === undefined ? base(row, index) : value;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return MarkerStyles.restyle({ ...marker, styles }, { cfg: reach.cfg, rows: [...data] });
|
|
84
|
+
}
|
|
85
|
+
/** Whether any rule outlines the hovered shapes: an `active` that sets one of the stroke's fields. */
|
|
86
|
+
get outlines() {
|
|
87
|
+
return this.#rules.some((rule) => HoverShapes.#outlining(rule));
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The outline of `marker`'s hovered shapes, to draw over every shape of the plot: the marker over its hovered
|
|
91
|
+
* rows only, with no fill, no label and no pointer of its own. A shape is drawn in its marker's order, so its
|
|
92
|
+
* neighbours drawn after it would cover part of its outline - a treemap's tile, a heatmap's cell with no gap.
|
|
93
|
+
* `undefined` when no rule outlines the shapes or nothing of the marker is hovered.
|
|
94
|
+
*/
|
|
95
|
+
outline(marker, rows, reach) {
|
|
96
|
+
if (!this.outlines || !HoverShapes.links(marker))
|
|
97
|
+
return undefined;
|
|
98
|
+
const rules = this.#rules.filter((rule) => HoverShapes.#outlining(rule));
|
|
99
|
+
const data = (marker.data ?? rows).filter((row) => rules.some((rule) => (rule.series === undefined || row?.[SERIES_KEY] === rule.series) &&
|
|
100
|
+
reach.roleOf(row, rule.series) === 'active'));
|
|
101
|
+
if (data.length === 0)
|
|
102
|
+
return undefined;
|
|
103
|
+
const styled = this.#styled(marker, rows, reach, true);
|
|
104
|
+
const isDot = marker.type === 'dot';
|
|
105
|
+
const unfilled = isDot
|
|
106
|
+
? { dotFill: 'none', dotFillOpacity: 0 }
|
|
107
|
+
: { fill: 'none', fillOpacity: 0 };
|
|
108
|
+
const rest = Object.fromEntries(Object.entries(styled).filter(([key]) => key !== 'label' && key !== 'hover' && !key.startsWith('on')));
|
|
109
|
+
return {
|
|
110
|
+
...rest,
|
|
111
|
+
data,
|
|
112
|
+
styles: { ...styled.styles, ...unfilled }
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
static #outlining(rule) {
|
|
116
|
+
const active = rule.active ?? {};
|
|
117
|
+
return HoverShapes.#OUTLINE_KEYS.some((key) => active[key] !== undefined);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* What the hover sets `field` to on `row` - the last rule that reaches the row and sets it wins - or `undefined`
|
|
121
|
+
* when none does: the row is not hovered, or the legend dims it and `field` is the legend's. An outline `active`
|
|
122
|
+
* sets is left to the outline drawn over every shape, unless `outlined`.
|
|
123
|
+
*/
|
|
124
|
+
#hovered(field, row, index, reach, outlined) {
|
|
125
|
+
let value;
|
|
126
|
+
let dimmed;
|
|
127
|
+
for (const rule of this.#rules) {
|
|
128
|
+
if (rule.series !== undefined && row?.[SERIES_KEY] !== rule.series)
|
|
129
|
+
continue;
|
|
130
|
+
const role = reach.roleOf(row, rule.series);
|
|
131
|
+
const style = role === 'active' ? rule.active : role === 'other' ? rule.others : undefined;
|
|
132
|
+
const own = style?.[field];
|
|
133
|
+
if (own === undefined)
|
|
134
|
+
continue;
|
|
135
|
+
if (role === 'active' &&
|
|
136
|
+
!outlined &&
|
|
137
|
+
HoverShapes.#OUTLINE_KEYS.includes(field) &&
|
|
138
|
+
HoverShapes.#outlining(rule))
|
|
139
|
+
continue;
|
|
140
|
+
dimmed ??= HoverShapes.#LEGEND_KEYS.has(field) && reach.dimmed(row);
|
|
141
|
+
if (dimmed)
|
|
142
|
+
return undefined;
|
|
143
|
+
value = typeof own === 'function' ? own(row, index) : own;
|
|
144
|
+
}
|
|
145
|
+
return value;
|
|
146
|
+
}
|
|
147
|
+
/** How the shape's own `style` for `field` reads on a row, as the marker would draw it. */
|
|
148
|
+
static #reader(field, style, rows) {
|
|
149
|
+
if (typeof style === 'function')
|
|
150
|
+
return style;
|
|
151
|
+
// An opacity is a channel of the mark, and svelteplot leaves out a row whose channel reads nothing.
|
|
152
|
+
if (style === undefined && HoverShapes.#OPACITY_KEYS.has(field))
|
|
153
|
+
return () => 1;
|
|
154
|
+
if (typeof style !== 'string' || field === 'strokeDasharray')
|
|
155
|
+
return () => style;
|
|
156
|
+
if (HoverShapes.#COLOR_KEYS.has(field)) {
|
|
157
|
+
const color = RowStyle.colorOf(style, rows);
|
|
158
|
+
return color ? (row) => color(row) : () => style;
|
|
159
|
+
}
|
|
160
|
+
// A number (an opacity, a width) a string names the field of.
|
|
161
|
+
return (row) => row?.[style];
|
|
162
|
+
}
|
|
163
|
+
}
|
|
@@ -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)
|
|
@@ -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;
|
|
@@ -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);
|
|
@@ -37,6 +37,10 @@ export declare class Box {
|
|
|
37
37
|
get empty(): boolean;
|
|
38
38
|
/** How far this box reaches out from its origin (the point it sits around), in whole pixels. */
|
|
39
39
|
get reach(): Margins;
|
|
40
|
+
/** Whether this box and `other` share any area. */
|
|
41
|
+
intersects(other: Box): boolean;
|
|
42
|
+
/** Whether this box lies wholly inside `bounds`. */
|
|
43
|
+
inside(bounds: Box): boolean;
|
|
40
44
|
/** This box grown by `px` on every side. */
|
|
41
45
|
pad(px: number): Box;
|
|
42
46
|
/**
|
|
@@ -61,6 +61,20 @@ export class Box {
|
|
|
61
61
|
get reach() {
|
|
62
62
|
return this.overflow(Box.size(0, 0));
|
|
63
63
|
}
|
|
64
|
+
/** Whether this box and `other` share any area. */
|
|
65
|
+
intersects(other) {
|
|
66
|
+
return (this.left < other.right &&
|
|
67
|
+
other.left < this.right &&
|
|
68
|
+
this.top < other.bottom &&
|
|
69
|
+
other.top < this.bottom);
|
|
70
|
+
}
|
|
71
|
+
/** Whether this box lies wholly inside `bounds`. */
|
|
72
|
+
inside(bounds) {
|
|
73
|
+
return (this.left >= bounds.left &&
|
|
74
|
+
this.right <= bounds.right &&
|
|
75
|
+
this.top >= bounds.top &&
|
|
76
|
+
this.bottom <= bounds.bottom);
|
|
77
|
+
}
|
|
64
78
|
/** This box grown by `px` on every side. */
|
|
65
79
|
pad(px) {
|
|
66
80
|
return new Box(this.x - px, this.y - px, this.width + 2 * px, this.height + 2 * px);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getContext, setContext } from 'svelte';
|
|
2
|
+
import { get } from 'svelte/store';
|
|
2
3
|
import { Margins } from './Margins';
|
|
3
4
|
import { Box } from './Box';
|
|
4
5
|
import { CellAlignment } from '../grid/GridAlignment.svelte';
|
|
@@ -27,6 +28,17 @@ export class PlotMargins {
|
|
|
27
28
|
#settled;
|
|
28
29
|
/** What svelteplot's own `<Plot>` lays the plot out by, once {@link follow} is handed it. */
|
|
29
30
|
#plot = $state.raw();
|
|
31
|
+
/** The room svelteplot's axes ask of each side, whether or not it is `'auto'`, once {@link follow} reads it. */
|
|
32
|
+
#autoMargins = $state.raw();
|
|
33
|
+
#auto = $derived.by(() => {
|
|
34
|
+
const maps = this.#autoMargins;
|
|
35
|
+
if (!maps)
|
|
36
|
+
return {};
|
|
37
|
+
return Object.fromEntries(Margins.SIDES.flatMap((side) => {
|
|
38
|
+
const values = [...maps[side].values()];
|
|
39
|
+
return values.length ? [[side, Math.max(...values)]] : [];
|
|
40
|
+
}));
|
|
41
|
+
});
|
|
30
42
|
constructor(inputs) {
|
|
31
43
|
this.#inputs = inputs;
|
|
32
44
|
setContext(PLOT_MARGINS_KEY, this);
|
|
@@ -124,6 +136,10 @@ export class PlotMargins {
|
|
|
124
136
|
*/
|
|
125
137
|
follow(plot) {
|
|
126
138
|
this.#plot = plot;
|
|
139
|
+
const stores = getContext('svelteplot/autoMargins');
|
|
140
|
+
if (stores) {
|
|
141
|
+
this.#autoMargins = Object.fromEntries(Margins.SIDES.map((side) => [side, get(stores[PlotMargins.#AUTO_STORE[side]])]));
|
|
142
|
+
}
|
|
127
143
|
const cell = this.#cell;
|
|
128
144
|
if (!cell)
|
|
129
145
|
return;
|
|
@@ -132,6 +148,12 @@ export class PlotMargins {
|
|
|
132
148
|
cell.report(new Margins(Number(marginTop) || 0, Number(marginRight) || 0, Number(marginBottom) || 0, Number(marginLeft) || 0));
|
|
133
149
|
});
|
|
134
150
|
}
|
|
151
|
+
static #AUTO_STORE = {
|
|
152
|
+
top: 'autoMarginTop',
|
|
153
|
+
right: 'autoMarginRight',
|
|
154
|
+
bottom: 'autoMarginBottom',
|
|
155
|
+
left: 'autoMarginLeft'
|
|
156
|
+
};
|
|
135
157
|
/** The room the `reserve` boxes take past the edges their points can sit on. */
|
|
136
158
|
#reserved = $derived.by(() => this.#inputs.reserve().reduce((room, { box, edges }) => {
|
|
137
159
|
const reach = box.reach;
|
|
@@ -143,7 +165,10 @@ export class PlotMargins {
|
|
|
143
165
|
const settled = this.#settled;
|
|
144
166
|
const { width, height } = this.#inputs.size();
|
|
145
167
|
const growth = this.#measured.max(this.#reserved).min(Margins.half(width, height));
|
|
146
|
-
|
|
168
|
+
// A side grows from at least the room svelteplot's axes take on it: their ticks and title.
|
|
169
|
+
const estimate = this.#inputs
|
|
170
|
+
.estimate()
|
|
171
|
+
.map((value, side) => Math.max(value, this.#auto[side] ?? 0));
|
|
147
172
|
const out = {};
|
|
148
173
|
for (const side of Margins.SIDES) {
|
|
149
174
|
const own = author?.[side];
|
|
@@ -45,6 +45,6 @@ interface $$IsomorphicComponent {
|
|
|
45
45
|
<TRow extends Record<string, unknown>, TScales extends object, TCore extends PlotCoreBase>(internal: unknown, props: ReturnType<__sveltets_Render<TRow, TScales, TCore>['props']> & {}): ReturnType<__sveltets_Render<TRow, TScales, TCore>['exports']>;
|
|
46
46
|
z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
|
|
47
47
|
}
|
|
48
|
-
declare const
|
|
49
|
-
type
|
|
50
|
-
export default
|
|
48
|
+
declare const AbstractPlot: $$IsomorphicComponent;
|
|
49
|
+
type AbstractPlot<TRow extends Record<string, unknown>, TScales extends object, TCore extends PlotCoreBase> = InstanceType<typeof AbstractPlot<TRow, TScales, TCore>>;
|
|
50
|
+
export default AbstractPlot;
|
|
@@ -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
|
);
|
|
@@ -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;
|