@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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildBoxDefaults } from './defaults';
|
|
4
4
|
import type { BoxPlotProps, BoxPlotCoreProps } from '../../../types/plots/distribution/box/props';
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}: BoxPlotProps<TData> = $props();
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
|
-
<
|
|
28
|
+
<AbstractPlot
|
|
29
29
|
core={core as BoxPlotCoreProps<TData>}
|
|
30
30
|
defaults={buildBoxDefaults}
|
|
31
31
|
bind:margins
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxisPlotDefaults } from '../../../types/phases';
|
|
2
|
-
import type { BoxPlotState,
|
|
2
|
+
import type { BoxPlotState, BoxPlotEnv } from '../../../types/plots/distribution/box/state';
|
|
3
3
|
/**
|
|
4
4
|
* BoxPlot on the shared pipeline: one box per category of each series along
|
|
5
5
|
* one category axis - `x`, or `y` for horizontal boxes, as the "data" phase
|
|
@@ -9,4 +9,4 @@ import type { BoxPlotState, BoxPlotCtx } from '../../../types/plots/distribution
|
|
|
9
9
|
* hover along the category axis, over one summary per box rather than every
|
|
10
10
|
* value inside it.
|
|
11
11
|
*/
|
|
12
|
-
export declare function buildBoxDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<BoxPlotState<TData>,
|
|
12
|
+
export declare function buildBoxDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<BoxPlotState<TData>, BoxPlotEnv>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { buildMarks } from './markers';
|
|
2
|
+
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
3
|
+
import { HoverDefaults } from '../../../layout/hover/HoverDefaults';
|
|
2
4
|
import { BoxSummaries } from './BoxSummaries';
|
|
3
|
-
import { TooltipState } from '../../../layout/tooltip/TooltipState.svelte';
|
|
4
5
|
/**
|
|
5
6
|
* BoxPlot on the shared pipeline: one box per category of each series along
|
|
6
7
|
* one category axis - `x`, or `y` for horizontal boxes, as the "data" phase
|
|
@@ -22,17 +23,30 @@ export function buildBoxDefaults() {
|
|
|
22
23
|
},
|
|
23
24
|
scales: {
|
|
24
25
|
bandOrder: 'data',
|
|
25
|
-
defaults: (_state,
|
|
26
|
-
category: { paddingInner:
|
|
26
|
+
defaults: (_state, env) => ({
|
|
27
|
+
category: { paddingInner: env.cfg.box.paddingInner, paddingOuter: env.cfg.box.paddingOuter }
|
|
27
28
|
})
|
|
28
29
|
},
|
|
30
|
+
// Each value's box: its quartiles and whiskers, worked out once for its tooltip and hover to read.
|
|
31
|
+
context: (state) => BoxSummaries.context(state),
|
|
32
|
+
styles: {
|
|
33
|
+
values: {
|
|
34
|
+
layout: 'point',
|
|
35
|
+
// A quartile is worked out, not read: at most two decimals, as the tooltip writes it.
|
|
36
|
+
format: (value, number) => number(Math.round(value * 100) / 100),
|
|
37
|
+
parts: {
|
|
38
|
+
placements: BoxSummaries.partPlacements,
|
|
39
|
+
default: ['min', 'median', 'max']
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
29
43
|
markers: { marks: buildMarks },
|
|
30
44
|
hover: {
|
|
45
|
+
// The hovered category's band behind its shape.
|
|
46
|
+
marker: (state) => HoverDefaults.behindBand(PlotAxes.other(PlotAxes.valueOf(state))),
|
|
31
47
|
rows: BoxSummaries.of,
|
|
32
48
|
position: BoxSummaries.position,
|
|
33
|
-
|
|
34
|
-
format: (state) => BoxSummaries.format(state),
|
|
35
|
-
sort: () => TooltipState.descending((row) => row.median)
|
|
49
|
+
format: (state) => BoxSummaries.format(state)
|
|
36
50
|
}
|
|
37
51
|
};
|
|
38
52
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BoxPlotState,
|
|
1
|
+
import type { BoxPlotState, BoxPlotEnv } from '../../../types/plots/distribution/box/state';
|
|
2
2
|
import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
3
3
|
/**
|
|
4
4
|
* BoxPlot's "markers" phase: one `box` per visual segment of each series,
|
|
@@ -9,4 +9,4 @@ import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
|
9
9
|
* A series toggled off in the legend (style mode), or dimmed by hovering
|
|
10
10
|
* another one, takes the legend's disabled fill.
|
|
11
11
|
*/
|
|
12
|
-
export declare function buildMarks<TData extends Record<string, unknown>>(state: BoxPlotState<TData>,
|
|
12
|
+
export declare function buildMarks<TData extends Record<string, unknown>>(state: BoxPlotState<TData>, env: BoxPlotEnv): AxisBasedMarkersConfig[];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { BoxSummaries } from './BoxSummaries';
|
|
2
|
+
import { SERIES_KEY } from '../../../phases/transforms/TransformsPhase';
|
|
1
3
|
/**
|
|
2
4
|
* BoxPlot's "markers" phase: one `box` per visual segment of each series,
|
|
3
5
|
* one box per category of its rows, filled with its series' color (or its
|
|
@@ -7,12 +9,12 @@
|
|
|
7
9
|
* A series toggled off in the legend (style mode), or dimmed by hovering
|
|
8
10
|
* another one, takes the legend's disabled fill.
|
|
9
11
|
*/
|
|
10
|
-
export function buildMarks(state,
|
|
12
|
+
export function buildMarks(state, env) {
|
|
11
13
|
const { channels } = state.processedData;
|
|
12
|
-
const { cfg } =
|
|
13
|
-
|
|
14
|
+
const { cfg } = env;
|
|
15
|
+
const boxes = (state.processedGroups ?? []).flatMap((group) => {
|
|
14
16
|
const name = group.series.name;
|
|
15
|
-
const disabled =
|
|
17
|
+
const disabled = env.interaction?.fillFor(name);
|
|
16
18
|
return group.visualSegments.map((seg) => {
|
|
17
19
|
const { stroke, strokeWidth, strokeOpacity, borderRadius } = seg.styles;
|
|
18
20
|
const fill = disabled?.fill ?? seg.styles.fill ?? state.colorForSeries(name);
|
|
@@ -38,4 +40,11 @@ export function buildMarks(state, ctx) {
|
|
|
38
40
|
};
|
|
39
41
|
});
|
|
40
42
|
});
|
|
43
|
+
// The parts of each box `styles.values` labels: its whiskers' ends and its median by default, beside it.
|
|
44
|
+
const labels = state.valueLabels?.show
|
|
45
|
+
? state.valueLabels.partMarkers(env, BoxSummaries.of(state), BoxSummaries.labelPoint(state), {
|
|
46
|
+
seriesColor: (row) => state.colorForSeries(String(row[SERIES_KEY]))
|
|
47
|
+
})
|
|
48
|
+
: [];
|
|
49
|
+
return [...boxes, ...labels];
|
|
41
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildDensityDefaults } from './defaults';
|
|
4
4
|
import type {
|
|
5
5
|
DensityPlotProps,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}: DensityPlotProps<TData> = $props();
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
|
-
<
|
|
31
|
+
<AbstractPlot
|
|
32
32
|
core={core as DensityPlotCoreProps<TData>}
|
|
33
33
|
defaults={buildDensityDefaults}
|
|
34
34
|
bind:margins
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AxisPlotDefaults } from '../../../types/phases';
|
|
2
|
-
import type { DensityPlotState,
|
|
2
|
+
import type { DensityPlotState, DensityPlotEnv } from '../../../types/plots/distribution/density/state';
|
|
3
3
|
/**
|
|
4
4
|
* DensityPlot on the shared pipeline: series read one position channel - `x`,
|
|
5
5
|
* or `y` for a horizontal curve - estimated by the plot's transforms merged
|
|
6
6
|
* over the default density of that axis, drawn from a zero baseline as an area
|
|
7
7
|
* or a line, and its own markers. Its plot defaults to: hover along the estimated axis.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildDensityDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DensityPlotState<TData>,
|
|
9
|
+
export declare function buildDensityDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<DensityPlotState<TData>, DensityPlotEnv>;
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
1
2
|
import { buildMarks } from './markers';
|
|
3
|
+
import { RowContext } from '../../../phases/context/RowContext';
|
|
4
|
+
import { TooltipState } from '../../../layout/tooltip/TooltipState.svelte';
|
|
5
|
+
import { NumberFormat } from '../../../utils/NumberFormat';
|
|
6
|
+
import { getConfiguration } from '../../../configuration/config.svelte';
|
|
7
|
+
/** A density is a small number: three decimals tell its points apart. */
|
|
8
|
+
const DENSITY_DECIMALS = 3;
|
|
2
9
|
/**
|
|
3
10
|
* The plot's own density along its axis merged over the default one, the
|
|
4
11
|
* author's props winning, and every other transform kept after it in order. A
|
|
@@ -27,9 +34,34 @@ export function buildDensityDefaults() {
|
|
|
27
34
|
}
|
|
28
35
|
},
|
|
29
36
|
transforms: {
|
|
37
|
+
// A curve is labelled at its peak.
|
|
38
|
+
labels: { select: 'max' },
|
|
30
39
|
transforms: (state) => mergeDensity(state.transforms ?? [], state.axes?.isHorizontal ?? false)
|
|
31
40
|
},
|
|
41
|
+
styles: {
|
|
42
|
+
values: {
|
|
43
|
+
layout: 'point',
|
|
44
|
+
layouts: { point: { side: 'above' }, path: { side: 'above', offset: 'max' } },
|
|
45
|
+
// The estimate tells a reader little: a label names the curve it is on, or a lone curve's peak position.
|
|
46
|
+
formatFor: (state) => {
|
|
47
|
+
const position = PlotAxes.other(PlotAxes.valueOf(state));
|
|
48
|
+
return (state.resolvedSeries?.length ?? 0) > 1
|
|
49
|
+
? (value, number, { series }) => series ?? number(value)
|
|
50
|
+
: (_value, number, context) => number(Number(context[position]));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
},
|
|
32
54
|
scales: { zero: ['value'] },
|
|
33
|
-
markers: { marks: buildMarks }
|
|
55
|
+
markers: { marks: buildMarks },
|
|
56
|
+
hover: {
|
|
57
|
+
// A hovered point reads as its estimate, the value its context gives it - a small number, written with
|
|
58
|
+
// three decimals unless the author asks otherwise.
|
|
59
|
+
label: (state) => {
|
|
60
|
+
const number = NumberFormat.of(NumberFormat.displayOf(state.values), getConfiguration(), DENSITY_DECIMALS);
|
|
61
|
+
return ((row) => number(Number(RowContext.of(row).value)));
|
|
62
|
+
},
|
|
63
|
+
// Its tooltip writes the estimate the same way.
|
|
64
|
+
format: (state) => TooltipState.default(state, NumberFormat.of(NumberFormat.displayOf(state.tooltip), getConfiguration(), DENSITY_DECIMALS))
|
|
65
|
+
}
|
|
34
66
|
};
|
|
35
67
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DensityPlotState,
|
|
1
|
+
import type { DensityPlotState, DensityPlotEnv } from '../../../types/plots/distribution/density/state';
|
|
2
2
|
import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
3
3
|
/**
|
|
4
4
|
* DensityPlot's "markers" phase: one `area` - or `line`, by `styles.mark` - per
|
|
@@ -6,4 +6,4 @@ import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
|
6
6
|
* its series. The markers the "statistics" phase already put in `state.markers`
|
|
7
7
|
* come after.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildMarks<TData extends Record<string, unknown>>(state: DensityPlotState<TData>,
|
|
9
|
+
export declare function buildMarks<TData extends Record<string, unknown>>(state: DensityPlotState<TData>, env: DensityPlotEnv): AxisBasedMarkersConfig[];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ValueLabels } from '../../../layout/styles/ValueLabels';
|
|
1
2
|
import { Transforms } from '../../../phases/transforms/Transforms';
|
|
2
3
|
/**
|
|
3
4
|
* DensityPlot's "markers" phase: one `area` - or `line`, by `styles.mark` - per
|
|
@@ -5,15 +6,15 @@ import { Transforms } from '../../../phases/transforms/Transforms';
|
|
|
5
6
|
* its series. The markers the "statistics" phase already put in `state.markers`
|
|
6
7
|
* come after.
|
|
7
8
|
*/
|
|
8
|
-
export function buildMarks(state,
|
|
9
|
+
export function buildMarks(state, env) {
|
|
9
10
|
const { channels, options, transforms } = state.processedData;
|
|
10
|
-
const { cfg } =
|
|
11
|
+
const { cfg } = env;
|
|
11
12
|
const styles = state.styles;
|
|
12
13
|
const asLine = styles?.mark === 'line';
|
|
13
|
-
|
|
14
|
+
const marks = (state.processedGroups ?? []).flatMap((group) => {
|
|
14
15
|
const name = group.series.name;
|
|
15
|
-
const disabledFill =
|
|
16
|
-
const disabledStroke =
|
|
16
|
+
const disabledFill = env.interaction?.fillFor(name);
|
|
17
|
+
const disabledStroke = env.interaction?.strokeFor(name);
|
|
17
18
|
return group.visualSegments.map((seg) => {
|
|
18
19
|
const color = seg.styles.fill ?? state.colorForSeries(name);
|
|
19
20
|
const style = asLine
|
|
@@ -43,4 +44,7 @@ export function buildMarks(state, ctx) {
|
|
|
43
44
|
}, transforms);
|
|
44
45
|
});
|
|
45
46
|
});
|
|
47
|
+
// `styles.values` labels each curve: its name at its peak by default, or along it.
|
|
48
|
+
const labels = state.valueLabels?.show ? state.valueLabels.forSeries(state, env) : undefined;
|
|
49
|
+
return ValueLabels.onMarkers(marks, asLine ? 'line' : 'area', labels);
|
|
46
50
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildHistogramDefaults } from './defaults';
|
|
4
4
|
import type {
|
|
5
5
|
HistogramPlotProps,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}: HistogramPlotProps<TData> = $props();
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
|
-
<
|
|
31
|
+
<AbstractPlot
|
|
32
32
|
core={core as HistogramPlotCoreProps<TData>}
|
|
33
33
|
defaults={buildHistogramDefaults}
|
|
34
34
|
bind:margins
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { AxisPlotDefaults } from '../../../types/phases';
|
|
2
|
-
import type { HistogramPlotState,
|
|
2
|
+
import type { HistogramPlotState, HistogramPlotEnv } from '../../../types/plots/distribution/histogram/state';
|
|
3
3
|
/**
|
|
4
4
|
* HistogramPlot on the shared pipeline: series read one position channel -
|
|
5
5
|
* `x`, or `y` for a horizontal histogram - binned by the plot's transforms
|
|
6
6
|
* merged over the default bin of that axis, bars from a zero baseline, and its
|
|
7
7
|
* own markers. Its plot defaults to: hover along the binned axis.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildHistogramDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<HistogramPlotState<TData>,
|
|
9
|
+
export declare function buildHistogramDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<HistogramPlotState<TData>, HistogramPlotEnv>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { buildMarks } from './markers';
|
|
2
|
-
import {
|
|
2
|
+
import { HoverDefaults } from '../../../layout/hover/HoverDefaults';
|
|
3
3
|
import { resolveAccessor } from '../../../utils/accessors';
|
|
4
4
|
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
5
5
|
/** One processed channel's value on a row - `undefined` for a channel the transforms didn't set. */
|
|
@@ -40,54 +40,54 @@ export function buildHistogramDefaults() {
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
transforms: {
|
|
43
|
-
|
|
43
|
+
labels: {},
|
|
44
|
+
transforms: (state, env) => mergeBin(state.transforms ?? [], env.cfg, state.axes?.isHorizontal ?? false)
|
|
45
|
+
},
|
|
46
|
+
// A bin's count and the edges it spans, for its label, its tooltip and its hover.
|
|
47
|
+
context: (state) => {
|
|
48
|
+
const { channels } = state.processedData;
|
|
49
|
+
const value = PlotAxes.valueOf(state);
|
|
50
|
+
const binned = PlotAxes.other(value);
|
|
51
|
+
const [count, from, to] = [
|
|
52
|
+
channels[value],
|
|
53
|
+
channels[`${binned}1`],
|
|
54
|
+
channels[`${binned}2`]
|
|
55
|
+
].map(readChannel);
|
|
56
|
+
return ((row) => ({
|
|
57
|
+
count: Number(count(row)),
|
|
58
|
+
from: Number(from(row)),
|
|
59
|
+
to: Number(to(row))
|
|
60
|
+
}));
|
|
44
61
|
},
|
|
45
62
|
scales: { zero: ['value'] },
|
|
46
63
|
styles: {
|
|
47
64
|
values: {
|
|
65
|
+
layout: 'path',
|
|
66
|
+
// A bin's value runs up, or right on a horizontal histogram: its end is that edge.
|
|
67
|
+
layouts: (state) => {
|
|
68
|
+
const end = state.axes?.isHorizontal ? 'right' : 'top';
|
|
69
|
+
return {
|
|
70
|
+
path: { edge: end, side: 'outside' },
|
|
71
|
+
box: { anchor: 'middle' },
|
|
72
|
+
point: { anchor: end, side: state.axes?.isHorizontal ? 'after' : 'above' }
|
|
73
|
+
};
|
|
74
|
+
},
|
|
48
75
|
// An `'outside'` label sits past its bin's end, which the longest bin takes to the edge.
|
|
49
76
|
reach: (labels, state) => {
|
|
50
|
-
|
|
77
|
+
const end = state.axes?.isHorizontal ? 'right' : 'top';
|
|
78
|
+
const { edge, side = 'outside' } = labels.placement;
|
|
79
|
+
if (labels.layout !== 'path' || edge !== end || side !== 'outside')
|
|
51
80
|
return [];
|
|
52
81
|
return state.axes?.isHorizontal
|
|
53
|
-
? [
|
|
54
|
-
|
|
55
|
-
'right'
|
|
56
|
-
])
|
|
57
|
-
]
|
|
58
|
-
: [
|
|
59
|
-
labels.edgeBox('0', { x: 'middle', y: 'before' }, { y: -labels.offset('y') }, [
|
|
60
|
-
'top'
|
|
61
|
-
])
|
|
62
|
-
];
|
|
82
|
+
? [labels.edgeBox('0', { x: 'after', y: 'middle' }, { x: labels.offset() }, ['right'])]
|
|
83
|
+
: [labels.edgeBox('0', { x: 'middle', y: 'before' }, { y: -labels.offset() }, ['top'])];
|
|
63
84
|
}
|
|
64
85
|
}
|
|
65
86
|
},
|
|
66
87
|
markers: { marks: buildMarks },
|
|
67
88
|
hover: {
|
|
68
|
-
//
|
|
69
|
-
|
|
70
|
-
label: (state) => {
|
|
71
|
-
const count = readChannel(state.processedData.channels[PlotAxes.valueOf(state)]);
|
|
72
|
-
return ((row) => String(Number(count(row))));
|
|
73
|
-
},
|
|
74
|
-
row: (state) => {
|
|
75
|
-
const { channels } = state.processedData;
|
|
76
|
-
const value = PlotAxes.valueOf(state);
|
|
77
|
-
const binned = PlotAxes.other(value);
|
|
78
|
-
const [count, from, to] = [
|
|
79
|
-
channels[value],
|
|
80
|
-
channels[`${binned}1`],
|
|
81
|
-
channels[`${binned}2`]
|
|
82
|
-
].map(readChannel);
|
|
83
|
-
return ((row) => ({
|
|
84
|
-
...row,
|
|
85
|
-
count: Number(count(row)),
|
|
86
|
-
from: Number(from(row)),
|
|
87
|
-
to: Number(to(row)),
|
|
88
|
-
group: row[SERIES_KEY]
|
|
89
|
-
}));
|
|
90
|
-
}
|
|
89
|
+
// The hovered bin's span behind its bar, the whole height of the plot: a bin is no band of a category.
|
|
90
|
+
marker: (state) => HoverDefaults.behindSpan(PlotAxes.other(PlotAxes.valueOf(state)), 'from', 'to')
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HistogramPlotState,
|
|
1
|
+
import type { HistogramPlotState, HistogramPlotEnv } from '../../../types/plots/distribution/histogram/state';
|
|
2
2
|
import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
3
3
|
/**
|
|
4
4
|
* HistogramPlot's "markers" phase: one `rect` per visual segment of each
|
|
@@ -6,4 +6,4 @@ import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
|
6
6
|
* the "statistics" phase already put in `state.markers` come after, and its
|
|
7
7
|
* value labels last.
|
|
8
8
|
*/
|
|
9
|
-
export declare function buildMarks<TData extends Record<string, unknown>>(state: HistogramPlotState<TData>,
|
|
9
|
+
export declare function buildMarks<TData extends Record<string, unknown>>(state: HistogramPlotState<TData>, env: HistogramPlotEnv): AxisBasedMarkersConfig[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ProcessedPositions } from '../../../phases/transforms/ProcessedPositions';
|
|
2
|
-
import { ValueLabels } from '../../../layout/styles/ValueLabels';
|
|
3
2
|
import { Transforms } from '../../../phases/transforms/Transforms';
|
|
4
3
|
import { resolveAccessor } from '../../../utils/accessors';
|
|
5
4
|
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
@@ -9,9 +8,9 @@ import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
|
9
8
|
* the "statistics" phase already put in `state.markers` come after, and its
|
|
10
9
|
* value labels last.
|
|
11
10
|
*/
|
|
12
|
-
export function buildMarks(state,
|
|
11
|
+
export function buildMarks(state, env) {
|
|
13
12
|
const { channels, options, transforms } = state.processedData;
|
|
14
|
-
const fillOpacity =
|
|
13
|
+
const fillOpacity = env.cfg.histogram.fillOpacity;
|
|
15
14
|
// Each bin writes its own count, along its bar: past its top (`'outside'`), against an edge, at its tip or its
|
|
16
15
|
// base - upward, or rightward on a horizontal histogram. A bin with nothing in it writes nothing.
|
|
17
16
|
const labels = state.valueLabels?.show ? state.valueLabels : undefined;
|
|
@@ -23,18 +22,20 @@ export function buildMarks(state, ctx) {
|
|
|
23
22
|
const bottomOf = read(channels[`${value}1`]) ?? (() => 0);
|
|
24
23
|
const countRead = read(channels[value]);
|
|
25
24
|
const countOf = (d) => countRead ? Number(countRead(d)) : Number(position[value](d)) - Number(bottomOf(d));
|
|
26
|
-
const labelFor = (name) => labels?.
|
|
25
|
+
const labelFor = (name) => labels?.label(env, (d) => (countOf(d) > 0 ? labels.text(d) : ''), {
|
|
27
26
|
fill: 'currentColor',
|
|
28
|
-
|
|
27
|
+
labelled: state.labelled,
|
|
28
|
+
seriesColor: () => state.colorForSeries(name)
|
|
29
29
|
});
|
|
30
30
|
const rects = (state.processedGroups ?? []).flatMap((group) => {
|
|
31
|
-
const disabled =
|
|
31
|
+
const disabled = env.interaction?.fillFor(group.series.name);
|
|
32
32
|
// A stroke the segment sets is not a reason to lose the series' fill, as the marker would take it for the color.
|
|
33
33
|
const color = state.colorForSeries(group.series.name);
|
|
34
34
|
return group.visualSegments.map((seg) => Transforms.finish({
|
|
35
35
|
type: 'rect',
|
|
36
36
|
series: group.series.name,
|
|
37
37
|
data: seg.data,
|
|
38
|
+
hover: 'style',
|
|
38
39
|
...(labels ? { label: labelFor(group.series.name) } : {}),
|
|
39
40
|
...channels,
|
|
40
41
|
...options,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildPyramidDefaults } from './defaults';
|
|
4
4
|
import type {
|
|
5
5
|
PyramidPlotProps,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
}: PyramidPlotProps<TData> = $props();
|
|
28
28
|
</script>
|
|
29
29
|
|
|
30
|
-
<
|
|
30
|
+
<AbstractPlot
|
|
31
31
|
core={core as PyramidPlotCoreProps<TData>}
|
|
32
32
|
defaults={buildPyramidDefaults}
|
|
33
33
|
bind:margins
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AxisPlotDefaults } from '../../../types/phases';
|
|
2
|
-
import type { PyramidPlotState,
|
|
2
|
+
import type { PyramidPlotState, PyramidPlotEnv } from '../../../types/plots/distribution/pyramid/state';
|
|
3
3
|
/**
|
|
4
4
|
* PyramidPlot on the shared pipeline. Its `x`/`y` are the visual axes: the one
|
|
5
5
|
* holding categories (read off the values by the "data" phase) runs the bars,
|
|
@@ -10,4 +10,4 @@ import type { PyramidPlotState, PyramidPlotCtx } from '../../../types/plots/dist
|
|
|
10
10
|
* category and magnitude.
|
|
11
11
|
* Its plot defaults to: hover along the category axis; the tween is of the magnitude, keyed by category and side.
|
|
12
12
|
*/
|
|
13
|
-
export declare function buildPyramidDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<PyramidPlotState<TData>,
|
|
13
|
+
export declare function buildPyramidDefaults<TData extends Record<string, unknown>>(): AxisPlotDefaults<PyramidPlotState<TData>, PyramidPlotEnv>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ProcessedPositions } from '../../../phases/transforms/ProcessedPositions';
|
|
2
|
+
import { HoverDefaults } from '../../../layout/hover/HoverDefaults';
|
|
2
3
|
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
3
4
|
import { buildMarks } from './markers';
|
|
4
5
|
import { ValueLabels } from '../../../layout/styles/ValueLabels';
|
|
@@ -44,18 +45,25 @@ export function buildPyramidDefaults() {
|
|
|
44
45
|
value: { tickFormat: (v) => String(Math.abs(Number(v))) }
|
|
45
46
|
})
|
|
46
47
|
},
|
|
48
|
+
transforms: { labels: {} },
|
|
47
49
|
styles: {
|
|
48
50
|
values: {
|
|
51
|
+
layout: 'path',
|
|
52
|
+
layouts: {
|
|
53
|
+
path: { edge: 'tip', side: 'outside' },
|
|
54
|
+
box: { anchor: 'middle' },
|
|
55
|
+
point: { anchor: 'top', side: 'above' }
|
|
56
|
+
},
|
|
49
57
|
// A label past its bar's end reaches out on its own side, the longest bar's to the edge.
|
|
50
58
|
reach: (labels, state) => {
|
|
51
|
-
if (labels.
|
|
59
|
+
if (!labels.pastTip)
|
|
52
60
|
return [];
|
|
53
61
|
const axis = PlotAxes.valueOf(state);
|
|
54
62
|
const isHorizontal = state.axes?.isHorizontal ?? true;
|
|
55
|
-
const offset = labels.offset(
|
|
63
|
+
const offset = labels.offset();
|
|
56
64
|
return labels.extremes(state.resolvedSeries ?? [], axis).map(({ series, value }) => {
|
|
57
65
|
const left = series.side === 'left';
|
|
58
|
-
const text = labels.format(Math.abs(value), series.name);
|
|
66
|
+
const text = labels.format(Math.abs(value), undefined, series.name);
|
|
59
67
|
return isHorizontal
|
|
60
68
|
? labels.edgeBox(text, { x: left ? 'before' : 'after', y: 'middle' }, { x: left ? -offset : offset }, [left ? 'left' : 'right'])
|
|
61
69
|
: labels.edgeBox(text, { x: 'middle', y: left ? 'after' : 'before' }, { y: left ? offset : -offset }, [left ? 'bottom' : 'top']);
|
|
@@ -65,6 +73,8 @@ export function buildPyramidDefaults() {
|
|
|
65
73
|
},
|
|
66
74
|
markers: { marks: buildMarks },
|
|
67
75
|
hover: {
|
|
76
|
+
// The hovered age group's band behind its bars, across both sides.
|
|
77
|
+
marker: (state) => HoverDefaults.behindBand(PlotAxes.other(PlotAxes.valueOf(state))),
|
|
68
78
|
// A bar sits at its signed magnitude - below or left of the baseline on the first
|
|
69
79
|
// side - and its category, and reads as its magnitude.
|
|
70
80
|
position: (state) => {
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
import type { PyramidPlotState,
|
|
1
|
+
import type { PyramidPlotState, PyramidPlotEnv } from '../../../types/plots/distribution/pyramid/state';
|
|
2
2
|
import type { AxisBasedMarkersConfig } from '../../../types/markers/common';
|
|
3
|
-
|
|
4
|
-
* PyramidPlot's "markers" phase: one `role: 'segment'` bar per visual
|
|
5
|
-
* segment, along the category axis the "data" phase read (horizontal bars for
|
|
6
|
-
* categories on y, signed magnitude on x; vertical ones the other way) and with
|
|
7
|
-
* no insets - prepended onto whatever the "statistics" phase already put in
|
|
8
|
-
* `state.markers`. Emits no `role: 'hitArea'` markers - PyramidPlot's hover
|
|
9
|
-
* matches nearest points rather than hit-testing category bands.
|
|
10
|
-
*/
|
|
11
|
-
export declare function buildMarks<TData extends Record<string, unknown>>(state: PyramidPlotState<TData>, ctx: PyramidPlotCtx): AxisBasedMarkersConfig[];
|
|
3
|
+
export declare function buildMarks<TData extends Record<string, unknown>>(state: PyramidPlotState<TData>, env: PyramidPlotEnv): AxisBasedMarkersConfig[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ValueLabels } from '../../../layout/styles/ValueLabels';
|
|
2
1
|
import { resolveAccessor } from '../../../utils/accessors';
|
|
3
2
|
import { seriesIdOf } from '../../../utils/grouping';
|
|
4
3
|
import { PlotAxes } from '../../../phases/data/PlotAxes';
|
|
@@ -8,26 +7,13 @@ const GAP_KINDS = ['start', 'middle', 'end'];
|
|
|
8
7
|
function signFor(s, magnitude) {
|
|
9
8
|
return s.side === 'left' ? -magnitude : magnitude;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
* PyramidPlot's "markers" phase: one `role: 'segment'` bar per visual
|
|
13
|
-
* segment, along the category axis the "data" phase read (horizontal bars for
|
|
14
|
-
* categories on y, signed magnitude on x; vertical ones the other way) and with
|
|
15
|
-
* no insets - prepended onto whatever the "statistics" phase already put in
|
|
16
|
-
* `state.markers`. Emits no `role: 'hitArea'` markers - PyramidPlot's hover
|
|
17
|
-
* matches nearest points rather than hit-testing category bands.
|
|
18
|
-
*/
|
|
19
|
-
export function buildMarks(state, ctx) {
|
|
10
|
+
export function buildMarks(state, env) {
|
|
20
11
|
const { groupedSeries, gapFillMaps } = state;
|
|
21
12
|
const gapDefaults = getConfiguration().pyramid.gap;
|
|
22
13
|
const categoryAxis = PlotAxes.categoryOf(state);
|
|
23
14
|
const valueAxis = PlotAxes.valueOf(state);
|
|
24
15
|
const isHorizontal = state.axes?.isHorizontal ?? true;
|
|
25
16
|
const labels = state.valueLabels?.show ? state.valueLabels : undefined;
|
|
26
|
-
/**
|
|
27
|
-
* Where a series' labels sit on its bars, which run out from the shared baseline to its own side: left and right
|
|
28
|
-
* of it on a horizontal pyramid, down and up on a vertical one.
|
|
29
|
-
*/
|
|
30
|
-
const anchorOf = (side) => ValueLabels.boxAnchor(labels?.anchor ?? 'outside', { isHorizontal, negative: side === 'left' });
|
|
31
17
|
/** One bar's own channels: its category, and its span from the baseline to its signed value. */
|
|
32
18
|
const span = (category, to) => ({
|
|
33
19
|
isHorizontal,
|
|
@@ -47,7 +33,7 @@ export function buildMarks(state, ctx) {
|
|
|
47
33
|
// practice, just not provably so to TypeScript here.
|
|
48
34
|
const category = group.series[categoryAxis];
|
|
49
35
|
const defaultColor = state.colorForSeries(group.series.name);
|
|
50
|
-
const disabledFill =
|
|
36
|
+
const disabledFill = env.interaction?.fillFor(group.series.name);
|
|
51
37
|
const processed = processedGroups.get(seriesIdOf(group.series));
|
|
52
38
|
const processedCategory = processed?.series[categoryAxis];
|
|
53
39
|
const getMagnitude = resolveAccessor((processed?.series[valueAxis] ?? group.series[valueAxis]));
|
|
@@ -60,11 +46,16 @@ export function buildMarks(state, ctx) {
|
|
|
60
46
|
type: 'bar',
|
|
61
47
|
role: 'segment',
|
|
62
48
|
data: realData,
|
|
49
|
+
hover: 'style',
|
|
63
50
|
...span(processedCategory, signed),
|
|
64
|
-
// Each bar writes its own magnitude
|
|
51
|
+
// Each bar writes its own magnitude; a bar's tip is on its own side of the baseline.
|
|
65
52
|
...(labels
|
|
66
53
|
? {
|
|
67
|
-
label: labels.
|
|
54
|
+
label: labels.label(env, (d) => labels.format(Math.abs(Number(getMagnitude(d))), d, group.series.name), {
|
|
55
|
+
fill: 'currentColor',
|
|
56
|
+
labelled: state.labelled,
|
|
57
|
+
seriesColor: () => state.colorForSeries(group.series.name)
|
|
58
|
+
})
|
|
68
59
|
}
|
|
69
60
|
: {}),
|
|
70
61
|
styles: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildViolinDefaults } from './defaults';
|
|
4
4
|
import type {
|
|
5
5
|
ViolinPlotProps,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}: ViolinPlotProps<TData> = $props();
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
|
-
<
|
|
31
|
+
<AbstractPlot
|
|
32
32
|
core={core as ViolinPlotCoreProps<TData>}
|
|
33
33
|
defaults={buildViolinDefaults}
|
|
34
34
|
bind:margins
|