@tetrascience-npm/ts-lib-viz 0.0.0-stage → 0.1.5
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 +202 -0
- package/README.md +2171 -2
- package/dist/src/builder/PlotPanel.d.ts +42 -0
- package/dist/src/builder/PlotPanel.js +433 -0
- package/dist/src/builder/Popover.d.ts +37 -0
- package/dist/src/builder/Popover.js +32 -0
- package/dist/src/builder/Stepper.d.ts +21 -0
- package/dist/src/builder/Stepper.js +41 -0
- package/dist/src/builder/index.d.ts +10 -0
- package/dist/src/builder/index.js +10 -0
- package/dist/src/core/adapters.d.ts +86 -0
- package/dist/src/core/adapters.js +219 -0
- package/dist/src/core/aggregate.d.ts +74 -0
- package/dist/src/core/aggregate.js +102 -0
- package/dist/src/core/annotations.d.ts +34 -0
- package/dist/src/core/annotations.js +71 -0
- package/dist/src/core/band-order.d.ts +86 -0
- package/dist/src/core/band-order.js +132 -0
- package/dist/src/core/binning.d.ts +123 -0
- package/dist/src/core/binning.js +193 -0
- package/dist/src/core/bounds.d.ts +40 -0
- package/dist/src/core/bounds.js +107 -0
- package/dist/src/core/brush.d.ts +73 -0
- package/dist/src/core/brush.js +102 -0
- package/dist/src/core/build.d.ts +322 -0
- package/dist/src/core/build.js +496 -0
- package/dist/src/core/camera.d.ts +152 -0
- package/dist/src/core/camera.js +303 -0
- package/dist/src/core/capabilities.d.ts +24 -0
- package/dist/src/core/capabilities.js +307 -0
- package/dist/src/core/chord.d.ts +49 -0
- package/dist/src/core/chord.js +57 -0
- package/dist/src/core/circular.d.ts +83 -0
- package/dist/src/core/circular.js +63 -0
- package/dist/src/core/cluster.d.ts +136 -0
- package/dist/src/core/cluster.js +607 -0
- package/dist/src/core/critique.d.ts +92 -0
- package/dist/src/core/critique.js +905 -0
- package/dist/src/core/density.d.ts +38 -0
- package/dist/src/core/density.js +82 -0
- package/dist/src/core/figure-set.d.ts +34 -0
- package/dist/src/core/figure-set.js +55 -0
- package/dist/src/core/finding-codes.d.ts +10 -0
- package/dist/src/core/finding-codes.js +1 -0
- package/dist/src/core/fit-types.d.ts +46 -0
- package/dist/src/core/fit-types.js +7 -0
- package/dist/src/core/fitter.d.ts +62 -0
- package/dist/src/core/fitter.js +102 -0
- package/dist/src/core/frame-geometry.d.ts +407 -0
- package/dist/src/core/frame-geometry.js +612 -0
- package/dist/src/core/frame.d.ts +329 -0
- package/dist/src/core/frame.js +1432 -0
- package/dist/src/core/geom-table.d.ts +503 -0
- package/dist/src/core/geom-table.js +484 -0
- package/dist/src/core/geom-types.d.ts +182 -0
- package/dist/src/core/geom-types.js +17 -0
- package/dist/src/core/grammar.d.ts +359 -0
- package/dist/src/core/grammar.js +397 -0
- package/dist/src/core/heat-reductions.d.ts +36 -0
- package/dist/src/core/heat-reductions.js +133 -0
- package/dist/src/core/hexbin.d.ts +84 -0
- package/dist/src/core/hexbin.js +168 -0
- package/dist/src/core/hierarchy.d.ts +59 -0
- package/dist/src/core/hierarchy.js +248 -0
- package/dist/src/core/hit.d.ts +75 -0
- package/dist/src/core/hit.js +37 -0
- package/dist/src/core/index.d.ts +33 -0
- package/dist/src/core/index.js +18 -0
- package/dist/src/core/internal.d.ts +58 -0
- package/dist/src/core/internal.js +58 -0
- package/dist/src/core/labels.d.ts +37 -0
- package/dist/src/core/labels.js +54 -0
- package/dist/src/core/layers.d.ts +594 -0
- package/dist/src/core/layers.js +2892 -0
- package/dist/src/core/load.d.ts +17 -0
- package/dist/src/core/load.js +356 -0
- package/dist/src/core/marginal.d.ts +65 -0
- package/dist/src/core/marginal.js +116 -0
- package/dist/src/core/mesh.d.ts +69 -0
- package/dist/src/core/mesh.js +237 -0
- package/dist/src/core/omission.d.ts +41 -0
- package/dist/src/core/omission.js +62 -0
- package/dist/src/core/palette-sets.d.ts +623 -0
- package/dist/src/core/palette-sets.js +1058 -0
- package/dist/src/core/palette.d.ts +871 -0
- package/dist/src/core/palette.js +511 -0
- package/dist/src/core/plot-data.d.ts +71 -0
- package/dist/src/core/plot-data.js +82 -0
- package/dist/src/core/predicate.d.ts +50 -0
- package/dist/src/core/predicate.js +20 -0
- package/dist/src/core/profile.d.ts +111 -0
- package/dist/src/core/profile.js +221 -0
- package/dist/src/core/readout.d.ts +108 -0
- package/dist/src/core/readout.js +215 -0
- package/dist/src/core/region.d.ts +56 -0
- package/dist/src/core/region.js +101 -0
- package/dist/src/core/rings.d.ts +96 -0
- package/dist/src/core/rings.js +171 -0
- package/dist/src/core/rules.d.ts +45 -0
- package/dist/src/core/rules.js +69 -0
- package/dist/src/core/sankey.d.ts +49 -0
- package/dist/src/core/sankey.js +96 -0
- package/dist/src/core/select.d.ts +52 -0
- package/dist/src/core/select.js +216 -0
- package/dist/src/core/side-track.d.ts +98 -0
- package/dist/src/core/side-track.js +197 -0
- package/dist/src/core/sizing.d.ts +54 -0
- package/dist/src/core/sizing.js +37 -0
- package/dist/src/core/spec-edit.d.ts +68 -0
- package/dist/src/core/spec-edit.js +105 -0
- package/dist/src/core/spec.d.ts +1111 -0
- package/dist/src/core/spec.js +39 -0
- package/dist/src/core/stats.d.ts +161 -0
- package/dist/src/core/stats.js +318 -0
- package/dist/src/core/tick-format.d.ts +21 -0
- package/dist/src/core/tick-format.js +87 -0
- package/dist/src/core/tokens.d.ts +47 -0
- package/dist/src/core/tokens.js +138 -0
- package/dist/src/core/transform.d.ts +21 -0
- package/dist/src/core/transform.js +19 -0
- package/dist/src/core/voxels.d.ts +53 -0
- package/dist/src/core/voxels.js +129 -0
- package/dist/src/core/zoom.d.ts +76 -0
- package/dist/src/core/zoom.js +103 -0
- package/dist/src/graph/GraphSurface.d.ts +127 -0
- package/dist/src/graph/GraphSurface.js +423 -0
- package/dist/src/graph/data.d.ts +103 -0
- package/dist/src/graph/data.js +140 -0
- package/dist/src/graph/index.d.ts +7 -0
- package/dist/src/graph/index.js +7 -0
- package/dist/src/mcp/data.d.ts +28 -0
- package/dist/src/mcp/data.js +131 -0
- package/dist/src/mcp/index.d.ts +7 -0
- package/dist/src/mcp/index.js +7 -0
- package/dist/src/mcp/paths.d.ts +12 -0
- package/dist/src/mcp/paths.js +30 -0
- package/dist/src/mcp/render.d.ts +67 -0
- package/dist/src/mcp/render.js +189 -0
- package/dist/src/mcp/server.d.ts +7 -0
- package/dist/src/mcp/server.js +25 -0
- package/dist/src/mcp/tools.d.ts +82 -0
- package/dist/src/mcp/tools.js +412 -0
- package/dist/src/react/BrushLayer.d.ts +20 -0
- package/dist/src/react/BrushLayer.js +98 -0
- package/dist/src/react/ColorLegend.d.ts +45 -0
- package/dist/src/react/ColorLegend.js +64 -0
- package/dist/src/react/Figure.d.ts +19 -0
- package/dist/src/react/Figure.js +6 -0
- package/dist/src/react/Frame.d.ts +87 -0
- package/dist/src/react/Frame.js +192 -0
- package/dist/src/react/MarkLegend.d.ts +32 -0
- package/dist/src/react/MarkLegend.js +24 -0
- package/dist/src/react/SeriesLegend.d.ts +38 -0
- package/dist/src/react/SeriesLegend.js +27 -0
- package/dist/src/react/SizeLegend.d.ts +24 -0
- package/dist/src/react/SizeLegend.js +25 -0
- package/dist/src/react/Toolbar.d.ts +109 -0
- package/dist/src/react/Toolbar.js +483 -0
- package/dist/src/react/Tooltip.d.ts +37 -0
- package/dist/src/react/Tooltip.js +59 -0
- package/dist/src/react/Viz.d.ts +112 -0
- package/dist/src/react/Viz.js +1311 -0
- package/dist/src/react/export.d.ts +32 -0
- package/dist/src/react/export.js +181 -0
- package/dist/src/react/geoms/Area.d.ts +38 -0
- package/dist/src/react/geoms/Area.js +48 -0
- package/dist/src/react/geoms/Bars.d.ts +130 -0
- package/dist/src/react/geoms/Bars.js +164 -0
- package/dist/src/react/geoms/Box.d.ts +50 -0
- package/dist/src/react/geoms/Box.js +32 -0
- package/dist/src/react/geoms/Chord.d.ts +60 -0
- package/dist/src/react/geoms/Chord.js +78 -0
- package/dist/src/react/geoms/Contour.d.ts +44 -0
- package/dist/src/react/geoms/Contour.js +78 -0
- package/dist/src/react/geoms/DensityCurve.d.ts +30 -0
- package/dist/src/react/geoms/DensityCurve.js +38 -0
- package/dist/src/react/geoms/FitCurve.d.ts +26 -0
- package/dist/src/react/geoms/FitCurve.js +52 -0
- package/dist/src/react/geoms/Freqpoly.d.ts +30 -0
- package/dist/src/react/geoms/Freqpoly.js +45 -0
- package/dist/src/react/geoms/Gauge.d.ts +42 -0
- package/dist/src/react/geoms/Gauge.js +90 -0
- package/dist/src/react/geoms/Heatmap.d.ts +79 -0
- package/dist/src/react/geoms/Heatmap.js +51 -0
- package/dist/src/react/geoms/Hexbin.d.ts +74 -0
- package/dist/src/react/geoms/Hexbin.js +89 -0
- package/dist/src/react/geoms/Icicle.d.ts +38 -0
- package/dist/src/react/geoms/Icicle.js +9 -0
- package/dist/src/react/geoms/Ideogram.d.ts +58 -0
- package/dist/src/react/geoms/Ideogram.js +77 -0
- package/dist/src/react/geoms/Interval.d.ts +30 -0
- package/dist/src/react/geoms/Interval.js +39 -0
- package/dist/src/react/geoms/Line.d.ts +39 -0
- package/dist/src/react/geoms/Line.js +52 -0
- package/dist/src/react/geoms/Parallel.d.ts +38 -0
- package/dist/src/react/geoms/Parallel.js +131 -0
- package/dist/src/react/geoms/Pie.d.ts +62 -0
- package/dist/src/react/geoms/Pie.js +59 -0
- package/dist/src/react/geoms/Points.d.ts +84 -0
- package/dist/src/react/geoms/Points.js +207 -0
- package/dist/src/react/geoms/Points3d.d.ts +49 -0
- package/dist/src/react/geoms/Points3d.js +58 -0
- package/dist/src/react/geoms/Radar.d.ts +39 -0
- package/dist/src/react/geoms/Radar.js +59 -0
- package/dist/src/react/geoms/Range.d.ts +31 -0
- package/dist/src/react/geoms/Range.js +20 -0
- package/dist/src/react/geoms/RingStack.d.ts +39 -0
- package/dist/src/react/geoms/RingStack.js +65 -0
- package/dist/src/react/geoms/Rule.d.ts +29 -0
- package/dist/src/react/geoms/Rule.js +51 -0
- package/dist/src/react/geoms/Sankey.d.ts +24 -0
- package/dist/src/react/geoms/Sankey.js +51 -0
- package/dist/src/react/geoms/Segment.d.ts +36 -0
- package/dist/src/react/geoms/Segment.js +39 -0
- package/dist/src/react/geoms/Sunburst.d.ts +46 -0
- package/dist/src/react/geoms/Sunburst.js +64 -0
- package/dist/src/react/geoms/Surface.d.ts +32 -0
- package/dist/src/react/geoms/Surface.js +49 -0
- package/dist/src/react/geoms/Text.d.ts +35 -0
- package/dist/src/react/geoms/Text.js +40 -0
- package/dist/src/react/geoms/Treemap.d.ts +39 -0
- package/dist/src/react/geoms/Treemap.js +16 -0
- package/dist/src/react/geoms/Violin.d.ts +56 -0
- package/dist/src/react/geoms/Violin.js +60 -0
- package/dist/src/react/geoms/Volume.d.ts +37 -0
- package/dist/src/react/geoms/Volume.js +40 -0
- package/dist/src/react/geoms/Waterfall.d.ts +43 -0
- package/dist/src/react/geoms/Waterfall.js +18 -0
- package/dist/src/react/geoms/cube-stage.d.ts +39 -0
- package/dist/src/react/geoms/cube-stage.js +85 -0
- package/dist/src/react/geoms/hierarchy-cells.d.ts +42 -0
- package/dist/src/react/geoms/hierarchy-cells.js +59 -0
- package/dist/src/react/geoms/sector-axis.d.ts +66 -0
- package/dist/src/react/geoms/sector-axis.js +99 -0
- package/dist/src/react/gl/GlMesh.d.ts +22 -0
- package/dist/src/react/gl/GlMesh.js +78 -0
- package/dist/src/react/gl/GlPoints.d.ts +45 -0
- package/dist/src/react/gl/GlPoints.js +117 -0
- package/dist/src/react/gl/GlVolume.d.ts +28 -0
- package/dist/src/react/gl/GlVolume.js +112 -0
- package/dist/src/react/gl/GlWalls.d.ts +24 -0
- package/dist/src/react/gl/GlWalls.js +55 -0
- package/dist/src/react/gl/context.d.ts +71 -0
- package/dist/src/react/gl/context.js +98 -0
- package/dist/src/react/gl/encode.d.ts +120 -0
- package/dist/src/react/gl/encode.js +215 -0
- package/dist/src/react/gl/index.d.ts +10 -0
- package/dist/src/react/gl/index.js +8 -0
- package/dist/src/react/gl/refresh.d.ts +7 -0
- package/dist/src/react/gl/refresh.js +19 -0
- package/dist/src/react/gl/renderer.d.ts +377 -0
- package/dist/src/react/gl/renderer.js +1081 -0
- package/dist/src/react/gl/shaders.d.ts +92 -0
- package/dist/src/react/gl/shaders.js +405 -0
- package/dist/src/react/gl/surface.d.ts +31 -0
- package/dist/src/react/gl/surface.js +73 -0
- package/dist/src/react/index.d.ts +12 -0
- package/dist/src/react/index.js +11 -0
- package/dist/src/react/orbit.d.ts +38 -0
- package/dist/src/react/orbit.js +81 -0
- package/dist/src/react/sides/DendrogramPanel.d.ts +32 -0
- package/dist/src/react/sides/DendrogramPanel.js +39 -0
- package/dist/src/react/sides/DensityPanel.d.ts +31 -0
- package/dist/src/react/sides/DensityPanel.js +37 -0
- package/dist/src/react/sides/HistogramPanel.d.ts +30 -0
- package/dist/src/react/sides/HistogramPanel.js +18 -0
- package/dist/src/react/sides/RugPanel.d.ts +28 -0
- package/dist/src/react/sides/RugPanel.js +21 -0
- package/dist/src/react/sides/TrackPanel.d.ts +37 -0
- package/dist/src/react/sides/TrackPanel.js +27 -0
- package/dist/src/react/theme.d.ts +48 -0
- package/dist/src/react/theme.js +148 -0
- package/dist/src/react/useFits.d.ts +26 -0
- package/dist/src/react/useFits.js +62 -0
- package/dist/src/react/useZoom.d.ts +50 -0
- package/dist/src/react/useZoom.js +141 -0
- package/package.json +164 -5
- package/theme/default.css +62 -0
|
@@ -0,0 +1,407 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The frame's arithmetic, apart from its drawing.
|
|
3
|
+
*
|
|
4
|
+
* Axis specs, tick stepping and the plot area inside a margin. The frame derivation and the zoom
|
|
5
|
+
* pass read these without a DOM.
|
|
6
|
+
*/
|
|
7
|
+
import { type Metrics } from "./sizing.js";
|
|
8
|
+
import type { SidePanel } from "./spec.js";
|
|
9
|
+
import { type AxisTransform } from "./transform.js";
|
|
10
|
+
/**
|
|
11
|
+
* Tick length and type size an axis falls back to.
|
|
12
|
+
*
|
|
13
|
+
* The regular column of `METRICS`. A spec built with metrics has its own resolved values.
|
|
14
|
+
*/
|
|
15
|
+
export declare const TICK_LEN: number;
|
|
16
|
+
export declare const TICK_PX: number;
|
|
17
|
+
/**
|
|
18
|
+
* How far above the plot area a vertical axis title draws.
|
|
19
|
+
*
|
|
20
|
+
* `Frame` draws the title at this offset and the critic measures the top tick label against it.
|
|
21
|
+
*/
|
|
22
|
+
export declare const Y_TITLE_ABOVE = 5;
|
|
23
|
+
/**
|
|
24
|
+
* How an axis draws itself, apart from what it measures.
|
|
25
|
+
*
|
|
26
|
+
* `labelTicks` is off for an inner panel of a small multiple. The dashes stay.
|
|
27
|
+
*/
|
|
28
|
+
export interface AxisChrome {
|
|
29
|
+
labelTicks?: boolean;
|
|
30
|
+
/** Width of the rule and the ticks. A vertical axis draws its rule only where this is set. */
|
|
31
|
+
lineWidth?: number;
|
|
32
|
+
tickLength?: number;
|
|
33
|
+
/** Which side of the rule the ticks fall on. */
|
|
34
|
+
tickSide?: "out" | "in";
|
|
35
|
+
/** Degrees the tick labels turn, counterclockwise, keeping the end of the label at the tick. */
|
|
36
|
+
tickAngle?: number;
|
|
37
|
+
/** Where the title sits along the rule. A vertical title turns to run along its own axis. */
|
|
38
|
+
titleAlign?: "start" | "center" | "end";
|
|
39
|
+
fontSize?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Weight of the tick and title ink. Muted is the default the ten rules ask for.
|
|
42
|
+
*
|
|
43
|
+
* Strong pulls the text up to geom ink. A band axis carrying identity is read as much as the
|
|
44
|
+
* cells beside it, and muted labels on a grid of categories read as chrome.
|
|
45
|
+
*/
|
|
46
|
+
ink?: "muted" | "strong";
|
|
47
|
+
grid?: boolean;
|
|
48
|
+
minorGrid?: boolean;
|
|
49
|
+
}
|
|
50
|
+
export interface LinearAxisSpec extends AxisChrome {
|
|
51
|
+
domain: [number, number];
|
|
52
|
+
label?: string;
|
|
53
|
+
/** Shorthand for `transform: "log10"`. */
|
|
54
|
+
log?: boolean;
|
|
55
|
+
/** How positions map. A stated transform wins over `log`. */
|
|
56
|
+
transform?: AxisTransform;
|
|
57
|
+
/** Whether the axis runs high to low. */
|
|
58
|
+
reverse?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Whether the domain is epoch milliseconds, read as dates.
|
|
61
|
+
*
|
|
62
|
+
* A sibling of `log`. It decides the scale, and eighteen months wants monthly ticks. Read in
|
|
63
|
+
* `timezone`.
|
|
64
|
+
*/
|
|
65
|
+
time?: boolean;
|
|
66
|
+
/** The clock a time axis reads in. UTC unless `local`. */
|
|
67
|
+
timezone?: "UTC" | "local";
|
|
68
|
+
/**
|
|
69
|
+
* Whether a value outside the domain draws at the end of the scale. On by default. A caller
|
|
70
|
+
* narrowing the domain turns this off and clips the plot area.
|
|
71
|
+
*/
|
|
72
|
+
clamp?: boolean;
|
|
73
|
+
/** A reading past this range draws at its nearer end, in data units. ggplot's `oob = squish`. A zoom keeps it. */
|
|
74
|
+
squish?: [number, number];
|
|
75
|
+
/** Labeled ticks wanted. A log axis reads this as a cap on the decades shown. */
|
|
76
|
+
tickCount?: number;
|
|
77
|
+
/** Interval between labeled ticks, in data units. Takes precedence over `tickCount`. */
|
|
78
|
+
tickStep?: number;
|
|
79
|
+
/** Unlabeled subdivisions between the labeled ticks. On by default. */
|
|
80
|
+
minorTicks?: boolean;
|
|
81
|
+
/** Labeled ticks, in data units. Over `tickStep` and `tickCount`. */
|
|
82
|
+
breaks?: readonly number[];
|
|
83
|
+
/** Unlabeled ticks, in data units. Over `minorTicks`. */
|
|
84
|
+
minorBreaks?: readonly number[];
|
|
85
|
+
format?: (value: number) => string;
|
|
86
|
+
/** What a tick is written as, keyed as `String(value)` writes it. Over `format`. */
|
|
87
|
+
names?: Record<string, string>;
|
|
88
|
+
}
|
|
89
|
+
export interface BandAxisSpec extends AxisChrome {
|
|
90
|
+
/** Categories in the order they should appear. */
|
|
91
|
+
values: string[];
|
|
92
|
+
label?: string;
|
|
93
|
+
padding?: number;
|
|
94
|
+
/**
|
|
95
|
+
* Breaks in the band, each the index in `values` the break falls before.
|
|
96
|
+
*
|
|
97
|
+
* What `gaps_row` states. A break is room and the bands narrow to pay for it.
|
|
98
|
+
*/
|
|
99
|
+
gaps?: number[];
|
|
100
|
+
/**
|
|
101
|
+
* Pixels a break takes.
|
|
102
|
+
*
|
|
103
|
+
* Resolved by the frame off the panel's metrics. The band arithmetic and the content-fit sum
|
|
104
|
+
* read one number.
|
|
105
|
+
*/
|
|
106
|
+
gapSize?: number;
|
|
107
|
+
/**
|
|
108
|
+
* What a category is written as, where that differs from its value.
|
|
109
|
+
*
|
|
110
|
+
* Drawn text. `values` stays the column's own strings. A category with no entry is written as
|
|
111
|
+
* itself.
|
|
112
|
+
*/
|
|
113
|
+
names?: Record<string, string>;
|
|
114
|
+
}
|
|
115
|
+
export type AxisSpec = LinearAxisSpec | BandAxisSpec;
|
|
116
|
+
export declare const isBand: (spec: AxisSpec) => spec is BandAxisSpec;
|
|
117
|
+
export interface AxisEnd {
|
|
118
|
+
axis: "x" | "y";
|
|
119
|
+
end: "low" | "high";
|
|
120
|
+
text: string;
|
|
121
|
+
}
|
|
122
|
+
export interface FrameNote {
|
|
123
|
+
text: string;
|
|
124
|
+
/** Data coordinates. The note survives a rescale. */
|
|
125
|
+
at: {
|
|
126
|
+
x: number | string;
|
|
127
|
+
y: number | string;
|
|
128
|
+
};
|
|
129
|
+
toward?: {
|
|
130
|
+
x: number | string;
|
|
131
|
+
y: number | string;
|
|
132
|
+
};
|
|
133
|
+
align?: "start" | "middle" | "end";
|
|
134
|
+
/** Position in the plot's own list. A note moved on the chart writes back to its record. */
|
|
135
|
+
source: number;
|
|
136
|
+
}
|
|
137
|
+
/** A note after a drag, in the units it was written in. */
|
|
138
|
+
export interface MovedNote {
|
|
139
|
+
source: number;
|
|
140
|
+
at: {
|
|
141
|
+
x: number | string;
|
|
142
|
+
y: number | string;
|
|
143
|
+
};
|
|
144
|
+
toward?: {
|
|
145
|
+
x: number | string;
|
|
146
|
+
y: number | string;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export type Scale = (value: number | string) => number;
|
|
150
|
+
/** The chrome with each fallback taken. The arithmetic reads numbers. */
|
|
151
|
+
export interface Chrome {
|
|
152
|
+
lineWidth: number;
|
|
153
|
+
tickLength: number;
|
|
154
|
+
tickSide: "out" | "in";
|
|
155
|
+
tickAngle: number;
|
|
156
|
+
titleAlign: "start" | "center" | "end";
|
|
157
|
+
fontSize: number;
|
|
158
|
+
rule: boolean;
|
|
159
|
+
ink: "muted" | "strong";
|
|
160
|
+
grid: boolean;
|
|
161
|
+
minorGrid: boolean;
|
|
162
|
+
}
|
|
163
|
+
export declare const chromeOf: (spec: AxisSpec, titleAlign: "start" | "center" | "end") => Chrome;
|
|
164
|
+
/**
|
|
165
|
+
* How wide a run of characters draws at a given type size.
|
|
166
|
+
*
|
|
167
|
+
* Anything reserving room for text reads this one estimate.
|
|
168
|
+
*/
|
|
169
|
+
export declare const textRun: (characters: number, fontSize: number) => number;
|
|
170
|
+
/**
|
|
171
|
+
* Gap between a tick and the label beside it, in pixels.
|
|
172
|
+
*
|
|
173
|
+
* Read by the drawing and by the room reserved for it. One number for both.
|
|
174
|
+
*/
|
|
175
|
+
export declare const LABEL_GAP = 4;
|
|
176
|
+
/**
|
|
177
|
+
* Room the ticks and their labels take outside the plot area.
|
|
178
|
+
*
|
|
179
|
+
* A turned label reaches across. The room it needs is the longest label's width with the turn
|
|
180
|
+
* applied.
|
|
181
|
+
*/
|
|
182
|
+
export declare function tickRoom(chrome: Chrome, labeled: boolean, longest: number, axis: "x" | "y"): number;
|
|
183
|
+
/**
|
|
184
|
+
* Room one label takes along its own axis.
|
|
185
|
+
*
|
|
186
|
+
* The arithmetic above with the axes swapped. A column label needs its whole run and a row label
|
|
187
|
+
* needs one line.
|
|
188
|
+
*/
|
|
189
|
+
export declare function bandReach(chrome: Chrome, longest: number, axis: "x" | "y"): number;
|
|
190
|
+
/**
|
|
191
|
+
* Room one axis needs, for a caller setting the frame's margin.
|
|
192
|
+
*
|
|
193
|
+
* A facet shares one margin across its panels. The chrome belongs to the axis.
|
|
194
|
+
*/
|
|
195
|
+
/**
|
|
196
|
+
* Room a title takes past its own line of type.
|
|
197
|
+
*
|
|
198
|
+
* Half of it opens the gap after the tick labels. The other half is the margin past the title.
|
|
199
|
+
*/
|
|
200
|
+
export declare const TITLE_PAD = 8;
|
|
201
|
+
/** Share of a line of type above its baseline. The rest hangs below it. */
|
|
202
|
+
export declare const ASCENT = 0.75;
|
|
203
|
+
export declare function axisRoom(spec: AxisSpec, axis: "x" | "y",
|
|
204
|
+
/** Longest label in characters, which a caller knows for categories and guesses for numbers. */
|
|
205
|
+
longest: number, hasTitle: boolean): number;
|
|
206
|
+
/** Room a ring leaves between its outer edge and the panel, in pixels. */
|
|
207
|
+
export declare const POLAR_INSET = 10;
|
|
208
|
+
/** A ring's center, its two radii, and the radius its labels sit on. */
|
|
209
|
+
export interface RingLayout {
|
|
210
|
+
cx: number;
|
|
211
|
+
cy: number;
|
|
212
|
+
outer: number;
|
|
213
|
+
/** Zero on a pie. The hole, resolved from the fraction `innerRadius` states. */
|
|
214
|
+
inner: number;
|
|
215
|
+
labelRadius: number;
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Places a ring in a panel of this size.
|
|
219
|
+
*
|
|
220
|
+
* The outer radius comes off the shorter side. `hole` is a fraction of it. Zero draws a pie.
|
|
221
|
+
*/
|
|
222
|
+
export declare function ringLayout(width: number, height: number, hole?: number): RingLayout;
|
|
223
|
+
/** One slice's share of the turn, from one angle to the next. */
|
|
224
|
+
export interface Slice {
|
|
225
|
+
from: number;
|
|
226
|
+
to: number;
|
|
227
|
+
/** Halfway between the two, which is where a label goes. */
|
|
228
|
+
mid: number;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Divides a full turn between the values, in arrival order.
|
|
232
|
+
*
|
|
233
|
+
* A negative reading takes no arc. An empty total returns no slices.
|
|
234
|
+
*/
|
|
235
|
+
export declare function sliceAngles(values: readonly number[]): Slice[];
|
|
236
|
+
/** Where an angle at this radius falls, in the panel's own pixels. */
|
|
237
|
+
export declare const polarPoint: (layout: RingLayout, radius: number, angle: number) => {
|
|
238
|
+
x: number;
|
|
239
|
+
y: number;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Joins two angles at one radius, as an SVG path.
|
|
243
|
+
*
|
|
244
|
+
* The curve is a quadratic bending toward the center. A half-turn link passes through it.
|
|
245
|
+
*/
|
|
246
|
+
export declare function linkPath(layout: RingLayout, radius: number, from: number, to: number): string;
|
|
247
|
+
/**
|
|
248
|
+
* The path of one arc, as SVG.
|
|
249
|
+
*
|
|
250
|
+
* A ring with a hole draws two arcs and two edges. A pie closes through the center.
|
|
251
|
+
*/
|
|
252
|
+
export declare function arcPath(layout: RingLayout, from: number, to: number): string;
|
|
253
|
+
/**
|
|
254
|
+
* Slices with labels that fit around the ring.
|
|
255
|
+
*
|
|
256
|
+
* The label ring's circumference over one label's run. `longest` is the drawn text in characters.
|
|
257
|
+
*/
|
|
258
|
+
export declare function slicesLegible(layout: RingLayout, fontSize: number, longest: number): number;
|
|
259
|
+
/**
|
|
260
|
+
* How far a dial sweeps, in radians.
|
|
261
|
+
*
|
|
262
|
+
* A half turn, opening upward. The arc runs from nine o'clock over the top to three o'clock.
|
|
263
|
+
*/
|
|
264
|
+
export declare const GAUGE_SWEEP: number;
|
|
265
|
+
/**
|
|
266
|
+
* Places a dial in a panel, with an arc of the stated weight.
|
|
267
|
+
*
|
|
268
|
+
* A dial draws a half circle above its center and its number below.
|
|
269
|
+
*/
|
|
270
|
+
export declare function dialLayout(width: number, height: number, weight: number, sweep?: number, scale?: number): RingLayout;
|
|
271
|
+
/**
|
|
272
|
+
* Where one reading falls along a dial, as an angle.
|
|
273
|
+
*
|
|
274
|
+
* Clamped to the ends. A reading outside the range draws pinned at the end.
|
|
275
|
+
*/
|
|
276
|
+
export declare function gaugeAngle(value: number, range: [number, number], sweep?: number): number;
|
|
277
|
+
/** A radar's center, the radius of its outermost ring, and how many spokes divide the turn. */
|
|
278
|
+
export interface SpokeLayout {
|
|
279
|
+
cx: number;
|
|
280
|
+
cy: number;
|
|
281
|
+
radius: number;
|
|
282
|
+
spokes: number;
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Places a radar's rules in a panel.
|
|
286
|
+
*
|
|
287
|
+
* The radius comes off the shorter side. A measure's name draws outside the outermost ring and
|
|
288
|
+
* the radius gives up that room first.
|
|
289
|
+
*/
|
|
290
|
+
export declare function spokeLayout(spokes: number, width: number, height: number): SpokeLayout;
|
|
291
|
+
/**
|
|
292
|
+
* Where a reading falls along one spoke, in panel pixels.
|
|
293
|
+
*
|
|
294
|
+
* `at` runs zero to one along the rule. The first spoke points up and the rest divide the turn
|
|
295
|
+
* clockwise.
|
|
296
|
+
*/
|
|
297
|
+
export declare function spokePoint(layout: SpokeLayout, index: number, at: number): {
|
|
298
|
+
x: number;
|
|
299
|
+
y: number;
|
|
300
|
+
};
|
|
301
|
+
/** Ticks a reader can count from: multiples of the step, landing on round numbers. */
|
|
302
|
+
export declare const TICK_LIMIT = 200;
|
|
303
|
+
export declare function everyStep(domain: [number, number], step: number): number[] | null;
|
|
304
|
+
/**
|
|
305
|
+
* Whole powers of the base on a log axis.
|
|
306
|
+
*
|
|
307
|
+
* `scaleLog.ticks()` returns the minor ticks between decades. Thinned past the cap.
|
|
308
|
+
*/
|
|
309
|
+
export declare function decades(all: number[], cap?: number, base?: 2 | 10): number[];
|
|
310
|
+
/**
|
|
311
|
+
* The plot area inside a frame of this size.
|
|
312
|
+
*
|
|
313
|
+
* A caller that rewrites a domain has to know the pixels the rule runs between.
|
|
314
|
+
*/
|
|
315
|
+
export declare const innerSize: (width: number, height: number, margin: Edges) => {
|
|
316
|
+
width: number;
|
|
317
|
+
height: number;
|
|
318
|
+
};
|
|
319
|
+
/** Tallest a fixed data aspect draws the plot area, as a multiple of its width. */
|
|
320
|
+
export declare const RATIO_CAP = 4;
|
|
321
|
+
/**
|
|
322
|
+
* Plot-area height that holds a fixed data aspect. ggplot's `coord_fixed`.
|
|
323
|
+
*
|
|
324
|
+
* `ratio` is units of y per unit of x on screen, both in transformed space. Null over a band.
|
|
325
|
+
*/
|
|
326
|
+
export declare function fixedHeight(x: AxisSpec, y: AxisSpec, width: number, ratio: number): number | null;
|
|
327
|
+
/** Room taken off each edge, in the shape a margin already has. */
|
|
328
|
+
export interface Edges {
|
|
329
|
+
top: number;
|
|
330
|
+
right: number;
|
|
331
|
+
bottom: number;
|
|
332
|
+
left: number;
|
|
333
|
+
}
|
|
334
|
+
/** One side panel with the box it draws in, in the frame's own coordinates. */
|
|
335
|
+
export interface SideRegion {
|
|
336
|
+
panel: SidePanel;
|
|
337
|
+
x: number;
|
|
338
|
+
y: number;
|
|
339
|
+
width: number;
|
|
340
|
+
height: number;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Room the side panels take off each edge.
|
|
344
|
+
*
|
|
345
|
+
* Answerable from the list alone. The panel size is derived before the frame exists.
|
|
346
|
+
*/
|
|
347
|
+
export declare function sideRoom(sides: readonly SidePanel[] | undefined): Edges;
|
|
348
|
+
/**
|
|
349
|
+
* Where the side panels draw, and what the plot area keeps.
|
|
350
|
+
*
|
|
351
|
+
* A side takes its extent off its own edge before the margin. Two sides on one edge stack
|
|
352
|
+
* outward.
|
|
353
|
+
*/
|
|
354
|
+
export declare function sideLayout(sides: readonly SidePanel[] | undefined, width: number, height: number, margin: Edges): {
|
|
355
|
+
room: Edges;
|
|
356
|
+
inner: {
|
|
357
|
+
width: number;
|
|
358
|
+
height: number;
|
|
359
|
+
};
|
|
360
|
+
inside: Edges;
|
|
361
|
+
regions: SideRegion[];
|
|
362
|
+
};
|
|
363
|
+
/** What a side panel is handed -- the geoms' own scales and the panel it draws for. */
|
|
364
|
+
export interface SideChildProps extends FrameChildProps {
|
|
365
|
+
panel: SidePanel;
|
|
366
|
+
}
|
|
367
|
+
export interface FrameChildProps {
|
|
368
|
+
x: Scale;
|
|
369
|
+
y: Scale;
|
|
370
|
+
/** The value at a pixel along each axis. A band axis answers its nearest category. */
|
|
371
|
+
xInvert: (px: number) => number | string;
|
|
372
|
+
yInvert: (px: number) => number | string;
|
|
373
|
+
/** Category width on a banded axis, zero on a continuous one. */
|
|
374
|
+
xBand: number;
|
|
375
|
+
yBand: number;
|
|
376
|
+
/** Distance between two neighboring band centers, one data unit along a band. Zero on a continuous axis. */
|
|
377
|
+
xStep: number;
|
|
378
|
+
yStep: number;
|
|
379
|
+
width: number;
|
|
380
|
+
height: number;
|
|
381
|
+
/**
|
|
382
|
+
* Type and spacing for the size this panel came out at.
|
|
383
|
+
*
|
|
384
|
+
* A geom takes its radius as a prop. Handed down resolved, and one panel has one answer.
|
|
385
|
+
*/
|
|
386
|
+
metrics: Metrics;
|
|
387
|
+
}
|
|
388
|
+
export declare const scaleKey: (spec: AxisSpec, range: [number, number]) => string;
|
|
389
|
+
export interface Axis {
|
|
390
|
+
scale: Scale;
|
|
391
|
+
/** The value at a pixel, for a caller reading a drag back into the units it was made in. */
|
|
392
|
+
invert: (px: number) => number | string;
|
|
393
|
+
bandwidth: number;
|
|
394
|
+
/** Distance between two neighboring band centers, zero on a continuous axis. */
|
|
395
|
+
step: number;
|
|
396
|
+
/** Ticks that carry a label, unless the caller asked for the dashes alone. */
|
|
397
|
+
ticks: (number | string)[];
|
|
398
|
+
labelTicks: boolean;
|
|
399
|
+
/** Ticks drawn as a shorter dash with no label. The eye reads the interval between majors. */
|
|
400
|
+
minor: number[];
|
|
401
|
+
format: (value: number | string) => string;
|
|
402
|
+
label?: string;
|
|
403
|
+
chrome: Chrome;
|
|
404
|
+
}
|
|
405
|
+
export declare function buildAxis(spec: AxisSpec, range: [number, number], defaultTicks: number, titleAlign: "start" | "center" | "end"): Axis;
|
|
406
|
+
/** The longest label an axis draws, in characters. */
|
|
407
|
+
export declare const longestOf: (axis: Axis) => number;
|