@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,21 @@
|
|
|
1
|
+
/** `stem(x, y)` — a drop line and a marker for each finite `(x, y)` pair. */
|
|
2
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
3
|
+
/** @category Math */
|
|
4
|
+
export interface StemPoint {
|
|
5
|
+
/** Index into the input `xs`/`ys`, matching a point to its row after non-finite pairs are dropped. */
|
|
6
|
+
index: number;
|
|
7
|
+
/** `baseline → (x, y)`, in data coordinates. */
|
|
8
|
+
drop: [Point, Point];
|
|
9
|
+
marker: Point;
|
|
10
|
+
}
|
|
11
|
+
/** @category Math */
|
|
12
|
+
export interface StemOptions {
|
|
13
|
+
/** The y value each drop line starts from. @default 0 */
|
|
14
|
+
baseline?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One drop line and marker per finite `(x, y)` pair, paired by index.
|
|
18
|
+
*
|
|
19
|
+
* @category Math & helpers
|
|
20
|
+
*/
|
|
21
|
+
export declare function stemPoints(xs: readonly number[], ys: readonly number[], options?: StemOptions): StemPoint[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scatter marker symbols: square, diamond, triangle, cross or star, each
|
|
3
|
+
* sized to the area of a circle of radius `r` so shapes read as equal sizes.
|
|
4
|
+
*/
|
|
5
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
6
|
+
/**
|
|
7
|
+
* The marker shapes a `Scatter` can draw.
|
|
8
|
+
*
|
|
9
|
+
* @category Math & helpers
|
|
10
|
+
*/
|
|
11
|
+
export type SymbolName = "circle" | "square" | "diamond" | "triangle" | "cross" | "star";
|
|
12
|
+
/**
|
|
13
|
+
* The symbols in the order a series cycles through them: most distinct first.
|
|
14
|
+
*
|
|
15
|
+
* @category Math & helpers
|
|
16
|
+
*/
|
|
17
|
+
export declare const SYMBOLS: readonly SymbolName[];
|
|
18
|
+
/**
|
|
19
|
+
* The outline (open ring) of `symbol` centred on `(cx, cy)`, with the area
|
|
20
|
+
* of a circle of radius `r`. A circle comes back as a 32-gon.
|
|
21
|
+
*
|
|
22
|
+
* @returns The vertices, counter-clockwise.
|
|
23
|
+
* @category Math & helpers
|
|
24
|
+
*/
|
|
25
|
+
export declare function symbolPolygon(symbol: SymbolName, cx: number, cy: number, r: number): Point[];
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node-link tree layouts (the tidy tree and the cluster dendrogram) over a
|
|
3
|
+
* nested tree of plain objects, plus the polyline of one link. Every node is
|
|
4
|
+
* kept. Coordinates are in the layout's box: `x` along the breadth axis
|
|
5
|
+
* (`[0, width]`), `y` along the depth axis (root at 0, deepest at `height`).
|
|
6
|
+
*/
|
|
7
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
8
|
+
import type { HierarchyNodeInfo, HierarchyOptions } from "./hierarchy.js";
|
|
9
|
+
/**
|
|
10
|
+
* Node-link layout: `"tidy"` places each level at its own depth with parents
|
|
11
|
+
* centred over their children; `"cluster"` is a dendrogram, every leaf at
|
|
12
|
+
* the far depth.
|
|
13
|
+
*
|
|
14
|
+
* @category Math & helpers
|
|
15
|
+
*/
|
|
16
|
+
export type TreeLayoutKind = "tidy" | "cluster";
|
|
17
|
+
/** @category Math */
|
|
18
|
+
export interface TreeLayoutOptions<T> extends HierarchyOptions<T> {
|
|
19
|
+
/** Which layout; see {@link TreeLayoutKind}. @default "tidy" */
|
|
20
|
+
layout?: TreeLayoutKind;
|
|
21
|
+
/** Extent of the breadth axis (`x`, siblings side by side). @default 1 */
|
|
22
|
+
width?: number;
|
|
23
|
+
/** Extent of the depth axis (`y`, root at 0). @default 1 */
|
|
24
|
+
height?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Gap between neighbours with different parents, relative to the sibling
|
|
27
|
+
* gap (1); 1 spaces every neighbour evenly.
|
|
28
|
+
* @default 2
|
|
29
|
+
*/
|
|
30
|
+
separation?: number;
|
|
31
|
+
/** A leaf's value; geometry does not depend on it. Omitted, every node's value is its leaf count. */
|
|
32
|
+
value?: (datum: T, index: number) => number;
|
|
33
|
+
/** Order siblings by descending value. @default false */
|
|
34
|
+
sort?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* A node's height above the leaves (a dendrogram's merge distance),
|
|
37
|
+
* placing it along the depth axis instead of its depth: the greatest
|
|
38
|
+
* distance at `y = 0`, 0 at `y = height`. A parent's missing or too-small
|
|
39
|
+
* distance is raised to its tallest child's.
|
|
40
|
+
*/
|
|
41
|
+
distance?: (datum: T, index: number) => number;
|
|
42
|
+
/**
|
|
43
|
+
* Lay out for a radial tree, dividing neighbour gaps by depth. Pair with
|
|
44
|
+
* `width = 2π` and {@link radialTreePoint}.
|
|
45
|
+
* @default false
|
|
46
|
+
*/
|
|
47
|
+
radial?: boolean;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* One laid-out tree node: {@link HierarchyNodeInfo} plus its position.
|
|
51
|
+
*
|
|
52
|
+
* @category Math & helpers
|
|
53
|
+
*/
|
|
54
|
+
export interface TreeNode<T> extends HierarchyNodeInfo<T> {
|
|
55
|
+
/** Position along the breadth axis, in `[0, width]`. */
|
|
56
|
+
x: number;
|
|
57
|
+
/** Position along the depth axis: 0 for the root, up to `height`. */
|
|
58
|
+
y: number;
|
|
59
|
+
/** The leaf's value, or the sum of a parent's leaves (the leaf count without `value`); may be 0. */
|
|
60
|
+
value: number;
|
|
61
|
+
/** The node's height above the leaves: its raised `distance` when given, else its height in levels. */
|
|
62
|
+
distance: number;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* How a parent-child link is drawn: `"curve"`, a cubic leaving and reaching
|
|
66
|
+
* along the depth axis; `"elbow"`, a right-angled dendrogram bracket.
|
|
67
|
+
*
|
|
68
|
+
* @category Math & helpers
|
|
69
|
+
*/
|
|
70
|
+
export type TreeLinkShape = "curve" | "elbow";
|
|
71
|
+
/** @category Math */
|
|
72
|
+
export interface TreeLinkOptions {
|
|
73
|
+
/** Points sampled along a `"curve"` link, ends included. @default 24 */
|
|
74
|
+
samples?: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* A node-link tree layout: the tidy tree (`layout: "tidy"`) or the
|
|
78
|
+
* dendrogram (`"cluster"`). The outermost nodes keep half a gap from the
|
|
79
|
+
* edges, so a lone root sits at `width / 2`. Not the graph `treeLayout` in
|
|
80
|
+
* `@sophistry/core/geometry`.
|
|
81
|
+
*
|
|
82
|
+
* @returns Every node in pre-order, or `[]` when the box is empty.
|
|
83
|
+
* @throws {Error} If the tree contains a cycle.
|
|
84
|
+
* @category Math & helpers
|
|
85
|
+
*/
|
|
86
|
+
export declare function hierarchyTreeLayout<T>(root: T, options?: TreeLayoutOptions<T>): TreeNode<T>[];
|
|
87
|
+
/**
|
|
88
|
+
* The polyline of one tree link from `parent` to `child`, in layout
|
|
89
|
+
* coordinates; drawn by arc length it grows out of the parent.
|
|
90
|
+
*
|
|
91
|
+
* @returns `samples` points along a curve, or two or three for an elbow.
|
|
92
|
+
* @category Math & helpers
|
|
93
|
+
*/
|
|
94
|
+
export declare function treeLink(parent: Point, child: Point, shape: TreeLinkShape, options?: TreeLinkOptions): Point[];
|
|
95
|
+
/**
|
|
96
|
+
* A radial tree point in Cartesian coordinates, y up: `angle` in radians
|
|
97
|
+
* clockwise from 12 o'clock (a node's `x` laid out with `width = 2π`), and
|
|
98
|
+
* `radius` from `center` (a node's `y`).
|
|
99
|
+
*
|
|
100
|
+
* @category Math & helpers
|
|
101
|
+
*/
|
|
102
|
+
export declare function radialTreePoint(angle: number, radius: number, center?: Point): Point;
|
|
103
|
+
/** @category Math */
|
|
104
|
+
export interface RadialTreeLinkOptions extends TreeLinkOptions {
|
|
105
|
+
/** The tree's centre. Defaults to the origin. */
|
|
106
|
+
center?: Point;
|
|
107
|
+
/** Points per radian along an elbow's arc. @default 24 */
|
|
108
|
+
arcDensity?: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The Cartesian polyline of one radial tree link, from `parent` to `child`
|
|
112
|
+
* in layout coordinates (`x` angle, `y` radius). `"curve"` is the cubic in
|
|
113
|
+
* polar coordinates; `"elbow"` runs round the parent's circle, then out.
|
|
114
|
+
*
|
|
115
|
+
* @category Math & helpers
|
|
116
|
+
*/
|
|
117
|
+
export declare function radialTreeLink(parent: Point, child: Point, shape: TreeLinkShape, options?: RadialTreeLinkOptions): Point[];
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contour lines, filled bands and flat pseudocolour over an unstructured
|
|
3
|
+
* triangulation (values at scattered points rather than on a grid). The
|
|
4
|
+
* mesh is the Delaunay triangulation or the caller's own triangles; over
|
|
5
|
+
* each triangle the field is linear. Level conventions match the grid
|
|
6
|
+
* versions: a count of line levels sits strictly inside the data's range, a
|
|
7
|
+
* count of band boundaries spans it inclusively.
|
|
8
|
+
*/
|
|
9
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
10
|
+
import type { ContourLine } from "./contour.js";
|
|
11
|
+
import type { ContourBand } from "./contourf.js";
|
|
12
|
+
/**
|
|
13
|
+
* Three indices into the point arrays, one triangle.
|
|
14
|
+
*
|
|
15
|
+
* @category Math & helpers
|
|
16
|
+
*/
|
|
17
|
+
export type TriangleIndices = readonly [number, number, number];
|
|
18
|
+
/** @category Math */
|
|
19
|
+
export interface TriangulationOptions {
|
|
20
|
+
/** The triangles, as index triples into the point arrays, either winding. Omitted, the points are Delaunay-triangulated. */
|
|
21
|
+
triangles?: readonly TriangleIndices[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* One face of a pseudocolour mesh.
|
|
25
|
+
*
|
|
26
|
+
* @category Math & helpers
|
|
27
|
+
*/
|
|
28
|
+
export interface TripcolorFace {
|
|
29
|
+
/** The triangle's corners, as indices into the point arrays, counter-clockwise. */
|
|
30
|
+
indices: [number, number, number];
|
|
31
|
+
/** The corners in data units, counter-clockwise. */
|
|
32
|
+
points: Point[];
|
|
33
|
+
/** The mean of the corners' values: the face's colour value. */
|
|
34
|
+
value: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The triangles a tri-chart draws: the caller's own, checked and turned
|
|
38
|
+
* counter-clockwise, or the Delaunay triangulation of the points. Triangles
|
|
39
|
+
* with a non-finite corner or no area are dropped.
|
|
40
|
+
*
|
|
41
|
+
* @returns Counter-clockwise index triples into `xs`/`ys`.
|
|
42
|
+
* @throws {RangeError} If an explicit triangle names a point that does not exist.
|
|
43
|
+
* @category Math & helpers
|
|
44
|
+
*/
|
|
45
|
+
export declare function triangulate(xs: readonly number[], ys: readonly number[], options?: TriangulationOptions): [number, number, number][];
|
|
46
|
+
/**
|
|
47
|
+
* Iso-lines of a field sampled at scattered points, by marching triangles.
|
|
48
|
+
*
|
|
49
|
+
* @param zs - The value at each point; triangles touching a non-finite value are skipped.
|
|
50
|
+
* @param levels - Explicit levels, or a count of evenly spaced ones strictly inside the data's range.
|
|
51
|
+
* @returns Polylines tagged with their level, in level order.
|
|
52
|
+
* @throws {RangeError} If an explicit triangle names a point that does not exist.
|
|
53
|
+
* @category Math & helpers
|
|
54
|
+
*/
|
|
55
|
+
export declare function tricontourLines(xs: readonly number[], ys: readonly number[], zs: readonly number[], levels: readonly number[] | number, options?: TriangulationOptions): ContourLine[];
|
|
56
|
+
/**
|
|
57
|
+
* Filled bands of a field sampled at scattered points: each triangle clipped
|
|
58
|
+
* to every band between consecutive boundaries.
|
|
59
|
+
*
|
|
60
|
+
* @param zs - The value at each point; triangles touching a non-finite value are skipped.
|
|
61
|
+
* @param levels - Explicit boundaries, or a count spanning the data (`N` make `N - 1` bands).
|
|
62
|
+
* @returns One {@link ContourBand} per band, its polygons counter-clockwise, one per contributing triangle.
|
|
63
|
+
* @throws {RangeError} If an explicit triangle names a point that does not exist.
|
|
64
|
+
* @category Math & helpers
|
|
65
|
+
*/
|
|
66
|
+
export declare function tricontourBands(xs: readonly number[], ys: readonly number[], zs: readonly number[], levels: readonly number[] | number, options?: TriangulationOptions): ContourBand[];
|
|
67
|
+
/**
|
|
68
|
+
* Flat-shaded pseudocolour faces over scattered points: one per triangle,
|
|
69
|
+
* valued at the mean of its corners.
|
|
70
|
+
*
|
|
71
|
+
* @param zs - The value at each point; triangles touching a non-finite value are skipped.
|
|
72
|
+
* @returns One face per drawable triangle, in triangulation order.
|
|
73
|
+
* @throws {RangeError} If an explicit triangle names a point that does not exist.
|
|
74
|
+
* @category Math & helpers
|
|
75
|
+
*/
|
|
76
|
+
export declare function tripcolorFaces(xs: readonly number[], ys: readonly number[], zs: readonly number[], options?: TriangulationOptions): TripcolorFace[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/** Violin geometry: a mirrored Gaussian kernel-density silhouette per group. */
|
|
2
|
+
import type { Point } from "@sophistry/core/geometry";
|
|
3
|
+
/** @category Math */
|
|
4
|
+
export interface KdePoint {
|
|
5
|
+
x: number;
|
|
6
|
+
density: number;
|
|
7
|
+
}
|
|
8
|
+
/** @category Math */
|
|
9
|
+
export interface GaussianKdeOptions {
|
|
10
|
+
/** Kernel bandwidth. Defaults to Silverman's rule of thumb. */
|
|
11
|
+
bandwidth?: number;
|
|
12
|
+
/** How many evenly spaced points to sample the density at. @default 80 */
|
|
13
|
+
samples?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The span to sample over. Defaults to the finite extent of `values`, padded by `3 * bandwidth`
|
|
16
|
+
* each side.
|
|
17
|
+
*/
|
|
18
|
+
domain?: [number, number];
|
|
19
|
+
}
|
|
20
|
+
/** @category Math */
|
|
21
|
+
export interface ViolinRingOptions {
|
|
22
|
+
/** Kernel bandwidth. Defaults to Silverman's rule of thumb. */
|
|
23
|
+
bandwidth?: number;
|
|
24
|
+
/** How many evenly spaced points to sample the density at. @default 80 */
|
|
25
|
+
samples?: number;
|
|
26
|
+
/** How far the silhouette reaches from `center` at its widest. @default 0.4 */
|
|
27
|
+
scale?: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* `GaussianKdeOptions.samples`'s default.
|
|
31
|
+
*
|
|
32
|
+
* @category Math & helpers
|
|
33
|
+
*/
|
|
34
|
+
export declare const DEFAULT_SAMPLES = 80;
|
|
35
|
+
/**
|
|
36
|
+
* `ViolinRingOptions.scale`'s default.
|
|
37
|
+
*
|
|
38
|
+
* @category Math & helpers
|
|
39
|
+
*/
|
|
40
|
+
export declare const DEFAULT_VIOLIN_SCALE = 0.4;
|
|
41
|
+
/**
|
|
42
|
+
* Gaussian kernel density estimate of `values`, sampled at `samples` evenly
|
|
43
|
+
* spaced points across `domain`.
|
|
44
|
+
*
|
|
45
|
+
* @param values - Raw samples; non-finite entries are dropped.
|
|
46
|
+
* @returns `{ x, density }` points ascending in `x`; `[]` for empty input.
|
|
47
|
+
* @category Math & helpers
|
|
48
|
+
*/
|
|
49
|
+
export declare function gaussianKde(values: readonly number[], options?: GaussianKdeOptions): KdePoint[];
|
|
50
|
+
/**
|
|
51
|
+
* One violin's outline: a mirrored KDE silhouette as one open ring, upright
|
|
52
|
+
* (y the data value, x around `center`). Each violin is normalized to its
|
|
53
|
+
* own max density, so every one reaches `scale` at its widest: shapes
|
|
54
|
+
* compare across groups, absolute densities don't.
|
|
55
|
+
*
|
|
56
|
+
* @param center - The slot centre the violin mirrors around, in x data units.
|
|
57
|
+
* @returns The ring in data coordinates; `[]` with fewer than 2 finite values.
|
|
58
|
+
* @category Math & helpers
|
|
59
|
+
*/
|
|
60
|
+
export declare function violinRing(values: readonly number[], center: number, options?: ViolinRingOptions): Point[];
|
|
61
|
+
/**
|
|
62
|
+
* One violin's half-silhouette before placement: the sampled heights
|
|
63
|
+
* (ascending) and the width at each as a share of the widest. Keyed
|
|
64
|
+
* transitions blend these ({@link blendViolinProfiles}) so every frame is a
|
|
65
|
+
* valid violin.
|
|
66
|
+
*
|
|
67
|
+
* @category Math & helpers
|
|
68
|
+
*/
|
|
69
|
+
export interface ViolinProfile {
|
|
70
|
+
/** Where the density was sampled, in data units, ascending. */
|
|
71
|
+
readonly ys: readonly number[];
|
|
72
|
+
/** The width at each of `ys`, as a share of the widest (0..1). */
|
|
73
|
+
readonly widths: readonly number[];
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The profile {@link violinRing} mirrors: the KDE of `values` divided by its
|
|
77
|
+
* largest density.
|
|
78
|
+
*
|
|
79
|
+
* @returns The profile, or null with fewer than 2 finite values or no usable density.
|
|
80
|
+
* @category Math & helpers
|
|
81
|
+
*/
|
|
82
|
+
export declare function violinProfile(values: readonly number[], options?: Pick<ViolinRingOptions, "bandwidth" | "samples">): ViolinProfile | null;
|
|
83
|
+
/**
|
|
84
|
+
* A profile mirrored about `center` and scaled to reach `scale` at its
|
|
85
|
+
* widest: {@link violinRing}'s ring, point for point.
|
|
86
|
+
*
|
|
87
|
+
* @category Math & helpers
|
|
88
|
+
*/
|
|
89
|
+
export declare function violinProfileRing(profile: ViolinProfile, center: number, scale: number): Point[];
|
|
90
|
+
/**
|
|
91
|
+
* Two violin profiles blended at `t` on the union of their heights (each 0
|
|
92
|
+
* beyond its own), so every frame is a valid outline. A missing (null) end
|
|
93
|
+
* is a violin of zero width, so a violin grows out of or shrinks into its
|
|
94
|
+
* centre line.
|
|
95
|
+
*
|
|
96
|
+
* @returns The blended profile; null only when both ends are.
|
|
97
|
+
* @category Math & helpers
|
|
98
|
+
*/
|
|
99
|
+
export declare function blendViolinProfiles(a: ViolinProfile | null, b: ViolinProfile | null, t: number): ViolinProfile | null;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waffle chart math: share out a fixed number of unit cells between
|
|
3
|
+
* categories so the counts sum exactly, and place each cell on the grid.
|
|
4
|
+
* `<Waffle>` is the caller that draws them.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Rounds each value's share of `total` to whole numbers summing to exactly
|
|
8
|
+
* `total` (largest remainder): shares round down, and leftover units go to
|
|
9
|
+
* the largest fractional parts, ties to the earlier entry. Negative and
|
|
10
|
+
* non-finite values count as 0.
|
|
11
|
+
*
|
|
12
|
+
* @param total - The whole to share out; rounded down to an integer.
|
|
13
|
+
* @returns One non-negative integer count per value, summing to `total` (all 0 when nothing is positive).
|
|
14
|
+
* @category Math & helpers
|
|
15
|
+
*/
|
|
16
|
+
export declare function largestRemainder(values: readonly number[], total: number): number[];
|
|
17
|
+
/** @category Math */
|
|
18
|
+
export interface WaffleOptions {
|
|
19
|
+
/** Rows of cells. @default 10 */
|
|
20
|
+
rows?: number;
|
|
21
|
+
/** Columns of cells. @default 10 */
|
|
22
|
+
columns?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* One unit cell of a waffle chart.
|
|
26
|
+
*
|
|
27
|
+
* @category Math & helpers
|
|
28
|
+
*/
|
|
29
|
+
export interface WaffleCell {
|
|
30
|
+
/** Place in fill order, 0-based: the bottom-left cell is 0. */
|
|
31
|
+
rank: number;
|
|
32
|
+
/** Row, counted up from the bottom (0 is the bottom row). */
|
|
33
|
+
row: number;
|
|
34
|
+
/** Column, counted from the left. */
|
|
35
|
+
column: number;
|
|
36
|
+
/** Index of the value this cell counts towards, or -1 for an empty cell. */
|
|
37
|
+
category: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Every cell of a `rows × columns` waffle in fill order, assigned to
|
|
41
|
+
* categories by {@link largestRemainder}. Cells fill row by row from the
|
|
42
|
+
* bottom-left, each category one contiguous run in data order.
|
|
43
|
+
*
|
|
44
|
+
* @param values - One value per category; negative and non-finite count as 0.
|
|
45
|
+
* @returns `rows × columns` cells by `rank`; all empty (`category: -1`) when no value is positive.
|
|
46
|
+
* @category Math & helpers
|
|
47
|
+
*/
|
|
48
|
+
export declare function waffleCells(values: readonly number[], options?: WaffleOptions): WaffleCell[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Waterfall steps: a running total broken into the changes that built it.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* One bar of a waterfall: where it starts and ends in data units, and what
|
|
6
|
+
* kind of step it is.
|
|
7
|
+
*
|
|
8
|
+
* @category Math & helpers
|
|
9
|
+
*/
|
|
10
|
+
export interface WaterfallStep {
|
|
11
|
+
/** The running total before this step (0 for a total bar). */
|
|
12
|
+
base: number;
|
|
13
|
+
/** The running total after this step. */
|
|
14
|
+
end: number;
|
|
15
|
+
/** The change itself, `end - base`. */
|
|
16
|
+
delta: number;
|
|
17
|
+
/** `"up"` or `"down"` for a change, `"total"` for a bar standing on zero. */
|
|
18
|
+
kind: "up" | "down" | "total";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Turns changes into floating bars, each starting where the running total
|
|
22
|
+
* stood. An entry flagged as a total is drawn from zero to the running total
|
|
23
|
+
* (its own value ignored). Non-finite changes count as 0.
|
|
24
|
+
*
|
|
25
|
+
* @param totals - Which entries are subtotal/total bars. Defaults to none.
|
|
26
|
+
* @category Math & helpers
|
|
27
|
+
*/
|
|
28
|
+
export declare function waterfallSteps(deltas: readonly number[], totals?: readonly boolean[]): WaterfallStep[];
|