@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
|
@@ -2,7 +2,8 @@ import { Box } from '../margins/Box';
|
|
|
2
2
|
import { PlotMargins } from '../margins/PlotMargins.svelte';
|
|
3
3
|
import { resolveAccessor } from '../../utils/accessors';
|
|
4
4
|
import { SERIES_KEY } from '../../phases/transforms/TransformsPhase';
|
|
5
|
-
import {
|
|
5
|
+
import { RowContext } from '../../phases/context/RowContext';
|
|
6
|
+
import { PlotAxes } from '../../phases/data/PlotAxes';
|
|
6
7
|
/** A tooltip anchor as the side of the point the tooltip sits on. */
|
|
7
8
|
const SIDES = {
|
|
8
9
|
left: 'before',
|
|
@@ -69,29 +70,33 @@ export class TooltipState {
|
|
|
69
70
|
return number && typeof value === 'number' ? number(value) : String(value);
|
|
70
71
|
}
|
|
71
72
|
/**
|
|
72
|
-
* How a hovered row reads by default, on every plot: its series,
|
|
73
|
-
* plot groups its rows; then where it sits - `category: value` when one
|
|
74
|
-
* axis
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* (the plot's `y` when neither axis holds categories) and the color's - read as it writes them.
|
|
73
|
+
* How a hovered row reads by default, on every plot, from its context (see {@link RowContext}): its series,
|
|
74
|
+
* when the plot groups its rows; then where it sits - `category: value` when one axis is a band of categories,
|
|
75
|
+
* else `x: y` (an axis the transforms spread into a span, a bin's, as `from-to`); then the value its color
|
|
76
|
+
* shows, when that is a number (a heatmap's cells). With `number`, the values - the one on the value axis and
|
|
77
|
+
* the color's - read as it writes them.
|
|
78
78
|
*/
|
|
79
79
|
static default(state, number) {
|
|
80
80
|
const processed = state.processedData;
|
|
81
81
|
if (!processed)
|
|
82
82
|
return () => '';
|
|
83
|
-
const
|
|
84
|
-
const
|
|
85
|
-
// With no band axis, the value is the y.
|
|
86
|
-
const valueY = TooltipState.#axisText(processed, 'y', number);
|
|
83
|
+
const valueAxis = PlotAxes.valueOf(state);
|
|
84
|
+
const contextOf = RowContext.reader(state);
|
|
87
85
|
const bandX = state.axes?.bands.includes('x') ?? false;
|
|
88
86
|
const bandY = state.axes?.bands.includes('y') ?? false;
|
|
89
|
-
const
|
|
87
|
+
const along = (axis) => {
|
|
88
|
+
const span = TooltipState.#spanText(processed, axis, number);
|
|
89
|
+
const measured = axis === valueAxis && !state.axes?.bands.includes(axis);
|
|
90
|
+
return (row) => span ? span(row) : TooltipState.value(contextOf(row)[axis], measured ? number : undefined);
|
|
91
|
+
};
|
|
92
|
+
const x = along('x');
|
|
93
|
+
const y = along('y');
|
|
94
|
+
const valueOf = (row) => TooltipState.value(contextOf(row).value, number);
|
|
90
95
|
const position = bandX && !bandY
|
|
91
|
-
? (row) => `${x(row)}: ${
|
|
96
|
+
? (row) => `${x(row)}: ${valueOf(row)}`
|
|
92
97
|
: bandY && !bandX
|
|
93
|
-
? (row) => `${y(row)}: ${
|
|
94
|
-
: (row) => `${x(row)}: ${
|
|
98
|
+
? (row) => `${y(row)}: ${valueOf(row)}`
|
|
99
|
+
: (row) => `${x(row)}: ${y(row)}`;
|
|
95
100
|
const grouped = state.channels?.grouping !== undefined;
|
|
96
101
|
const color = state.channels?.color;
|
|
97
102
|
const colorName = typeof color?.source === 'string' ? color.source : 'color';
|
|
@@ -106,26 +111,20 @@ export class TooltipState {
|
|
|
106
111
|
};
|
|
107
112
|
}
|
|
108
113
|
/**
|
|
109
|
-
* How
|
|
110
|
-
* the
|
|
114
|
+
* How an axis the transforms spread into a span reads on a processed row - a bin's edges as `from-to` - or
|
|
115
|
+
* `undefined` when the axis has a value of its own or is a stack's (whose own value the context gives).
|
|
111
116
|
*/
|
|
112
|
-
static #
|
|
117
|
+
static #spanText(processed, axis, number) {
|
|
113
118
|
const { channels, transforms } = processed;
|
|
114
|
-
const read = (channel) => resolveAccessor(channel);
|
|
115
|
-
const point = channels[axis];
|
|
116
|
-
if (point !== undefined) {
|
|
117
|
-
const value = read(point);
|
|
118
|
-
return (row) => TooltipState.value(value(row), number);
|
|
119
|
-
}
|
|
120
119
|
const low = channels[`${axis}1`];
|
|
121
120
|
const high = channels[`${axis}2`];
|
|
122
|
-
if (low === undefined || high === undefined)
|
|
123
|
-
return
|
|
121
|
+
if (channels[axis] !== undefined || low === undefined || high === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
if (transforms.some((t) => t.type === STACKS[axis]))
|
|
124
|
+
return undefined;
|
|
125
|
+
const read = (channel) => resolveAccessor(channel);
|
|
124
126
|
const from = read(low);
|
|
125
127
|
const to = read(high);
|
|
126
|
-
if (transforms.some((t) => t.type === STACKS[axis])) {
|
|
127
|
-
return (row) => TooltipState.value(Number(to(row)) - Number(from(row)), number);
|
|
128
|
-
}
|
|
129
128
|
return (row) => `${TooltipState.value(from(row), number)}-${TooltipState.value(to(row), number)}`;
|
|
130
129
|
}
|
|
131
130
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MarkerTraits } from '../types/markers/traits';
|
|
1
|
+
import type { InheritedChannel, MarkerTraits } from '../types/markers/traits';
|
|
2
2
|
/**
|
|
3
3
|
* Every marker kind's traits, in one row each. Typed over every kind, so a
|
|
4
4
|
* new kind can't be added without declaring all of its traits here.
|
|
@@ -6,20 +6,42 @@ import type { MarkerTraits } from '../types/markers/traits';
|
|
|
6
6
|
export declare class MarkerKinds {
|
|
7
7
|
static readonly traits: {
|
|
8
8
|
area: {
|
|
9
|
+
oriented: true;
|
|
10
|
+
inherits: ("grouping" | "x" | "y" | "color" | "opacity")[];
|
|
9
11
|
clip: true;
|
|
10
12
|
drawsRows: true;
|
|
11
13
|
legendSymbol: "area";
|
|
14
|
+
labels: {
|
|
15
|
+
default: "point";
|
|
16
|
+
path: "area";
|
|
17
|
+
point: "top";
|
|
18
|
+
};
|
|
12
19
|
};
|
|
13
20
|
arrow: {
|
|
14
21
|
clip: false;
|
|
15
22
|
drawsRows: true;
|
|
16
23
|
};
|
|
24
|
+
band: {
|
|
25
|
+
clip: true;
|
|
26
|
+
drawsRows: false;
|
|
27
|
+
legendSymbol: "rect";
|
|
28
|
+
};
|
|
17
29
|
bar: {
|
|
30
|
+
oriented: true;
|
|
31
|
+
inherits: ("x" | "y" | "color")[];
|
|
18
32
|
clip: true;
|
|
19
33
|
drawsRows: true;
|
|
20
34
|
legendSymbol: "bar";
|
|
35
|
+
labels: {
|
|
36
|
+
default: "box";
|
|
37
|
+
box: "band";
|
|
38
|
+
path: "box";
|
|
39
|
+
point: "box";
|
|
40
|
+
};
|
|
21
41
|
};
|
|
22
42
|
bollinger: {
|
|
43
|
+
oriented: true;
|
|
44
|
+
inherits: ("x" | "y")[];
|
|
23
45
|
clip: true;
|
|
24
46
|
drawsRows: true;
|
|
25
47
|
legendSymbol: "line";
|
|
@@ -29,14 +51,23 @@ export declare class MarkerKinds {
|
|
|
29
51
|
drawsRows: false;
|
|
30
52
|
};
|
|
31
53
|
box: {
|
|
54
|
+
oriented: true;
|
|
55
|
+
inherits: ("x" | "y")[];
|
|
32
56
|
clip: true;
|
|
33
57
|
drawsRows: true;
|
|
34
58
|
legendSymbol: "bar";
|
|
35
59
|
};
|
|
36
60
|
cell: {
|
|
61
|
+
inherits: ("x" | "y" | "color" | "opacity")[];
|
|
37
62
|
clip: true;
|
|
38
63
|
drawsRows: true;
|
|
39
64
|
legendSymbol: "cell";
|
|
65
|
+
labels: {
|
|
66
|
+
default: "box";
|
|
67
|
+
box: "cell";
|
|
68
|
+
path: "box";
|
|
69
|
+
point: "box";
|
|
70
|
+
};
|
|
40
71
|
};
|
|
41
72
|
component: {
|
|
42
73
|
clip: false;
|
|
@@ -47,10 +78,12 @@ export declare class MarkerKinds {
|
|
|
47
78
|
drawsRows: false;
|
|
48
79
|
};
|
|
49
80
|
delaunayLink: {
|
|
81
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
50
82
|
clip: true;
|
|
51
83
|
drawsRows: true;
|
|
52
84
|
};
|
|
53
85
|
delaunayMesh: {
|
|
86
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
54
87
|
clip: true;
|
|
55
88
|
drawsRows: true;
|
|
56
89
|
};
|
|
@@ -59,19 +92,27 @@ export declare class MarkerKinds {
|
|
|
59
92
|
drawsRows: false;
|
|
60
93
|
};
|
|
61
94
|
density: {
|
|
95
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
62
96
|
clip: true;
|
|
63
97
|
drawsRows: true;
|
|
64
98
|
legendSymbol: "area";
|
|
65
99
|
};
|
|
66
100
|
difference: {
|
|
101
|
+
inherits: ("x" | "y")[];
|
|
67
102
|
clip: true;
|
|
68
103
|
drawsRows: true;
|
|
69
104
|
legendSymbol: "area";
|
|
70
105
|
};
|
|
71
106
|
dot: {
|
|
107
|
+
inherits: ("symbol" | "x" | "y" | "color" | "opacity" | "r")[];
|
|
72
108
|
clip: false;
|
|
73
109
|
drawsRows: true;
|
|
74
110
|
legendSymbol: "dot";
|
|
111
|
+
labels: {
|
|
112
|
+
default: "point";
|
|
113
|
+
path: "rim";
|
|
114
|
+
point: "dot";
|
|
115
|
+
};
|
|
75
116
|
};
|
|
76
117
|
geo: {
|
|
77
118
|
clip: false;
|
|
@@ -94,11 +135,13 @@ export declare class MarkerKinds {
|
|
|
94
135
|
drawsRows: false;
|
|
95
136
|
};
|
|
96
137
|
hull: {
|
|
138
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
97
139
|
clip: true;
|
|
98
140
|
drawsRows: true;
|
|
99
141
|
legendSymbol: "area";
|
|
100
142
|
};
|
|
101
143
|
image: {
|
|
144
|
+
inherits: ("x" | "y")[];
|
|
102
145
|
clip: false;
|
|
103
146
|
drawsRows: true;
|
|
104
147
|
};
|
|
@@ -107,9 +150,15 @@ export declare class MarkerKinds {
|
|
|
107
150
|
drawsRows: false;
|
|
108
151
|
};
|
|
109
152
|
line: {
|
|
153
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
110
154
|
clip: true;
|
|
111
155
|
drawsRows: true;
|
|
112
156
|
legendSymbol: "line";
|
|
157
|
+
labels: {
|
|
158
|
+
default: "point";
|
|
159
|
+
path: "stroke";
|
|
160
|
+
point: "row";
|
|
161
|
+
};
|
|
113
162
|
};
|
|
114
163
|
link: {
|
|
115
164
|
clip: false;
|
|
@@ -120,11 +169,20 @@ export declare class MarkerKinds {
|
|
|
120
169
|
drawsRows: true;
|
|
121
170
|
};
|
|
122
171
|
rect: {
|
|
172
|
+
inherits: ("x" | "y" | "color" | "opacity")[];
|
|
123
173
|
clip: true;
|
|
124
174
|
drawsRows: true;
|
|
125
175
|
legendSymbol: "rect";
|
|
176
|
+
labels: {
|
|
177
|
+
default: "box";
|
|
178
|
+
box: "edges";
|
|
179
|
+
path: "box";
|
|
180
|
+
point: "box";
|
|
181
|
+
};
|
|
126
182
|
};
|
|
127
183
|
regression: {
|
|
184
|
+
oriented: true;
|
|
185
|
+
inherits: ("x" | "y")[];
|
|
128
186
|
clip: true;
|
|
129
187
|
drawsRows: true;
|
|
130
188
|
legendSymbol: "line";
|
|
@@ -139,40 +197,65 @@ export declare class MarkerKinds {
|
|
|
139
197
|
drawsRows: false;
|
|
140
198
|
};
|
|
141
199
|
text: {
|
|
200
|
+
inherits: ("x" | "y")[];
|
|
142
201
|
clip: false;
|
|
143
202
|
drawsRows: true;
|
|
144
203
|
};
|
|
145
204
|
tick: {
|
|
205
|
+
oriented: true;
|
|
206
|
+
inherits: "color"[];
|
|
146
207
|
clip: true;
|
|
147
208
|
drawsRows: true;
|
|
148
209
|
};
|
|
149
210
|
trail: {
|
|
211
|
+
inherits: ("grouping" | "x" | "y" | "color" | "opacity" | "r")[];
|
|
150
212
|
clip: true;
|
|
151
213
|
drawsRows: true;
|
|
152
214
|
legendSymbol: "line";
|
|
215
|
+
labels: {
|
|
216
|
+
default: "point";
|
|
217
|
+
path: "stroke";
|
|
218
|
+
point: "row";
|
|
219
|
+
};
|
|
153
220
|
};
|
|
154
221
|
vector: {
|
|
222
|
+
inherits: "length"[];
|
|
155
223
|
clip: false;
|
|
156
224
|
drawsRows: false;
|
|
157
225
|
};
|
|
158
226
|
violin: {
|
|
227
|
+
oriented: true;
|
|
228
|
+
inherits: ("x" | "y")[];
|
|
159
229
|
clip: true;
|
|
160
230
|
drawsRows: true;
|
|
161
231
|
legendSymbol: "area";
|
|
162
232
|
};
|
|
163
233
|
voronoi: {
|
|
234
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
164
235
|
clip: true;
|
|
165
236
|
drawsRows: true;
|
|
166
237
|
};
|
|
167
238
|
voronoiMesh: {
|
|
239
|
+
inherits: ("grouping" | "x" | "y" | "color")[];
|
|
168
240
|
clip: true;
|
|
169
241
|
drawsRows: true;
|
|
170
242
|
};
|
|
171
243
|
waffle: {
|
|
244
|
+
oriented: true;
|
|
245
|
+
inherits: ("x" | "y" | "color")[];
|
|
172
246
|
clip: true;
|
|
173
247
|
drawsRows: true;
|
|
248
|
+
labels: {
|
|
249
|
+
default: "box";
|
|
250
|
+
box: "band";
|
|
251
|
+
path: "box";
|
|
252
|
+
point: "box";
|
|
253
|
+
};
|
|
174
254
|
};
|
|
175
255
|
};
|
|
176
256
|
/** The traits of a marker kind, or `undefined` for a type no kind declares. */
|
|
177
257
|
static of(type: string | undefined): MarkerTraits | undefined;
|
|
258
|
+
static inherits(type: string | undefined, channel: InheritedChannel): boolean;
|
|
259
|
+
/** Whether the kind takes the plot's scales: it inherits a channel that has one. */
|
|
260
|
+
static inheritsScales(type: string | undefined): boolean;
|
|
178
261
|
}
|
|
@@ -1,47 +1,167 @@
|
|
|
1
|
+
const SCALED = ['color', 'opacity', 'symbol', 'r', 'length'];
|
|
1
2
|
/**
|
|
2
3
|
* Every marker kind's traits, in one row each. Typed over every kind, so a
|
|
3
4
|
* new kind can't be added without declaring all of its traits here.
|
|
4
5
|
*/
|
|
5
6
|
export class MarkerKinds {
|
|
6
7
|
static traits = {
|
|
7
|
-
area: {
|
|
8
|
+
area: {
|
|
9
|
+
oriented: true,
|
|
10
|
+
inherits: ['x', 'y', 'grouping', 'color', 'opacity'],
|
|
11
|
+
clip: true,
|
|
12
|
+
drawsRows: true,
|
|
13
|
+
legendSymbol: 'area',
|
|
14
|
+
labels: { default: 'point', path: 'area', point: 'top' }
|
|
15
|
+
},
|
|
8
16
|
arrow: { clip: false, drawsRows: true },
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
band: { clip: true, drawsRows: false, legendSymbol: 'rect' },
|
|
18
|
+
bar: {
|
|
19
|
+
oriented: true,
|
|
20
|
+
inherits: ['x', 'y', 'color'],
|
|
21
|
+
clip: true,
|
|
22
|
+
drawsRows: true,
|
|
23
|
+
legendSymbol: 'bar',
|
|
24
|
+
labels: { default: 'box', box: 'band', path: 'box', point: 'box' }
|
|
25
|
+
},
|
|
26
|
+
bollinger: {
|
|
27
|
+
oriented: true,
|
|
28
|
+
inherits: ['x', 'y'],
|
|
29
|
+
clip: true,
|
|
30
|
+
drawsRows: true,
|
|
31
|
+
legendSymbol: 'line'
|
|
32
|
+
},
|
|
11
33
|
brush: { clip: false, drawsRows: false },
|
|
12
|
-
box: {
|
|
13
|
-
|
|
34
|
+
box: {
|
|
35
|
+
oriented: true,
|
|
36
|
+
inherits: ['x', 'y'],
|
|
37
|
+
clip: true,
|
|
38
|
+
drawsRows: true,
|
|
39
|
+
legendSymbol: 'bar'
|
|
40
|
+
},
|
|
41
|
+
cell: {
|
|
42
|
+
inherits: ['x', 'y', 'color', 'opacity'],
|
|
43
|
+
clip: true,
|
|
44
|
+
drawsRows: true,
|
|
45
|
+
legendSymbol: 'cell',
|
|
46
|
+
labels: { default: 'box', box: 'cell', path: 'box', point: 'box' }
|
|
47
|
+
},
|
|
14
48
|
component: { clip: false, drawsRows: false },
|
|
15
49
|
contour: { clip: false, drawsRows: false },
|
|
16
|
-
delaunayLink: {
|
|
17
|
-
|
|
50
|
+
delaunayLink: {
|
|
51
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
52
|
+
clip: true,
|
|
53
|
+
drawsRows: true
|
|
54
|
+
},
|
|
55
|
+
delaunayMesh: {
|
|
56
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
57
|
+
clip: true,
|
|
58
|
+
drawsRows: true
|
|
59
|
+
},
|
|
18
60
|
delta: { clip: false, drawsRows: false },
|
|
19
|
-
density: {
|
|
20
|
-
|
|
21
|
-
|
|
61
|
+
density: {
|
|
62
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
63
|
+
clip: true,
|
|
64
|
+
drawsRows: true,
|
|
65
|
+
legendSymbol: 'area'
|
|
66
|
+
},
|
|
67
|
+
difference: {
|
|
68
|
+
inherits: ['x', 'y'],
|
|
69
|
+
clip: true,
|
|
70
|
+
drawsRows: true,
|
|
71
|
+
legendSymbol: 'area'
|
|
72
|
+
},
|
|
73
|
+
dot: {
|
|
74
|
+
inherits: ['x', 'y', 'color', 'opacity', 'symbol', 'r'],
|
|
75
|
+
clip: false,
|
|
76
|
+
drawsRows: true,
|
|
77
|
+
legendSymbol: 'dot',
|
|
78
|
+
labels: { default: 'point', path: 'rim', point: 'dot' }
|
|
79
|
+
},
|
|
22
80
|
geo: { clip: false, drawsRows: false },
|
|
23
81
|
'geo-component': { clip: false, drawsRows: true },
|
|
24
82
|
'geo-hover': { clip: false, drawsRows: false },
|
|
25
83
|
graticule: { clip: false, drawsRows: false },
|
|
26
84
|
hover: { clip: false, drawsRows: false },
|
|
27
|
-
hull: {
|
|
28
|
-
|
|
85
|
+
hull: {
|
|
86
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
87
|
+
clip: true,
|
|
88
|
+
drawsRows: true,
|
|
89
|
+
legendSymbol: 'area'
|
|
90
|
+
},
|
|
91
|
+
image: {
|
|
92
|
+
inherits: ['x', 'y'],
|
|
93
|
+
clip: false,
|
|
94
|
+
drawsRows: true
|
|
95
|
+
},
|
|
29
96
|
inset: { clip: false, drawsRows: false },
|
|
30
|
-
line: {
|
|
97
|
+
line: {
|
|
98
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
99
|
+
clip: true,
|
|
100
|
+
drawsRows: true,
|
|
101
|
+
legendSymbol: 'line',
|
|
102
|
+
labels: { default: 'point', path: 'stroke', point: 'row' }
|
|
103
|
+
},
|
|
31
104
|
link: { clip: false, drawsRows: false },
|
|
32
105
|
raster: { clip: true, drawsRows: true },
|
|
33
|
-
rect: {
|
|
34
|
-
|
|
106
|
+
rect: {
|
|
107
|
+
inherits: ['x', 'y', 'color', 'opacity'],
|
|
108
|
+
clip: true,
|
|
109
|
+
drawsRows: true,
|
|
110
|
+
legendSymbol: 'rect',
|
|
111
|
+
labels: { default: 'box', box: 'edges', path: 'box', point: 'box' }
|
|
112
|
+
},
|
|
113
|
+
regression: {
|
|
114
|
+
oriented: true,
|
|
115
|
+
inherits: ['x', 'y'],
|
|
116
|
+
clip: true,
|
|
117
|
+
drawsRows: true,
|
|
118
|
+
legendSymbol: 'line'
|
|
119
|
+
},
|
|
35
120
|
rule: { clip: true, drawsRows: false, legendSymbol: 'line' },
|
|
36
121
|
sphere: { clip: false, drawsRows: false },
|
|
37
|
-
text: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
122
|
+
text: {
|
|
123
|
+
inherits: ['x', 'y'],
|
|
124
|
+
clip: false,
|
|
125
|
+
drawsRows: true
|
|
126
|
+
},
|
|
127
|
+
tick: {
|
|
128
|
+
oriented: true,
|
|
129
|
+
inherits: ['color'],
|
|
130
|
+
clip: true,
|
|
131
|
+
drawsRows: true
|
|
132
|
+
},
|
|
133
|
+
trail: {
|
|
134
|
+
inherits: ['x', 'y', 'grouping', 'color', 'opacity', 'r'],
|
|
135
|
+
clip: true,
|
|
136
|
+
drawsRows: true,
|
|
137
|
+
legendSymbol: 'line',
|
|
138
|
+
labels: { default: 'point', path: 'stroke', point: 'row' }
|
|
139
|
+
},
|
|
140
|
+
vector: { inherits: ['length'], clip: false, drawsRows: false },
|
|
141
|
+
violin: {
|
|
142
|
+
oriented: true,
|
|
143
|
+
inherits: ['x', 'y'],
|
|
144
|
+
clip: true,
|
|
145
|
+
drawsRows: true,
|
|
146
|
+
legendSymbol: 'area'
|
|
147
|
+
},
|
|
148
|
+
voronoi: {
|
|
149
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
150
|
+
clip: true,
|
|
151
|
+
drawsRows: true
|
|
152
|
+
},
|
|
153
|
+
voronoiMesh: {
|
|
154
|
+
inherits: ['x', 'y', 'grouping', 'color'],
|
|
155
|
+
clip: true,
|
|
156
|
+
drawsRows: true
|
|
157
|
+
},
|
|
158
|
+
waffle: {
|
|
159
|
+
oriented: true,
|
|
160
|
+
inherits: ['x', 'y', 'color'],
|
|
161
|
+
clip: true,
|
|
162
|
+
drawsRows: true,
|
|
163
|
+
labels: { default: 'box', box: 'band', path: 'box', point: 'box' }
|
|
164
|
+
}
|
|
45
165
|
};
|
|
46
166
|
/** The traits of a marker kind, or `undefined` for a type no kind declares. */
|
|
47
167
|
static of(type) {
|
|
@@ -49,4 +169,11 @@ export class MarkerKinds {
|
|
|
49
169
|
? MarkerKinds.traits[type]
|
|
50
170
|
: undefined;
|
|
51
171
|
}
|
|
172
|
+
static inherits(type, channel) {
|
|
173
|
+
return MarkerKinds.of(type)?.inherits?.includes(channel) ?? false;
|
|
174
|
+
}
|
|
175
|
+
/** Whether the kind takes the plot's scales: it inherits a channel that has one. */
|
|
176
|
+
static inheritsScales(type) {
|
|
177
|
+
return SCALED.some((channel) => MarkerKinds.inherits(type, channel));
|
|
178
|
+
}
|
|
52
179
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
const events = MarkerEvents.use(() => marker);
|
|
17
17
|
|
|
18
18
|
const plot = usePlot();
|
|
19
|
-
const isHorizontal = $derived(plot.axes?.isHorizontal ?? false);
|
|
19
|
+
const isHorizontal = $derived(marker.isHorizontal ?? plot.axes?.isHorizontal ?? false);
|
|
20
20
|
const AreaMark = $derived(isHorizontal ? AreaX : AreaY);
|
|
21
21
|
|
|
22
22
|
const cfg = $derived(getConfiguration());
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { usePlot } from '../../layout/plot/usePlot';
|
|
3
|
+
import { getConfiguration } from '../../configuration/config.svelte';
|
|
4
|
+
import { MarkerEvents } from '../utils/MarkerEvents';
|
|
5
|
+
import { RowStyle } from '../utils/RowStyle';
|
|
6
|
+
import { Bands, type Band } from './Bands';
|
|
7
|
+
import type { BandMarkerConfig } from '../../types/markers/common';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Renders one `'band'` marker: a rectangle over the band of each category it names, across the whole of the
|
|
11
|
+
* other axis. Nothing on an axis that is not a band scale. It takes the pointer only with a handler of its own,
|
|
12
|
+
* so a band behind the plot's shapes does not take their hover.
|
|
13
|
+
*/
|
|
14
|
+
const { marker }: { marker: BandMarkerConfig } = $props();
|
|
15
|
+
const cfg = $derived(getConfiguration());
|
|
16
|
+
const events = MarkerEvents.use(() => marker);
|
|
17
|
+
const plot = usePlot().svelteplot;
|
|
18
|
+
|
|
19
|
+
const bands = $derived(Bands.of(marker));
|
|
20
|
+
const rows = $derived(marker.data ?? []);
|
|
21
|
+
const styles = $derived({ ...cfg.band, ...marker.styles });
|
|
22
|
+
const scale = $derived(plot.scales[marker.axis]);
|
|
23
|
+
const across = $derived(plot.scales[marker.axis === 'x' ? 'y' : 'x']);
|
|
24
|
+
|
|
25
|
+
/** The pixels the other axis spans, lowest first. */
|
|
26
|
+
const extent = $derived.by((): [number, number] => {
|
|
27
|
+
const range = across?.fn?.range?.() as number[] | undefined;
|
|
28
|
+
if (!range || range.length < 2) return [0, 0];
|
|
29
|
+
const [a, b] = [Number(range[0]), Number(range[range.length - 1])];
|
|
30
|
+
return [Math.min(a, b), Math.max(a, b)];
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
/** Where a band is drawn: its slice of the band along the axis, the other axis' whole span across it. */
|
|
34
|
+
function boxOf(band: Band) {
|
|
35
|
+
const bandwidth = scale.fn.bandwidth?.() ?? 0;
|
|
36
|
+
const start = Number(scale.fn(band.category as never));
|
|
37
|
+
const from = start + band.slice.start * bandwidth;
|
|
38
|
+
const size = Math.max(0, bandwidth * (1 - band.slice.start - band.slice.end));
|
|
39
|
+
const [low, high] = extent;
|
|
40
|
+
return marker.axis === 'x'
|
|
41
|
+
? { x: from, y: low, width: size, height: high - low }
|
|
42
|
+
: { x: low, y: from, width: high - low, height: size };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A color of `styles` for the row: a value, the field of the rows it names, or a function of the row. */
|
|
46
|
+
const colorOf = (style: unknown, row: unknown) => RowStyle.colorOf(style, rows)?.(row);
|
|
47
|
+
/** A number of `styles` for the row: a value, the field of the rows it names, or a function of the row. */
|
|
48
|
+
const numberOf = (style: unknown, row: unknown): number | undefined => {
|
|
49
|
+
const read = RowStyle.field(style as never) as unknown;
|
|
50
|
+
const value = typeof read === 'function' ? (read as (row: unknown) => unknown)(row) : read;
|
|
51
|
+
return value == null ? undefined : Number(value);
|
|
52
|
+
};
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
{#if scale?.type === 'band'}
|
|
56
|
+
<g class="band" pointer-events={events.any ? undefined : 'none'}>
|
|
57
|
+
{#each bands as band (band.category instanceof Date ? +band.category : band.category)}
|
|
58
|
+
{@const box = boxOf(band)}
|
|
59
|
+
{@const radius = numberOf(styles.borderRadius, band.row)}
|
|
60
|
+
<rect
|
|
61
|
+
{...box}
|
|
62
|
+
rx={radius}
|
|
63
|
+
ry={radius}
|
|
64
|
+
fill={colorOf(styles.fill, band.row)}
|
|
65
|
+
fill-opacity={numberOf(styles.fillOpacity, band.row)}
|
|
66
|
+
stroke={colorOf(styles.stroke, band.row)}
|
|
67
|
+
stroke-width={numberOf(styles.strokeWidth, band.row)}
|
|
68
|
+
stroke-opacity={numberOf(styles.strokeOpacity, band.row)}
|
|
69
|
+
stroke-dasharray={colorOf(styles.strokeDasharray, band.row)}
|
|
70
|
+
{...events.forRow(band.row, band.index)}
|
|
71
|
+
/>
|
|
72
|
+
{/each}
|
|
73
|
+
</g>
|
|
74
|
+
{/if}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { BandMarkerConfig } from '../../types/markers/common';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
marker: BandMarkerConfig;
|
|
4
|
+
};
|
|
5
|
+
declare const BandMarker: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
|
+
type BandMarker = ReturnType<typeof BandMarker>;
|
|
7
|
+
export default BandMarker;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AxisValue } from '../../types/layout/mapping';
|
|
2
|
+
import type { BandSlice } from '../../types/layout/hover';
|
|
3
|
+
import type { BandMarkerConfig } from '../../types/markers/common';
|
|
4
|
+
/** One band to draw: its category, the part of it filled, and the first row that names it. */
|
|
5
|
+
export type Band = {
|
|
6
|
+
category: AxisValue;
|
|
7
|
+
slice: BandSlice;
|
|
8
|
+
row: unknown;
|
|
9
|
+
index: number;
|
|
10
|
+
};
|
|
11
|
+
/** The bands a `band` marker draws, one per category its rows (or its `value`) name, in the order they first come. */
|
|
12
|
+
export declare class Bands {
|
|
13
|
+
#private;
|
|
14
|
+
/** The marker's bands. Rows that share a category share one band, which fills what all of their slices do. */
|
|
15
|
+
static of(marker: Pick<BandMarkerConfig, 'value' | 'slice' | 'data'>): Band[];
|
|
16
|
+
}
|