@fundar/data-chart-telling 1.0.0 → 1.2.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 +53 -0
- package/README.md +58 -19
- package/dist/configuration/config.svelte.d.ts +1 -1
- package/dist/configuration/config.svelte.js +172 -95
- package/dist/configuration/themes/index.d.ts +5 -1304
- package/dist/index.d.ts +24 -14
- package/dist/index.js +20 -10
- package/dist/layout/base/BasePlotLayout.svelte +129 -51
- package/dist/layout/base/BasePlotLayout.svelte.d.ts +1 -38
- package/dist/layout/coordinates/CoordinatesLayout.svelte +42 -40
- package/dist/layout/coordinates/CoordinatesLayout.svelte.d.ts +0 -2
- package/dist/layout/coordinates/ProjectionZoom.svelte +48 -0
- package/dist/layout/coordinates/ProjectionZoom.svelte.d.ts +10 -0
- package/dist/layout/coordinates/ZoomedProjection.d.ts +11 -0
- package/dist/layout/coordinates/ZoomedProjection.js +24 -0
- package/dist/layout/coordinates/camera.svelte.js +11 -8
- package/dist/layout/coordinates/projections/argentina.js +1 -1
- package/dist/layout/coordinates/projections/fit.d.ts +1 -1
- package/dist/layout/coordinates/projections/fit.js +1 -1
- package/dist/layout/coordinates/zoom.svelte.d.ts +4 -5
- package/dist/layout/coordinates/zoom.svelte.js +4 -5
- package/dist/layout/facet/FacetLayout.svelte +1 -1
- package/dist/layout/facet/config.js +1 -1
- package/dist/layout/figure/Figure.svelte +2 -0
- package/dist/layout/geometry/GeometryLayout.svelte +14 -9
- package/dist/layout/geometry/GeometryLayout.svelte.d.ts +0 -3
- package/dist/layout/geometry/MarkerOffset.svelte +28 -0
- package/dist/layout/geometry/MarkerOffset.svelte.d.ts +13 -0
- package/dist/layout/grid/GridCell.svelte +6 -8
- package/dist/layout/hover/HoverSettings.d.ts +20 -6
- package/dist/layout/hover/HoverSettings.js +29 -4
- package/dist/layout/legend/ContinuousSection.svelte +44 -9
- package/dist/layout/legend/DiscreteBadgeItem.svelte +2 -2
- package/dist/layout/legend/DiscreteSection.svelte +2 -2
- package/dist/layout/legend/DiscreteSymbolIcon.svelte +1 -1
- package/dist/layout/legend/LegendChannels.js +36 -12
- package/dist/layout/legend/LegendLayout.svelte +9 -1
- package/dist/layout/legend/LegendState.svelte.d.ts +9 -0
- package/dist/layout/legend/LegendState.svelte.js +24 -3
- package/dist/layout/legend/SizeSection.svelte +1 -1
- package/dist/layout/margins/PlotMargins.svelte.d.ts +2 -5
- package/dist/layout/margins/PlotMargins.svelte.js +4 -8
- package/dist/layout/plot/Plot.svelte +6 -3
- package/dist/layout/plot/PublicPlotContext.d.ts +5 -4
- package/dist/layout/plot/PublicPlotContext.js +7 -3
- package/dist/layout/plot/Slice.d.ts +5 -1
- package/dist/layout/plot/Slice.js +18 -6
- package/dist/layout/scales/EdgeTicks.d.ts +39 -0
- package/dist/layout/scales/EdgeTicks.js +82 -0
- package/dist/layout/scales/NiceTicks.d.ts +43 -0
- package/dist/layout/scales/NiceTicks.js +76 -0
- package/dist/layout/scales/ScalesLayout.svelte +133 -34
- package/dist/layout/scales/ScalesLayout.svelte.d.ts +10 -0
- package/dist/layout/scales/SveltePlotScale.d.ts +15 -0
- package/dist/layout/scales/SveltePlotScale.js +86 -0
- package/dist/layout/scales/TickLabels.d.ts +32 -0
- package/dist/layout/scales/TickLabels.js +55 -0
- package/dist/layout/styles/StylesLayout.svelte +2 -2
- package/dist/layout/styles/ValueLabels.d.ts +33 -5
- package/dist/layout/styles/ValueLabels.js +83 -23
- package/dist/layout/timeline/Timeline.svelte +5 -2
- package/dist/layout/timeline/Timeline.svelte.d.ts +2 -0
- package/dist/layout/timeline/TimelineLayout.svelte +39 -13
- package/dist/layout/timeline/TimelineLayout.svelte.d.ts +7 -5
- package/dist/layout/timeline/TimelineRule.svelte +1 -0
- package/dist/layout/timeline/TimelineState.svelte.d.ts +13 -5
- package/dist/layout/timeline/TimelineState.svelte.js +42 -8
- package/dist/layout/timeline/TimelineTime.d.ts +18 -0
- package/dist/layout/timeline/TimelineTime.js +117 -0
- package/dist/layout/tooltip/Tooltip.svelte +10 -7
- package/dist/layout/tooltip/Tooltip.svelte.d.ts +6 -4
- package/dist/layout/tooltip/TooltipState.svelte.d.ts +8 -2
- package/dist/layout/tooltip/TooltipState.svelte.js +23 -4
- package/dist/markers/MarkerKinds.d.ts +5 -0
- package/dist/markers/MarkerKinds.js +1 -0
- package/dist/markers/area/AreaMarker.svelte +15 -63
- package/dist/markers/arrow/ArrowMarker.svelte +51 -9
- package/dist/markers/bar/BarMarker.svelte +8 -4
- package/dist/markers/bollinger/BollingerMarker.svelte +33 -18
- package/dist/markers/box/BoxMarker.svelte +40 -9
- package/dist/markers/delta/Delta.js +1 -1
- package/dist/markers/delta/DeltaMarker.svelte +9 -7
- package/dist/markers/dot/DotMarker.svelte +24 -27
- package/dist/markers/image/ImageMarker.svelte +17 -12
- package/dist/markers/inset/InsetMarker.svelte +2 -2
- package/dist/markers/line/LineMarker.svelte +1 -0
- package/dist/markers/link/LinkMarker.svelte +174 -29
- package/dist/markers/regression/RegressionMarker.svelte +16 -33
- package/dist/markers/rule/RuleMarker.svelte +9 -3
- package/dist/markers/text/Declutter.d.ts +4 -0
- package/dist/markers/text/Declutter.js +26 -11
- package/dist/markers/text/TextMarker.svelte +91 -48
- package/dist/markers/tick/TickMarker.svelte +27 -25
- package/dist/markers/utils/MarkerChannels.d.ts +24 -0
- package/dist/markers/utils/MarkerChannels.js +42 -7
- package/dist/markers/utils/RowOffset.d.ts +23 -0
- package/dist/markers/utils/RowOffset.js +23 -0
- package/dist/markers/utils/RowOffsetMarks.svelte +30 -0
- package/dist/markers/utils/RowOffsetMarks.svelte.d.ts +33 -0
- package/dist/markers/utils/RowStroke.d.ts +31 -0
- package/dist/markers/utils/RowStroke.js +28 -0
- package/dist/markers/violin/ViolinMarker.svelte +75 -0
- package/dist/markers/violin/ViolinMarker.svelte.d.ts +7 -0
- package/dist/markers/violin/ViolinProfiles.d.ts +29 -0
- package/dist/markers/violin/ViolinProfiles.js +55 -0
- package/dist/markers/waffle/WaffleMarker.svelte +17 -37
- package/dist/phases/Pipeline.d.ts +5 -0
- package/dist/phases/Pipeline.js +8 -2
- package/dist/phases/data/DataPhase.d.ts +5 -11
- package/dist/phases/data/DataPhase.js +14 -11
- package/dist/phases/data/PlotAxes.d.ts +10 -0
- package/dist/phases/data/PlotAxes.js +14 -1
- package/dist/phases/facet/FacetPanels.d.ts +55 -0
- package/dist/phases/facet/FacetPanels.js +96 -0
- package/dist/phases/facet/FacetPhase.d.ts +1 -42
- package/dist/phases/facet/FacetPhase.js +1 -87
- package/dist/phases/hover/HoverPhase.d.ts +6 -43
- package/dist/phases/hover/HoverPhase.js +19 -54
- package/dist/phases/mapping/MappingPhase.d.ts +1 -1
- package/dist/phases/mapping/MappingPhase.js +3 -5
- package/dist/phases/markers/MarkersPhase.js +2 -1
- package/dist/phases/scales/CategoryOrder.d.ts +23 -0
- package/dist/phases/scales/CategoryOrder.js +73 -0
- package/dist/phases/scales/ScalesPhase.d.ts +1 -3
- package/dist/phases/scales/ScalesPhase.js +37 -27
- package/dist/phases/sharedScales/SharedScalesPhase.d.ts +6 -2
- package/dist/phases/sharedScales/SharedScalesPhase.js +14 -8
- package/dist/phases/statistics/Statistics.d.ts +10 -6
- package/dist/phases/statistics/Statistics.js +20 -10
- package/dist/phases/statistics/StatisticsPhase.js +10 -6
- package/dist/phases/statistics/methods/BollingerStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/BollingerStatistic.js +13 -11
- package/dist/phases/statistics/methods/BoxStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/BoxStatistic.js +14 -12
- package/dist/phases/statistics/methods/Density2dStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/Density2dStatistic.js +13 -11
- package/dist/phases/statistics/methods/DensityStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/DensityStatistic.js +11 -9
- package/dist/phases/statistics/methods/DeviationStatistic.d.ts +8 -0
- package/dist/phases/statistics/methods/DeviationStatistic.js +111 -0
- package/dist/phases/statistics/methods/MovingAverageStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/MovingAverageStatistic.js +11 -9
- package/dist/phases/statistics/methods/RegressionStatistic.d.ts +1 -1
- package/dist/phases/statistics/methods/RegressionStatistic.js +16 -14
- package/dist/phases/tooltip/TooltipPhase.d.ts +4 -2
- package/dist/phases/tooltip/TooltipPhase.js +10 -3
- package/dist/phases/transforms/ProcessedPositions.d.ts +30 -0
- package/dist/phases/transforms/ProcessedPositions.js +74 -0
- package/dist/phases/transforms/TransformsPhase.d.ts +5 -42
- package/dist/phases/transforms/TransformsPhase.js +67 -58
- package/dist/phases/transforms/ValueSelection.d.ts +30 -0
- package/dist/phases/transforms/ValueSelection.js +53 -0
- package/dist/plots/{heatmap → correlation/heatmap}/Plot.svelte +5 -2
- package/dist/plots/{heatmap → correlation/heatmap}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{heatmap → correlation/heatmap}/defaults.d.ts +2 -2
- package/dist/plots/{heatmap → correlation/heatmap}/defaults.js +5 -5
- package/dist/plots/{heatmap → correlation/heatmap}/markers.d.ts +4 -4
- package/dist/plots/{heatmap → correlation/heatmap}/markers.js +4 -3
- package/dist/plots/{scatter → correlation/scatter}/Plot.svelte +5 -2
- package/dist/plots/{scatter → correlation/scatter}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{scatter → correlation/scatter}/defaults.d.ts +2 -2
- package/dist/plots/{scatter → correlation/scatter}/defaults.js +6 -5
- package/dist/plots/{scatter → correlation/scatter}/markers.d.ts +4 -4
- package/dist/plots/{scatter → correlation/scatter}/markers.js +5 -4
- package/dist/plots/distribution/box/BoxSummaries.d.ts +19 -0
- package/dist/plots/distribution/box/BoxSummaries.js +101 -0
- package/dist/plots/distribution/box/Plot.svelte +42 -0
- package/dist/plots/distribution/box/Plot.svelte.d.ts +26 -0
- package/dist/plots/distribution/box/defaults.d.ts +12 -0
- package/dist/plots/distribution/box/defaults.js +34 -0
- package/dist/plots/distribution/box/markers.d.ts +12 -0
- package/dist/plots/distribution/box/markers.js +34 -0
- package/dist/plots/distribution/density/Plot.svelte +45 -0
- package/dist/plots/distribution/density/Plot.svelte.d.ts +26 -0
- package/dist/plots/distribution/density/defaults.d.ts +9 -0
- package/dist/plots/distribution/density/defaults.js +29 -0
- package/dist/plots/distribution/density/markers.d.ts +9 -0
- package/dist/plots/distribution/density/markers.js +42 -0
- package/dist/plots/{histogram → distribution/histogram}/Plot.svelte +2 -2
- package/dist/plots/{histogram → distribution/histogram}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{histogram → distribution/histogram}/defaults.d.ts +2 -2
- package/dist/plots/{histogram → distribution/histogram}/defaults.js +4 -4
- package/dist/plots/{histogram → distribution/histogram}/markers.d.ts +3 -3
- package/dist/plots/{histogram → distribution/histogram}/markers.js +7 -7
- package/dist/plots/{pyramid → distribution/pyramid}/Plot.svelte +5 -2
- package/dist/plots/{pyramid → distribution/pyramid}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{pyramid → distribution/pyramid}/defaults.d.ts +2 -2
- package/dist/plots/{pyramid → distribution/pyramid}/defaults.js +7 -6
- package/dist/plots/{pyramid → distribution/pyramid}/markers.d.ts +4 -4
- package/dist/plots/{pyramid → distribution/pyramid}/markers.js +8 -11
- package/dist/plots/distribution/violin/Plot.svelte +45 -0
- package/dist/plots/distribution/violin/Plot.svelte.d.ts +26 -0
- package/dist/plots/distribution/violin/defaults.d.ts +10 -0
- package/dist/plots/distribution/violin/defaults.js +58 -0
- package/dist/plots/distribution/violin/markers.d.ts +10 -0
- package/dist/plots/distribution/violin/markers.js +71 -0
- package/dist/plots/{area → evolution/area}/Plot.svelte +2 -2
- package/dist/plots/{area → evolution/area}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{area → evolution/area}/defaults.d.ts +2 -2
- package/dist/plots/{area → evolution/area}/defaults.js +2 -0
- package/dist/plots/{area → evolution/area}/markers.d.ts +2 -2
- package/dist/plots/{area → evolution/area}/markers.js +2 -3
- package/dist/plots/{line → evolution/line}/Plot.svelte +2 -2
- package/dist/plots/{line → evolution/line}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{line → evolution/line}/defaults.d.ts +2 -2
- package/dist/plots/{line → evolution/line}/defaults.js +2 -0
- package/dist/plots/{line → evolution/line}/markers.d.ts +11 -8
- package/dist/plots/{line → evolution/line}/markers.js +7 -6
- package/dist/plots/evolution/slope/Plot.svelte +42 -0
- package/dist/plots/evolution/slope/Plot.svelte.d.ts +26 -0
- package/dist/plots/evolution/slope/defaults.d.ts +8 -0
- package/dist/plots/evolution/slope/defaults.js +31 -0
- package/dist/plots/evolution/slope/markers.d.ts +16 -0
- package/dist/plots/evolution/slope/markers.js +79 -0
- package/dist/plots/evolution/sparkline/Plot.svelte +45 -0
- package/dist/plots/evolution/sparkline/Plot.svelte.d.ts +26 -0
- package/dist/plots/evolution/sparkline/defaults.d.ts +7 -0
- package/dist/plots/evolution/sparkline/defaults.js +23 -0
- package/dist/plots/evolution/sparkline/markers.d.ts +7 -0
- package/dist/plots/evolution/sparkline/markers.js +56 -0
- package/dist/plots/{geo → map/geo}/Core.svelte +11 -10
- package/dist/plots/{geo → map/geo}/Core.svelte.d.ts +1 -1
- package/dist/plots/map/geo/GeoFeatures.svelte.d.ts +9 -0
- package/dist/plots/map/geo/GeoFeatures.svelte.js +55 -0
- package/dist/plots/map/geo/GeoGeometry.d.ts +27 -0
- package/dist/plots/map/geo/GeoGeometry.js +142 -0
- package/dist/plots/map/geo/GeoSegments.d.ts +16 -0
- package/dist/plots/map/geo/GeoSegments.js +23 -0
- package/dist/plots/{geo → map/geo}/Plot.svelte +10 -10
- package/dist/plots/{geo → map/geo}/Plot.svelte.d.ts +2 -2
- package/dist/plots/{geo → map/geo}/defaults.d.ts +2 -2
- package/dist/plots/{geo → map/geo}/defaults.js +1 -1
- package/dist/plots/{geo → map/geo}/phases/data.d.ts +1 -1
- package/dist/plots/{geo → map/geo}/phases/data.js +7 -6
- package/dist/plots/{geo → map/geo}/phases/hover.d.ts +1 -1
- package/dist/plots/{geo → map/geo}/phases/hover.js +5 -5
- package/dist/plots/{geo → map/geo}/phases/markers.d.ts +1 -1
- package/dist/plots/{geo → map/geo}/phases/markers.js +8 -13
- package/dist/plots/{geo → map/geo}/phases/scales.d.ts +2 -2
- package/dist/plots/{geo → map/geo}/phases/scales.js +28 -12
- package/dist/plots/{geo → map/geo}/phases/tooltip.d.ts +1 -1
- package/dist/plots/map/geo/phases/tooltip.js +5 -0
- package/dist/plots/{geo → map/geo}/slices.d.ts +2 -2
- package/dist/plots/{geo → map/geo}/slices.js +7 -4
- package/dist/plots/{bar → ranking/bar}/Plot.svelte +2 -2
- package/dist/plots/{bar → ranking/bar}/Plot.svelte.d.ts +2 -2
- package/dist/plots/ranking/bar/defaults.d.ts +16 -0
- package/dist/plots/{bar → ranking/bar}/defaults.js +17 -15
- package/dist/plots/{bar → ranking/bar}/markers.d.ts +8 -8
- package/dist/plots/{bar → ranking/bar}/markers.js +11 -19
- package/dist/plots/ranking/bullet/Plot.svelte +42 -0
- package/dist/plots/ranking/bullet/Plot.svelte.d.ts +26 -0
- package/dist/plots/ranking/bullet/defaults.d.ts +8 -0
- package/dist/plots/ranking/bullet/defaults.js +24 -0
- package/dist/plots/ranking/bullet/markers.d.ts +10 -0
- package/dist/plots/ranking/bullet/markers.js +90 -0
- package/dist/plots/ranking/cleveland/ClevelandConnector.d.ts +48 -0
- package/dist/plots/ranking/cleveland/ClevelandConnector.js +140 -0
- package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +33 -0
- package/dist/plots/ranking/cleveland/ClevelandMarkers.js +375 -0
- package/dist/plots/ranking/cleveland/ClevelandRanges.d.ts +31 -0
- package/dist/plots/ranking/cleveland/ClevelandRanges.js +116 -0
- package/dist/plots/ranking/cleveland/Plot.svelte +45 -0
- package/dist/plots/ranking/cleveland/Plot.svelte.d.ts +26 -0
- package/dist/plots/ranking/cleveland/defaults.d.ts +13 -0
- package/dist/plots/ranking/cleveland/defaults.js +66 -0
- package/dist/plots/ranking/dumbbell/Plot.svelte +45 -0
- package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +26 -0
- package/dist/plots/ranking/dumbbell/defaults.d.ts +9 -0
- package/dist/plots/ranking/dumbbell/defaults.js +19 -0
- package/dist/plots/ranking/forest/Plot.svelte +42 -0
- package/dist/plots/ranking/forest/Plot.svelte.d.ts +26 -0
- package/dist/plots/ranking/forest/defaults.d.ts +11 -0
- package/dist/plots/ranking/forest/defaults.js +20 -0
- package/dist/plots/ranking/lollipop/Plot.svelte +45 -0
- package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +26 -0
- package/dist/plots/ranking/lollipop/defaults.d.ts +9 -0
- package/dist/plots/ranking/lollipop/defaults.js +18 -0
- package/dist/plots/utils/RowNumbers.d.ts +16 -0
- package/dist/plots/utils/RowNumbers.js +24 -0
- package/dist/plots/utils/gaps.js +1 -1
- package/dist/plots/utils/segments.js +1 -1
- package/dist/types/configuration/styling.d.ts +287 -132
- package/dist/types/layout/composer.d.ts +5 -2
- package/dist/types/layout/coordinates.d.ts +5 -4
- package/dist/types/layout/legend.d.ts +21 -5
- package/dist/types/layout/plot.d.ts +44 -1
- package/dist/types/layout/scales.d.ts +51 -3
- package/dist/types/layout/statistics/deviation.d.ts +40 -0
- package/dist/types/layout/statistics/index.d.ts +7 -2
- package/dist/types/layout/styles/base.d.ts +18 -0
- package/dist/types/layout/styles/bullet.d.ts +25 -0
- package/dist/types/layout/styles/connector.d.ts +98 -0
- package/dist/types/layout/styles/curve.d.ts +11 -0
- package/dist/types/layout/styles/frame.d.ts +17 -0
- package/dist/types/layout/styles/gaps.d.ts +12 -0
- package/dist/types/layout/styles/geo.d.ts +55 -0
- package/dist/types/layout/styles/index.d.ts +8 -0
- package/dist/types/layout/styles/index.js +8 -0
- package/dist/types/layout/styles/values.d.ts +47 -0
- package/dist/types/layout/timeline.d.ts +19 -7
- package/dist/types/layout/tooltip.d.ts +6 -2
- package/dist/types/markers/axis/area.d.ts +2 -2
- package/dist/types/markers/axis/arrow.d.ts +3 -0
- package/dist/types/markers/axis/axisBasedMarkersConfig.d.ts +2 -1
- package/dist/types/markers/axis/bar.d.ts +1 -1
- package/dist/types/markers/axis/box.d.ts +5 -0
- package/dist/types/markers/axis/difference.d.ts +2 -2
- package/dist/types/markers/axis/image.d.ts +3 -2
- package/dist/types/markers/axis/line.d.ts +2 -0
- package/dist/types/markers/axis/rule.d.ts +9 -0
- package/dist/types/markers/axis/trail.d.ts +2 -3
- package/dist/types/markers/axis/violin.d.ts +25 -0
- package/dist/types/markers/basic/dot.d.ts +3 -2
- package/dist/types/markers/basic/text.d.ts +13 -3
- package/dist/types/markers/channels/commonMarkerConfig.d.ts +7 -3
- package/dist/types/markers/channels/commonMarkerConfigWithRowOffset.d.ts +13 -0
- package/dist/types/markers/common.d.ts +1 -1
- package/dist/types/markers/common.js +1 -0
- package/dist/types/markers/geo/link.d.ts +5 -1
- package/dist/types/phases/hover/phase.d.ts +6 -0
- package/dist/types/phases/index.d.ts +1 -1
- package/dist/types/phases/scales/phase.d.ts +5 -1
- package/dist/types/phases/state.d.ts +20 -4
- package/dist/types/phases/statistics/phase.d.ts +3 -1
- package/dist/types/phases/statistics/source.d.ts +3 -1
- package/dist/types/phases/transforms/phase.d.ts +32 -0
- package/dist/types/plots/{heatmap → correlation/heatmap}/props.d.ts +6 -6
- package/dist/types/plots/{heatmap → correlation/heatmap}/state.d.ts +4 -4
- package/dist/types/plots/{scatter → correlation/scatter}/props.d.ts +6 -6
- package/dist/types/plots/{scatter → correlation/scatter}/state.d.ts +2 -2
- package/dist/types/plots/distribution/box/props.d.ts +10 -0
- package/dist/types/plots/distribution/box/state.d.ts +23 -0
- package/dist/types/plots/distribution/density/props.d.ts +23 -0
- package/dist/types/plots/distribution/density/state.d.ts +6 -0
- package/dist/types/plots/distribution/density/state.js +1 -0
- package/dist/types/plots/{histogram → distribution/histogram}/props.d.ts +7 -7
- package/dist/types/plots/distribution/histogram/props.js +1 -0
- package/dist/types/plots/{histogram → distribution/histogram}/state.d.ts +2 -2
- package/dist/types/plots/distribution/histogram/state.js +1 -0
- package/dist/types/plots/{pyramid → distribution/pyramid}/props.d.ts +6 -6
- package/dist/types/plots/distribution/pyramid/props.js +1 -0
- package/dist/types/plots/{pyramid → distribution/pyramid}/state.d.ts +3 -3
- package/dist/types/plots/distribution/pyramid/state.js +1 -0
- package/dist/types/plots/distribution/violin/props.d.ts +23 -0
- package/dist/types/plots/distribution/violin/props.js +1 -0
- package/dist/types/plots/distribution/violin/state.d.ts +6 -0
- package/dist/types/plots/distribution/violin/state.js +1 -0
- package/dist/types/plots/{area → evolution/area}/props.d.ts +6 -6
- package/dist/types/plots/evolution/area/props.js +1 -0
- package/dist/types/plots/{area → evolution/area}/state.d.ts +2 -2
- package/dist/types/plots/evolution/area/state.js +1 -0
- package/dist/types/plots/evolution/line/props.d.ts +10 -0
- package/dist/types/plots/evolution/line/props.js +1 -0
- package/dist/types/plots/{line → evolution/line}/state.d.ts +3 -3
- package/dist/types/plots/evolution/line/state.js +1 -0
- package/dist/types/plots/evolution/slope/props.d.ts +5 -0
- package/dist/types/plots/evolution/slope/props.js +1 -0
- package/dist/types/plots/evolution/slope/state.d.ts +5 -0
- package/dist/types/plots/evolution/slope/state.js +1 -0
- package/dist/types/plots/evolution/sparkline/props.d.ts +5 -0
- package/dist/types/plots/evolution/sparkline/props.js +1 -0
- package/dist/types/plots/evolution/sparkline/state.d.ts +5 -0
- package/dist/types/plots/evolution/sparkline/state.js +1 -0
- package/dist/types/plots/{geo → map/geo}/props.d.ts +8 -8
- package/dist/types/plots/map/geo/props.js +1 -0
- package/dist/types/plots/{geo → map/geo}/state.d.ts +18 -11
- package/dist/types/plots/map/geo/state.js +1 -0
- package/dist/types/plots/props.d.ts +3 -1
- package/dist/types/plots/{bar → ranking/bar}/props.d.ts +6 -6
- package/dist/types/plots/ranking/bar/props.js +1 -0
- package/dist/types/plots/{bar → ranking/bar}/state.d.ts +2 -2
- package/dist/types/plots/ranking/bar/state.js +1 -0
- package/dist/types/plots/ranking/bullet/props.d.ts +22 -0
- package/dist/types/plots/ranking/bullet/props.js +1 -0
- package/dist/types/plots/ranking/bullet/state.d.ts +5 -0
- package/dist/types/plots/ranking/bullet/state.js +1 -0
- package/dist/types/plots/ranking/cleveland/props.d.ts +10 -0
- package/dist/types/plots/ranking/cleveland/props.js +1 -0
- package/dist/types/plots/ranking/cleveland/state.d.ts +49 -0
- package/dist/types/plots/ranking/cleveland/state.js +1 -0
- package/dist/types/plots/ranking/dumbbell/props.d.ts +10 -0
- package/dist/types/plots/ranking/dumbbell/props.js +1 -0
- package/dist/types/plots/ranking/dumbbell/state.d.ts +5 -0
- package/dist/types/plots/ranking/dumbbell/state.js +1 -0
- package/dist/types/plots/ranking/forest/props.d.ts +23 -0
- package/dist/types/plots/ranking/forest/props.js +1 -0
- package/dist/types/plots/ranking/forest/state.d.ts +5 -0
- package/dist/types/plots/ranking/forest/state.js +1 -0
- package/dist/types/plots/ranking/lollipop/props.d.ts +10 -0
- package/dist/types/plots/ranking/lollipop/props.js +1 -0
- package/dist/types/plots/ranking/lollipop/state.d.ts +5 -0
- package/dist/types/plots/ranking/lollipop/state.js +1 -0
- package/dist/types/plots/segments/common.d.ts +4 -1
- package/dist/utils/OpacityScale.d.ts +14 -0
- package/dist/utils/OpacityScale.js +43 -0
- package/dist/utils/{symbol.d.ts → SymbolPath.d.ts} +0 -12
- package/dist/utils/{symbol.js → SymbolPath.js} +0 -24
- package/dist/utils/SymbolScale.d.ts +18 -0
- package/dist/utils/SymbolScale.js +29 -0
- package/dist/utils/color/ColorRamp.d.ts +27 -0
- package/dist/utils/color/ColorRamp.js +120 -0
- package/dist/utils/color/CssColor.d.ts +19 -0
- package/dist/utils/color/CssColor.js +114 -0
- package/dist/utils/color/Palette.d.ts +21 -0
- package/dist/utils/color/Palette.js +52 -0
- package/dist/utils/color/index.d.ts +11 -3
- package/dist/utils/color/index.js +14 -3
- package/dist/utils/grouping.js +1 -1
- package/docs/architecture.md +1 -1
- package/docs/chrome.md +39 -8
- package/docs/composer.md +19 -3
- package/docs/concepts.md +1 -1
- package/docs/development.md +14 -5
- package/docs/facets.md +62 -8
- package/docs/getting-started.md +8 -9
- package/docs/legend.md +73 -24
- package/docs/markers.md +45 -32
- package/docs/plots/correlation/heatmap.md +26 -0
- package/docs/plots/correlation/scatter.md +35 -0
- package/docs/plots/distribution/box.md +28 -0
- package/docs/plots/distribution/density.md +26 -0
- package/docs/plots/distribution/histogram.md +33 -0
- package/docs/plots/distribution/pyramid.md +31 -0
- package/docs/plots/distribution/violin.md +35 -0
- package/docs/plots/evolution/area.md +32 -0
- package/docs/plots/evolution/line.md +93 -0
- package/docs/plots/evolution/slope.md +39 -0
- package/docs/plots/evolution/sparkline.md +34 -0
- package/docs/plots/ranking/bar.md +59 -0
- package/docs/plots/ranking/bullet.md +37 -0
- package/docs/plots/ranking/cleveland.md +54 -0
- package/docs/plots/ranking/dumbbell.md +39 -0
- package/docs/plots/ranking/forest.md +40 -0
- package/docs/plots/ranking/lollipop.md +39 -0
- package/docs/plots.md +22 -154
- package/docs/scales.md +50 -27
- package/docs/state.md +1 -1
- package/docs/styles-and-segments.md +96 -39
- package/docs/theming.md +33 -19
- package/docs/timeline.md +62 -28
- package/docs/tooltip-and-hover.md +72 -24
- package/docs/transforms-and-statistics.md +56 -25
- package/examples/BarValues.svelte +2 -2
- package/examples/Box.svelte +7 -0
- package/examples/Bullet.svelte +17 -0
- package/examples/Chrome.svelte +17 -0
- package/examples/ChromeOrder.svelte +18 -0
- package/examples/Cleveland.svelte +15 -0
- package/examples/Composer.svelte +23 -0
- package/examples/CustomTooltip.svelte +21 -14
- package/examples/Density.svelte +7 -0
- package/examples/Dumbbell.svelte +16 -0
- package/examples/Facets.svelte +3 -3
- package/examples/FacetsCarousel.svelte +14 -0
- package/examples/FacetsRowsCols.svelte +23 -0
- package/examples/FirstPlot.svelte +7 -0
- package/examples/Forest.svelte +17 -0
- package/examples/Gaps.svelte +21 -0
- package/examples/GroupedBars.svelte +15 -0
- package/examples/Heatmap.svelte +7 -0
- package/examples/HeatmapSegments.svelte +26 -0
- package/examples/Histogram.svelte +14 -0
- package/examples/HorizontalBars.svelte +15 -0
- package/examples/LegendSections.svelte +27 -0
- package/examples/LegendToggle.svelte +3 -3
- package/examples/LineByRegion.svelte +18 -0
- package/examples/LineDates.svelte +15 -0
- package/examples/LineStep.svelte +16 -0
- package/examples/LineStepSegment.svelte +18 -0
- package/examples/Lollipop.svelte +17 -0
- package/examples/Markers.svelte +27 -0
- package/examples/MovingAverage.svelte +15 -0
- package/examples/Pyramid.svelte +14 -0
- package/examples/Regression.svelte +14 -0
- package/examples/ResponsiveLine.svelte +7 -7
- package/examples/Scales.svelte +26 -0
- package/examples/Scatter.svelte +16 -0
- package/examples/SegmentHighlight.svelte +22 -0
- package/examples/Segments.svelte +11 -3
- package/examples/SegmentsBySeries.svelte +25 -0
- package/examples/Slope.svelte +17 -0
- package/examples/Sparkline.svelte +14 -0
- package/examples/StackedArea.svelte +16 -0
- package/examples/StackedBars.svelte +15 -0
- package/examples/TimelinePlayer.svelte +8 -7
- package/examples/TimelineRule.svelte +19 -0
- package/examples/Tooltip.svelte +3 -3
- package/examples/ValueLabels.svelte +21 -0
- package/examples/Violin.svelte +14 -0
- package/examples/datasets/argentina-chile-trends.ts +34 -0
- package/examples/datasets/commodity-prices.ts +48 -0
- package/examples/datasets/countries-over-time.ts +368 -0
- package/examples/datasets/daily-temperature.ts +121 -0
- package/examples/datasets/earthquakes.ts +977 -0
- package/examples/datasets/flight-routes.ts +29 -0
- package/examples/datasets/height-density.ts +37 -0
- package/examples/datasets/heights.ts +370 -0
- package/examples/datasets/index.ts +24 -0
- package/examples/datasets/inflation-by-region.ts +44 -0
- package/examples/datasets/inflation-ranges.ts +34 -0
- package/examples/datasets/iris-flower.ts +207 -0
- package/examples/datasets/life-expectancy.ts +95 -0
- package/examples/datasets/napoleons-march.ts +182 -0
- package/examples/datasets/penguins.ts +54 -0
- package/examples/datasets/population-by-age-with-gaps.ts +23 -0
- package/examples/datasets/population-by-age.ts +890 -0
- package/examples/datasets/province-population.ts +521 -0
- package/examples/datasets/stock-prices.ts +63 -0
- package/examples/datasets/weather-stations-over-time.ts +31 -0
- package/examples/datasets/weather-stations.ts +22 -0
- package/examples/datasets/wind-vectors.ts +30 -0
- package/examples/datasets/world-temperature.ts +400 -0
- package/llms-full.txt +51 -12
- package/llms.txt +60 -4
- package/package.json +12 -2
- package/dist/layout/scales/buildScale.d.ts +0 -8
- package/dist/layout/scales/buildScale.js +0 -67
- package/dist/layout/scales/niceDomain.d.ts +0 -23
- package/dist/layout/scales/niceDomain.js +0 -59
- package/dist/plots/bar/defaults.d.ts +0 -9
- package/dist/plots/geo/features.svelte.d.ts +0 -5
- package/dist/plots/geo/features.svelte.js +0 -44
- package/dist/plots/geo/phases/tooltip.js +0 -5
- package/dist/plots/utils/geoAccessors.d.ts +0 -72
- package/dist/plots/utils/geoAccessors.js +0 -220
- package/dist/plots/utils/geoSegments.d.ts +0 -29
- package/dist/plots/utils/geoSegments.js +0 -37
- package/dist/types/layout/styles.d.ts +0 -122
- package/dist/types/markers/axis/curveName.d.ts +0 -2
- package/dist/types/plots/line/props.d.ts +0 -10
- package/dist/utils/color/contrast.d.ts +0 -9
- package/dist/utils/color/contrast.js +0 -40
- package/dist/utils/color/cssColor.d.ts +0 -4
- package/dist/utils/color/cssColor.js +0 -77
- package/dist/utils/color/ramp.d.ts +0 -17
- package/dist/utils/color/ramp.js +0 -110
- package/dist/utils/opacity.d.ts +0 -9
- package/dist/utils/opacity.js +0 -38
- package/examples/data.ts +0 -12
- /package/dist/types/layout/{styles.js → statistics/deviation.js} +0 -0
- /package/dist/types/{markers/axis/curveName.js → layout/styles/base.js} +0 -0
- /package/dist/types/{plots/area/props.js → layout/styles/bullet.js} +0 -0
- /package/dist/types/{plots/area/state.js → layout/styles/connector.js} +0 -0
- /package/dist/types/{plots/bar/props.js → layout/styles/curve.js} +0 -0
- /package/dist/types/{plots/bar/state.js → layout/styles/frame.js} +0 -0
- /package/dist/types/{plots/geo/props.js → layout/styles/gaps.js} +0 -0
- /package/dist/types/{plots/geo/state.js → layout/styles/geo.js} +0 -0
- /package/dist/types/{plots/heatmap/props.js → layout/styles/values.js} +0 -0
- /package/dist/types/{plots/heatmap/state.js → markers/axis/violin.js} +0 -0
- /package/dist/types/{plots/histogram/props.js → markers/channels/commonMarkerConfigWithRowOffset.js} +0 -0
- /package/dist/types/plots/{line → correlation/heatmap}/props.js +0 -0
- /package/dist/types/plots/{histogram → correlation/heatmap}/state.js +0 -0
- /package/dist/types/plots/{pyramid → correlation/scatter}/props.js +0 -0
- /package/dist/types/plots/{line → correlation/scatter}/state.js +0 -0
- /package/dist/types/plots/{scatter → distribution/box}/props.js +0 -0
- /package/dist/types/plots/{pyramid → distribution/box}/state.js +0 -0
- /package/dist/types/plots/{scatter/state.js → distribution/density/props.js} +0 -0
- /package/dist/{plots/utils → utils}/accessors.d.ts +0 -0
- /package/dist/{plots/utils → utils}/accessors.js +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Margins } from '../margins/Margins';
|
|
2
|
+
/**
|
|
3
|
+
* "Nice" (1/2/5×10ⁿ) tick steps and the domains they round to, compatible with
|
|
4
|
+
* d3-array's and reimplemented here to avoid depending on internals svelteplot
|
|
5
|
+
* itself pulls in (not one of our declared dependencies) - see
|
|
6
|
+
* https://d3js.org/d3-array/ticks.
|
|
7
|
+
*/
|
|
8
|
+
export class NiceTicks {
|
|
9
|
+
/**
|
|
10
|
+
* How far past a tick, as a share of the tick step, a domain still ends on
|
|
11
|
+
* it. Plain `Math.ceil`/`Math.floor` (what d3's `nice()` uses) has no
|
|
12
|
+
* tolerance: parts that add up to `100`, but come out `100.00000000000001`
|
|
13
|
+
* after summing or `100.2` after each was rounded at the source, round a
|
|
14
|
+
* full step further (`100` → `120`). 5% of the step catches that noise and
|
|
15
|
+
* lets a mark pass the last tick by a few pixels at most.
|
|
16
|
+
*/
|
|
17
|
+
static TOLERANCE = 0.05;
|
|
18
|
+
/** The pixels between ticks an axis aims for, along x and along y. */
|
|
19
|
+
static SPACING = { x: 80, y: 50 };
|
|
20
|
+
/** The step between nice ticks for an approximate `count` over `[start, stop]`. */
|
|
21
|
+
static step(start, stop, count) {
|
|
22
|
+
const e10 = Math.sqrt(50);
|
|
23
|
+
const e5 = Math.sqrt(10);
|
|
24
|
+
const e2 = Math.sqrt(2);
|
|
25
|
+
const step0 = Math.abs(stop - start) / Math.max(0, count);
|
|
26
|
+
let step1 = 10 ** Math.floor(Math.log10(step0));
|
|
27
|
+
const error = step0 / step1;
|
|
28
|
+
if (error >= e10)
|
|
29
|
+
step1 *= 10;
|
|
30
|
+
else if (error >= e5)
|
|
31
|
+
step1 *= 5;
|
|
32
|
+
else if (error >= e2)
|
|
33
|
+
step1 *= 2;
|
|
34
|
+
return step1;
|
|
35
|
+
}
|
|
36
|
+
/** Multiples of `step` covering `[start, stop]`, inclusive of either endpoint when it lands exactly on one. */
|
|
37
|
+
static inRange(start, stop, step) {
|
|
38
|
+
if (!(step > 0) || !Number.isFinite(step))
|
|
39
|
+
return [];
|
|
40
|
+
const lo = Math.ceil(start / step);
|
|
41
|
+
const hi = Math.floor(stop / step);
|
|
42
|
+
const out = [];
|
|
43
|
+
for (let i = lo; i <= hi; i++)
|
|
44
|
+
out.push(i * step);
|
|
45
|
+
return out;
|
|
46
|
+
}
|
|
47
|
+
/** The tolerance a scale's `nice` asks for, or `undefined` for the default. */
|
|
48
|
+
static toleranceOf(nice) {
|
|
49
|
+
return typeof nice === 'object' ? nice.tolerance : undefined;
|
|
50
|
+
}
|
|
51
|
+
/** How many ticks fit `span` pixels at one per `spacing`, and at least `min`. */
|
|
52
|
+
static count(span, spacing, min) {
|
|
53
|
+
return Math.max(min, Math.round(span / spacing));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* `[lo, hi]` widened outward to the nearest nice step for about `count`
|
|
57
|
+
* ticks, like d3's `scale.nice(count)` - except a value within
|
|
58
|
+
* `tolerance × step` past a tick stays on it (see {@link NiceTicks.TOLERANCE}).
|
|
59
|
+
*/
|
|
60
|
+
static domain(lo, hi, count = 5, tolerance = NiceTicks.TOLERANCE) {
|
|
61
|
+
if (!(hi > lo))
|
|
62
|
+
return [lo, hi];
|
|
63
|
+
const step = NiceTicks.step(lo, hi, count);
|
|
64
|
+
const slack = step * tolerance;
|
|
65
|
+
const niceLo = Math.floor((lo + slack) / step) * step;
|
|
66
|
+
const niceHi = Math.ceil((hi - slack) / step) * step;
|
|
67
|
+
// `|| 0` turns a `-0` (a bound at zero, rounded toward it) into `0`, which an axis writes without a sign.
|
|
68
|
+
return [niceLo || 0, niceHi || 0];
|
|
69
|
+
}
|
|
70
|
+
/** {@link NiceTicks.domain} with as many ticks as fit `axis` in a plot of this size. */
|
|
71
|
+
static fit(size, axis, lo, hi, tolerance) {
|
|
72
|
+
const box = Margins.AXIS_ESTIMATE.contentBox(size.width, size.height);
|
|
73
|
+
const span = axis === 'x' ? box.width : box.height;
|
|
74
|
+
return NiceTicks.domain(lo, hi, NiceTicks.count(span, NiceTicks.SPACING[axis], 2), tolerance);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
import { AxisX, AxisY, GridX, GridY } from 'svelteplot';
|
|
5
5
|
import { usePlot } from '../plot/usePlot';
|
|
6
6
|
import { getConfiguration } from '../../configuration/config.svelte';
|
|
7
|
-
import {
|
|
7
|
+
import { NiceTicks } from './NiceTicks';
|
|
8
|
+
import { EdgeTicks } from './EdgeTicks';
|
|
8
9
|
import { DISCRETE_SCALE_TYPES } from '../../types/layout/scales';
|
|
9
10
|
import type { AxisBasedScalesConfig } from '../../types/layout/scales';
|
|
10
11
|
import type { AxisValue } from '../../types/layout/mapping';
|
|
12
|
+
import type { PlotLayoutState } from '../../types/layout/plot';
|
|
11
13
|
|
|
12
14
|
/** Axis ticks, titles and grid lines for the plot kinds with an x/y axis pair. */
|
|
13
15
|
let {
|
|
@@ -17,7 +19,10 @@
|
|
|
17
19
|
width,
|
|
18
20
|
height,
|
|
19
21
|
numericMargins,
|
|
20
|
-
scales
|
|
22
|
+
scales,
|
|
23
|
+
edgeDomains = undefined,
|
|
24
|
+
tickValues = undefined,
|
|
25
|
+
state: plotState
|
|
21
26
|
}: {
|
|
22
27
|
data: TData[];
|
|
23
28
|
getX: (d: TData) => AxisValue;
|
|
@@ -26,8 +31,23 @@
|
|
|
26
31
|
height: number;
|
|
27
32
|
numericMargins: { top: number; right: number; bottom: number; left: number };
|
|
28
33
|
scales?: AxisBasedScalesConfig<TData>;
|
|
34
|
+
/**
|
|
35
|
+
* Where to leave the domain an axis widens to when an edge tick's
|
|
36
|
+
* `'extend'` resolved a collision (see `EdgeTicks`), for the plot to give its scale.
|
|
37
|
+
*/
|
|
38
|
+
edgeDomains?: Map<'x' | 'y', [number, number]>;
|
|
39
|
+
/** The labels a category axis writes, when it leaves some out for want of room. */
|
|
40
|
+
tickValues?: Partial<Record<'x' | 'y', string[]>>;
|
|
41
|
+
/** The plot's state: its fitted axes and the y channel's field, which titles a vertical y axis with no rows. */
|
|
42
|
+
state: Pick<PlotLayoutState, 'fittedAxes' | 'channels'>;
|
|
29
43
|
} = $props();
|
|
30
44
|
|
|
45
|
+
const fittedAxes = $derived(plotState.fittedAxes);
|
|
46
|
+
const yField = $derived.by(() => {
|
|
47
|
+
const source = plotState.channels?.y?.source;
|
|
48
|
+
return typeof source === 'string' ? source : undefined;
|
|
49
|
+
});
|
|
50
|
+
|
|
31
51
|
const cfg = $derived(getConfiguration());
|
|
32
52
|
const plot = usePlot().svelteplot;
|
|
33
53
|
|
|
@@ -50,7 +70,7 @@
|
|
|
50
70
|
return hi > lo ? [lo, hi] : undefined;
|
|
51
71
|
}
|
|
52
72
|
|
|
53
|
-
/** An axis paired with a discrete scale plays the "index" role for the pair, so *this* axis is the plain magnitude/value one (see `autoTickCount`, `
|
|
73
|
+
/** An axis paired with a discrete scale plays the "index" role for the pair, so *this* axis is the plain magnitude/value one (see `autoTickCount`, `edgeTicksOf`). */
|
|
54
74
|
const isDiscreteType = (type: string) =>
|
|
55
75
|
(DISCRETE_SCALE_TYPES as readonly string[]).includes(type);
|
|
56
76
|
|
|
@@ -75,7 +95,7 @@
|
|
|
75
95
|
return undefined;
|
|
76
96
|
if (oppositeType != null && isDiscreteType(oppositeType)) return undefined;
|
|
77
97
|
const uniqueCount = new Set(values.map(String)).size;
|
|
78
|
-
const natural =
|
|
98
|
+
const natural = NiceTicks.count(span, spacing, min);
|
|
79
99
|
return uniqueCount >= 2 && uniqueCount < natural ? uniqueCount : undefined;
|
|
80
100
|
}
|
|
81
101
|
|
|
@@ -94,58 +114,92 @@
|
|
|
94
114
|
if (!extent) return undefined;
|
|
95
115
|
const [lo, hi] = extent;
|
|
96
116
|
if (!Number.isInteger(lo) || !Number.isInteger(hi)) return undefined;
|
|
97
|
-
|
|
117
|
+
const numbers = values.filter((v): v is number => typeof v === 'number');
|
|
118
|
+
if (numbers.length === 0 || !numbers.every(Number.isInteger)) return undefined;
|
|
119
|
+
return hi - lo < NiceTicks.count(span, spacing, min) ? 1 : undefined;
|
|
98
120
|
}
|
|
99
121
|
|
|
100
122
|
const xSpan = $derived(Math.max(0, width - numericMargins.left - numericMargins.right));
|
|
101
123
|
const ySpan = $derived(Math.max(0, height - numericMargins.top - numericMargins.bottom));
|
|
102
124
|
|
|
103
|
-
const xTickCount = $derived(
|
|
104
|
-
|
|
125
|
+
const xTickCount = $derived(
|
|
126
|
+
autoTickCount(plot.scales.y.type, scales?.x, xValues, xSpan, NiceTicks.SPACING.x, 3)
|
|
127
|
+
);
|
|
128
|
+
const yTickCount = $derived(
|
|
129
|
+
autoTickCount(plot.scales.x.type, scales?.y, yValues, ySpan, NiceTicks.SPACING.y, 2)
|
|
130
|
+
);
|
|
105
131
|
|
|
106
|
-
const xTickInterval = $derived(
|
|
107
|
-
|
|
132
|
+
const xTickInterval = $derived(
|
|
133
|
+
integerTickInterval(scales?.x, xValues, xSpan, NiceTicks.SPACING.x, 3)
|
|
134
|
+
);
|
|
135
|
+
const yTickInterval = $derived(
|
|
136
|
+
integerTickInterval(scales?.y, yValues, ySpan, NiceTicks.SPACING.y, 2)
|
|
137
|
+
);
|
|
108
138
|
|
|
109
139
|
/**
|
|
110
|
-
* A continuous axis' nice ticks plus
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* or the domain.
|
|
140
|
+
* A continuous axis' nice ticks plus the data's first and last values (see
|
|
141
|
+
* {@link EdgeTicks}), when its other axis is continuous too and the author
|
|
142
|
+
* left its density and domain to the plot. Unset otherwise.
|
|
114
143
|
*/
|
|
115
|
-
function
|
|
144
|
+
function edgeTicksOf(
|
|
145
|
+
axis: 'x' | 'y',
|
|
146
|
+
type: string | undefined,
|
|
116
147
|
oppositeType: string | undefined,
|
|
117
148
|
scale: AxisBasedScalesConfig<TData>['x'],
|
|
118
149
|
values: AxisValue[],
|
|
119
150
|
span: number,
|
|
120
|
-
spacing: number,
|
|
121
151
|
min: number
|
|
122
|
-
)
|
|
152
|
+
) {
|
|
123
153
|
if (
|
|
124
154
|
scale?.ticks != null ||
|
|
125
155
|
scale?.tickSpacing != null ||
|
|
126
156
|
scale?.interval != null ||
|
|
127
|
-
scale?.domain != null
|
|
157
|
+
(scale?.domain != null && !fittedAxes?.includes(axis))
|
|
128
158
|
)
|
|
129
159
|
return undefined;
|
|
160
|
+
if (type != null && isDiscreteType(type)) return undefined;
|
|
130
161
|
if (oppositeType != null && isDiscreteType(oppositeType)) return undefined;
|
|
131
162
|
if (scale?.type != null && scale.type !== 'linear' && scale.type !== 'auto') return undefined;
|
|
132
|
-
const
|
|
133
|
-
if (!
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
163
|
+
const present = values.filter((v) => v != null);
|
|
164
|
+
if (!present.every((v) => typeof v === 'number')) return undefined;
|
|
165
|
+
return EdgeTicks.build({
|
|
166
|
+
axis,
|
|
167
|
+
values: (present as number[]).filter(Number.isFinite),
|
|
168
|
+
span,
|
|
169
|
+
spacing: NiceTicks.SPACING[axis],
|
|
170
|
+
min,
|
|
171
|
+
fontSize: cfg.axis.fontSize,
|
|
172
|
+
options: EdgeTicks.resolve(scale?.edgeTicks, cfg.axis.edgeTicks[axis])
|
|
173
|
+
});
|
|
143
174
|
}
|
|
144
175
|
|
|
145
|
-
const
|
|
146
|
-
|
|
176
|
+
const xEdgeTicks = $derived(
|
|
177
|
+
edgeTicksOf('x', plot.scales.x.type, plot.scales.y.type, scales?.x, xValues, xSpan, 3)
|
|
178
|
+
);
|
|
179
|
+
const yEdgeTicks = $derived(
|
|
180
|
+
edgeTicksOf('y', plot.scales.y.type, plot.scales.x.type, scales?.y, yValues, ySpan, 2)
|
|
147
181
|
);
|
|
148
182
|
|
|
183
|
+
// Hands the plot the domain an axis widens to, only when it changes.
|
|
184
|
+
$effect(() => {
|
|
185
|
+
const next = { x: xEdgeTicks?.domain, y: yEdgeTicks?.domain };
|
|
186
|
+
untrack(() => {
|
|
187
|
+
for (const axis of ['x', 'y'] as const) {
|
|
188
|
+
const domain = next[axis];
|
|
189
|
+
const current = edgeDomains?.get(axis);
|
|
190
|
+
if (domain?.[0] === current?.[0] && domain?.[1] === current?.[1]) continue;
|
|
191
|
+
if (domain) edgeDomains?.set(axis, domain);
|
|
192
|
+
else edgeDomains?.delete(axis);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
/** A turned label is written on one line: the axis does not wrap it. */
|
|
198
|
+
const turned = $derived(scales?.x?.tickRotate ? { wordwrap: false } : {}) as Record<
|
|
199
|
+
string,
|
|
200
|
+
unknown
|
|
201
|
+
>;
|
|
202
|
+
|
|
149
203
|
const yTitleFontSize = $derived(scales?.y?.titleFontSize ?? cfg.axis.titleFontSize);
|
|
150
204
|
|
|
151
205
|
/**
|
|
@@ -154,7 +208,8 @@
|
|
|
154
208
|
*/
|
|
155
209
|
const verticalYLabel = $derived.by(() => {
|
|
156
210
|
if (scales?.y?.labelOrientation !== 'vertical' || scales.y.label === false) return null;
|
|
157
|
-
const text =
|
|
211
|
+
const text =
|
|
212
|
+
scales.y.label || plot.scales.y.autoTitle || (data.length === 0 ? yField : undefined);
|
|
158
213
|
if (!text) return null;
|
|
159
214
|
const position = scales.y.labelPosition ?? 'middle';
|
|
160
215
|
const x = yTitleFontSize;
|
|
@@ -187,11 +242,54 @@
|
|
|
187
242
|
$effect(() => () => {
|
|
188
243
|
$autoMarginLeft.delete(marginId);
|
|
189
244
|
});
|
|
245
|
+
|
|
246
|
+
// An x label centred on the domain's end reaches past the plot's right side; an `'auto'` right margin takes that much room.
|
|
247
|
+
let xAxisEl: SVGGElement | undefined = $state();
|
|
248
|
+
const { autoMarginRight } = getContext<{ autoMarginRight: Writable<Map<string, number>> }>(
|
|
249
|
+
'svelteplot/autoMargins'
|
|
250
|
+
);
|
|
251
|
+
const overhangId = `dct-x-tick-overhang-${Math.random().toString(36).slice(2)}`;
|
|
252
|
+
$effect(() => {
|
|
253
|
+
const el = xAxisEl;
|
|
254
|
+
// Read so a new axis, a new box or a new margin measures again.
|
|
255
|
+
void [scales?.x, xEdgeTicks, tickValues?.x, plot.options.marginLeft, plot.facetWidth];
|
|
256
|
+
if (!el) return;
|
|
257
|
+
let frame: number | undefined;
|
|
258
|
+
let cancelled = false;
|
|
259
|
+
const measure = () => {
|
|
260
|
+
if (cancelled) return;
|
|
261
|
+
const labels = el.querySelectorAll('g.tick text');
|
|
262
|
+
const last = labels.item(labels.length - 1);
|
|
263
|
+
const svg = el.ownerSVGElement;
|
|
264
|
+
const { marginLeft } = plot.options;
|
|
265
|
+
if (last && svg && Number.isFinite(marginLeft) && Number.isFinite(plot.facetWidth)) {
|
|
266
|
+
const edge = svg.getBoundingClientRect().left + Number(marginLeft) + plot.facetWidth;
|
|
267
|
+
const overhang = Math.max(0, Math.ceil(last.getBoundingClientRect().right - edge));
|
|
268
|
+
untrack(() => {
|
|
269
|
+
if (overhang === 0) $autoMarginRight.delete(overhangId);
|
|
270
|
+
else if ($autoMarginRight.get(overhangId) !== overhang)
|
|
271
|
+
$autoMarginRight.set(overhangId, overhang);
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
// Text measures right only once its fonts load.
|
|
276
|
+
(document.fonts?.ready ?? Promise.resolve()).then(() => {
|
|
277
|
+
if (!cancelled) frame = requestAnimationFrame(measure);
|
|
278
|
+
});
|
|
279
|
+
return () => {
|
|
280
|
+
cancelled = true;
|
|
281
|
+
if (frame !== undefined) cancelAnimationFrame(frame);
|
|
282
|
+
};
|
|
283
|
+
});
|
|
284
|
+
$effect(() => () => {
|
|
285
|
+
$autoMarginRight.delete(overhangId);
|
|
286
|
+
});
|
|
190
287
|
</script>
|
|
191
288
|
|
|
192
289
|
{#snippet axisX()}
|
|
193
290
|
<AxisX
|
|
194
|
-
ticks={
|
|
291
|
+
ticks={(xEdgeTicks?.ticks ?? tickValues?.x) as string[] | undefined}
|
|
292
|
+
{...turned}
|
|
195
293
|
tickCount={xTickCount}
|
|
196
294
|
interval={xTickInterval}
|
|
197
295
|
tickSize={scales?.x?.tickSize ?? cfg.axis.xTickSize}
|
|
@@ -201,12 +299,13 @@
|
|
|
201
299
|
/>
|
|
202
300
|
{/snippet}
|
|
203
301
|
{#if scales?.x?.axisDisplay === 'hidden'}
|
|
204
|
-
<g style:visibility="hidden">{@render axisX()}</g>
|
|
302
|
+
<g style:visibility="hidden" bind:this={xAxisEl}>{@render axisX()}</g>
|
|
205
303
|
{:else if scales?.x?.axisDisplay !== 'none'}
|
|
206
|
-
{@render axisX()}
|
|
304
|
+
<g bind:this={xAxisEl}>{@render axisX()}</g>
|
|
207
305
|
{/if}
|
|
208
306
|
{#snippet axisY()}
|
|
209
307
|
<AxisY
|
|
308
|
+
ticks={(yEdgeTicks?.ticks ?? tickValues?.y) as string[] | undefined}
|
|
210
309
|
tickCount={yTickCount}
|
|
211
310
|
interval={yTickInterval}
|
|
212
311
|
tickSize={scales?.y?.tickSize ?? cfg.axis.yTickSize}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AxisBasedScalesConfig } from '../../types/layout/scales';
|
|
2
2
|
import type { AxisValue } from '../../types/layout/mapping';
|
|
3
|
+
import type { PlotLayoutState } from '../../types/layout/plot';
|
|
3
4
|
declare function $$render<TData extends Record<string, unknown>>(): {
|
|
4
5
|
props: {
|
|
5
6
|
data: TData[];
|
|
@@ -14,6 +15,15 @@ declare function $$render<TData extends Record<string, unknown>>(): {
|
|
|
14
15
|
left: number;
|
|
15
16
|
};
|
|
16
17
|
scales?: AxisBasedScalesConfig<TData>;
|
|
18
|
+
/**
|
|
19
|
+
* Where to leave the domain an axis widens to when an edge tick's
|
|
20
|
+
* `'extend'` resolved a collision (see `EdgeTicks`), for the plot to give its scale.
|
|
21
|
+
*/
|
|
22
|
+
edgeDomains?: Map<"x" | "y", [number, number]>;
|
|
23
|
+
/** The labels a category axis writes, when it leaves some out for want of room. */
|
|
24
|
+
tickValues?: Partial<Record<"x" | "y", string[]>>;
|
|
25
|
+
/** The plot's state: its fitted axes and the y channel's field, which titles a vertical y axis with no rows. */
|
|
26
|
+
state: Pick<PlotLayoutState, "fittedAxes" | "channels">;
|
|
17
27
|
};
|
|
18
28
|
exports: {};
|
|
19
29
|
bindings: "";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { AxisScale } from '../../types/layout/scales';
|
|
2
|
+
import type { AxisValue } from '../../types/layout/mapping';
|
|
3
|
+
/** An {@link AxisScale} turned into the options svelteplot's `<Plot x>`/`<Plot y>` accepts. */
|
|
4
|
+
export declare class SveltePlotScale {
|
|
5
|
+
#private;
|
|
6
|
+
/** Scale types the default `nice` applies to - every other type has its own tick semantics (or isn't numeric at all). */
|
|
7
|
+
static readonly CONTINUOUS_NUMERIC_TYPES: ReadonlySet<string>;
|
|
8
|
+
/**
|
|
9
|
+
* The scale without what the package handles itself - `grid`, `axisDisplay`
|
|
10
|
+
* and a vertical `label`, which `ScalesLayout` draws, and a `nice` object's `tolerance`,
|
|
11
|
+
* which the "scales" phase applies (svelteplot is told plain `nice: true`) - with a custom `sort` resolved into a
|
|
12
|
+
* `domain`, and `nice: true` on an unpinned numeric axis.
|
|
13
|
+
*/
|
|
14
|
+
static build<TData>(scale: AxisScale<TData> | undefined, rows: TData[], getAxisValue: (d: TData) => AxisValue): AxisScale<TData> | undefined;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { SvelteSet } from 'svelte/reactivity';
|
|
2
|
+
/** An {@link AxisScale} turned into the options svelteplot's `<Plot x>`/`<Plot y>` accepts. */
|
|
3
|
+
export class SveltePlotScale {
|
|
4
|
+
/** Scale types the default `nice` applies to - every other type has its own tick semantics (or isn't numeric at all). */
|
|
5
|
+
static CONTINUOUS_NUMERIC_TYPES = new Set([
|
|
6
|
+
'auto',
|
|
7
|
+
'linear',
|
|
8
|
+
'pow',
|
|
9
|
+
'sqrt',
|
|
10
|
+
'log',
|
|
11
|
+
'symlog'
|
|
12
|
+
]);
|
|
13
|
+
/**
|
|
14
|
+
* The scale without what the package handles itself - `grid`, `axisDisplay`
|
|
15
|
+
* and a vertical `label`, which `ScalesLayout` draws, and a `nice` object's `tolerance`,
|
|
16
|
+
* which the "scales" phase applies (svelteplot is told plain `nice: true`) - with a custom `sort` resolved into a
|
|
17
|
+
* `domain`, and `nice: true` on an unpinned numeric axis.
|
|
18
|
+
*/
|
|
19
|
+
static build(scale, rows, getAxisValue) {
|
|
20
|
+
const sorted = SveltePlotScale.#sorted(scale, rows, getAxisValue);
|
|
21
|
+
const wantsNice = scale?.domain == null &&
|
|
22
|
+
scale?.ticks == null &&
|
|
23
|
+
scale?.nice == null &&
|
|
24
|
+
(scale?.type == null || SveltePlotScale.CONTINUOUS_NUMERIC_TYPES.has(scale.type)) &&
|
|
25
|
+
SveltePlotScale.#isNumeric(rows, getAxisValue);
|
|
26
|
+
const removesAxis = scale?.axisDisplay === 'none';
|
|
27
|
+
// svelteplot treats a categorical axis told to be `nice` as linear, and draws nothing.
|
|
28
|
+
const dropsNice = scale?.nice != null && SveltePlotScale.#isCategorical(rows, getAxisValue);
|
|
29
|
+
if (!sorted && !wantsNice && !removesAxis && !dropsNice)
|
|
30
|
+
return sorted;
|
|
31
|
+
const out = { ...sorted };
|
|
32
|
+
delete out.grid;
|
|
33
|
+
delete out.axisDisplay;
|
|
34
|
+
if (removesAxis)
|
|
35
|
+
out.axis = false;
|
|
36
|
+
if (scale?.labelOrientation === 'vertical')
|
|
37
|
+
out.label = false;
|
|
38
|
+
if (dropsNice)
|
|
39
|
+
delete out.nice;
|
|
40
|
+
else if (wantsNice || typeof scale?.nice === 'object')
|
|
41
|
+
out.nice = true;
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/** svelteplot's `sort` option only does a fixed ascending sort; a custom `scale.sort` comparator is resolved into an explicit `domain` instead, which svelteplot honors as-is. */
|
|
45
|
+
static #sorted(scale, rows, getAxisValue) {
|
|
46
|
+
const sort = scale?.sort;
|
|
47
|
+
if (typeof sort !== 'function' || scale?.domain)
|
|
48
|
+
return scale;
|
|
49
|
+
const reps = SveltePlotScale.#uniqueRows(rows, getAxisValue);
|
|
50
|
+
if (reps.length === 0 || !reps.every((r) => typeof getAxisValue(r) === 'string'))
|
|
51
|
+
return scale;
|
|
52
|
+
const domain = [...reps].sort(sort).map(getAxisValue);
|
|
53
|
+
return { ...scale, domain };
|
|
54
|
+
}
|
|
55
|
+
/** One representative row per unique axis value (first occurrence in `rows`). */
|
|
56
|
+
static #uniqueRows(rows, getAxisValue) {
|
|
57
|
+
const seen = new SvelteSet();
|
|
58
|
+
const out = [];
|
|
59
|
+
for (const row of rows) {
|
|
60
|
+
const v = getAxisValue(row);
|
|
61
|
+
if (seen.has(v))
|
|
62
|
+
continue;
|
|
63
|
+
seen.add(v);
|
|
64
|
+
out.push(row);
|
|
65
|
+
}
|
|
66
|
+
return out;
|
|
67
|
+
}
|
|
68
|
+
/** Whether the axis lays out text categories: any of its values is a string. */
|
|
69
|
+
static #isCategorical(rows, getAxisValue) {
|
|
70
|
+
return rows.some((row) => typeof getAxisValue(row) === 'string');
|
|
71
|
+
}
|
|
72
|
+
/** Whether the axis' values are numeric; `nice` on a categorical axis would make svelteplot treat it as linear. */
|
|
73
|
+
static #isNumeric(rows, getAxisValue) {
|
|
74
|
+
let numericSeen = 0;
|
|
75
|
+
for (const row of rows) {
|
|
76
|
+
const v = getAxisValue(row);
|
|
77
|
+
if (v == null)
|
|
78
|
+
continue;
|
|
79
|
+
if (typeof v !== 'number')
|
|
80
|
+
return false;
|
|
81
|
+
if (++numericSeen >= 2)
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
return numericSeen > 0;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PlotStylesConfig } from '../../types/configuration/styling';
|
|
2
|
+
/** How a category axis lays its tick labels out: the angle they stand at, and which of them are written. */
|
|
3
|
+
export type TickLayout = {
|
|
4
|
+
/** `0`, `-45` or `-90` degrees. */
|
|
5
|
+
rotate: 0 | -45 | -90;
|
|
6
|
+
/** Every how-manieth label is written: `1` writes them all. */
|
|
7
|
+
every: number;
|
|
8
|
+
/** The widest label, in px, as it is written - not wrapped, when it is rotated. */
|
|
9
|
+
width: number;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Where the tick labels of a category axis fit. Written flat they wrap at their
|
|
13
|
+
* spaces to the width of their band - a word is never split - and stand side by
|
|
14
|
+
* side as long as the widest line is narrower than the step between categories.
|
|
15
|
+
* Otherwise they turn: at 45 degrees a label needs a step of about one and a
|
|
16
|
+
* half lines of text, at 90 degrees of one; past that, only every few labels
|
|
17
|
+
* are written.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TickLabels {
|
|
20
|
+
/** The gap, in px, kept between neighbouring labels. */
|
|
21
|
+
static readonly GAP = 6;
|
|
22
|
+
/**
|
|
23
|
+
* The layout of `labels` along an axis `span` px long - the categories
|
|
24
|
+
* `bandPadding` (0-1) apart - written at `fontSize`.
|
|
25
|
+
*/
|
|
26
|
+
static layout(labels: readonly string[], span: number, bandPadding: number, fontSize: number, cfg: Pick<PlotStylesConfig, 'font'>): TickLayout;
|
|
27
|
+
/**
|
|
28
|
+
* The layout of a category axis running down the plot, whose labels stand
|
|
29
|
+
* flat in a row each: only how many can be written.
|
|
30
|
+
*/
|
|
31
|
+
static rows(count: number, span: number, fontSize: number): number;
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Box } from '../margins/Box';
|
|
2
|
+
/**
|
|
3
|
+
* Where the tick labels of a category axis fit. Written flat they wrap at their
|
|
4
|
+
* spaces to the width of their band - a word is never split - and stand side by
|
|
5
|
+
* side as long as the widest line is narrower than the step between categories.
|
|
6
|
+
* Otherwise they turn: at 45 degrees a label needs a step of about one and a
|
|
7
|
+
* half lines of text, at 90 degrees of one; past that, only every few labels
|
|
8
|
+
* are written.
|
|
9
|
+
*/
|
|
10
|
+
export class TickLabels {
|
|
11
|
+
/** The gap, in px, kept between neighbouring labels. */
|
|
12
|
+
static GAP = 6;
|
|
13
|
+
/**
|
|
14
|
+
* The layout of `labels` along an axis `span` px long - the categories
|
|
15
|
+
* `bandPadding` (0-1) apart - written at `fontSize`.
|
|
16
|
+
*/
|
|
17
|
+
static layout(labels, span, bandPadding, fontSize, cfg) {
|
|
18
|
+
const count = labels.length;
|
|
19
|
+
const measure = (text) => Box.ofText(text, fontSize, cfg).width;
|
|
20
|
+
const lineHeight = fontSize * 1.2;
|
|
21
|
+
const whole = Math.max(0, ...labels.map(measure));
|
|
22
|
+
const flat = { rotate: 0, every: 1, width: whole };
|
|
23
|
+
if (count < 2 || span <= 0 || whole === 0)
|
|
24
|
+
return flat;
|
|
25
|
+
const step = span / count;
|
|
26
|
+
const room = step - TickLabels.GAP;
|
|
27
|
+
// What a flat label measures once wrapped to its band, as the axis does.
|
|
28
|
+
const maxLine = step * (1 - bandPadding) * 0.9;
|
|
29
|
+
const wrapped = Math.max(0, ...labels.map((label) => {
|
|
30
|
+
const text = measure(label);
|
|
31
|
+
if (text <= maxLine)
|
|
32
|
+
return text;
|
|
33
|
+
const words = Math.max(0, ...label.split(/\s+/).map(measure));
|
|
34
|
+
return Math.max(words, maxLine);
|
|
35
|
+
}));
|
|
36
|
+
if (wrapped <= room)
|
|
37
|
+
return { ...flat, width: wrapped };
|
|
38
|
+
// Turned, a label stands as wide as a line of text across its step.
|
|
39
|
+
if (room >= lineHeight / Math.sin(Math.PI / 4))
|
|
40
|
+
return { rotate: -45, every: 1, width: whole };
|
|
41
|
+
if (room >= lineHeight)
|
|
42
|
+
return { rotate: -90, every: 1, width: whole };
|
|
43
|
+
return { rotate: -90, every: Math.ceil(lineHeight / Math.max(1, room)), width: whole };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* The layout of a category axis running down the plot, whose labels stand
|
|
47
|
+
* flat in a row each: only how many can be written.
|
|
48
|
+
*/
|
|
49
|
+
static rows(count, span, fontSize) {
|
|
50
|
+
if (count < 2 || span <= 0)
|
|
51
|
+
return 1;
|
|
52
|
+
const row = span / count;
|
|
53
|
+
return Math.max(1, Math.ceil((fontSize * 1.2 + 2) / row));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { Frame } from 'svelteplot';
|
|
3
3
|
import TileLayer from './TileLayer.svelte';
|
|
4
|
-
import {
|
|
4
|
+
import { GeoGeometry } from '../../plots/map/geo/GeoGeometry';
|
|
5
5
|
import type { StylesLayoutConfig } from '../../types/layout/styles';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
let minLat = Infinity;
|
|
37
37
|
let maxLat = -Infinity;
|
|
38
38
|
for (const f of features) {
|
|
39
|
-
const b =
|
|
39
|
+
const b = GeoGeometry.lonLatBounds(f.geometry);
|
|
40
40
|
if (!b) continue;
|
|
41
41
|
if (b[0] < minLon) minLon = b[0];
|
|
42
42
|
if (b[2] > maxLon) maxLon = b[2];
|
|
@@ -8,7 +8,7 @@ import type { FontStyle, StrokeStyle } from '../../types/plots/styling';
|
|
|
8
8
|
import type { TextAnchor, ValueAnchor } from '../../types/plots/constants';
|
|
9
9
|
import type { BoxAnchors, EdgeBox } from '../../types/layout/box';
|
|
10
10
|
import type { MarginSide } from '../../types/plots/props';
|
|
11
|
-
import type { AxisPlotCtx, AxisPlotState, ProcessedRow } from '../../types/phases';
|
|
11
|
+
import type { AxisPlotCtx, AxisPlotState, ProcessedData, ProcessedRow } from '../../types/phases';
|
|
12
12
|
import type { TextMarkerConfig } from '../../types/markers/common';
|
|
13
13
|
/**
|
|
14
14
|
* A plot's value labels: the author's `styles.values` over the plot kind's
|
|
@@ -20,12 +20,14 @@ export declare class ValueLabels {
|
|
|
20
20
|
#private;
|
|
21
21
|
readonly show: boolean;
|
|
22
22
|
readonly anchor: ValueAnchor;
|
|
23
|
-
readonly format: (value: number, seriesName: string) => string;
|
|
23
|
+
readonly format: (value: number, seriesName: string, row?: Record<string, unknown>) => string;
|
|
24
24
|
readonly hoverIsolate: boolean;
|
|
25
25
|
readonly font: FontStyle | undefined;
|
|
26
26
|
readonly fontSize: number;
|
|
27
27
|
/** The connectors of labels that had to move apart. */
|
|
28
28
|
readonly strokeStyle: StrokeStyle | undefined;
|
|
29
|
+
/** `'series'` writes each label in its series' color; any other CSS color writes them all in it. */
|
|
30
|
+
readonly color: 'series' | string | undefined;
|
|
29
31
|
/** How labels that would overlap move apart - the configuration's `text.declutter`. */
|
|
30
32
|
readonly declutter: PlotStylesConfig['text']['declutter'];
|
|
31
33
|
/** Where the labels are expected to sit: boxes around their points, on the edges those can reach. */
|
|
@@ -33,6 +35,14 @@ export declare class ValueLabels {
|
|
|
33
35
|
constructor(values: ValuesStyle | undefined, cfg: PlotStylesConfig, options?: Omit<ValueLabelsOptions<never>, 'reach'>, reach?: (labels: ValueLabels) => EdgeBox[]);
|
|
34
36
|
/** A plot's value labels: `values` over `options`, the kind's own defaults, their reach read off `state`. */
|
|
35
37
|
static build<TState>(values: ValuesStyle | undefined, cfg: PlotStylesConfig, options: ValueLabelsOptions<TState>, state: TState): ValueLabels;
|
|
38
|
+
/** The configuration the labels were built under, for a plot kind's own label defaults. */
|
|
39
|
+
get config(): PlotStylesConfig;
|
|
40
|
+
/**
|
|
41
|
+
* The fill every label takes whatever its series: the author's own
|
|
42
|
+
* `fontStyle.fill`, else a literal `color`. `undefined` leaves each label to
|
|
43
|
+
* its plot's default (its series' color, or the axis').
|
|
44
|
+
*/
|
|
45
|
+
get fill(): string | undefined;
|
|
36
46
|
/** One line of label text's height. */
|
|
37
47
|
get lineHeight(): number;
|
|
38
48
|
/** The box one label's `text` takes. */
|
|
@@ -82,9 +92,27 @@ export declare class ValueLabels {
|
|
|
82
92
|
* (`filter` + `selectLast`, per series), at its top (a stacked row's
|
|
83
93
|
* `y2`), labelled with its own value and placed by `anchor`. Labels that
|
|
84
94
|
* would overlap fan out into a shared column (`declutter`), colored by the
|
|
85
|
-
* segment the row falls in.
|
|
95
|
+
* segment the row falls in. A plot that labels each end of its series apart
|
|
96
|
+
* passes the `rows` and `anchor` of one end, and `lane` to route its labels
|
|
97
|
+
* out to a lane whether or not they overlap (`flip: false` keeps one on the
|
|
98
|
+
* left in the margin instead of flipping it over its points).
|
|
86
99
|
*/
|
|
87
|
-
atSeriesEnds<TData extends Record<string, unknown>>(state: AxisPlotState<TData, object
|
|
100
|
+
atSeriesEnds<TData extends Record<string, unknown>>(state: AxisPlotState<TData, object>, end?: {
|
|
101
|
+
rows?: ProcessedRow[];
|
|
102
|
+
anchor?: ValueAnchor;
|
|
103
|
+
lane?: boolean | {
|
|
104
|
+
elbowGap: number;
|
|
105
|
+
};
|
|
106
|
+
flip?: boolean;
|
|
107
|
+
}): TextMarkerConfig[];
|
|
108
|
+
/** How far (px) a lane takes the label of a series' first point from it - clear of the line that leaves it. */
|
|
109
|
+
static readonly FIRST_LANE_GAP = 28;
|
|
110
|
+
/** The rows of a series-over-`x` plot that cannot be labelled: a gap, or a stack with no top. For the "transforms" phase's `labels.skip`. */
|
|
111
|
+
static skipGaps<TData extends Record<string, unknown>>(state: {
|
|
112
|
+
processedData?: ProcessedData;
|
|
113
|
+
resolvedSeries?: Series<TData>[];
|
|
114
|
+
axes?: PlotAxes;
|
|
115
|
+
}): (row: ProcessedRow) => boolean;
|
|
88
116
|
/**
|
|
89
117
|
* Where {@link atSeriesEnds}' labels are expected to sit: past each
|
|
90
118
|
* series' last point, at the right edge (or the left, for labels set
|
|
@@ -93,5 +121,5 @@ export declare class ValueLabels {
|
|
|
93
121
|
* domain when the scales set one, so it holds across a timeline; else off
|
|
94
122
|
* every value.
|
|
95
123
|
*/
|
|
96
|
-
reachAtSeriesEnds<TData extends Record<string, unknown>>(state: AxisPlotState<TData, object
|
|
124
|
+
reachAtSeriesEnds<TData extends Record<string, unknown>>(state: AxisPlotState<TData, object>, anchor?: ValueAnchor): EdgeBox[];
|
|
97
125
|
}
|