@fundar/data-chart-telling 1.18.0 → 1.20.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 +2 -1
- package/dist/configuration/config.svelte.js +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/layout/coordinates/CoordinatesLayout.svelte +3 -1
- package/dist/layout/facet/FacetLayout.svelte +54 -41
- package/dist/layout/geometry/GeometryLayout.svelte +57 -22
- 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/HoverShapes.d.ts +20 -8
- package/dist/layout/hover/HoverShapes.js +119 -59
- package/dist/layout/legend/ContinuousSection.svelte +10 -0
- package/dist/layout/legend/LegendState.svelte.d.ts +13 -1
- package/dist/layout/legend/LegendState.svelte.js +32 -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 → AbstractPlot.svelte} +83 -6
- package/dist/layout/plot/{Plot.svelte.d.ts → AbstractPlot.svelte.d.ts} +4 -4
- package/dist/layout/plot/PublicPlotContext.d.ts +5 -0
- package/dist/layout/plot/PublicPlotContext.js +7 -0
- package/dist/layout/styles/ValueLabels.d.ts +109 -58
- package/dist/layout/styles/ValueLabels.js +299 -141
- package/dist/markers/MarkerKinds.d.ts +79 -1
- package/dist/markers/MarkerKinds.js +149 -23
- package/dist/markers/area/AreaMarker.svelte +1 -1
- package/dist/markers/band/BandMarker.svelte +2 -1
- package/dist/markers/bar/BarMarker.svelte +8 -6
- 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/geo/GeoHoverMarker.svelte +14 -11
- 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/violin/ViolinMarker.svelte +1 -1
- package/dist/markers/waffle/WaffleMarker.svelte +1 -1
- package/dist/phases/context/RowContext.d.ts +2 -0
- package/dist/phases/context/RowContext.js +4 -2
- package/dist/phases/context/rowContextKey.d.ts +2 -0
- package/dist/phases/context/rowContextKey.js +2 -0
- package/dist/phases/markers/MarkerStyles.js +14 -11
- package/dist/phases/markers/MarkersPhase.d.ts +2 -3
- package/dist/phases/markers/MarkersPhase.js +17 -11
- package/dist/phases/sharedScales/SharedStepScales.d.ts +10 -0
- package/dist/phases/sharedScales/SharedStepScales.js +43 -0
- package/dist/phases/statistics/MarkerGrouping.js +5 -32
- 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/transforms/TransformsPhase.js +5 -3
- 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.js +14 -1
- package/dist/plots/correlation/heatmap/markers.d.ts +0 -6
- package/dist/plots/correlation/heatmap/markers.js +5 -9
- 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.js +9 -3
- package/dist/plots/correlation/scatter/markers.d.ts +0 -9
- package/dist/plots/correlation/scatter/markers.js +21 -28
- package/dist/plots/distribution/box/BoxSummaries.d.ts +5 -0
- package/dist/plots/distribution/box/BoxSummaries.js +9 -0
- 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.js +11 -0
- package/dist/plots/distribution/box/markers.js +10 -1
- 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.js +16 -0
- package/dist/plots/distribution/density/markers.js +5 -1
- 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.js +16 -11
- package/dist/plots/distribution/histogram/markers.js +3 -3
- 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.js +9 -2
- package/dist/plots/distribution/pyramid/markers.d.ts +0 -8
- package/dist/plots/distribution/pyramid/markers.js +6 -16
- 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.js +11 -0
- package/dist/plots/distribution/violin/markers.js +27 -3
- 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.js +4 -7
- package/dist/plots/evolution/area/markers.js +3 -1
- 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.js +4 -6
- package/dist/plots/evolution/line/markers.js +3 -1
- 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.js +4 -3
- package/dist/plots/evolution/slope/markers.d.ts +4 -3
- package/dist/plots/evolution/slope/markers.js +16 -9
- 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.js +1 -1
- package/dist/plots/evolution/sparkline/markers.js +3 -1
- 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 +29 -6
- package/dist/plots/map/geo/Plot.svelte +40 -12
- package/dist/plots/map/geo/Plot.svelte.d.ts +0 -1
- package/dist/plots/map/geo/phases/data.d.ts +2 -1
- package/dist/plots/map/geo/phases/data.js +8 -2
- package/dist/plots/map/geo/phases/scales.js +6 -2
- package/dist/plots/map/geo/slices.d.ts +27 -3
- package/dist/plots/map/geo/slices.js +58 -5
- 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.js +2 -2
- 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.js +13 -3
- package/dist/plots/ranking/bar/markers.js +12 -29
- 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.js +20 -0
- package/dist/plots/ranking/bullet/markers.js +7 -1
- package/dist/plots/ranking/cleveland/ClevelandMarkers.d.ts +2 -9
- package/dist/plots/ranking/cleveland/ClevelandMarkers.js +65 -47
- 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.js +33 -2
- package/dist/plots/ranking/dumbbell/Plot.svelte +2 -2
- package/dist/plots/ranking/dumbbell/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/forest/Plot.svelte +2 -2
- package/dist/plots/ranking/forest/Plot.svelte.d.ts +0 -1
- package/dist/plots/ranking/lollipop/Plot.svelte +2 -2
- package/dist/plots/ranking/lollipop/Plot.svelte.d.ts +0 -1
- package/dist/types/layout/context.d.ts +2 -0
- package/dist/types/layout/plot.d.ts +2 -0
- package/dist/types/layout/styles/bullet.d.ts +4 -1
- package/dist/types/layout/styles/geo.d.ts +3 -3
- package/dist/types/layout/styles/values.d.ts +51 -11
- package/dist/types/markers/axis/area.d.ts +5 -1
- package/dist/types/markers/axis/bar.d.ts +5 -2
- 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/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/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/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/markers/phase.d.ts +1 -8
- package/dist/types/phases/statistics/phase.d.ts +8 -3
- package/dist/types/phases/styles/phase.d.ts +15 -3
- package/dist/types/phases/transforms/phase.d.ts +2 -0
- package/dist/types/plots/constants.d.ts +0 -12
- package/dist/types/plots/correlation/heatmap/props.d.ts +3 -2
- package/dist/types/plots/correlation/scatter/props.d.ts +3 -2
- package/dist/types/plots/data/geo.d.ts +19 -5
- package/dist/types/plots/distribution/box/props.d.ts +6 -2
- package/dist/types/plots/distribution/density/props.d.ts +2 -1
- package/dist/types/plots/distribution/histogram/props.d.ts +3 -2
- package/dist/types/plots/distribution/pyramid/props.d.ts +3 -2
- package/dist/types/plots/distribution/violin/props.d.ts +4 -1
- package/dist/types/plots/evolution/area/props.d.ts +3 -2
- package/dist/types/plots/evolution/line/props.d.ts +3 -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/props.d.ts +9 -3
- package/dist/types/plots/map/geo/state.d.ts +3 -1
- package/dist/types/plots/part-of-a-whole/treemap/props.d.ts +4 -2
- package/dist/types/plots/ranking/bar/props.d.ts +3 -2
- package/dist/types/plots/ranking/cleveland/props.d.ts +3 -2
- package/dist/types/plots/ranking/dumbbell/props.d.ts +3 -2
- package/dist/types/plots/ranking/forest/props.d.ts +5 -2
- package/dist/types/plots/ranking/lollipop/props.d.ts +3 -2
- package/dist/utils/ConfigEquality.d.ts +11 -0
- package/dist/utils/ConfigEquality.js +37 -0
- package/docs/architecture.md +9 -9
- package/docs/facets.md +12 -0
- package/docs/geo.md +35 -7
- package/docs/legend.md +6 -0
- package/docs/markers.md +2 -4
- package/docs/plots/ranking/bar.md +1 -1
- package/docs/plots/ranking/cleveland.md +1 -1
- package/docs/state.md +1 -1
- package/docs/styles-and-segments.md +1 -14
- package/docs/timeline.md +1 -1
- package/docs/transforms-and-statistics.md +1 -1
- package/docs/value-labels.md +159 -0
- package/examples/BarValues.svelte +1 -1
- package/llms-full.txt +5 -5
- package/llms.txt +1 -0
- 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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildForestDefaults } from './defaults';
|
|
4
4
|
import type { ForestPlotProps, ForestPlotCoreProps } from '../../../types/plots/ranking/forest/props';
|
|
5
5
|
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
}: ForestPlotProps<TData> = $props();
|
|
26
26
|
</script>
|
|
27
27
|
|
|
28
|
-
<
|
|
28
|
+
<AbstractPlot
|
|
29
29
|
core={core as ForestPlotCoreProps<TData>}
|
|
30
30
|
defaults={buildForestDefaults}
|
|
31
31
|
bind:margins
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" generics="TData extends Record<string, unknown>">
|
|
2
|
-
import
|
|
2
|
+
import AbstractPlot from '../../../layout/plot/AbstractPlot.svelte';
|
|
3
3
|
import { buildLollipopDefaults } from './defaults';
|
|
4
4
|
import type {
|
|
5
5
|
LollipopPlotProps,
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}: LollipopPlotProps<TData> = $props();
|
|
29
29
|
</script>
|
|
30
30
|
|
|
31
|
-
<
|
|
31
|
+
<AbstractPlot
|
|
32
32
|
core={core as LollipopPlotCoreProps<TData>}
|
|
33
33
|
defaults={buildLollipopDefaults}
|
|
34
34
|
bind:margins
|
|
@@ -16,6 +16,8 @@ export type PlotRowContext<TRow = Record<string, unknown>> = {
|
|
|
16
16
|
value?: number;
|
|
17
17
|
/** The row itself, as the plot drew it: the data's fields, plus whatever its transforms added. */
|
|
18
18
|
row?: TRow;
|
|
19
|
+
/** Which of the row's values a label writes, on a plot whose rows have several (`styles.values.parts`). */
|
|
20
|
+
part?: string;
|
|
19
21
|
};
|
|
20
22
|
/** A plot kind's own context of a row: the shared one, with what the kind works out for it. */
|
|
21
23
|
export type KindRowContext<TExtra extends object, TRow = Record<string, unknown>> = PlotRowContext<TRow> & TExtra;
|
|
@@ -31,6 +31,8 @@ export type PlotCellContext<TRow extends Record<string, unknown>, TScales extend
|
|
|
31
31
|
panel?: object;
|
|
32
32
|
/** Where this slice sits among the facet panels - `undefined` when the plot has no facet. */
|
|
33
33
|
facet?: NonNullable<SlicePlace['facet']>;
|
|
34
|
+
/** The timeline step this slice shows - `undefined` when the plot has no timeline. */
|
|
35
|
+
time?: TimeValue;
|
|
34
36
|
/** Whether any row - the plot's own or a marker's - belongs in this slice; rows without a slicing field belong in all. */
|
|
35
37
|
keep: (row: TRow) => boolean;
|
|
36
38
|
};
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import type { WithValues, BarValueLabel } from './values';
|
|
1
2
|
import type { GapsAwarePlotStylesConfig } from './gaps';
|
|
2
3
|
import type { BarSegmentStyle } from '../../plots/segments/common';
|
|
4
|
+
/** The values of a bullet's row its value labels can write: its bar's, its target, its ranges' bounds. */
|
|
5
|
+
export type BulletValuePart = 'value' | 'target' | 'ranges';
|
|
3
6
|
/** `BulletPlot`'s `styles`: a bar plot's, with the look of its ranges and its target. Each field falls back to `bullet` in the configuration. */
|
|
4
|
-
export type BulletStylesConfig = GapsAwarePlotStylesConfig<BarSegmentStyle> & {
|
|
7
|
+
export type BulletStylesConfig = WithValues<GapsAwarePlotStylesConfig<BarSegmentStyle>, BarValueLabel, BulletValuePart> & {
|
|
5
8
|
/** The bar that shows the value. */
|
|
6
9
|
bar?: {
|
|
7
10
|
/** Its thickness across the category band, in px. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GeoFeature } from '../../plots/data/geo';
|
|
1
|
+
import type { GeoFeature, GeoSliceContext } from '../../plots/data/geo';
|
|
2
2
|
import type { FrameProp } from './frame';
|
|
3
3
|
import type { BasePlotStylesConfig } from './base';
|
|
4
4
|
export type GeoTileLayerConfig = {
|
|
@@ -26,8 +26,8 @@ export type GeoStylesConfig<TProps extends Record<string, unknown> = Record<stri
|
|
|
26
26
|
strokeWidth?: number;
|
|
27
27
|
/** Raster XYZ tile basemap under the vector geometry. Mercator-family projections only. */
|
|
28
28
|
tileLayer?: GeoTileLayerConfig;
|
|
29
|
-
/** Fired when a base-map feature is clicked. */
|
|
30
|
-
onFeatureClick?: (feature: GeoFeature<TProps>, event: Event) => void;
|
|
29
|
+
/** Fired when a base-map feature is clicked, with the slice it was drawn in. */
|
|
30
|
+
onFeatureClick?: (feature: GeoFeature<TProps>, event: Event, slice: GeoSliceContext) => void;
|
|
31
31
|
};
|
|
32
32
|
/**
|
|
33
33
|
* `GeoTileLayerConfig`, plus `features` - never author-facing (the public
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MarkerLabelConfig } from '../../markers/labels/common';
|
|
2
|
+
import type { BoxLabelConfig } from '../../markers/labels/box';
|
|
3
|
+
import type { PointLabelConfig } from '../../markers/labels/point';
|
|
4
|
+
import type { AreaEdgeLabelConfig, PageEdge, PathLabelConfig, RimLabelConfig, StrokeLabelConfig, ValueEdge } from '../../markers/labels/path';
|
|
2
5
|
import type { FontStyle, StrokeStyle } from '../../plots/styling';
|
|
3
6
|
import type { NumberDisplay } from '../numbers';
|
|
4
7
|
import type { PlotRowContext } from '../context';
|
|
@@ -14,17 +17,42 @@ export type ValueSelect = 'first' | 'last' | 'min' | 'max';
|
|
|
14
17
|
* marker over the rows the plot itself draws (after its own `transforms`):
|
|
15
18
|
* one at the end of each series on a line or area plot, one per bar on a bar,
|
|
16
19
|
* pyramid or histogram plot, one per point on a scatter plot and one per cell
|
|
17
|
-
* on a heatmap.
|
|
18
|
-
*
|
|
19
|
-
* `
|
|
20
|
-
*
|
|
21
|
-
* label text and connector-line styling
|
|
20
|
+
* on a heatmap. `layout` and its options place them as a marker's `label` would (each
|
|
21
|
+
* plot kind takes the layouts its shapes do, with defaults of its own for each);
|
|
22
|
+
* `fontStyle` (`fill`, `fontSize`, `lineHeight`, `rotate`, `class`, …) styles
|
|
23
|
+
* the text, never where it sits - mirrors {@link DeltaConfig}'s
|
|
24
|
+
* `fontStyle`/`strokeStyle` split, so label text and connector-line styling
|
|
25
|
+
* never mix into one flat bag of props.
|
|
22
26
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
/** The options of a label that place it, as `styles.values` takes them: its `layout` optional, the kind's by default. */
|
|
28
|
+
type LayoutKey = 'anchor' | 'edge' | 'side' | 'offset' | 'gap';
|
|
29
|
+
export type ValueLayoutOf<TLabel> = TLabel extends {
|
|
30
|
+
layout?: infer TLayout;
|
|
31
|
+
} ? Pick<TLabel, Extract<keyof TLabel, LayoutKey>> & {
|
|
32
|
+
layout?: TLayout;
|
|
33
|
+
} : never;
|
|
34
|
+
/**
|
|
35
|
+
* `TStyles` with its `values` taking only the labels of `TLabel` - the layouts a plot kind's shapes write - and, on a
|
|
36
|
+
* kind whose rows have several values, the `TPart`s it can label.
|
|
37
|
+
*/
|
|
38
|
+
export type WithValues<TStyles, TLabel extends MarkerLabelConfig, TPart extends string = 'value'> = Omit<TStyles, 'values'> & {
|
|
39
|
+
values?: ValuesStyle<TLabel, TPart>;
|
|
40
|
+
};
|
|
41
|
+
export type ValuesStyle<TLabel extends MarkerLabelConfig = MarkerLabelConfig, TPart extends string = string> = ValuesOptions & ValueLayoutOf<TLabel> & {
|
|
42
|
+
parts?: ValueParts<TPart, TLabel>;
|
|
43
|
+
};
|
|
44
|
+
/** What a part's own label sets, over the plot's: where it sits and its text. */
|
|
45
|
+
export type ValuePartOptions<TLabel = MarkerLabelConfig> = Omit<ValueLayoutOf<TLabel>, 'layout'> & Pick<ValuesOptions, 'format'>;
|
|
46
|
+
/**
|
|
47
|
+
* The parts of each row a plot kind with several values per row labels - a box's `median`, a bullet's `target`: a
|
|
48
|
+
* list of them, or a record turning each on (`true`) or setting its own options.
|
|
49
|
+
*/
|
|
50
|
+
export type ValueParts<TPart extends string, TLabel = MarkerLabelConfig> = TPart[] | Partial<Record<TPart, boolean | ValuePartOptions<TLabel>>>;
|
|
51
|
+
/** A value label's text style, without what places it: the layout's options do that. */
|
|
52
|
+
export type ValuesFontStyle = Omit<FontStyle, 'textAnchor' | 'lineAnchor' | 'dx' | 'dy'>;
|
|
53
|
+
type ValuesOptions = NumberDisplay & {
|
|
54
|
+
/** Whether the labels are drawn. Setting any other option of them turns them on; off by default, except on a heatmap. */
|
|
25
55
|
show?: boolean;
|
|
26
|
-
/** Where each label sits on its mark - see {@link ValueAnchor}. */
|
|
27
|
-
anchor?: ValueAnchor;
|
|
28
56
|
/**
|
|
29
57
|
* Which rows of each group are labelled: one selector, or a list of them (a
|
|
30
58
|
* row picked by any is labelled) - see {@link ValueSelect}. Each plot has its
|
|
@@ -48,7 +76,19 @@ export type ValuesStyle = NumberDisplay & {
|
|
|
48
76
|
format?: (value: number, number: (value: number) => string, context: PlotRowContext) => string;
|
|
49
77
|
/** Hovering a label dims every other series, like toggling them off in the legend. */
|
|
50
78
|
hoverIsolate?: boolean;
|
|
51
|
-
|
|
79
|
+
/** The text's look; where it sits is the layout's (`side`, `gap`, `offset`...). */
|
|
80
|
+
fontStyle?: ValuesFontStyle;
|
|
52
81
|
/** The connectors a line or area plot routes back from labels that had to move apart. */
|
|
53
82
|
strokeStyle?: StrokeStyle;
|
|
54
83
|
};
|
|
84
|
+
/** The labels a plot of bars writes on them: in each, along an edge (its `tip` too) or beside a point of it. */
|
|
85
|
+
export type BarValueLabel = BoxLabelConfig | PathLabelConfig<PageEdge | ValueEdge> | PointLabelConfig;
|
|
86
|
+
/** The labels a plot of boxes with no value direction (a heatmap's cells, a histogram's bins) writes on them. */
|
|
87
|
+
export type CellValueLabel = BoxLabelConfig | PathLabelConfig<PageEdge> | PointLabelConfig;
|
|
88
|
+
/** The labels a plot of lines writes: beside its points, or along its lines. */
|
|
89
|
+
export type LineValueLabel = PointLabelConfig | StrokeLabelConfig;
|
|
90
|
+
/** The labels a plot of areas writes: beside its points, or along their top or bottom edge. */
|
|
91
|
+
export type AreaValueLabel = PointLabelConfig | AreaEdgeLabelConfig;
|
|
92
|
+
/** The labels a plot of dots writes: beside them, or around their rim. */
|
|
93
|
+
export type DotValueLabel = PointLabelConfig | RimLabelConfig;
|
|
94
|
+
export {};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { AreaEdgeLabelConfig } from '../labels/path';
|
|
2
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
3
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
4
|
+
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
1
5
|
import type { AreaStyle } from '../../plots/styling';
|
|
2
6
|
import type { CommonMarkerConfigWithArea } from '../channels/commonMarkerConfigWithArea';
|
|
3
7
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
@@ -9,4 +13,4 @@ export type AreaMarkerConfig = {
|
|
|
9
13
|
curve?: CurveName;
|
|
10
14
|
tension?: number;
|
|
11
15
|
styles?: AreaStyle;
|
|
12
|
-
} & CommonMarkerConfigWithArea & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval
|
|
16
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfigWithArea & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel<AreaEdgeLabelConfig | PointLabelConfig>;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { PathLabelConfig, PageEdge, ValueEdge } from '../labels/path';
|
|
2
|
+
import type { BoxLabelConfig } from '../labels/box';
|
|
3
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
4
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
5
|
import type { AxisValue } from '../../layout/mapping';
|
|
2
6
|
import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
|
|
3
7
|
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
@@ -7,8 +11,7 @@ import type { CommonMarkerConfigWithInterval } from '../channels/commonMarkerCon
|
|
|
7
11
|
export type BarMarkerConfig = {
|
|
8
12
|
type: 'bar';
|
|
9
13
|
role: 'segment' | 'hitArea';
|
|
10
|
-
isHorizontal: boolean;
|
|
11
14
|
thickness?: number;
|
|
12
15
|
styles?: PerRow<AreaStyle> & InsetStyle;
|
|
13
16
|
category?: AxisValue;
|
|
14
|
-
} & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel
|
|
17
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel<BoxLabelConfig | PathLabelConfig<PageEdge | ValueEdge> | PointLabelConfig>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
2
|
import type { BollingerStatisticOptions } from '../../layout/statistics';
|
|
2
3
|
import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
|
|
3
4
|
/** A moving-average band (svelteplot's `BollingerX`/`BollingerY`). */
|
|
4
5
|
export type BollingerMarkerConfig = {
|
|
5
6
|
type: 'bollinger';
|
|
6
|
-
} & BollingerStatisticOptions & CommonMarkerConfig;
|
|
7
|
+
} & CommonMarkerConfigWithOrientation & BollingerStatisticOptions & CommonMarkerConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
2
|
import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
|
|
2
3
|
/**
|
|
3
4
|
* A box plot (svelteplot's `BoxX`/`BoxY`). Styled per sub-mark through `bar`,
|
|
@@ -16,4 +17,4 @@ export type BoxMarkerConfig = {
|
|
|
16
17
|
index: number;
|
|
17
18
|
count: number;
|
|
18
19
|
};
|
|
19
|
-
} & CommonMarkerConfig;
|
|
20
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfig;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { PathLabelConfig, PageEdge } from '../labels/path';
|
|
2
|
+
import type { BoxLabelConfig } from '../labels/box';
|
|
3
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
1
4
|
import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
|
|
2
5
|
import type { CommonMarkerConfigWithArea } from '../channels/commonMarkerConfigWithArea';
|
|
3
6
|
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
@@ -6,4 +9,4 @@ import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfig
|
|
|
6
9
|
export type CellMarkerConfig = {
|
|
7
10
|
type: 'cell';
|
|
8
11
|
styles?: PerRow<AreaStyle & Pick<InsetStyle, 'inset'>>;
|
|
9
|
-
} & CommonMarkerConfigWithColor & CommonMarkerConfigWithArea & CommonMarkerConfigWithLabel
|
|
12
|
+
} & CommonMarkerConfigWithColor & CommonMarkerConfigWithArea & CommonMarkerConfigWithLabel<BoxLabelConfig | PathLabelConfig<PageEdge> | PointLabelConfig>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { StrokeLabelConfig } from '../labels/path';
|
|
2
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
3
|
+
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
1
4
|
import type { StrokeStyle } from '../../plots/styling';
|
|
2
5
|
import type { CurveName } from '../../layout/styles/curve';
|
|
3
6
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
@@ -6,4 +9,4 @@ export type LineMarkerConfig = {
|
|
|
6
9
|
type: 'line';
|
|
7
10
|
curve?: CurveName;
|
|
8
11
|
styles?: StrokeStyle;
|
|
9
|
-
} & CommonMarkerConfigWithColor
|
|
12
|
+
} & CommonMarkerConfigWithColor & CommonMarkerConfigWithLabel<StrokeLabelConfig | PointLabelConfig>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { PathLabelConfig, PageEdge } from '../labels/path';
|
|
2
|
+
import type { BoxLabelConfig } from '../labels/box';
|
|
3
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
1
4
|
import type { AreaStyle, PerRow, InsetStyle } from '../../plots/styling';
|
|
2
5
|
import type { CommonMarkerConfigWithArea } from '../channels/commonMarkerConfigWithArea';
|
|
3
6
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
@@ -8,4 +11,4 @@ export type RectMarkerConfig = {
|
|
|
8
11
|
type: 'rect';
|
|
9
12
|
interval?: number | string;
|
|
10
13
|
styles?: PerRow<AreaStyle & InsetStyle>;
|
|
11
|
-
} & CommonMarkerConfigWithArea & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel
|
|
14
|
+
} & CommonMarkerConfigWithArea & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel<BoxLabelConfig | PathLabelConfig<PageEdge> | PointLabelConfig>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
2
|
import type { RegressionStatisticOptions } from '../../layout/statistics';
|
|
2
3
|
import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
|
|
3
4
|
/** A fitted regression curve (svelteplot's `RegressionX`/`RegressionY`). */
|
|
4
5
|
export type RegressionMarkerConfig = {
|
|
5
6
|
type: 'regression';
|
|
6
|
-
} & RegressionStatisticOptions & CommonMarkerConfig;
|
|
7
|
+
} & CommonMarkerConfigWithOrientation & RegressionStatisticOptions & CommonMarkerConfig;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
2
|
import type { StrokeStyle, PerRow } from '../../plots/styling';
|
|
2
3
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
3
4
|
/** A short tick per row along one axis (svelteplot's `TickX`/`TickY`). */
|
|
@@ -5,4 +6,4 @@ export type TickMarkerConfig = {
|
|
|
5
6
|
type: 'tick';
|
|
6
7
|
tickLength?: number | ((d: any) => number);
|
|
7
8
|
styles?: PerRow<StrokeStyle>;
|
|
8
|
-
} & CommonMarkerConfigWithColor;
|
|
9
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfigWithColor;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { StrokeLabelConfig } from '../labels/path';
|
|
2
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
3
|
+
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
1
4
|
import type { AreaStyle } from '../../plots/styling';
|
|
2
5
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
3
6
|
import type { CommonMarkerConfigWithRadius } from '../channels/commonMarkerConfigWithRadius';
|
|
@@ -10,4 +13,4 @@ export type TrailMarkerConfig = {
|
|
|
10
13
|
cap?: 'butt' | 'round';
|
|
11
14
|
resolution?: number | 'auto';
|
|
12
15
|
styles?: Pick<AreaStyle, 'fill' | 'fillOpacity'>;
|
|
13
|
-
} & CommonMarkerConfigWithRadius & CommonMarkerConfigWithColor
|
|
16
|
+
} & CommonMarkerConfigWithRadius & CommonMarkerConfigWithColor & CommonMarkerConfigWithLabel<StrokeLabelConfig | PointLabelConfig>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
2
|
import type { AreaStyle } from '../../plots/styling';
|
|
2
3
|
import type { DensityKernel } from '../../transforms/density';
|
|
3
4
|
import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
|
|
@@ -22,4 +23,4 @@ export type ViolinMarkerConfig = {
|
|
|
22
23
|
count: number;
|
|
23
24
|
};
|
|
24
25
|
styles?: AreaStyle;
|
|
25
|
-
} & CommonMarkerConfig;
|
|
26
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfig;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import type { PathLabelConfig, PageEdge, ValueEdge } from '../labels/path';
|
|
2
|
+
import type { BoxLabelConfig } from '../labels/box';
|
|
3
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
4
|
+
import type { CommonMarkerConfigWithOrientation } from '../channels/commonMarkerConfigWithOrientation';
|
|
1
5
|
import type { AreaStyle, PerRow } from '../../plots/styling';
|
|
2
6
|
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
3
7
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
@@ -11,4 +15,4 @@ export type WaffleMarkerConfig = {
|
|
|
11
15
|
gap?: number;
|
|
12
16
|
round?: boolean;
|
|
13
17
|
styles?: PerRow<AreaStyle>;
|
|
14
|
-
} & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel
|
|
18
|
+
} & CommonMarkerConfigWithOrientation & CommonMarkerConfigWithColor & CommonMarkerConfigWithInterval & CommonMarkerConfigWithLabel<BoxLabelConfig | PathLabelConfig<PageEdge | ValueEdge> | PointLabelConfig>;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { RimLabelConfig } from '../labels/path';
|
|
2
|
+
import type { PointLabelConfig } from '../labels/point';
|
|
3
|
+
import type { CommonMarkerConfigWithLabel } from '../channels/commonMarkerConfigWithLabel';
|
|
1
4
|
import type { DotStyle, PerRow } from '../../plots/styling';
|
|
2
5
|
import type { CommonMarkerConfigWithColor } from '../channels/commonMarkerConfigWithColor';
|
|
3
6
|
import type { CommonMarkerConfigWithRadius } from '../channels/commonMarkerConfigWithRadius';
|
|
@@ -7,4 +10,4 @@ import type { CommonMarkerConfigWithSymbol } from '../channels/commonMarkerConfi
|
|
|
7
10
|
export type DotMarkerConfig = CommonMarkerConfigWithRowOffset<{
|
|
8
11
|
type: 'dot';
|
|
9
12
|
styles?: PerRow<DotStyle>;
|
|
10
|
-
} & CommonMarkerConfigWithRadius & CommonMarkerConfigWithColor & CommonMarkerConfigWithSymbol
|
|
13
|
+
} & CommonMarkerConfigWithRadius & CommonMarkerConfigWithColor & CommonMarkerConfigWithSymbol & CommonMarkerConfigWithLabel<RimLabelConfig | PointLabelConfig>>;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
|
+
import type { CoveringShape } from '../labels/point';
|
|
1
2
|
import type { FontStyle, StrokeStyle, PerRow } from '../../plots/styling';
|
|
2
3
|
import type { CommonMarkerConfig } from '../channels/commonMarkerConfig';
|
|
3
4
|
import type { CommonMarkerConfigWithRowOffset } from '../channels/commonMarkerConfigWithRowOffset';
|
|
4
5
|
import type { Margins } from '../../../layout/margins/Margins';
|
|
5
6
|
import type { BandSlice } from '../../layout/hover';
|
|
6
|
-
import type { LabelAnchor, TextAnchor } from '../../plots/constants';
|
|
7
|
+
import type { LabelAnchor, LineAnchor, TextAnchor } from '../../plots/constants';
|
|
7
8
|
import type { NumberDisplay } from '../../layout/numbers';
|
|
8
9
|
/**
|
|
9
|
-
*
|
|
10
|
-
* shared column, each routed back to its
|
|
11
|
-
*
|
|
10
|
+
* How labels that would overlap are laid out. `'lanes'` spreads them apart
|
|
11
|
+
* vertically, all reaching out to one shared column, each routed back to its
|
|
12
|
+
* own point by an elbow connector; `'around'` puts each one on a free spot
|
|
13
|
+
* around its point (its own side first, then on clockwise),
|
|
14
|
+
* clear of the other labels and points, and leaves out one with no room.
|
|
12
15
|
*/
|
|
16
|
+
export type TextDeclutterMode = 'lanes' | 'around';
|
|
17
|
+
/** {@link TextDeclutterMode}'s options. Unset geometry falls back to the configuration's `text.declutter`. */
|
|
13
18
|
export type TextDeclutterConfig = {
|
|
19
|
+
/** Defaults to `'lanes'`. */
|
|
20
|
+
mode?: TextDeclutterMode;
|
|
14
21
|
/** Shortest lane's distance (px) from the point before a connector bends. */
|
|
15
22
|
elbowGap?: number;
|
|
16
23
|
/** Extra distance (px) each further lane sits out from the last. */
|
|
@@ -68,8 +75,10 @@ export type TextMarkerConfig = CommonMarkerConfigWithRowOffset<{
|
|
|
68
75
|
styles?: PerRow<TextRowStyle> & Omit<FontStyle, TextRowStyleKey>;
|
|
69
76
|
/** Which side of its point the text sits on: a value, or a function of the row. Wins over `styles.textAnchor`. */
|
|
70
77
|
textAnchor?: TextAnchor | ((d: any) => TextAnchor);
|
|
71
|
-
/**
|
|
72
|
-
|
|
78
|
+
/** Which side of its point the text sits on vertically: a value, or a function of the row. Wins over `styles.lineAnchor`. */
|
|
79
|
+
lineAnchor?: LineAnchor | ((d: any) => LineAnchor);
|
|
80
|
+
/** Lays out overlapping labels - see {@link TextDeclutterConfig}. `true` is `'lanes'` with every default. */
|
|
81
|
+
declutter?: boolean | TextDeclutterMode | TextDeclutterConfig;
|
|
73
82
|
/** Writes each label to fit its box - see {@link TextFitConfig}. `true` takes every default. */
|
|
74
83
|
fit?: boolean | TextFitConfig;
|
|
75
84
|
/**
|
|
@@ -80,6 +89,16 @@ export type TextMarkerConfig = CommonMarkerConfigWithRowOffset<{
|
|
|
80
89
|
edgeAware?: boolean;
|
|
81
90
|
/** The slice of its category band each label sits in (a grouped bar's series); it is drawn off the band's middle, whatever the band's width. */
|
|
82
91
|
bandSlice?: BandSlice;
|
|
92
|
+
/**
|
|
93
|
+
* The shape each row's point sits in: a label is left out where the shape of a row drawn after its own covers it,
|
|
94
|
+
* as a dot drawn over another hides that one's label.
|
|
95
|
+
*/
|
|
96
|
+
covers?: (d: any, scales: any) => CoveringShape | undefined;
|
|
97
|
+
/** How far each row's point sits off its `x`/`y`, in pixels: labels, connectors and lanes start there. */
|
|
98
|
+
origin?: (d: any, scales: any) => {
|
|
99
|
+
dx: number;
|
|
100
|
+
dy: number;
|
|
101
|
+
} | undefined;
|
|
83
102
|
/** Where, in the plot's frame, a label sits on an axis it sets no position for: `{ type: 'text', x: 5, frameAnchor: 'top' }` is at the frame's top edge. */
|
|
84
103
|
frameAnchor?: LabelAnchor;
|
|
85
104
|
/** Grows the plot's margins, on every side the author left open, so the labels fit. */
|
|
@@ -87,21 +106,6 @@ export type TextMarkerConfig = CommonMarkerConfigWithRowOffset<{
|
|
|
87
106
|
/** Reports how far the rendered labels reach past the plot's content box, in pixels, on each side. */
|
|
88
107
|
onoverflow?: (overflow: Margins) => void;
|
|
89
108
|
} & NumberDisplay & CommonMarkerConfig>;
|
|
90
|
-
/** A `text` marker as a shape's `label`: all of it but what the shape sets - its `type`, its rows and the label's position. */
|
|
91
|
-
export type TextLabelConfig = Omit<TextMarkerConfig, 'type' | 'data' | 'x' | 'y' | 'frameAnchor'> & {
|
|
92
|
-
/**
|
|
93
|
-
* Where in its shape the label sits: its `'middle'` (the default), against one of its edges (`'top'`, `'bottom'`,
|
|
94
|
-
* `'left'`, `'right'`) or in one of its corners (`'top-left'`...). The label's `dx` and `dy` move it from there.
|
|
95
|
-
*/
|
|
96
|
-
anchor?: LabelAnchor;
|
|
97
|
-
/**
|
|
98
|
-
* Puts a label anchored to an edge beyond that edge, outside the shape, instead of inside it. A label out there is not
|
|
99
|
-
* fitted to the shape, and with `fitMargins` the plot's margins grow to hold it.
|
|
100
|
-
*/
|
|
101
|
-
outside?: boolean;
|
|
102
|
-
/** Pixels between the label and the edge it is anchored to. Defaults to the configuration's `text.label.gap`, `4`. */
|
|
103
|
-
gap?: number;
|
|
104
|
-
};
|
|
105
109
|
export type { LabelAnchor };
|
|
106
110
|
/** Where one decluttered label goes - see `Declutter.buildLanes`. */
|
|
107
111
|
export type LabelLane = {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/**
|
|
3
|
-
export type CommonMarkerConfigWithLabel = {
|
|
4
|
-
/**
|
|
5
|
-
|
|
6
|
-
* which the shape sets. The label is centred on its shape, and fitted to it unless `fit` is `false` - see
|
|
7
|
-
* {@link TextFitConfig}. It never takes the pointer from the shape under it.
|
|
8
|
-
*/
|
|
9
|
-
label?: TextLabelConfig;
|
|
1
|
+
import type { MarkerLabelConfig, MarkerLabels } from '../labels/common';
|
|
2
|
+
/** `TLabel` names the layouts the marker kind supports. */
|
|
3
|
+
export type CommonMarkerConfigWithLabel<TLabel extends MarkerLabelConfig> = {
|
|
4
|
+
/** One label per shape, or a list of them. `layout` defaults to the marker kind's. */
|
|
5
|
+
label?: MarkerLabels<TLabel>;
|
|
10
6
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { LabelBaseConfig } from './common';
|
|
2
|
+
import type { TextMarkerConfig } from '../basic/text';
|
|
3
|
+
import type { LabelAnchor } from '../../plots/constants';
|
|
4
|
+
/** A label written in the box of each shape, fitted to it unless `fit` is `false`. */
|
|
5
|
+
export type BoxLabelConfig = LabelBaseConfig & {
|
|
6
|
+
layout?: 'box';
|
|
7
|
+
anchor?: LabelAnchor;
|
|
8
|
+
/** Defaults to the configuration's `text.label.gap`. */
|
|
9
|
+
gap?: number;
|
|
10
|
+
};
|
|
11
|
+
export type BoxShape = 'edges' | 'cell' | 'band';
|
|
12
|
+
/** A field, a symbol, a function of the row or a literal. */
|
|
13
|
+
export type BoxEdge = unknown;
|
|
14
|
+
export type BoxChannels = {
|
|
15
|
+
x1: BoxEdge;
|
|
16
|
+
x2: BoxEdge;
|
|
17
|
+
y1: BoxEdge;
|
|
18
|
+
y2: BoxEdge;
|
|
19
|
+
};
|
|
20
|
+
export type BoxScales = Record<string, {
|
|
21
|
+
type?: string;
|
|
22
|
+
fn: any;
|
|
23
|
+
} | undefined>;
|
|
24
|
+
export type BoxSizer = (row: unknown, scales: BoxScales) => {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
} | undefined;
|
|
28
|
+
export type BoxGeometryOf = {
|
|
29
|
+
x: unknown;
|
|
30
|
+
y: unknown;
|
|
31
|
+
box: BoxChannels | BoxSizer;
|
|
32
|
+
size?: BoxSizer;
|
|
33
|
+
/** For a shape that runs along a value: the axis it runs on, and where each row starts (its base) and ends (its tip). */
|
|
34
|
+
ends?: {
|
|
35
|
+
axis: 'x' | 'y';
|
|
36
|
+
from: (row: unknown) => unknown;
|
|
37
|
+
to: (row: unknown) => unknown;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export type BoxLabelMarker = {
|
|
41
|
+
marker: TextMarkerConfig;
|
|
42
|
+
box: BoxChannels | BoxSizer;
|
|
43
|
+
};
|
|
44
|
+
export type BoxedMarker = {
|
|
45
|
+
type?: string;
|
|
46
|
+
data?: unknown[];
|
|
47
|
+
x?: BoxEdge;
|
|
48
|
+
y?: BoxEdge;
|
|
49
|
+
x1?: BoxEdge;
|
|
50
|
+
x2?: BoxEdge;
|
|
51
|
+
y1?: BoxEdge;
|
|
52
|
+
y2?: BoxEdge;
|
|
53
|
+
isHorizontal?: boolean;
|
|
54
|
+
role?: string;
|
|
55
|
+
thickness?: number;
|
|
56
|
+
styles?: object;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TextMarkerConfig } from '../basic/text';
|
|
2
|
+
import type { BoxLabelConfig, BoxShape } from './box';
|
|
3
|
+
import type { PointLabelConfig, PointShape } from './point';
|
|
4
|
+
import type { PathLabelConfig, PathShape } from './path';
|
|
5
|
+
export type LabelLayout = 'box' | 'path' | 'point';
|
|
6
|
+
export type LabelBaseConfig = Omit<TextMarkerConfig, 'type' | 'data' | 'x' | 'y' | 'frameAnchor' | 'origin'>;
|
|
7
|
+
export type MarkerLabelConfig = BoxLabelConfig | PathLabelConfig<string, string> | PointLabelConfig;
|
|
8
|
+
export type MarkerLabels<TLabel extends MarkerLabelConfig = MarkerLabelConfig> = TLabel | TLabel[];
|
|
9
|
+
/** The layout a label takes by default, and the geometry the kind gives each layout it supports. */
|
|
10
|
+
export type MarkerLabelTraits = {
|
|
11
|
+
default: LabelLayout;
|
|
12
|
+
box?: BoxShape;
|
|
13
|
+
path?: PathShape;
|
|
14
|
+
point?: PointShape;
|
|
15
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { LabelAnchor } from '../../plots/constants';
|
|
2
|
+
import type { LabelBaseConfig } from './common';
|
|
3
|
+
/** An edge of a shape as it is drawn on the page. */
|
|
4
|
+
export type PageEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
5
|
+
/** An edge of a shape that runs along a value: the end away from zero, `'tip'`, or the one at zero, `'base'`. */
|
|
6
|
+
export type ValueEdge = 'tip' | 'base';
|
|
7
|
+
/** Where a label sits off a closed shape's edge: beyond it, against it within the shape, or centred on it. */
|
|
8
|
+
export type ShapeSide = 'outside' | 'inside' | 'on';
|
|
9
|
+
/** Where a label sits off an open stroke, as its text reads: above it, below it, or centred on it. */
|
|
10
|
+
export type StrokeSide = 'above' | 'below' | 'on';
|
|
11
|
+
/** A label written along an edge of its shape, read per row: a `'tip'` follows the sign of the row's value. */
|
|
12
|
+
export type PathLabelConfig<TEdge extends string = PageEdge | ValueEdge, TSide extends string = ShapeSide> = LabelBaseConfig & {
|
|
13
|
+
layout: 'path';
|
|
14
|
+
/** `'tip'` on a shape that runs along a value, else `'top'`. */
|
|
15
|
+
edge?: TEdge;
|
|
16
|
+
/** Defaults to `'outside'` on a shape, `'above'` on a stroke. */
|
|
17
|
+
side?: TSide;
|
|
18
|
+
/**
|
|
19
|
+
* Where along the edge, from its left or top end. On a line or an area, `'max'` and `'min'` are the point of each
|
|
20
|
+
* one with its highest or lowest value - its peak, its trough. Defaults to `'middle'`.
|
|
21
|
+
*/
|
|
22
|
+
offset?: 'start' | 'middle' | 'end' | 'max' | 'min' | `${number}%`;
|
|
23
|
+
/** Defaults to the configuration's `text.label.gap`. */
|
|
24
|
+
gap?: number;
|
|
25
|
+
};
|
|
26
|
+
/** A label written along each line a marker draws, curving with it. */
|
|
27
|
+
export type StrokeLabelConfig = Omit<PathLabelConfig<never, StrokeSide>, 'edge'>;
|
|
28
|
+
/** A label written along the top (`y2`) or bottom (`y1`) edge of each area, curving with it. */
|
|
29
|
+
export type AreaEdgeLabelConfig = PathLabelConfig<'top' | 'bottom', StrokeSide>;
|
|
30
|
+
/** A label written along the rim of each dot, from its left over its top. */
|
|
31
|
+
export type RimLabelConfig = Omit<PathLabelConfig<never, ShapeSide>, 'edge'>;
|
|
32
|
+
/**
|
|
33
|
+
* Where a kind writes `'path'` labels: `'box'` along the edges of each row's box, `'stroke'` along each line it
|
|
34
|
+
* draws, `'area'` along the top or bottom edge of each area, `'rim'` around each dot.
|
|
35
|
+
*/
|
|
36
|
+
export type PathShape = 'box' | 'stroke' | 'area' | 'rim';
|
|
37
|
+
/** Where a plot's value label goes on its shape: in its box at an `anchor`, or along one of its edges. */
|
|
38
|
+
export type ShapePlacement = {
|
|
39
|
+
anchor: LabelAnchor;
|
|
40
|
+
} | Required<Pick<PathLabelConfig, 'layout' | 'edge' | 'side'>>;
|
|
41
|
+
/** One label along a curve, in pixels: the path its text follows and where on it the text sits. */
|
|
42
|
+
export type CurvedLabel = {
|
|
43
|
+
d: string;
|
|
44
|
+
text: string;
|
|
45
|
+
/** A row it labels: the row of a dot, the first of a line. */
|
|
46
|
+
row: unknown;
|
|
47
|
+
startOffset: string;
|
|
48
|
+
textAnchor: 'start' | 'middle' | 'end';
|
|
49
|
+
dy: number;
|
|
50
|
+
baseline: 'auto' | 'hanging' | 'central';
|
|
51
|
+
fill?: string;
|
|
52
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|