@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
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Breadcrumbs for a drill-down: the trail of names from a hierarchy's root
|
|
3
|
+
* to the focused node, laid out left to right, with text widths from a
|
|
4
|
+
* `measure` callback. A trail may be a `{ from, to, t }` transition: shared
|
|
5
|
+
* crumbs stay put, others fade with their end's weight, so it scrubs.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* A focus path (names below the root: `[]` is the root, `["src", "lib"]`
|
|
9
|
+
* is "lib" inside "src"), or a scrubbable `{ from, to, t }` transition
|
|
10
|
+
* between two, either end possibly itself a transition. What
|
|
11
|
+
* {@link useDrillDown} produces and both a hierarchy chart's `focus` and
|
|
12
|
+
* {@link Breadcrumbs} take.
|
|
13
|
+
*
|
|
14
|
+
* @category Charts
|
|
15
|
+
*/
|
|
16
|
+
export type HierarchyPathSpec = readonly string[] | {
|
|
17
|
+
from: HierarchyPathSpec;
|
|
18
|
+
to: HierarchyPathSpec;
|
|
19
|
+
t: number;
|
|
20
|
+
};
|
|
21
|
+
/** Whether a path spec is a transition rather than a plain path. */
|
|
22
|
+
export declare function isPathTransition(spec: HierarchyPathSpec): spec is Exclude<HierarchyPathSpec, readonly string[]>;
|
|
23
|
+
/**
|
|
24
|
+
* One path of a (possibly nested) transition with its share of the blend.
|
|
25
|
+
*
|
|
26
|
+
* @category Math & helpers
|
|
27
|
+
*/
|
|
28
|
+
export interface WeightedPath {
|
|
29
|
+
path: readonly string[];
|
|
30
|
+
/** 0..1; the weights of one spec sum to 1. */
|
|
31
|
+
weight: number;
|
|
32
|
+
}
|
|
33
|
+
/** Whether two paths name the same node. */
|
|
34
|
+
export declare function samePath(a: readonly string[], b: readonly string[]): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* A path spec as the paths it blends, each with its weight (equal paths
|
|
37
|
+
* merged, zero weights dropped, in first-seen order).
|
|
38
|
+
*
|
|
39
|
+
* @category Math & helpers
|
|
40
|
+
*/
|
|
41
|
+
export declare function flattenPathSpec(spec: HierarchyPathSpec): WeightedPath[];
|
|
42
|
+
/**
|
|
43
|
+
* Where a path spec is heading: `to`'s path (recursively), or the plain path.
|
|
44
|
+
*
|
|
45
|
+
* @category Math & helpers
|
|
46
|
+
*/
|
|
47
|
+
export declare function pathTarget(spec: HierarchyPathSpec): readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* One crumb of a laid-out trail. Offsets are from the trail's anchor, in
|
|
50
|
+
* the unit `measure` returned.
|
|
51
|
+
*
|
|
52
|
+
* @category Math & helpers
|
|
53
|
+
*/
|
|
54
|
+
export interface BreadcrumbItem {
|
|
55
|
+
/** Stable identity: the crumb's path, JSON-encoded (`"…"` for the ellipsis). */
|
|
56
|
+
key: string;
|
|
57
|
+
/** The crumb's own path below the root (`[]` for the root crumb); for the ellipsis, the deepest crumb it hides. */
|
|
58
|
+
path: string[];
|
|
59
|
+
/** The text shown (the root's name for the root crumb). */
|
|
60
|
+
name: string;
|
|
61
|
+
/** 0 for the root crumb, +1 per level (the ellipsis is 1). */
|
|
62
|
+
depth: number;
|
|
63
|
+
/** Left edge of the crumb's text. */
|
|
64
|
+
x: number;
|
|
65
|
+
/** Width of the crumb's text. */
|
|
66
|
+
width: number;
|
|
67
|
+
/** Centre of the separator drawn before this crumb (unused at depth 0). */
|
|
68
|
+
separatorX: number;
|
|
69
|
+
/** Presence, 0..1: the summed weight of the paths that show it. */
|
|
70
|
+
weight: number;
|
|
71
|
+
/** How much this crumb is the focused (last) one, 0..1, as a fraction of its own weight. */
|
|
72
|
+
current: number;
|
|
73
|
+
/** Whether this is the ellipsis standing for the crumbs collapsed out of the middle. */
|
|
74
|
+
ellipsis?: boolean;
|
|
75
|
+
/** For the ellipsis: the names it stands for, root side first (of its heaviest path). */
|
|
76
|
+
hidden?: string[];
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The trail's "back" control, laid out before the root crumb.
|
|
80
|
+
*
|
|
81
|
+
* @category Math & helpers
|
|
82
|
+
*/
|
|
83
|
+
export interface BreadcrumbBack {
|
|
84
|
+
/** Left edge of the control. */
|
|
85
|
+
x: number;
|
|
86
|
+
/** Its width, as given. */
|
|
87
|
+
width: number;
|
|
88
|
+
/** Presence, 0..1: the weight of the paths below the root (none at the root). */
|
|
89
|
+
weight: number;
|
|
90
|
+
/** Where it goes: the parent of the path the spec is heading for; null when heading for the root. */
|
|
91
|
+
path: string[] | null;
|
|
92
|
+
}
|
|
93
|
+
/** @category Math */
|
|
94
|
+
export interface BreadcrumbLayoutOptions {
|
|
95
|
+
/** The root crumb's text. */
|
|
96
|
+
root: string;
|
|
97
|
+
/** Width of a crumb's text. */
|
|
98
|
+
measure: (text: string) => number;
|
|
99
|
+
/** Width of the separator's text. */
|
|
100
|
+
separatorWidth: number;
|
|
101
|
+
/** Space each side of a separator. */
|
|
102
|
+
gap: number;
|
|
103
|
+
/** Where the anchor is on the trail. @default "left" */
|
|
104
|
+
align?: "left" | "center" | "right";
|
|
105
|
+
/**
|
|
106
|
+
* The widest a trail may be, back control included. Wider paths keep the
|
|
107
|
+
* root and as many last crumbs as fit, collapsing the rest into one
|
|
108
|
+
* ellipsis; root, ellipsis and last crumb always show. Omitted, never collapses.
|
|
109
|
+
*/
|
|
110
|
+
maxWidth?: number;
|
|
111
|
+
/** The ellipsis's text. @default "…" */
|
|
112
|
+
ellipsis?: string;
|
|
113
|
+
/** Reserve room for a back control this wide before the root crumb (plus `2 × gap`). Omitted, none. */
|
|
114
|
+
backWidth?: number;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Lays out a path spec's crumbs: one per distinct prefix of every blended
|
|
118
|
+
* path, each placed after those before it on its own path. With
|
|
119
|
+
* `maxWidth`, paths too wide collapse their middle into an ellipsis whose
|
|
120
|
+
* `path` is the deepest crumb it hides.
|
|
121
|
+
*
|
|
122
|
+
* @category Math & helpers
|
|
123
|
+
*/
|
|
124
|
+
export declare function breadcrumbLayout(spec: HierarchyPathSpec, options: BreadcrumbLayoutOptions): {
|
|
125
|
+
items: BreadcrumbItem[];
|
|
126
|
+
width: number;
|
|
127
|
+
back?: BreadcrumbBack;
|
|
128
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bubble sizing: values to marker radii with area, not radius, proportional
|
|
3
|
+
* to value (a viewer reads area).
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* One radius per input value, parallel to `values`.
|
|
7
|
+
*
|
|
8
|
+
* @category Math & helpers
|
|
9
|
+
*/
|
|
10
|
+
export type BubbleRadii = number[];
|
|
11
|
+
/** @category Math */
|
|
12
|
+
export interface BubbleRadiusOptions {
|
|
13
|
+
/** Radius for a value of 0. @default 0 */
|
|
14
|
+
minRadius?: number;
|
|
15
|
+
/** Radius for `maxValue`. @default 1 */
|
|
16
|
+
maxRadius?: number;
|
|
17
|
+
/** The value that maps to `maxRadius`. Defaults to the greatest finite value in `values`. */
|
|
18
|
+
maxValue?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Values to marker radii with area proportional to value:
|
|
22
|
+
* `minRadius + (maxRadius - minRadius) * sqrt(value / maxValue)`. When every
|
|
23
|
+
* value is 0, every radius is `minRadius`.
|
|
24
|
+
*
|
|
25
|
+
* @param values - One per marker; non-finite or negative entries clamp to 0.
|
|
26
|
+
* @returns One radius per value, in `minRadius`/`maxRadius`'s units.
|
|
27
|
+
* @category Math & helpers
|
|
28
|
+
*/
|
|
29
|
+
export declare function bubbleRadiusScale(values: readonly number[], options?: BubbleRadiusOptions): BubbleRadii;
|
|
30
|
+
/**
|
|
31
|
+
* Reference values for a size key over `[0, maxValue]`: at most `count`
|
|
32
|
+
* round numbers above zero, the largest kept.
|
|
33
|
+
*
|
|
34
|
+
* @param count - Defaults to 3.
|
|
35
|
+
* @returns Ascending values in `(0, maxValue]`; empty when `maxValue` is not positive.
|
|
36
|
+
* @category Math & helpers
|
|
37
|
+
*/
|
|
38
|
+
export declare function bubbleLegendValues(maxValue: number, count?: number): number[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/** Bullet-chart geometry: one row's scale, qualitative bands, measure bar and target marker, as data values and as fractions of the row. */
|
|
2
|
+
import type { Range } from "@sophistry/core/geometry";
|
|
3
|
+
/**
|
|
4
|
+
* Options for {@link bulletDomain}.
|
|
5
|
+
*
|
|
6
|
+
* @category Math & helpers
|
|
7
|
+
*/
|
|
8
|
+
export interface BulletDomainOptions {
|
|
9
|
+
/**
|
|
10
|
+
* The scale's start, in data units. Defaults to 0, or below the smallest value when one is
|
|
11
|
+
* negative.
|
|
12
|
+
*/
|
|
13
|
+
min?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The scale's end, in data units. Defaults to the largest value (0 when every value is
|
|
16
|
+
* negative).
|
|
17
|
+
*/
|
|
18
|
+
max?: number;
|
|
19
|
+
/** Round default ends out to tick values; an explicit `min`/`max` is kept. @default true */
|
|
20
|
+
nice?: boolean;
|
|
21
|
+
/** Roughly how many ticks the scale should offer. @default 5 */
|
|
22
|
+
targetTicks?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The scale one bullet (or several sharing a scale) spans: from 0, or the
|
|
26
|
+
* smallest value when negative, to the largest, rounded out to ticks.
|
|
27
|
+
* Non-finite values are ignored; with nothing to fit it reads `0..1`.
|
|
28
|
+
*
|
|
29
|
+
* @param values - Everything the scale must show: values, targets, thresholds.
|
|
30
|
+
* @returns `[min, max, step]`, with `step` the tick spacing.
|
|
31
|
+
* @category Math & helpers
|
|
32
|
+
*/
|
|
33
|
+
export declare function bulletDomain(values: readonly number[], options?: BulletDomainOptions): Range;
|
|
34
|
+
/**
|
|
35
|
+
* A stretch of a bullet's scale, in data units and as fractions of its
|
|
36
|
+
* length (0 at the scale's start, 1 at its end).
|
|
37
|
+
*
|
|
38
|
+
* @category Math & helpers
|
|
39
|
+
*/
|
|
40
|
+
export interface BulletSpan {
|
|
41
|
+
/** Start, in data units. */
|
|
42
|
+
from: number;
|
|
43
|
+
/** End, in data units. */
|
|
44
|
+
to: number;
|
|
45
|
+
/** `from` as a fraction of the scale, 0..1. */
|
|
46
|
+
startFraction: number;
|
|
47
|
+
/** `to` as a fraction of the scale, 0..1. */
|
|
48
|
+
endFraction: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One qualitative band of a bullet: a {@link BulletSpan} and its place in the
|
|
52
|
+
* input `ranges`.
|
|
53
|
+
*
|
|
54
|
+
* @category Math & helpers
|
|
55
|
+
*/
|
|
56
|
+
export interface BulletBand extends BulletSpan {
|
|
57
|
+
/** Position in the input `ranges` array: 0 is the worst band. */
|
|
58
|
+
index: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Options for {@link bulletRow}.
|
|
62
|
+
*
|
|
63
|
+
* @category Math & helpers
|
|
64
|
+
*/
|
|
65
|
+
export interface BulletRowOptions extends BulletDomainOptions {
|
|
66
|
+
/** The comparative measure the value is judged against, in data units. */
|
|
67
|
+
target?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Qualitative thresholds in ascending order, each where a band ends:
|
|
70
|
+
* `[150, 225, 300]` is poor to 150, satisfactory to 225, good beyond. The
|
|
71
|
+
* last band runs on to the scale's end.
|
|
72
|
+
*/
|
|
73
|
+
ranges?: readonly number[];
|
|
74
|
+
/** Use this scale as is, ignoring `min`, `max`, `nice` and `targetTicks`, so several bullets share one ({@link bulletDomain}). */
|
|
75
|
+
domain?: Range;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* One bullet's resolved geometry.
|
|
79
|
+
*
|
|
80
|
+
* @category Math & helpers
|
|
81
|
+
*/
|
|
82
|
+
export interface BulletRowGeometry {
|
|
83
|
+
/** The scale, `[min, max, step]`. */
|
|
84
|
+
domain: Range;
|
|
85
|
+
/** Tick values along the scale, ascending. */
|
|
86
|
+
ticks: number[];
|
|
87
|
+
/** One band per input threshold, in input order (worst first). */
|
|
88
|
+
bands: BulletBand[];
|
|
89
|
+
/** Where the measure bar starts: 0, or the scale end nearest it when the scale has no zero. */
|
|
90
|
+
baseline: number;
|
|
91
|
+
/** Whether the scale contains zero, so the bar can grow from it (otherwise it fades in). */
|
|
92
|
+
zero: boolean;
|
|
93
|
+
/** The measure bar from `baseline` to the value (clamped to the scale), or null for a non-finite value. */
|
|
94
|
+
measure: BulletSpan | null;
|
|
95
|
+
/** The target (clamped to the scale) and its fraction, or null when there is none. */
|
|
96
|
+
target: {
|
|
97
|
+
value: number;
|
|
98
|
+
fraction: number;
|
|
99
|
+
} | null;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Resolves one bullet: scale (covering value, target and thresholds), ticks,
|
|
103
|
+
* bands, measure bar and target marker, clamped to the scale. Non-finite
|
|
104
|
+
* inputs drop their part; a bad threshold leaves an empty band so `index`
|
|
105
|
+
* stays aligned.
|
|
106
|
+
*
|
|
107
|
+
* @param value - The featured measure, in data units.
|
|
108
|
+
* @category Math & helpers
|
|
109
|
+
*/
|
|
110
|
+
export declare function bulletRow(value: number, options?: BulletRowOptions): BulletRowGeometry;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chord diagram layout over a square flow matrix: `matrix[i][j]` is the
|
|
3
|
+
* flow from group `i` to `j`. Each group is an arc as long as its outflow;
|
|
4
|
+
* a chord joins sub-arc `i → j` to `j → i`, each end as wide as its flow.
|
|
5
|
+
* Angles are radians from +x, y up, starting at 12 o'clock clockwise.
|
|
6
|
+
*/
|
|
7
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
8
|
+
import type { PolarSweepOptions } from "./shared/polar.js";
|
|
9
|
+
/** @category Math */
|
|
10
|
+
export interface ChordOptions extends PolarSweepOptions {
|
|
11
|
+
/** Gap between neighbouring groups, in radians. @default 0.04 */
|
|
12
|
+
padAngle?: number;
|
|
13
|
+
/** Order each group's sub-arcs by descending flow instead of by column. @default false */
|
|
14
|
+
sortSubgroups?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Every non-zero `matrix[i][j]` becomes its own chord, equally wide at both
|
|
17
|
+
* ends, and a group's arc holds outflow then inflow (so receive-only groups
|
|
18
|
+
* get an arc). Off, one chord per pair with arcs sized by outflow.
|
|
19
|
+
* @default false
|
|
20
|
+
*/
|
|
21
|
+
directed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One group's arc.
|
|
25
|
+
*
|
|
26
|
+
* @category Math & helpers
|
|
27
|
+
*/
|
|
28
|
+
export interface ChordGroup {
|
|
29
|
+
/** Row (and column) of the matrix. */
|
|
30
|
+
index: number;
|
|
31
|
+
/** Radians from +x, where the arc begins. */
|
|
32
|
+
startAngle: number;
|
|
33
|
+
/** Radians from +x, where it ends: `endAngle - startAngle` is the signed sweep. */
|
|
34
|
+
endAngle: number;
|
|
35
|
+
/** The row's total: everything leaving the group (plus, when `directed`, everything arriving). */
|
|
36
|
+
value: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One end of a chord: a sub-arc of a group.
|
|
40
|
+
*
|
|
41
|
+
* @category Math & helpers
|
|
42
|
+
*/
|
|
43
|
+
export interface ChordEnd {
|
|
44
|
+
/** The group the end sits on. */
|
|
45
|
+
index: number;
|
|
46
|
+
/** The group at the chord's other end. */
|
|
47
|
+
subindex: number;
|
|
48
|
+
startAngle: number;
|
|
49
|
+
endAngle: number;
|
|
50
|
+
/** The flow this end stands for: `matrix[index][subindex]` (a directed chord's target end: `matrix[subindex][index]`). */
|
|
51
|
+
value: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* A chord between two groups (or a group and itself).
|
|
55
|
+
*
|
|
56
|
+
* @category Math & helpers
|
|
57
|
+
*/
|
|
58
|
+
export interface ChordLink {
|
|
59
|
+
/** The end with the larger flow. */
|
|
60
|
+
source: ChordEnd;
|
|
61
|
+
/** The other end. */
|
|
62
|
+
target: ChordEnd;
|
|
63
|
+
}
|
|
64
|
+
/** @category Math */
|
|
65
|
+
export interface ChordLayout {
|
|
66
|
+
/** One arc per matrix row, in index order. */
|
|
67
|
+
groups: ChordGroup[];
|
|
68
|
+
/** One chord per pair of groups with any flow between them, by source row then column. */
|
|
69
|
+
chords: ChordLink[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Lays a square flow matrix out as a chord diagram's groups and chords.
|
|
73
|
+
*
|
|
74
|
+
* @param matrix - `matrix[i][j]` is the flow from `i` to `j`; negative and non-finite entries count as 0, ragged rows are padded with 0.
|
|
75
|
+
* @returns The groups and chords; no chords and zero-length groups when there is no flow.
|
|
76
|
+
* @category Math & helpers
|
|
77
|
+
*/
|
|
78
|
+
export declare function chordLayout(matrix: readonly (readonly number[])[], options?: ChordOptions): ChordLayout;
|
|
79
|
+
/** @category Math */
|
|
80
|
+
export interface ChordRibbonOptions {
|
|
81
|
+
/** Centre. Defaults to the origin. */
|
|
82
|
+
center?: Point;
|
|
83
|
+
/** Points per radian along each end's arc. @default 24 */
|
|
84
|
+
arcDensity?: number;
|
|
85
|
+
/** Points along each curve through the middle. @default 24 */
|
|
86
|
+
curveSamples?: number;
|
|
87
|
+
/**
|
|
88
|
+
* Draw the target end as an arrowhead: the ribbon stops this far short of
|
|
89
|
+
* the circle and narrows to a point on it. For directed chords; in
|
|
90
|
+
* `radius`'s units.
|
|
91
|
+
* @default 0
|
|
92
|
+
*/
|
|
93
|
+
headRadius?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A chord's ribbon as one open ring: along the source arc, a quadratic
|
|
97
|
+
* curve through the centre to the target, along its arc (or an arrowhead
|
|
98
|
+
* with `headRadius`), and back.
|
|
99
|
+
*
|
|
100
|
+
* @param radius - Radius the ends sit on.
|
|
101
|
+
* @category Math & helpers
|
|
102
|
+
*/
|
|
103
|
+
export declare function chordRibbon(chord: ChordLink, radius: number, options?: ChordRibbonOptions): Point[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agglomerative hierarchical clustering: pairwise row distances, the merge
|
|
3
|
+
* tree single, complete or average linkage builds, and the leaf order a
|
|
4
|
+
* dendrogram follows. The tree feeds {@link hierarchyTreeLayout} with
|
|
5
|
+
* `distance: (n) => n.height`.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* How cluster distance is measured from member distances: `"single"` (the
|
|
9
|
+
* closest pair; chained clusters), `"complete"` (the farthest pair; compact
|
|
10
|
+
* clusters) or `"average"` (the mean over all pairs, UPGMA).
|
|
11
|
+
*
|
|
12
|
+
* @category Math & helpers
|
|
13
|
+
*/
|
|
14
|
+
export type ClusterLinkage = "single" | "complete" | "average";
|
|
15
|
+
/**
|
|
16
|
+
* How far apart two rows are: `"euclidean"`, `"manhattan"` (sum of absolute
|
|
17
|
+
* differences) or `"correlation"` (`1 − r`: rows that rise and fall
|
|
18
|
+
* together are close whatever their level).
|
|
19
|
+
*
|
|
20
|
+
* @category Math & helpers
|
|
21
|
+
*/
|
|
22
|
+
export type ClusterMetric = "euclidean" | "manhattan" | "correlation";
|
|
23
|
+
/**
|
|
24
|
+
* One node of a merge tree: a leaf (one input row) or the merge of two
|
|
25
|
+
* clusters.
|
|
26
|
+
*
|
|
27
|
+
* @category Math & helpers
|
|
28
|
+
*/
|
|
29
|
+
export interface ClusterNode {
|
|
30
|
+
/** The input row of a leaf; -1 for a merge. */
|
|
31
|
+
index: number;
|
|
32
|
+
/** The linkage distance at which the two children merged; 0 for a leaf. */
|
|
33
|
+
height: number;
|
|
34
|
+
/** How many rows the cluster holds. */
|
|
35
|
+
size: number;
|
|
36
|
+
/** A merge's two clusters, the one holding the lower row index first; absent on a leaf. */
|
|
37
|
+
children?: [ClusterNode, ClusterNode];
|
|
38
|
+
}
|
|
39
|
+
/** @category Math */
|
|
40
|
+
export interface ClusterTree {
|
|
41
|
+
/** The merge tree, or `null` when there are no rows. */
|
|
42
|
+
root: ClusterNode | null;
|
|
43
|
+
/** The rows in dendrogram (left-to-right leaf) order: the order to draw them in. */
|
|
44
|
+
order: number[];
|
|
45
|
+
}
|
|
46
|
+
/** @category Math */
|
|
47
|
+
export interface ClusterOptions {
|
|
48
|
+
/** See {@link ClusterLinkage}. @default "average" */
|
|
49
|
+
linkage?: ClusterLinkage;
|
|
50
|
+
/** See {@link ClusterMetric}. @default "euclidean" */
|
|
51
|
+
metric?: ClusterMetric;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The distance between every pair of rows. Non-finite entries are skipped
|
|
55
|
+
* pairwise and the sum scaled up to all columns, so a gap neither shrinks
|
|
56
|
+
* nor grows a distance; rows with no column in common get `NaN`.
|
|
57
|
+
*
|
|
58
|
+
* @param metric - Defaults to `"euclidean"`.
|
|
59
|
+
* @returns A symmetric `n × n` matrix with zeros on the diagonal.
|
|
60
|
+
* @category Math & helpers
|
|
61
|
+
*/
|
|
62
|
+
export declare function distanceMatrix(rows: readonly (readonly number[])[], metric?: ClusterMetric): number[][];
|
|
63
|
+
/**
|
|
64
|
+
* Agglomerative clustering over a distance matrix: the two closest clusters
|
|
65
|
+
* merge until one is left. Ties merge the lowest row indices first, so it
|
|
66
|
+
* is deterministic; heights rise toward the root. A non-finite distance
|
|
67
|
+
* counts as the largest finite one. O(n³) in rows.
|
|
68
|
+
*
|
|
69
|
+
* @param linkage - Defaults to `"average"`.
|
|
70
|
+
* @returns The merge tree and the dendrogram's leaf order.
|
|
71
|
+
* @category Math & helpers
|
|
72
|
+
*/
|
|
73
|
+
export declare function linkageTree(distances: readonly (readonly number[])[], linkage?: ClusterLinkage): ClusterTree;
|
|
74
|
+
/**
|
|
75
|
+
* Clusters rows by their values: {@link distanceMatrix} then
|
|
76
|
+
* {@link linkageTree}.
|
|
77
|
+
*
|
|
78
|
+
* @param rows - One vector per row (non-finite entries are gaps).
|
|
79
|
+
* @returns The merge tree and the rows' dendrogram order.
|
|
80
|
+
* @category Math & helpers
|
|
81
|
+
*/
|
|
82
|
+
export declare function clusterRows(rows: readonly (readonly number[])[], options?: ClusterOptions): ClusterTree;
|
|
83
|
+
/**
|
|
84
|
+
* A merge tree's leaves, left to right: the input rows in dendrogram order.
|
|
85
|
+
*
|
|
86
|
+
* @category Math & helpers
|
|
87
|
+
*/
|
|
88
|
+
export declare function leafOrder(root: ClusterNode): number[];
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contour lines: iso-lines of a scalar field on a regular grid, by marching
|
|
3
|
+
* squares. `x` has length `ncols`, `y` length `nrows`, and `z[row][col]` is
|
|
4
|
+
* the sample at `(x[col], y[row])`.
|
|
5
|
+
*/
|
|
6
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
7
|
+
type Pt = Point;
|
|
8
|
+
/** @category Math */
|
|
9
|
+
export interface ContourLine {
|
|
10
|
+
level: number;
|
|
11
|
+
points: Point[];
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `count` evenly spaced levels strictly between `min` and `max`.
|
|
15
|
+
*
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export declare function evenLevels(min: number, max: number, count: number): number[];
|
|
19
|
+
/**
|
|
20
|
+
* A contour segment: its two crossing points, and the identity of each — the
|
|
21
|
+
* grid or triangle edge it lies on, or the corner when the field is exactly at
|
|
22
|
+
* the level there — so the two cells sharing an edge meet at the same key.
|
|
23
|
+
*
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export interface KeyedSegment {
|
|
27
|
+
keys: [number, number];
|
|
28
|
+
points: [Pt, Pt];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Stitches keyed segments into connected polylines, each running in its
|
|
32
|
+
* lowest-index segment's direction; a loop repeats its first point at the end.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare function stitch(segments: readonly KeyedSegment[]): Point[][];
|
|
37
|
+
/**
|
|
38
|
+
* Iso-lines of `z` at `levels` by marching squares, one {@link ContourLine}
|
|
39
|
+
* per connected run. Cells touching a NaN corner are skipped; saddles are
|
|
40
|
+
* resolved by the cell's mean value.
|
|
41
|
+
*
|
|
42
|
+
* @param z - Samples as `z[row][col]`, at `(x[col], y[row])`.
|
|
43
|
+
* @param levels - Explicit levels, or a count strictly between the data's min and max.
|
|
44
|
+
* @returns Polylines tagged with their level; `[]` for a grid under 2 x 2 or `x`/`y` shorter than `z`.
|
|
45
|
+
* @category Math & helpers
|
|
46
|
+
*/
|
|
47
|
+
export declare function contourLines(x: readonly number[], y: readonly number[], z: readonly (readonly number[])[], levels: readonly number[] | number): ContourLine[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filled contours: bands between consecutive level thresholds over a grid
|
|
3
|
+
* (`x` length `ncols`, `y` length `nrows`, `z[row][col]` at `(x[col],
|
|
4
|
+
* y[row])`). Each grid cell is clipped on its own, giving many small
|
|
5
|
+
* polygons per band that meet edge to edge without gaps.
|
|
6
|
+
*/
|
|
7
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
8
|
+
/**
|
|
9
|
+
* A clip vertex: a point plus the field value at it.
|
|
10
|
+
*
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export interface Vtx {
|
|
14
|
+
x: number;
|
|
15
|
+
y: number;
|
|
16
|
+
z: number;
|
|
17
|
+
}
|
|
18
|
+
/** @category Math */
|
|
19
|
+
export interface ContourBand {
|
|
20
|
+
loLevel: number;
|
|
21
|
+
hiLevel: number;
|
|
22
|
+
/** Closed polygon rings, in data space, one per contributing grid cell. */
|
|
23
|
+
polygons: Point[][];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `count` evenly spaced band boundaries spanning `[min, max]` inclusively,
|
|
27
|
+
* so every sample falls in a band.
|
|
28
|
+
*
|
|
29
|
+
* @internal
|
|
30
|
+
*/
|
|
31
|
+
export declare function evenBoundaries(min: number, max: number, count: number): number[];
|
|
32
|
+
/**
|
|
33
|
+
* Clips a convex polygon by a half-plane of `z` (`z >= threshold` with
|
|
34
|
+
* `keepAbove`, else `z <= threshold`); new vertices sit exactly on the
|
|
35
|
+
* threshold.
|
|
36
|
+
*
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
export declare function clipByThreshold(poly: Vtx[], threshold: number, keepAbove: boolean): Vtx[];
|
|
40
|
+
/**
|
|
41
|
+
* Fills `z` into bands between consecutive `levels`: `N` levels make `N - 1`
|
|
42
|
+
* closed bands `loLevel <= z <= hiLevel`. Cells touching a NaN corner, and
|
|
43
|
+
* constant fields, contribute nothing.
|
|
44
|
+
*
|
|
45
|
+
* @param z - Samples as `z[row][col]`, at `(x[col], y[row])`.
|
|
46
|
+
* @param levels - Explicit boundaries, or a count spanning the data.
|
|
47
|
+
* @returns One {@link ContourBand} per pair of consecutive levels.
|
|
48
|
+
* @category Math & helpers
|
|
49
|
+
*/
|
|
50
|
+
export declare function contourBands(x: readonly number[], y: readonly number[], z: readonly (readonly number[])[], levels: readonly number[] | number): ContourBand[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dodging overlapping marks apart: in data space, sub-bands within a
|
|
3
|
+
* category's band (`dodgeSpan`, grouped bars); in screen space, circles
|
|
4
|
+
* pushed off an axis until they clear each other (`beeswarmOffsets`).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Sub-band `slot` of `count` within one band, as fractions `[from, to]` of
|
|
8
|
+
* the band, with `padding` of each sub-band left empty.
|
|
9
|
+
*
|
|
10
|
+
* @param padding - Fraction of each sub-band left empty, 0..1. Defaults to 0.1.
|
|
11
|
+
* @category Math & helpers
|
|
12
|
+
*/
|
|
13
|
+
export declare function dodgeSpan(slot: number, count: number, padding?: number): [number, number];
|
|
14
|
+
/** @category Math */
|
|
15
|
+
export interface BeeswarmOptions {
|
|
16
|
+
/**
|
|
17
|
+
* Which side of the axis circles may move to: `"both"` (centred on the
|
|
18
|
+
* axis), `"positive"` or `"negative"` (standing on a baseline).
|
|
19
|
+
* @default "both"
|
|
20
|
+
*/
|
|
21
|
+
side?: "both" | "positive" | "negative";
|
|
22
|
+
/** Extra room left between neighbouring circles, in the same units as the radii. @default 0 */
|
|
23
|
+
gap?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Beeswarm offsets: each circle keeps its position along the axis and moves
|
|
27
|
+
* across it just far enough to clear those placed before it (in ascending
|
|
28
|
+
* order). Deterministic, so it scrubs. Positions and radii share units
|
|
29
|
+
* (scene units).
|
|
30
|
+
*
|
|
31
|
+
* @param positions - Each circle's centre along the axis; non-finite ones get `NaN`.
|
|
32
|
+
* @param radii - One radius for every circle, or one per circle.
|
|
33
|
+
* @returns One offset across the axis per circle.
|
|
34
|
+
* @category Math & helpers
|
|
35
|
+
*/
|
|
36
|
+
export declare function beeswarmOffsets(positions: readonly number[], radii: number | readonly number[], options?: BeeswarmOptions): number[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Empirical CDF: a step function rising from 0 to 1 by `1/n` at each observed value. */
|
|
2
|
+
/**
|
|
3
|
+
* Step data shaped for `stairsPolyline`/`<Stairs>`: `edges.length === values.length + 1`.
|
|
4
|
+
*
|
|
5
|
+
* @category Math & helpers
|
|
6
|
+
*/
|
|
7
|
+
export interface EcdfSteps {
|
|
8
|
+
edges: number[];
|
|
9
|
+
values: number[];
|
|
10
|
+
}
|
|
11
|
+
/** @category Math */
|
|
12
|
+
export interface EcdfOptions {
|
|
13
|
+
/**
|
|
14
|
+
* Padding left of the smallest value and right of the largest, in data units. Defaults to 5% of
|
|
15
|
+
* the data's span (0.5 when the span is 0).
|
|
16
|
+
*/
|
|
17
|
+
pad?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* `EcdfOptions.pad`'s fraction-of-span default.
|
|
21
|
+
*
|
|
22
|
+
* @category Math & helpers
|
|
23
|
+
*/
|
|
24
|
+
export declare const DEFAULT_ECDF_PAD_FRACTION = 0.05;
|
|
25
|
+
/**
|
|
26
|
+
* `EcdfOptions.pad`'s fallback when the data's span is 0 (every value identical).
|
|
27
|
+
*
|
|
28
|
+
* @category Math & helpers
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_ECDF_PAD_FALLBACK = 0.5;
|
|
31
|
+
/**
|
|
32
|
+
* The step function of the empirical CDF of `values`, over the sorted unique
|
|
33
|
+
* finite values `u_1 < … < u_k`: `edges = [u_1 - pad, u_1, …, u_k, u_k + pad]`
|
|
34
|
+
* and `values = [0, F(u_1), …, F(u_k)]`, so the curve is 0 before `u_1`,
|
|
35
|
+
* jumps at each value, and ends at 1.
|
|
36
|
+
*
|
|
37
|
+
* @param values - The sample; non-finite entries are dropped.
|
|
38
|
+
* @returns `edges` and `values` for {@link stairsPolyline}; both empty when no finite value remains.
|
|
39
|
+
* @category Math & helpers
|
|
40
|
+
*/
|
|
41
|
+
export declare function ecdfSteps(values: readonly number[], options?: EcdfOptions): EcdfSteps;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** `errorbar(x, y, yerr, xerr)` — a marker plus optional error bars for each finite `(x, y)` pair. */
|
|
2
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
3
|
+
/**
|
|
4
|
+
* Symmetric errors as one magnitude per index, or asymmetric ones as a
|
|
5
|
+
* `[lower[], upper[]]` tuple.
|
|
6
|
+
*
|
|
7
|
+
* @category Math & helpers
|
|
8
|
+
*/
|
|
9
|
+
export type ErrorSpec = readonly number[] | readonly [readonly number[], readonly number[]];
|
|
10
|
+
/** @category Math */
|
|
11
|
+
export interface ErrorBarPoint {
|
|
12
|
+
/** Index into the input `xs`/`ys`, matching a point to its row after non-finite pairs are dropped. */
|
|
13
|
+
index: number;
|
|
14
|
+
point: Point;
|
|
15
|
+
/** `[point - lower, point + upper]` along y; omitted where `yerr` has no finite magnitude here. */
|
|
16
|
+
yBar?: [Point, Point];
|
|
17
|
+
/** `[point - lower, point + upper]` along x; omitted where `xerr` has no finite magnitude here. */
|
|
18
|
+
xBar?: [Point, Point];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* One marker plus optional error bars per finite `(x, y)` pair.
|
|
22
|
+
*
|
|
23
|
+
* @param yerr - Vertical error magnitudes. See {@link ErrorSpec}.
|
|
24
|
+
* @param xerr - Horizontal error magnitudes. See {@link ErrorSpec}.
|
|
25
|
+
* @category Math & helpers
|
|
26
|
+
*/
|
|
27
|
+
export declare function errorBarPoints(xs: readonly number[], ys: readonly number[], yerr?: ErrorSpec, xerr?: ErrorSpec): ErrorBarPoint[];
|