@sophistry/charts 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +32 -2
- package/dist/3d/bar-chart3d.d.ts +55 -0
- package/dist/3d/definitions.d.ts +37 -0
- package/dist/3d/definitions.js +14 -0
- package/dist/3d/forward.d.ts +64 -0
- package/dist/3d/index.d.ts +30 -0
- package/dist/3d/index.js +1 -0
- package/dist/3d/quiver3d.d.ts +52 -0
- package/dist/3d/scatter3d.d.ts +44 -0
- package/dist/3d/stem3d.d.ts +45 -0
- package/dist/3d/surface-grid3d.d.ts +33 -0
- package/dist/3d/tri-surface3d.d.ts +45 -0
- package/dist/3d/voxels3d.d.ts +25 -0
- package/dist/3d/wireframe3d.d.ts +30 -0
- package/dist/band.d.ts +20 -0
- package/dist/bars/bar-chart.d.ts +143 -0
- package/dist/bars/bar-labels.d.ts +116 -0
- package/dist/bars/bars.d.ts +223 -0
- package/dist/bars/bullet.d.ts +157 -0
- package/dist/bars/candlestick.d.ts +97 -0
- package/dist/bars/funnel.d.ts +90 -0
- package/dist/bars/histogram.d.ts +108 -0
- package/dist/bars/index.d.ts +22 -0
- package/dist/bars/race.d.ts +28 -0
- package/dist/bars/rules.d.ts +121 -0
- package/dist/bars/shared.d.ts +41 -0
- package/dist/bars/transforms.d.ts +249 -0
- package/dist/bars/waterfall.d.ts +106 -0
- package/dist/batch.d.ts +142 -0
- package/dist/channels-_Xf-p6Lx.js +56 -0
- package/dist/chart.d.ts +87 -0
- package/dist/color-norm.d.ts +90 -0
- package/dist/context.d.ts +111 -0
- package/dist/curves/density.d.ts +125 -0
- package/dist/curves/ecdf.d.ts +72 -0
- package/dist/curves/fill-between.d.ts +100 -0
- package/dist/curves/index.d.ts +15 -0
- package/dist/curves/line-plot.d.ts +104 -0
- package/dist/curves/regression.d.ts +124 -0
- package/dist/curves/shared.d.ts +52 -0
- package/dist/curves/stack-plot.d.ts +140 -0
- package/dist/curves/stairs.d.ts +170 -0
- package/dist/data/channels.d.ts +170 -0
- package/dist/end-space.d.ts +81 -0
- package/dist/entries/definitions.d.ts +20 -0
- package/dist/entries/definitions.js +6 -0
- package/dist/frame/band-axis.d.ts +42 -0
- package/dist/frame/coords.d.ts +111 -0
- package/dist/frame/fit.d.ts +170 -0
- package/dist/frame/format.d.ts +40 -0
- package/dist/frame/guide-metrics.d.ts +36 -0
- package/dist/frame/guides.d.ts +67 -0
- package/dist/frame/keys.d.ts +96 -0
- package/dist/frame/layout.d.ts +145 -0
- package/dist/frame/registry.d.ts +31 -0
- package/dist/frame/reports.d.ts +53 -0
- package/dist/frame/secondary-axes.d.ts +73 -0
- package/dist/frame/secondary.d.ts +56 -0
- package/dist/frame/tooltip-overlay.d.ts +64 -0
- package/dist/frame/types.d.ts +658 -0
- package/dist/grids/barbs.d.ts +51 -0
- package/dist/grids/cell-rects.d.ts +37 -0
- package/dist/grids/cells.d.ts +130 -0
- package/dist/grids/contour-f.d.ts +80 -0
- package/dist/grids/contour-shared.d.ts +53 -0
- package/dist/grids/contour.d.ts +84 -0
- package/dist/grids/dendrogram.d.ts +104 -0
- package/dist/grids/heatmap.d.ts +163 -0
- package/dist/grids/hex-bin.d.ts +93 -0
- package/dist/grids/hist2d.d.ts +107 -0
- package/dist/grids/imshow.d.ts +84 -0
- package/dist/grids/index.d.ts +26 -0
- package/dist/grids/pcolormesh.d.ts +90 -0
- package/dist/grids/ramp-cells.d.ts +66 -0
- package/dist/grids/tri-contour.d.ts +120 -0
- package/dist/grids/tri-shared.d.ts +61 -0
- package/dist/grids/tripcolor.d.ts +73 -0
- package/dist/guides/colorbar.d.ts +110 -0
- package/dist/guides/index.d.ts +11 -0
- package/dist/guides/legend.d.ts +118 -0
- package/dist/guides/nodes.d.ts +13 -0
- package/dist/guides/size-legend.d.ts +233 -0
- package/dist/hierarchy/breadcrumbs.d.ts +133 -0
- package/dist/hierarchy/circle-pack.d.ts +72 -0
- package/dist/hierarchy/drill.d.ts +245 -0
- package/dist/hierarchy/frame.d.ts +67 -0
- package/dist/hierarchy/icicle.d.ts +76 -0
- package/dist/hierarchy/index.d.ts +20 -0
- package/dist/hierarchy/labels.d.ts +24 -0
- package/dist/hierarchy/mosaic.d.ts +130 -0
- package/dist/hierarchy/own-tooltip.d.ts +12 -0
- package/dist/hierarchy/props.d.ts +13 -0
- package/dist/hierarchy/sankey.d.ts +132 -0
- package/dist/hierarchy/shared.d.ts +247 -0
- package/dist/hierarchy/sunburst.d.ts +74 -0
- package/dist/hierarchy/tree.d.ts +124 -0
- package/dist/hierarchy/treemap.d.ts +76 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +5 -0
- package/dist/item-tooltip.d.ts +33 -0
- package/dist/join.d.ts +223 -0
- package/dist/math/3d/bar3d.d.ts +27 -0
- package/dist/math/3d/quiver3d.d.ts +26 -0
- package/dist/math/3d/scatter3d.d.ts +15 -0
- package/dist/math/3d/stem3d.d.ts +22 -0
- package/dist/math/3d/surfaceGrid3d.d.ts +33 -0
- package/dist/math/3d/trisurface.d.ts +11 -0
- package/dist/math/3d/voxels.d.ts +17 -0
- package/dist/math/aggregate.d.ts +68 -0
- package/dist/math/bar.d.ts +31 -0
- package/dist/math/barLabels.d.ts +83 -0
- package/dist/math/barbs.d.ts +36 -0
- package/dist/math/boxplot.d.ts +36 -0
- package/dist/math/breadcrumbs.d.ts +128 -0
- package/dist/math/bubble.d.ts +38 -0
- package/dist/math/bullet.d.ts +110 -0
- package/dist/math/chord.d.ts +103 -0
- package/dist/math/cluster.d.ts +88 -0
- package/dist/math/contour.d.ts +48 -0
- package/dist/math/contourf.d.ts +50 -0
- package/dist/math/dodge.d.ts +36 -0
- package/dist/math/ecdf.d.ts +41 -0
- package/dist/math/errorbar.d.ts +27 -0
- package/dist/math/eventplot.d.ts +26 -0
- package/dist/math/facet.d.ts +90 -0
- package/dist/math/fillBetween.d.ts +28 -0
- package/dist/math/gauge.d.ts +71 -0
- package/dist/math/hexbin.d.ts +20 -0
- package/dist/math/hierarchy.d.ts +179 -0
- package/dist/math/hierarchyJoin.d.ts +59 -0
- package/dist/math/histogram.d.ts +36 -0
- package/dist/math/histogram2d.d.ts +44 -0
- package/dist/math/imshow.d.ts +26 -0
- package/dist/math/index.d.ts +139 -0
- package/dist/math/index.js +3 -0
- package/dist/math/jitter.d.ts +16 -0
- package/dist/math/join.d.ts +135 -0
- package/dist/math/keyframes.d.ts +127 -0
- package/dist/math/legend.d.ts +120 -0
- package/dist/math/line.d.ts +53 -0
- package/dist/math/morph.d.ts +81 -0
- package/dist/math/mosaic.d.ts +119 -0
- package/dist/math/ordinal.d.ts +79 -0
- package/dist/math/parallel.d.ts +38 -0
- package/dist/math/pcolormesh.d.ts +22 -0
- package/dist/math/pie.d.ts +105 -0
- package/dist/math/polarArea.d.ts +34 -0
- package/dist/math/radar.d.ts +110 -0
- package/dist/math/range.d.ts +98 -0
- package/dist/math/regression.d.ts +109 -0
- package/dist/math/reveal.d.ts +63 -0
- package/dist/math/sankey.d.ts +154 -0
- package/dist/math/scatter.d.ts +14 -0
- package/dist/math/shared/binning.d.ts +23 -0
- package/dist/math/shared/gridCells.d.ts +41 -0
- package/dist/math/shared/gridExtent.d.ts +5 -0
- package/dist/math/shared/pairs.d.ts +2 -0
- package/dist/math/shared/polar.d.ts +23 -0
- package/dist/math/stack.d.ts +69 -0
- package/dist/math/stackplot.d.ts +35 -0
- package/dist/math/stairs.d.ts +17 -0
- package/dist/math/stem.d.ts +21 -0
- package/dist/math/symbol.d.ts +25 -0
- package/dist/math/tree.d.ts +117 -0
- package/dist/math/tricontour.d.ts +76 -0
- package/dist/math/violin.d.ts +99 -0
- package/dist/math/waffle.d.ts +48 -0
- package/dist/math/waterfall.d.ts +28 -0
- package/dist/math-CSHNpGej.js +3648 -0
- package/dist/mix.d.ts +24 -0
- package/dist/multiview/brush.d.ts +165 -0
- package/dist/multiview/chart-group.d.ts +265 -0
- package/dist/multiview/chart-link.d.ts +188 -0
- package/dist/multiview/chart-zoom.d.ts +144 -0
- package/dist/multiview/facet.d.ts +238 -0
- package/dist/multiview/group-guides.d.ts +99 -0
- package/dist/multiview/index.d.ts +17 -0
- package/dist/multiview/joint-plot.d.ts +114 -0
- package/dist/multiview/pair-plot.d.ts +153 -0
- package/dist/multiview/panels.d.ts +22 -0
- package/dist/multiview/parallel-coordinates.d.ts +109 -0
- package/dist/points/event-plot.d.ts +67 -0
- package/dist/points/index.d.ts +19 -0
- package/dist/points/labels.d.ts +70 -0
- package/dist/points/links.d.ts +123 -0
- package/dist/points/rects.d.ts +80 -0
- package/dist/points/rug.d.ts +72 -0
- package/dist/points/scatter.d.ts +169 -0
- package/dist/points/segment-marks.d.ts +39 -0
- package/dist/points/shared.d.ts +34 -0
- package/dist/points/stem.d.ts +75 -0
- package/dist/points/strip.d.ts +145 -0
- package/dist/points/symbol-marker.d.ts +33 -0
- package/dist/points/ticks.d.ts +102 -0
- package/dist/props.d.ts +126 -0
- package/dist/radial/chord.d.ts +148 -0
- package/dist/radial/gauge.d.ts +126 -0
- package/dist/radial/index.d.ts +15 -0
- package/dist/radial/pie-chart.d.ts +143 -0
- package/dist/radial/polar-area-chart.d.ts +135 -0
- package/dist/radial/radar-chart.d.ts +176 -0
- package/dist/radial/radial-bar-chart.d.ts +116 -0
- package/dist/radial/shared.d.ts +78 -0
- package/dist/radial/waffle.d.ts +130 -0
- package/dist/raster.d.ts +43 -0
- package/dist/series.d.ts +71 -0
- package/dist/src-CwGo1bes.js +19221 -0
- package/dist/stagger.d.ts +54 -0
- package/dist/statistics/box-plot.d.ts +151 -0
- package/dist/statistics/error-bar.d.ts +148 -0
- package/dist/statistics/groups.d.ts +140 -0
- package/dist/statistics/index.d.ts +7 -0
- package/dist/statistics/violin-plot.d.ts +143 -0
- package/dist/text-width.d.ts +9 -0
- package/dist/tooltip.d.ts +276 -0
- package/dist/util.d.ts +33 -0
- package/dist/voxels-9lJ2TZS4.js +235 -0
- package/dist/wireframe3d-D157GZAq.js +345 -0
- package/package.json +86 -3
package/dist/join.d.ts
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyed data transitions (`to` + `blend`) shared by chart marks: the join
|
|
3
|
+
* between the two datasets' keys and each stage's progress. A key in both
|
|
4
|
+
* ends updates (interpolates in data space), one only in `to` enters at its
|
|
5
|
+
* new place, one only in `data` exits at its old place. Stages come from the
|
|
6
|
+
* enclosing chart, or from the join alone outside one.
|
|
7
|
+
*
|
|
8
|
+
* Each is a factory called once in
|
|
9
|
+
* a composite's `setup` that returns a function to call in every `update`.
|
|
10
|
+
* The factory keeps last-input caches (keys compared by value), so a frame
|
|
11
|
+
* of a blend recomputes the stage progress and nothing else. Internal.
|
|
12
|
+
*/
|
|
13
|
+
import type { BandKey, Point } from "@sophistry/core/geometry";
|
|
14
|
+
import type { Channel, DateSink } from "./data/channels.js";
|
|
15
|
+
import type { AxisExtent, ColorExtent, LayerTransition } from "./frame/types.js";
|
|
16
|
+
import type { JoinStages, JoinStaging, KeyedJoin } from "./math/join.js";
|
|
17
|
+
import type { Category, GroupKey } from "./series.js";
|
|
18
|
+
/** One update's view of a keyed join. See {@link createJoin}. */
|
|
19
|
+
export interface JoinState {
|
|
20
|
+
/** True while a transition is requested (`to` given). */
|
|
21
|
+
active: boolean;
|
|
22
|
+
/** Every key to keep an item for: the union while active, else `data`'s keys. */
|
|
23
|
+
keys: readonly BandKey[];
|
|
24
|
+
/** The join, while active. */
|
|
25
|
+
join: KeyedJoin | undefined;
|
|
26
|
+
/** Where each key sits in `data`'s keys. */
|
|
27
|
+
fromSlots: Map<BandKey, number>;
|
|
28
|
+
/** Where each key sits in `to`'s keys, while active. */
|
|
29
|
+
toSlots: Map<BandKey, number> | undefined;
|
|
30
|
+
/** The blend, clamped (0 when inactive). */
|
|
31
|
+
t: number;
|
|
32
|
+
/** The stages in use, while active. */
|
|
33
|
+
stages: JoinStages | undefined;
|
|
34
|
+
/** Progress of the update stage, 0..1 (0 when inactive). */
|
|
35
|
+
update: number;
|
|
36
|
+
/** Progress of the enter stage, 0..1 (0 when inactive). */
|
|
37
|
+
enter: number;
|
|
38
|
+
/** One entering key's progress through the enter stage: its own sub-window under `enterStagger`, else `enter`. */
|
|
39
|
+
enterOf(key: BandKey): number;
|
|
40
|
+
/** Progress of the exit stage, 0..1 (0 when inactive). */
|
|
41
|
+
exit: number;
|
|
42
|
+
/** Whether anything enters or exits, including the mark's own `more` (false when inactive). */
|
|
43
|
+
flags: {
|
|
44
|
+
enters: boolean;
|
|
45
|
+
exits: boolean;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/** What {@link createJoin}'s function takes on each update. */
|
|
49
|
+
export interface JoinSpec {
|
|
50
|
+
fromKeys: readonly BandKey[];
|
|
51
|
+
/** `to`'s keys, or undefined without a transition. */
|
|
52
|
+
toKeys: readonly BandKey[] | undefined;
|
|
53
|
+
blend: number | undefined;
|
|
54
|
+
staging: JoinStaging | undefined;
|
|
55
|
+
/** The enclosing chart's stages (`frame.join`), which win over the join's own. */
|
|
56
|
+
chartStages?: JoinStages | undefined;
|
|
57
|
+
/** Enters and exits beyond the keys (a radar's axes), so the stages make room. */
|
|
58
|
+
more?: {
|
|
59
|
+
enters?: boolean;
|
|
60
|
+
exits?: boolean;
|
|
61
|
+
} | undefined;
|
|
62
|
+
/** Fraction of the enter stage spent staggering entering keys, 0..0.95. */
|
|
63
|
+
enterStagger?: number | undefined;
|
|
64
|
+
/** Each entering key's stagger rank; defaults to `to`'s order. */
|
|
65
|
+
enterRanks?: (entering: readonly BandKey[], join: KeyedJoin) => readonly number[];
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Makes a keyed join for one mark. Call once, in `setup`; call the result
|
|
69
|
+
* in every `update` with that update's keys and blend.
|
|
70
|
+
*
|
|
71
|
+
* @returns `(spec) => JoinState`, caching the join while the keys are equal
|
|
72
|
+
* by value.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createJoin(): (spec: JoinSpec) => JoinState;
|
|
75
|
+
/** Which end of a transition a key's datum is read from. */
|
|
76
|
+
export type JoinEnd = "from" | "to";
|
|
77
|
+
/** What one key is on one frame of a keyed transition. See {@link joinFrame}. */
|
|
78
|
+
export interface JoinFrame<S> {
|
|
79
|
+
/** Its state: `data`'s, `to`'s, or the two blended by the update stage. */
|
|
80
|
+
state: S;
|
|
81
|
+
/** 0..1 presence: `1 − exit` while leaving, `enter` while arriving, else 1. */
|
|
82
|
+
presence: number;
|
|
83
|
+
/** The end its datum is read from: the nearer one while it updates. */
|
|
84
|
+
end: JoinEnd;
|
|
85
|
+
/** That datum's index in its end's data. */
|
|
86
|
+
index: number;
|
|
87
|
+
/**
|
|
88
|
+
* While an axis changes kind, for a key in both ends mid-update: each end's
|
|
89
|
+
* own state and the update progress, so the mark can blend them in scene
|
|
90
|
+
* units; `state` is then only the data-unit blend.
|
|
91
|
+
*/
|
|
92
|
+
pair?: {
|
|
93
|
+
a: S;
|
|
94
|
+
b: S;
|
|
95
|
+
u: number;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* One key's frame: in both ends it blends from `a` to `b` on the update
|
|
100
|
+
* stage; only in `data` it stays at `a` as presence falls; only in `to` it
|
|
101
|
+
* stands at `b` as presence rises. Marks spend `presence` like their reveal
|
|
102
|
+
* spends `progress`, so exit is the reveal reversed.
|
|
103
|
+
*
|
|
104
|
+
* @param blend - Blends two states at update progress `u`.
|
|
105
|
+
* @param key - The key, so an entering one reads its staggered enter.
|
|
106
|
+
* @param pair - Keep both ends' states mid-swap: pass `space.swapping`.
|
|
107
|
+
* @returns The frame, or undefined when neither end has the key.
|
|
108
|
+
*/
|
|
109
|
+
export declare function joinFrame<S>(join: JoinState, a: {
|
|
110
|
+
state: S;
|
|
111
|
+
index: number;
|
|
112
|
+
} | undefined, b: {
|
|
113
|
+
state: S;
|
|
114
|
+
index: number;
|
|
115
|
+
} | undefined, blend: (a: S, b: S, u: number) => S, key?: BandKey, pair?: boolean): JoinFrame<S> | undefined;
|
|
116
|
+
/** One update's keyed data: the join, plus where each key's datum is at each end. */
|
|
117
|
+
export interface KeyedData extends JoinState {
|
|
118
|
+
/** Each `to` datum's category, with a `series` and a transition. */
|
|
119
|
+
toOf: Category[] | undefined;
|
|
120
|
+
/** A key's datum index in `data`, or -1 (entering). */
|
|
121
|
+
fromIndex(key: BandKey): number;
|
|
122
|
+
/** A key's datum index in `to`, or -1 (leaving, or no transition). */
|
|
123
|
+
toIndex(key: BandKey): number;
|
|
124
|
+
}
|
|
125
|
+
/** What {@link createKeyedData}'s function takes on each update. */
|
|
126
|
+
export interface KeyedDataSpec<T> {
|
|
127
|
+
data: readonly T[];
|
|
128
|
+
to: readonly T[] | undefined;
|
|
129
|
+
key: Channel<T, BandKey> | undefined;
|
|
130
|
+
series: Channel<T, BandKey> | undefined;
|
|
131
|
+
/** `data`'s categories (the `series` channel read across it), if any. */
|
|
132
|
+
of: readonly Category[] | undefined;
|
|
133
|
+
/** The indices a dataset draws, in draw order; defaults to all. */
|
|
134
|
+
drawn?: (data: readonly T[]) => readonly number[];
|
|
135
|
+
blend: number | undefined;
|
|
136
|
+
staging: JoinStaging | undefined;
|
|
137
|
+
chartStages?: JoinStages | undefined;
|
|
138
|
+
more?: {
|
|
139
|
+
enters?: boolean;
|
|
140
|
+
exits?: boolean;
|
|
141
|
+
} | undefined;
|
|
142
|
+
enterStagger?: number | undefined;
|
|
143
|
+
/** As {@link JoinSpec.enterRanks}, also given each entering key's index in `to`. */
|
|
144
|
+
enterRanks?: (entering: readonly BandKey[], join: KeyedJoin, toIndex: (key: BandKey) => number) => readonly number[];
|
|
145
|
+
/** The chart's date sink, for channels reading dates. */
|
|
146
|
+
dates?: DateSink | null;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The keyed join of a per-datum mark (dots, stems, error bars, ticks): each
|
|
150
|
+
* end's keys (the `key` channel, else place within series, else index),
|
|
151
|
+
* restricted to what the mark draws. Call once, in `setup`; call the result
|
|
152
|
+
* in each `update`, draw its `keys` and read each key's frame with
|
|
153
|
+
* {@link joinFrame} (or all of them with {@link joinFrames}).
|
|
154
|
+
*/
|
|
155
|
+
export declare function createKeyedData<T>(): (spec: KeyedDataSpec<T>) => KeyedData;
|
|
156
|
+
/**
|
|
157
|
+
* Every key's {@link joinFrame} for a per-datum mark, in key order.
|
|
158
|
+
* `stateOf(end, index)` reads one end's datum, or undefined where it draws
|
|
159
|
+
* nothing.
|
|
160
|
+
*
|
|
161
|
+
* @param pair - Mid-swap, keep both ends' states (`space.swapping`).
|
|
162
|
+
*/
|
|
163
|
+
export declare function joinFrames<S>(keyed: KeyedData, stateOf: (end: JoinEnd, index: number) => S | undefined, blend: (a: S, b: S, u: number) => S, pair?: boolean): Map<BandKey, JoinFrame<S>>;
|
|
164
|
+
/** Each key's place in a per-datum mark's reveal order: `data`'s keys, then those only in `to`. */
|
|
165
|
+
export declare function keyRanks(keys: readonly BandKey[]): Map<BandKey, number>;
|
|
166
|
+
/**
|
|
167
|
+
* A layer's `transition` report: the far end's extents, the blend and what
|
|
168
|
+
* the join contains. Undefined without a transition.
|
|
169
|
+
*
|
|
170
|
+
* @param far - The `to` data's extents (omit axes the layer doesn't report),
|
|
171
|
+
* and `enters` / `exits` when the layer decides them rather than the join.
|
|
172
|
+
*/
|
|
173
|
+
export declare function layerTransition(join: JoinState, staging: JoinStaging | undefined, far: {
|
|
174
|
+
x?: AxisExtent;
|
|
175
|
+
y?: AxisExtent;
|
|
176
|
+
enters?: boolean;
|
|
177
|
+
exits?: boolean;
|
|
178
|
+
}): LayerTransition | undefined;
|
|
179
|
+
/**
|
|
180
|
+
* A layer's `color` report across a keyed transition: both ends' categories,
|
|
181
|
+
* `data`'s first (so colours hold still), with each end's as `ends` (so the
|
|
182
|
+
* legend fades entries). Otherwise the report as given.
|
|
183
|
+
*/
|
|
184
|
+
export declare function transitionColor(own: ColorExtent | undefined, toCategories: readonly Category[] | undefined): ColorExtent | undefined;
|
|
185
|
+
/** The keyed join of a grouped mark (one shape per `series` category, or one {@link WHOLE} shape). */
|
|
186
|
+
export interface GroupJoin extends JoinState {
|
|
187
|
+
/** Every group to draw: both ends' while a transition runs (`data`'s first), else `data`'s. */
|
|
188
|
+
groups: readonly GroupKey[];
|
|
189
|
+
/** The categories `to` draws (its groups, less {@link WHOLE}), while a transition runs. */
|
|
190
|
+
toCategories: readonly BandKey[] | undefined;
|
|
191
|
+
/** Whether a group is only in `to`: it enters, on the enter stage. */
|
|
192
|
+
entering(key: GroupKey): boolean;
|
|
193
|
+
/** A group's fade: `1 − exit` for one only `data` has (it leaves), else 1. */
|
|
194
|
+
fade(key: GroupKey): number;
|
|
195
|
+
}
|
|
196
|
+
/** What {@link createGroupJoin}'s function takes on each update. */
|
|
197
|
+
export interface GroupJoinSpec {
|
|
198
|
+
fromGroups: readonly GroupKey[];
|
|
199
|
+
toGroups: readonly GroupKey[] | undefined;
|
|
200
|
+
blend: number | undefined;
|
|
201
|
+
staging: JoinStaging | undefined;
|
|
202
|
+
chartStages?: JoinStages | undefined;
|
|
203
|
+
enterStagger?: number | undefined;
|
|
204
|
+
enterRanks?: (entering: readonly BandKey[], join: KeyedJoin) => readonly number[];
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* The keyed join of a grouped mark: groups matched by category. A group in
|
|
208
|
+
* both ends morphs on the update stage, one only in `to` enters, one only
|
|
209
|
+
* in `data` exits. Without `to`, `groups` is `data`'s and every stage reads
|
|
210
|
+
* 0. Call once, in `setup`.
|
|
211
|
+
*/
|
|
212
|
+
export declare function createGroupJoin(): (spec: GroupJoinSpec) => GroupJoin;
|
|
213
|
+
/**
|
|
214
|
+
* An entering shape swept in along x (along y when `vertical`): its lines
|
|
215
|
+
* and rings cut at the front `enter` of the way across their extent.
|
|
216
|
+
*/
|
|
217
|
+
export declare function sweepIn(shape: {
|
|
218
|
+
lines: readonly (readonly Point[])[];
|
|
219
|
+
rings: readonly (readonly Point[])[];
|
|
220
|
+
}, enter: number, vertical?: boolean): {
|
|
221
|
+
lines: Point[][];
|
|
222
|
+
rings: Point[][];
|
|
223
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3D bar geometry: one box per index, anchored at `(x, y, z)` (not centred)
|
|
3
|
+
* and extended by `(width, height, depth)`. Each extent is a number for
|
|
4
|
+
* every bar or one per bar; arrays pair by index up to the shortest.
|
|
5
|
+
*/
|
|
6
|
+
/** @category Math */
|
|
7
|
+
export interface BarSlotBox3D {
|
|
8
|
+
/** Index into the input arrays, keeping a `colors` array aligned past dropped entries. */
|
|
9
|
+
index: number;
|
|
10
|
+
x0: number;
|
|
11
|
+
x1: number;
|
|
12
|
+
y0: number;
|
|
13
|
+
y1: number;
|
|
14
|
+
z0: number;
|
|
15
|
+
z1: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* One box per index: anchored at `(xs[i], ys[i], zs[i])` and extended by
|
|
19
|
+
* that index's `(width, height, depth)`. Negative extents still give a
|
|
20
|
+
* well-formed box; non-finite components drop the entry.
|
|
21
|
+
*
|
|
22
|
+
* @param widths - Extent along x: one number for every bar, or one per bar.
|
|
23
|
+
* @param heights - Extent along y: one number for every bar, or one per bar.
|
|
24
|
+
* @param depths - Extent along z: one number for every bar, or one per bar.
|
|
25
|
+
* @category Math & helpers
|
|
26
|
+
*/
|
|
27
|
+
export declare function bar3dSlots(xs: readonly number[], ys: readonly number[], zs: readonly number[], widths: number | readonly number[], heights: number | readonly number[], depths: number | readonly number[]): BarSlotBox3D[];
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 3D vector field geometry: one arrow per index, tail at `(x, y, z)`,
|
|
3
|
+
* direction and length `(u, v, w) * scale` (not normalised; pre-normalise
|
|
4
|
+
* the components for equal lengths).
|
|
5
|
+
*/
|
|
6
|
+
import type { Point3 } from "@sophistry/core/internal";
|
|
7
|
+
/** @category Math */
|
|
8
|
+
export interface QuiverVector3 {
|
|
9
|
+
/** Index into the input arrays, keeping a `colors` array aligned past dropped entries. */
|
|
10
|
+
index: number;
|
|
11
|
+
origin: Point3;
|
|
12
|
+
vector: Point3;
|
|
13
|
+
}
|
|
14
|
+
/** @category Math */
|
|
15
|
+
export interface QuiverOptions {
|
|
16
|
+
/** Multiplies `(u, v, w)` before it becomes the drawn vector. @default 1 */
|
|
17
|
+
scale?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* One vector per finite `(x, y, z, u, v, w)`, keeping its index; the six
|
|
21
|
+
* arrays pair by index.
|
|
22
|
+
*
|
|
23
|
+
* @param us - Vector x component, in data units (before `scale`).
|
|
24
|
+
* @category Math & helpers
|
|
25
|
+
*/
|
|
26
|
+
export declare function quiverVectors(xs: readonly number[], ys: readonly number[], zs: readonly number[], us: readonly number[], vs: readonly number[], ws: readonly number[], options?: QuiverOptions): QuiverVector3[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** 3D scatter geometry: one marker per finite `(x, y, z)` triple. */
|
|
2
|
+
/** @category Math */
|
|
3
|
+
export interface ScatterPoint3 {
|
|
4
|
+
/** Index into the input arrays, keeping `sizes`/`colors` aligned past dropped triples. */
|
|
5
|
+
index: number;
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
z: number;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The finite `(x, y, z)` triples, paired by index, each keeping its index.
|
|
12
|
+
*
|
|
13
|
+
* @category Math & helpers
|
|
14
|
+
*/
|
|
15
|
+
export declare function scatterPoints3(xs: readonly number[], ys: readonly number[], zs: readonly number[]): ScatterPoint3[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** 3D stem geometry: a drop line along world y (up) from `baseline`, and a marker, per finite `(x, y, z)`. */
|
|
2
|
+
import type { Point3 } from "@sophistry/core/internal";
|
|
3
|
+
/** @category Math */
|
|
4
|
+
export interface StemPoint3 {
|
|
5
|
+
/** Index into the input arrays, keeping a `colors` array aligned past dropped triples. */
|
|
6
|
+
index: number;
|
|
7
|
+
/** `(x, baseline, z) → (x, y, z)`, in data coordinates. */
|
|
8
|
+
drop: [Point3, Point3];
|
|
9
|
+
marker: Point3;
|
|
10
|
+
}
|
|
11
|
+
/** @category Math */
|
|
12
|
+
export interface Stem3DOptions {
|
|
13
|
+
/** The y (height) value each drop line starts from. @default 0 */
|
|
14
|
+
baseline?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One drop line and marker per finite `(x, y, z)`, paired by index.
|
|
18
|
+
*
|
|
19
|
+
* @param ys - Heights; the drop runs along this axis.
|
|
20
|
+
* @category Math & helpers
|
|
21
|
+
*/
|
|
22
|
+
export declare function stemPoints3(xs: readonly number[], ys: readonly number[], zs: readonly number[], options?: Stem3DOptions): StemPoint3[];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured-grid surfaces: `X`, `Y`, `Z` are three `nrows x ncols` arrays of
|
|
3
|
+
* world coordinates for one grid of points, computed by the caller. Quads
|
|
4
|
+
* are wound so `MeshFaces` sees them facing outward. Mismatched grid
|
|
5
|
+
* shapes throw.
|
|
6
|
+
*/
|
|
7
|
+
import type { Point3 } from "@sophistry/core/internal";
|
|
8
|
+
/** @category Math */
|
|
9
|
+
export interface SurfaceGridFace {
|
|
10
|
+
points: Point3[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A rectangular grid of numbers (rows of columns).
|
|
14
|
+
*
|
|
15
|
+
* @category Math & helpers
|
|
16
|
+
*/
|
|
17
|
+
export type SurfaceGrid = readonly (readonly number[])[];
|
|
18
|
+
/**
|
|
19
|
+
* One outward-wound quad per grid cell, `(nrows - 1) * (ncols - 1)` total.
|
|
20
|
+
*
|
|
21
|
+
* @param X - World x of each grid point, `X[row][col]`.
|
|
22
|
+
* @throws If the three grids differ in row count or any row's length.
|
|
23
|
+
* @category Math & helpers
|
|
24
|
+
*/
|
|
25
|
+
export declare function surfaceGridFaces(X: SurfaceGrid, Y: SurfaceGrid, Z: SurfaceGrid): SurfaceGridFace[];
|
|
26
|
+
/**
|
|
27
|
+
* One polyline per grid row plus one per column: the wireframe.
|
|
28
|
+
*
|
|
29
|
+
* @param X - World x of each grid point, `X[row][col]`.
|
|
30
|
+
* @throws If the three grids differ in row count or any row's length.
|
|
31
|
+
* @category Math & helpers
|
|
32
|
+
*/
|
|
33
|
+
export declare function surfaceGridWireframe(X: SurfaceGrid, Y: SurfaceGrid, Z: SurfaceGrid): Point3[][];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Triangulated surface faces: the xy-plane Delaunay triangulation, lifted to each point's `z`. */
|
|
2
|
+
import type { Point3 } from "@sophistry/core/internal";
|
|
3
|
+
/**
|
|
4
|
+
* The xy-plane Delaunay triangles, each as 3 world points with `zs` as height.
|
|
5
|
+
*
|
|
6
|
+
* @param zs - Heights per point; triangles with a non-finite height are skipped.
|
|
7
|
+
* @category Math & helpers
|
|
8
|
+
*/
|
|
9
|
+
export declare function trisurfaceFaces(xs: readonly number[], ys: readonly number[], zs: readonly number[]): {
|
|
10
|
+
points: Point3[];
|
|
11
|
+
}[];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Boolean voxel grid geometry: each `true` `filled[i][j][k]` occupies the unit
|
|
3
|
+
* cube `[i, i+1] x [j, j+1] x [k, k+1]`; ragged or missing entries are empty.
|
|
4
|
+
* Only exposed faces are emitted (faces between two filled voxels are
|
|
5
|
+
* culled), wound counter-clockwise from outside.
|
|
6
|
+
*/
|
|
7
|
+
import type { Point3 } from "@sophistry/core/internal";
|
|
8
|
+
/** @category Math */
|
|
9
|
+
export interface VoxelFace {
|
|
10
|
+
points: Point3[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One quad per exposed face of every filled voxel.
|
|
14
|
+
*
|
|
15
|
+
* @category Math & helpers
|
|
16
|
+
*/
|
|
17
|
+
export declare function voxelFaces(filled: readonly (readonly (readonly boolean[])[])[]): VoxelFace[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reducers and per-series maps: the arithmetic behind the `group`, `bin`,
|
|
3
|
+
* `rolling` and `normalize` transforms. Arrays of numbers in, numbers out.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* How a set of values becomes one number. Every reducer but `"count"` (which
|
|
7
|
+
* counts rows) drops non-finite values first. An empty set reduces to `NaN`
|
|
8
|
+
* (0 for `"count"` and `"sum"`).
|
|
9
|
+
*
|
|
10
|
+
* @category Math & helpers
|
|
11
|
+
*/
|
|
12
|
+
export type ReducerName = "count" | "sum" | "mean" | "median" | "min" | "max" | "first" | "last" | "deviation" | "variance";
|
|
13
|
+
/**
|
|
14
|
+
* A named reducer, or your own function of the values.
|
|
15
|
+
*
|
|
16
|
+
* @category Math & helpers
|
|
17
|
+
*/
|
|
18
|
+
export type Reducer = ReducerName | ((values: number[]) => number);
|
|
19
|
+
/**
|
|
20
|
+
* Reduces `values` to one number; see {@link ReducerName}.
|
|
21
|
+
*
|
|
22
|
+
* @category Math & helpers
|
|
23
|
+
*/
|
|
24
|
+
export declare function reduceValues(values: readonly number[], reducer: Reducer): number;
|
|
25
|
+
/** @category Math */
|
|
26
|
+
export interface RollingOptions {
|
|
27
|
+
/** Window size, in values. @default 3 */
|
|
28
|
+
k?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Where each value sits in its window: `"middle"` (centred), `"start"`
|
|
31
|
+
* (looking ahead) or `"end"` (trailing).
|
|
32
|
+
* @default "middle"
|
|
33
|
+
*/
|
|
34
|
+
anchor?: "start" | "middle" | "end";
|
|
35
|
+
/** @default "mean" */
|
|
36
|
+
reduce?: Reducer;
|
|
37
|
+
/**
|
|
38
|
+
* Only reduce full windows of finite values (elsewhere `NaN`). Off, windows
|
|
39
|
+
* cut short or holding non-finite values reduce what they have.
|
|
40
|
+
* @default false
|
|
41
|
+
*/
|
|
42
|
+
strict?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A moving-window reduction of `values`, a rolling mean by default.
|
|
46
|
+
*
|
|
47
|
+
* @returns One value per input value.
|
|
48
|
+
* @category Math & helpers
|
|
49
|
+
*/
|
|
50
|
+
export declare function rollingValues(values: readonly number[], options?: RollingOptions): number[];
|
|
51
|
+
/**
|
|
52
|
+
* What {@link normalizeValues} divides by: `"first"` (growth from the first
|
|
53
|
+
* value), `"last"`, `"sum"`, `"mean"`, `"median"`, `"min"` or `"max"`;
|
|
54
|
+
* `"extent"` rescales min..max to 0..1; `"deviation"` gives z-scores; a
|
|
55
|
+
* number divides by itself.
|
|
56
|
+
*
|
|
57
|
+
* @category Math & helpers
|
|
58
|
+
*/
|
|
59
|
+
export type NormalizeBasis = "first" | "last" | "sum" | "mean" | "median" | "min" | "max" | "extent" | "deviation" | number;
|
|
60
|
+
/**
|
|
61
|
+
* Normalizes a series against a basis. Non-finite values, and every value
|
|
62
|
+
* under a zero or non-finite basis, become `NaN`.
|
|
63
|
+
*
|
|
64
|
+
* @param basis - Defaults to `"first"`.
|
|
65
|
+
* @returns One value per input value.
|
|
66
|
+
* @category Math & helpers
|
|
67
|
+
*/
|
|
68
|
+
export declare function normalizeValues(values: readonly number[], basis?: NormalizeBasis): number[];
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A bar's box in data space: slot `index` occupies `[index, index + 1]`, the
|
|
3
|
+
* bar `barWidth` of it, centred.
|
|
4
|
+
*
|
|
5
|
+
* @category Math & helpers
|
|
6
|
+
*/
|
|
7
|
+
export interface BarSlotBox {
|
|
8
|
+
/** The bar's x extent (not the whole slot): `barWidth` wide, centred on the slot. */
|
|
9
|
+
x0: number;
|
|
10
|
+
x1: number;
|
|
11
|
+
/** The bar's y extent, sorted from `baseline` and `value`, so a negative value hangs below the baseline. */
|
|
12
|
+
y0: number;
|
|
13
|
+
y1: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bar width as a fraction of the slot.
|
|
17
|
+
*
|
|
18
|
+
* @category Math & helpers
|
|
19
|
+
*/
|
|
20
|
+
export declare const DEFAULT_BAR_WIDTH = 0.6;
|
|
21
|
+
/**
|
|
22
|
+
* One bar's box in data space at full height: `barWidth` of slot `[index,
|
|
23
|
+
* index + 1]`, centred at `index + 0.5`, spanning `baseline` to `value` in
|
|
24
|
+
* either order.
|
|
25
|
+
*
|
|
26
|
+
* @param baseline - The value the bar stands on (usually 0).
|
|
27
|
+
* @param barWidth - Fraction of the slot. Defaults to {@link DEFAULT_BAR_WIDTH}.
|
|
28
|
+
* @returns The box, or `null` when `value` is not finite.
|
|
29
|
+
* @category Math & helpers
|
|
30
|
+
*/
|
|
31
|
+
export declare function barSlot(index: number, value: number, baseline: number, barWidth?: number): BarSlotBox | null;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a bar's value label goes, in scene units: centred inside the bar
|
|
3
|
+
* and whether it fits there, and which bar of a stack carries the stack's
|
|
4
|
+
* total past its outer end.
|
|
5
|
+
*
|
|
6
|
+
* @category Math & helpers
|
|
7
|
+
*/
|
|
8
|
+
import type { Bounds } from "@sophistry/core/geometry";
|
|
9
|
+
/** A label's size in scene units: its advance width and ink height. */
|
|
10
|
+
export interface BarLabelSize {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
}
|
|
14
|
+
/** How far past first fitting (as a fraction of the label's length) the bar grows before its label is fully opaque. */
|
|
15
|
+
export declare const INSIDE_LABEL_FADE = 0.5;
|
|
16
|
+
/**
|
|
17
|
+
* How visible a label centred inside a bar is, 0..1: 0 while the bar is too
|
|
18
|
+
* small for the label plus `pad`, rising to 1 as it grows past that, and 1
|
|
19
|
+
* at full length whenever the label fits. A label never shows ahead of its
|
|
20
|
+
* growing segment.
|
|
21
|
+
*
|
|
22
|
+
* @param box - The bar now (mid-reveal or mid-transition).
|
|
23
|
+
* @param rest - The bar at full length on this frame.
|
|
24
|
+
* @param pad - Room kept between the label and each edge.
|
|
25
|
+
* @param vertical - Whether the bar runs up the y axis.
|
|
26
|
+
* @category Math & helpers
|
|
27
|
+
*/
|
|
28
|
+
export declare function insideLabelFit(box: Bounds, rest: Bounds, size: BarLabelSize, pad: number, vertical: boolean): number;
|
|
29
|
+
/**
|
|
30
|
+
* One bar's share in its stack's total: the total of its side of zero, and
|
|
31
|
+
* whether it is that side's outermost segment (the one the total is
|
|
32
|
+
* written past).
|
|
33
|
+
*
|
|
34
|
+
* @category Math & helpers
|
|
35
|
+
*/
|
|
36
|
+
export interface StackTotal {
|
|
37
|
+
/** The sum of the segments on this bar's side of zero, in data units. */
|
|
38
|
+
total: number;
|
|
39
|
+
/** Whether this bar ends its side of the stack. */
|
|
40
|
+
outer: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Each stacked bar's {@link StackTotal}: segments grouped by category and
|
|
44
|
+
* sign, each side's total carried by the segment reaching furthest its way.
|
|
45
|
+
* Zero and non-finite segments belong to no side (`undefined`).
|
|
46
|
+
*
|
|
47
|
+
* @param own - Each bar's own signed value.
|
|
48
|
+
* @param ends - Where each bar ends on the value axis (the stack's `y2`).
|
|
49
|
+
* @category Math & helpers
|
|
50
|
+
*/
|
|
51
|
+
export declare function stackTotals(categories: readonly unknown[], own: readonly number[], ends: readonly number[]): (StackTotal | undefined)[];
|
|
52
|
+
/** What a bar's labels read from its dataset. */
|
|
53
|
+
export interface BarLabelSide {
|
|
54
|
+
/** Each bar's own value (a stacked segment's, not where it ends). */
|
|
55
|
+
own: readonly number[];
|
|
56
|
+
/** Where each bar ends. */
|
|
57
|
+
values: readonly number[];
|
|
58
|
+
/** Where each bar starts, when not at the baseline. */
|
|
59
|
+
bases: readonly number[] | undefined;
|
|
60
|
+
stacked: boolean;
|
|
61
|
+
/** Whether the stack is of shares (`offset="normalize"`). */
|
|
62
|
+
normalized: boolean;
|
|
63
|
+
/** Each stacked bar's side of its stack's total. */
|
|
64
|
+
totals: readonly (StackTotal | undefined)[] | undefined;
|
|
65
|
+
}
|
|
66
|
+
/** The numbers a bar's labels write: its own (a share, when normalized) and its stack's total when it ends its side. @internal */
|
|
67
|
+
export declare function barLabelValues(side: BarLabelSide, index: number): {
|
|
68
|
+
share: number;
|
|
69
|
+
total: number | undefined;
|
|
70
|
+
};
|
|
71
|
+
/** Two ends' label values blended at `u`; a total carried at only one end shows while that end is nearer. @internal */
|
|
72
|
+
export declare function mixBarLabelValues(from: {
|
|
73
|
+
share: number;
|
|
74
|
+
total: number | undefined;
|
|
75
|
+
}, to: {
|
|
76
|
+
share: number;
|
|
77
|
+
total: number | undefined;
|
|
78
|
+
}, u: number): {
|
|
79
|
+
share: number;
|
|
80
|
+
total: number | undefined;
|
|
81
|
+
};
|
|
82
|
+
/** Decimal places a value is written with, so a counting label keeps one width (`"1.5e-7"` has 8). @internal */
|
|
83
|
+
export declare function decimalsOf(value: number): number;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wind barb glyphs: a shaft with ticks near one end coding magnitude
|
|
3
|
+
* (pennant 50, full tick 10, half tick 5), built in a local frame (shaft
|
|
4
|
+
* along +x from the origin) for a caller to place, rotate and scale.
|
|
5
|
+
*/
|
|
6
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
7
|
+
/**
|
|
8
|
+
* One barb glyph: how many of each tick it decomposed to, and its geometry.
|
|
9
|
+
*
|
|
10
|
+
* @category Math & helpers
|
|
11
|
+
*/
|
|
12
|
+
export interface BarbGlyph {
|
|
13
|
+
pennants: number;
|
|
14
|
+
fullBarbs: number;
|
|
15
|
+
halfBarbs: number;
|
|
16
|
+
/** Polylines and polygons in the local frame: the shaft first, then each tick. */
|
|
17
|
+
segments: Point[][];
|
|
18
|
+
}
|
|
19
|
+
/** @category Math */
|
|
20
|
+
export interface BarbGlyphOptions {
|
|
21
|
+
/** Shaft length, local units. @default 1 */
|
|
22
|
+
shaftLength?: number;
|
|
23
|
+
/** Spacing between successive ticks along the shaft. Defaults to `shaftLength / 6`. */
|
|
24
|
+
barbSpacing?: number;
|
|
25
|
+
/** Tick length, local units. Defaults to `shaftLength / 2`. */
|
|
26
|
+
barbLength?: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Local-frame geometry for a wind barb: a shaft from the origin to
|
|
30
|
+
* `(shaftLength, 0)` plus ticks stepping in from the far end, each at 45° on
|
|
31
|
+
* the `-y` side. Negative or `NaN` magnitudes draw a bare shaft (calm).
|
|
32
|
+
*
|
|
33
|
+
* @param magnitude - Wind speed in the tick values' units (conventionally knots).
|
|
34
|
+
* @category Math & helpers
|
|
35
|
+
*/
|
|
36
|
+
export declare function barbGlyph(magnitude: number, options?: BarbGlyphOptions): BarbGlyph;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** Box-and-whisker statistics: quartiles, median, whiskers clipped to Tukey's fences, and outliers beyond them. */
|
|
2
|
+
/** @category Math */
|
|
3
|
+
export interface BoxplotStats {
|
|
4
|
+
min: number;
|
|
5
|
+
q1: number;
|
|
6
|
+
median: number;
|
|
7
|
+
q3: number;
|
|
8
|
+
max: number;
|
|
9
|
+
/** Lower whisker end — the smallest finite value still inside the fence. */
|
|
10
|
+
low: number;
|
|
11
|
+
/** Upper whisker end — the largest finite value still inside the fence. */
|
|
12
|
+
high: number;
|
|
13
|
+
/** Finite values outside `[q1 - whiskerScale * iqr, q3 + whiskerScale * iqr]`. */
|
|
14
|
+
outliers: number[];
|
|
15
|
+
}
|
|
16
|
+
/** @category Math */
|
|
17
|
+
export interface BoxplotOptions {
|
|
18
|
+
/** How many IQRs past q1/q3 the whiskers may reach before a point is an outlier. @default 1.5 */
|
|
19
|
+
whiskerScale?: number;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* `BoxplotOptions.whiskerScale`'s default.
|
|
23
|
+
*
|
|
24
|
+
* @category Math & helpers
|
|
25
|
+
*/
|
|
26
|
+
export declare const DEFAULT_WHISKER_SCALE = 1.5;
|
|
27
|
+
/**
|
|
28
|
+
* Five-number summary of `values` by Tukey's rule: whiskers reach the most
|
|
29
|
+
* extreme value within `whiskerScale * iqr` of the box; anything further is
|
|
30
|
+
* an outlier.
|
|
31
|
+
*
|
|
32
|
+
* @param values - Raw samples; non-finite entries are dropped.
|
|
33
|
+
* @returns The summary, or `null` when no finite value remains.
|
|
34
|
+
* @category Math & helpers
|
|
35
|
+
*/
|
|
36
|
+
export declare function boxplotStats(values: readonly number[], options?: BoxplotOptions): BoxplotStats | null;
|