@tetrascience-npm/ts-lib-viz 0.0.0-stage → 0.1.4
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 +28 -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,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A range held on one axis.
|
|
3
|
+
*
|
|
4
|
+
* Records outside the range stop drawing on all axes together. Ranges compose and a second axis
|
|
5
|
+
* narrows what the first left.
|
|
6
|
+
*/
|
|
7
|
+
/** Low and high of a dragged range, in the axis's own units. */
|
|
8
|
+
export type Extent = [number, number];
|
|
9
|
+
/** A range per axis id. An axis with no entry keeps all records. */
|
|
10
|
+
export type AxisRanges = Record<string, Extent>;
|
|
11
|
+
/** What an axis spans, and where it runs in the panel. */
|
|
12
|
+
export interface AxisSpan {
|
|
13
|
+
lo: number;
|
|
14
|
+
hi: number;
|
|
15
|
+
top: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
}
|
|
18
|
+
/** Vertical position of a value on one axis. */
|
|
19
|
+
export declare function placeOn(value: number, span: AxisSpan): number;
|
|
20
|
+
/**
|
|
21
|
+
* The value at a vertical position, clamped to the axis's own range.
|
|
22
|
+
*
|
|
23
|
+
* A drag past the end of the rule reads as the end of it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function valueOn(y: number, span: AxisSpan): number;
|
|
26
|
+
/** A drag read as a range, whichever direction the hand moved. */
|
|
27
|
+
export declare const extentOf: (from: number, to: number) => Extent;
|
|
28
|
+
/** Whether any range is in force. An untouched figure says nothing about a filter. */
|
|
29
|
+
export declare const anyRange: (ranges: AxisRanges) => boolean;
|
|
30
|
+
/** A range added or lifted, as a new set. */
|
|
31
|
+
export declare function setRange(ranges: AxisRanges, axisId: string, extent: Extent | null): AxisRanges;
|
|
32
|
+
/** Whether one record's readings fall inside all the ranges in force. */
|
|
33
|
+
export declare function withinRanges(values: number[], axisIds: string[], ranges: AxisRanges): boolean;
|
|
34
|
+
/** The records the ranges keep, in the order they were built. */
|
|
35
|
+
export declare function keptLines<L extends {
|
|
36
|
+
values: number[];
|
|
37
|
+
}>(lines: L[], axisIds: string[], ranges: AxisRanges): L[];
|
|
38
|
+
/** Where the rules stand across a panel, and the range each one spans. */
|
|
39
|
+
export interface AxisLayout {
|
|
40
|
+
spans: AxisSpan[];
|
|
41
|
+
/** Horizontal position of each rule, left to right. */
|
|
42
|
+
at: number[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Rules spread evenly across a panel.
|
|
46
|
+
*
|
|
47
|
+
* Inset on both sides. The outermost rules take a value label at each end. One rule takes the
|
|
48
|
+
* middle.
|
|
49
|
+
*/
|
|
50
|
+
export declare function axisLayout(axes: readonly {
|
|
51
|
+
lo: number;
|
|
52
|
+
hi: number;
|
|
53
|
+
}[], width: number, height: number, inset: {
|
|
54
|
+
x: number;
|
|
55
|
+
top: number;
|
|
56
|
+
bottom: number;
|
|
57
|
+
}): AxisLayout;
|
|
58
|
+
/**
|
|
59
|
+
* The line running closest to a point.
|
|
60
|
+
*
|
|
61
|
+
* The search runs over the lines. The pointer's segment is arithmetic and each line's height
|
|
62
|
+
* inside it is one interpolation.
|
|
63
|
+
*/
|
|
64
|
+
export declare function nearestLine<L extends {
|
|
65
|
+
values: number[];
|
|
66
|
+
}>(lines: readonly L[], layout: AxisLayout, x: number, y: number, reach?: number): {
|
|
67
|
+
line: L;
|
|
68
|
+
index: number;
|
|
69
|
+
at: {
|
|
70
|
+
x: number;
|
|
71
|
+
y: number;
|
|
72
|
+
};
|
|
73
|
+
} | null;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A range held on one axis.
|
|
3
|
+
*
|
|
4
|
+
* Records outside the range stop drawing on all axes together. Ranges compose and a second axis
|
|
5
|
+
* narrows what the first left.
|
|
6
|
+
*/
|
|
7
|
+
/** Vertical position of a value on one axis. */
|
|
8
|
+
export function placeOn(value, span) {
|
|
9
|
+
const reach = span.hi - span.lo || 1;
|
|
10
|
+
return span.bottom - ((value - span.lo) / reach) * (span.bottom - span.top);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The value at a vertical position, clamped to the axis's own range.
|
|
14
|
+
*
|
|
15
|
+
* A drag past the end of the rule reads as the end of it.
|
|
16
|
+
*/
|
|
17
|
+
export function valueOn(y, span) {
|
|
18
|
+
const height = span.bottom - span.top || 1;
|
|
19
|
+
const at = span.lo + ((span.bottom - y) / height) * (span.hi - span.lo);
|
|
20
|
+
return Math.min(span.hi, Math.max(span.lo, at));
|
|
21
|
+
}
|
|
22
|
+
/** A drag read as a range, whichever direction the hand moved. */
|
|
23
|
+
export const extentOf = (from, to) => (from <= to ? [from, to] : [to, from]);
|
|
24
|
+
/** Whether any range is in force. An untouched figure says nothing about a filter. */
|
|
25
|
+
export const anyRange = (ranges) => Object.keys(ranges).length > 0;
|
|
26
|
+
/** A range added or lifted, as a new set. */
|
|
27
|
+
export function setRange(ranges, axisId, extent) {
|
|
28
|
+
if (extent)
|
|
29
|
+
return { ...ranges, [axisId]: extent };
|
|
30
|
+
if (!(axisId in ranges))
|
|
31
|
+
return ranges;
|
|
32
|
+
const next = { ...ranges };
|
|
33
|
+
delete next[axisId];
|
|
34
|
+
return next;
|
|
35
|
+
}
|
|
36
|
+
/** Whether one record's readings fall inside all the ranges in force. */
|
|
37
|
+
export function withinRanges(values, axisIds, ranges) {
|
|
38
|
+
for (let at = 0; at < axisIds.length; at += 1) {
|
|
39
|
+
const range = ranges[axisIds[at]];
|
|
40
|
+
if (!range)
|
|
41
|
+
continue;
|
|
42
|
+
const value = values[at];
|
|
43
|
+
/* A missing reading drops the record. NaN fails both comparisons and would otherwise pass. */
|
|
44
|
+
if (value == null || !Number.isFinite(value) || value < range[0] || value > range[1])
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
/** The records the ranges keep, in the order they were built. */
|
|
50
|
+
export function keptLines(lines, axisIds, ranges) {
|
|
51
|
+
if (!anyRange(ranges))
|
|
52
|
+
return lines;
|
|
53
|
+
return lines.filter((line) => withinRanges(line.values, axisIds, ranges));
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Rules spread evenly across a panel.
|
|
57
|
+
*
|
|
58
|
+
* Inset on both sides. The outermost rules take a value label at each end. One rule takes the
|
|
59
|
+
* middle.
|
|
60
|
+
*/
|
|
61
|
+
export function axisLayout(axes, width, height, inset) {
|
|
62
|
+
const usable = Math.max(0, width - inset.x * 2);
|
|
63
|
+
const gap = axes.length > 1 ? usable / (axes.length - 1) : 0;
|
|
64
|
+
return {
|
|
65
|
+
at: axes.map((_, index) => (axes.length > 1 ? inset.x + gap * index : width / 2)),
|
|
66
|
+
spans: axes.map((axis) => ({ lo: axis.lo, hi: axis.hi, top: inset.top, bottom: height - inset.bottom })),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The line running closest to a point.
|
|
71
|
+
*
|
|
72
|
+
* The search runs over the lines. The pointer's segment is arithmetic and each line's height
|
|
73
|
+
* inside it is one interpolation.
|
|
74
|
+
*/
|
|
75
|
+
export function nearestLine(lines, layout, x, y, reach = 6) {
|
|
76
|
+
const { at, spans } = layout;
|
|
77
|
+
if (at.length < 2 || lines.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
/* The pair of rules the pointer falls between, clamped to the run on either overshoot. */
|
|
80
|
+
let seg = 0;
|
|
81
|
+
while (seg < at.length - 2 && x > at[seg + 1])
|
|
82
|
+
seg += 1;
|
|
83
|
+
const left = at[seg];
|
|
84
|
+
const span = at[seg + 1] - left || 1;
|
|
85
|
+
const t = Math.min(1, Math.max(0, (x - left) / span));
|
|
86
|
+
let best = null;
|
|
87
|
+
let closest = reach;
|
|
88
|
+
for (let index = 0; index < lines.length; index += 1) {
|
|
89
|
+
const values = lines[index].values;
|
|
90
|
+
const from = values[seg];
|
|
91
|
+
const to = values[seg + 1];
|
|
92
|
+
if (from == null || to == null)
|
|
93
|
+
continue;
|
|
94
|
+
const height = placeOn(from, spans[seg]) + (placeOn(to, spans[seg + 1]) - placeOn(from, spans[seg])) * t;
|
|
95
|
+
const off = Math.abs(height - y);
|
|
96
|
+
if (off <= closest) {
|
|
97
|
+
closest = off;
|
|
98
|
+
best = { line: lines[index], index, at: { x, y: height } };
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return best;
|
|
102
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authoring, apart from the format it produces.
|
|
3
|
+
*
|
|
4
|
+
* `plot()` takes rows and an aes and `spec()` emits a `ChartSpec`. `StoredSpec` adds where a host
|
|
5
|
+
* keeps it, and the host writes those fields.
|
|
6
|
+
*/
|
|
7
|
+
import type { VizData } from "./adapters.js";
|
|
8
|
+
import type { WaivableCode } from "./finding-codes.js";
|
|
9
|
+
import { type Aesthetic, type BoundTo, type LayerFieldOf, type OptionalAesthetic, type PaintOf, type PartOf, type Parts, type RequiredAesthetic, type StatArgs, type StatOf, type StyleOf } from "./geom-table.js";
|
|
10
|
+
import type { Stat } from "./grammar.js";
|
|
11
|
+
import { type Annotation, type ChartScales, type ChartSpec, type Aes, type FitSpec, type LayerStyle, type LegendOptions, type PlotKind, type LayerSpec, type SidePanel, type SmoothMethod } from "./spec.js";
|
|
12
|
+
/** Fields any layer states, whatever its kind. */
|
|
13
|
+
declare const COMMON_FIELDS: readonly ["name", "axis", "visible", "palette", "scales", "data", "showLegend"];
|
|
14
|
+
type CommonField = (typeof COMMON_FIELDS)[number];
|
|
15
|
+
/** A type's own keys as one object literal, the form a hover and an error print. */
|
|
16
|
+
type Simplify<T> = {
|
|
17
|
+
[K in keyof T]: T[K];
|
|
18
|
+
} & {};
|
|
19
|
+
/**
|
|
20
|
+
* What a layer states for itself as constants, over the aes it inherits.
|
|
21
|
+
*
|
|
22
|
+
* Flat, and narrowed by the kind. `GEOMS` names the style fields and statistic parameters a kind
|
|
23
|
+
* reads. A row listing `bin` takes the bin statistic's parameters. A flat option is a value, and a column
|
|
24
|
+
* binds through `aes`. A kind with no parts takes no `parts` key.
|
|
25
|
+
*/
|
|
26
|
+
export type LayerOptions<K extends PlotKind, S extends Stat = StatOf<K> | Extract<LayerFieldOf<K>, Stat>> = Partial<Pick<LayerSpec, CommonField>> & Partial<Pick<LayerSpec, Exclude<LayerFieldOf<K>, Stat>>> & Partial<Pick<LayerStyle, StyleOf<K> | PaintOf<K>>> & StatArgs<S> & ([PartOf<K>] extends [never] ? unknown : {
|
|
27
|
+
/** Paint for a named part of this geometry. */
|
|
28
|
+
parts?: Parts<K>;
|
|
29
|
+
});
|
|
30
|
+
/** The columns a layer's own aes binds, keyed by the aesthetics its kind reads. */
|
|
31
|
+
export type LayerAes<K extends PlotKind> = {
|
|
32
|
+
[C in RequiredAesthetic<K> | OptionalAesthetic<K>]?: BoundTo<C>;
|
|
33
|
+
};
|
|
34
|
+
/** Keys of an aes holding a defined value. An optional key, or one holding `undefined`, binds nothing. */
|
|
35
|
+
type BoundKeys<A> = Exclude<{
|
|
36
|
+
[C in keyof A]: undefined extends A[C] ? never : C;
|
|
37
|
+
}[keyof A], undefined>;
|
|
38
|
+
/** Aesthetics a kind requires that the plot's aes left unbound. */
|
|
39
|
+
type Unbound<K extends PlotKind, A> = Exclude<RequiredAesthetic<K>, BoundKeys<A>>;
|
|
40
|
+
/**
|
|
41
|
+
* What a layer method takes -- its constants, and an aes for the columns it binds itself.
|
|
42
|
+
*
|
|
43
|
+
* The aes is required, with each required aesthetic the plot's aes left unbound, and optional
|
|
44
|
+
* where the plot's aes bound them all.
|
|
45
|
+
*/
|
|
46
|
+
export type LayerArgs<K extends PlotKind, A> = Simplify<LayerOptions<K> & ([Unbound<K, A>] extends [never] ? {
|
|
47
|
+
aes?: LayerAes<K>;
|
|
48
|
+
} : {
|
|
49
|
+
aes: LayerAes<K> & {
|
|
50
|
+
[C in Unbound<K, A>]: BoundTo<C>;
|
|
51
|
+
};
|
|
52
|
+
})>;
|
|
53
|
+
/** What `layer` takes for a kind typed `PlotKind`: each kind's fields at once. */
|
|
54
|
+
export type AnyLayerOptions = LayerOptions<PlotKind> & {
|
|
55
|
+
aes?: Aes;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* The argument list `layer(kind, ...)` and the kind's own method take.
|
|
59
|
+
*
|
|
60
|
+
* A tuple. The options go missing where the aes bound the required aesthetics, and a required
|
|
61
|
+
* options object names the aesthetics its aes owes. A union of kinds takes the fields of each.
|
|
62
|
+
*/
|
|
63
|
+
export type LayerCall<K extends PlotKind, A> = PlotKind extends K ? [options?: AnyLayerOptions] : [K] extends ["smooth"] ? [options: SmoothOptions<A>] : [K] extends ["hline"] ? [options: RuleArgs<"hline", "yintercept">] : [K] extends ["vline"] ? [options: RuleArgs<"vline", "xintercept">] : [K] extends ["abline"] ? [options?: RuleOptions<"abline"> & {
|
|
64
|
+
slope?: RuleValue;
|
|
65
|
+
intercept?: RuleValue;
|
|
66
|
+
}] : Record<never, never> extends LayerArgs<K, A> ? [options?: LayerArgs<K, A>] : [options: LayerArgs<K, A>];
|
|
67
|
+
/**
|
|
68
|
+
* What a smooth layer states -- the method, its own arguments, and the layer's.
|
|
69
|
+
*
|
|
70
|
+
* Flat, the way `geom_smooth()` reads. `level` and `band` default.
|
|
71
|
+
*/
|
|
72
|
+
export type SmoothOptions<A = Aes> = Simplify<SmoothMethod & LayerArgs<"smooth", A> & {
|
|
73
|
+
level?: number;
|
|
74
|
+
band?: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/** What a fit layer states, over the geom that draws the readings underneath it. */
|
|
77
|
+
export type FitOptions<A = Aes> = Simplify<Omit<FitSpec, "level" | "band"> & Omit<LayerArgs<"point", A>, "fit"> & {
|
|
78
|
+
level?: number;
|
|
79
|
+
band?: boolean;
|
|
80
|
+
}>;
|
|
81
|
+
/** What `labs` names: the headline, its subtitle, the caption, and a title per aesthetic scale. */
|
|
82
|
+
export type Labs = {
|
|
83
|
+
headline?: string;
|
|
84
|
+
subtitle?: string;
|
|
85
|
+
caption?: string;
|
|
86
|
+
} & {
|
|
87
|
+
[A in keyof ChartScales]?: string;
|
|
88
|
+
};
|
|
89
|
+
/** A position per reference line, one number or a list of them. A column binds through `aes`. */
|
|
90
|
+
export type RuleValue = number | readonly number[];
|
|
91
|
+
/** The three reference kinds. */
|
|
92
|
+
type RuleKind = "hline" | "vline" | "abline";
|
|
93
|
+
/**
|
|
94
|
+
* What a reference layer states beside its own positions: `color`, `linewidth`, `linetype` and
|
|
95
|
+
* `alpha` constants, and the columns its aes maps.
|
|
96
|
+
*
|
|
97
|
+
* `label` is rule 4's text: one per line or one for all. A column of labels binds through `aes.label`.
|
|
98
|
+
*/
|
|
99
|
+
export type RuleOptions<K extends RuleKind = RuleKind> = LayerOptions<K> & {
|
|
100
|
+
aes?: LayerAes<K>;
|
|
101
|
+
label?: string | readonly string[];
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* A reference layer with its position `P`, numbers flat or a column the aes binds.
|
|
105
|
+
*
|
|
106
|
+
* The flat position goes optional where the aes binds it.
|
|
107
|
+
*/
|
|
108
|
+
type RuleArgs<K extends RuleKind, P extends RequiredAesthetic<K>> = RuleOptions<K> & ({
|
|
109
|
+
[Q in P]: RuleValue;
|
|
110
|
+
} | ({
|
|
111
|
+
[Q in P]?: RuleValue;
|
|
112
|
+
} & {
|
|
113
|
+
aes: {
|
|
114
|
+
[Q in P]: string;
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
/** A value `annotate` writes into its rows: one for all of them, or one per row. */
|
|
118
|
+
export type AnnotateValue = string | number | readonly (string | number)[];
|
|
119
|
+
/**
|
|
120
|
+
* What `annotate(kind, values)` takes, ggplot's `annotate()`.
|
|
121
|
+
*
|
|
122
|
+
* The kind's required aesthetics take a value or a list, and a list makes a row each. Each other key
|
|
123
|
+
* is a constant. A reference kind takes numbers for its positions, and no aes or rows.
|
|
124
|
+
*/
|
|
125
|
+
export type AnnotateValues<K extends PlotKind> = K extends "hline" | "vline" | "abline" ? Omit<RuleOptions, "aes" | "data"> & {
|
|
126
|
+
[C in RequiredAesthetic<K>]: number | readonly number[];
|
|
127
|
+
} : {
|
|
128
|
+
[C in RequiredAesthetic<K>]: AnnotateValue;
|
|
129
|
+
} & Omit<LayerOptions<K>, "data">;
|
|
130
|
+
/** The chart-level fields a builder holds between calls. */
|
|
131
|
+
type Draft = Partial<Omit<ChartSpec, "id" | "layers">>;
|
|
132
|
+
/**
|
|
133
|
+
* A chart under construction, ggplot's plot object.
|
|
134
|
+
*
|
|
135
|
+
* Persistent. Each method returns a new builder and leaves this one as it was, and a base plot
|
|
136
|
+
* branches into as many charts as the author builds from it. `plot()` makes the first.
|
|
137
|
+
*/
|
|
138
|
+
declare class PlotBuilder<Data, A extends Aes = Aes> {
|
|
139
|
+
private readonly data;
|
|
140
|
+
private readonly aes;
|
|
141
|
+
private readonly id;
|
|
142
|
+
private readonly layers;
|
|
143
|
+
private readonly draft;
|
|
144
|
+
constructor(data: Data, aes: A, id: string, layers?: readonly LayerSpec[], draft?: Readonly<Draft>);
|
|
145
|
+
/** This chart with some chart-level fields stated. */
|
|
146
|
+
private stating;
|
|
147
|
+
/**
|
|
148
|
+
* This chart and one more layer, under the plot's aes or under `own` alone.
|
|
149
|
+
*
|
|
150
|
+
* The id is the kind and the layer's position, and two builds agree. A key the kind reads nowhere
|
|
151
|
+
* throws, naming the key.
|
|
152
|
+
*/
|
|
153
|
+
private push;
|
|
154
|
+
/**
|
|
155
|
+
* One layer of a named kind, under the plot's aes. `layer("point", options)` is `point(options)`.
|
|
156
|
+
*
|
|
157
|
+
* The kind decides the options, as it does on the kind's own method. A kind typed `PlotKind` takes
|
|
158
|
+
* each kind's fields at once.
|
|
159
|
+
*/
|
|
160
|
+
layer<K extends PlotKind>(kind: K, ...args: LayerCall<K, A>): PlotBuilder<Data, A>;
|
|
161
|
+
point(...args: LayerCall<"point", A>): PlotBuilder<Data, A>;
|
|
162
|
+
line(...args: LayerCall<"line", A>): PlotBuilder<Data, A>;
|
|
163
|
+
area(...args: LayerCall<"area", A>): PlotBuilder<Data, A>;
|
|
164
|
+
bar(...args: LayerCall<"bar", A>): PlotBuilder<Data, A>;
|
|
165
|
+
waterfall(...args: LayerCall<"waterfall", A>): PlotBuilder<Data, A>;
|
|
166
|
+
histogram(...args: LayerCall<"histogram", A>): PlotBuilder<Data, A>;
|
|
167
|
+
freqpoly(...args: LayerCall<"freqpoly", A>): PlotBuilder<Data, A>;
|
|
168
|
+
hex(...args: LayerCall<"hex", A>): PlotBuilder<Data, A>;
|
|
169
|
+
boxplot(...args: LayerCall<"boxplot", A>): PlotBuilder<Data, A>;
|
|
170
|
+
violin(...args: LayerCall<"violin", A>): PlotBuilder<Data, A>;
|
|
171
|
+
density(...args: LayerCall<"density", A>): PlotBuilder<Data, A>;
|
|
172
|
+
contour(...args: LayerCall<"contour", A>): PlotBuilder<Data, A>;
|
|
173
|
+
heatmap(...args: LayerCall<"heatmap", A>): PlotBuilder<Data, A>;
|
|
174
|
+
ribbon(...args: LayerCall<"ribbon", A>): PlotBuilder<Data, A>;
|
|
175
|
+
errorbar(...args: LayerCall<"errorbar", A>): PlotBuilder<Data, A>;
|
|
176
|
+
linerange(...args: LayerCall<"linerange", A>): PlotBuilder<Data, A>;
|
|
177
|
+
pointrange(...args: LayerCall<"pointrange", A>): PlotBuilder<Data, A>;
|
|
178
|
+
crossbar(...args: LayerCall<"crossbar", A>): PlotBuilder<Data, A>;
|
|
179
|
+
segment(...args: LayerCall<"segment", A>): PlotBuilder<Data, A>;
|
|
180
|
+
sankey(...args: LayerCall<"sankey", A>): PlotBuilder<Data, A>;
|
|
181
|
+
/** The same pairs round a center, with an axis per sector. */
|
|
182
|
+
chord(...args: LayerCall<"chord", A>): PlotBuilder<Data, A>;
|
|
183
|
+
/** A genome round a circle, one sector per chromosome. */
|
|
184
|
+
ideogram(...args: LayerCall<"ideogram", A>): PlotBuilder<Data, A>;
|
|
185
|
+
treemap(...args: LayerCall<"treemap", A>): PlotBuilder<Data, A>;
|
|
186
|
+
icicle(...args: LayerCall<"icicle", A>): PlotBuilder<Data, A>;
|
|
187
|
+
sunburst(...args: LayerCall<"sunburst", A>): PlotBuilder<Data, A>;
|
|
188
|
+
parcoords(...args: LayerCall<"parcoords", A>): PlotBuilder<Data, A>;
|
|
189
|
+
pie(...args: LayerCall<"pie", A>): PlotBuilder<Data, A>;
|
|
190
|
+
gauge(...args: LayerCall<"gauge", A>): PlotBuilder<Data, A>;
|
|
191
|
+
radar(...args: LayerCall<"radar", A>): PlotBuilder<Data, A>;
|
|
192
|
+
/** ggplot's `geom_text`: a label per row at its reading. `vjust` and `hjust` read ggplot's way. */
|
|
193
|
+
text(...args: LayerCall<"text", A>): PlotBuilder<Data, A>;
|
|
194
|
+
/** ggplot's `geom_label`: the same label with a box behind it. */
|
|
195
|
+
label(...args: LayerCall<"label", A>): PlotBuilder<Data, A>;
|
|
196
|
+
/**
|
|
197
|
+
* ggplot's `geom_hline`. A number or a list draws a line at each, and a column the aes binds reads
|
|
198
|
+
* them off rows.
|
|
199
|
+
*
|
|
200
|
+
* It inherits no aes and trains no scale.
|
|
201
|
+
*/
|
|
202
|
+
hline({ yintercept, ...options }: RuleArgs<"hline", "yintercept">): PlotBuilder<Data, A>;
|
|
203
|
+
/** ggplot's `geom_vline`, taking its positions the way `hline` does. */
|
|
204
|
+
vline({ xintercept, ...options }: RuleArgs<"vline", "xintercept">): PlotBuilder<Data, A>;
|
|
205
|
+
/**
|
|
206
|
+
* ggplot's `geom_abline`, read in the scales' transformed space.
|
|
207
|
+
*
|
|
208
|
+
* Neither argument, flat or in the aes, draws the identity line. On log axes a 2-fold line is an
|
|
209
|
+
* intercept of `log10(2)`.
|
|
210
|
+
*/
|
|
211
|
+
abline({ slope, intercept, ...options }?: RuleOptions<"abline"> & {
|
|
212
|
+
slope?: RuleValue;
|
|
213
|
+
intercept?: RuleValue;
|
|
214
|
+
}): PlotBuilder<Data, A>;
|
|
215
|
+
/**
|
|
216
|
+
* A reference layer off its positions.
|
|
217
|
+
*
|
|
218
|
+
* Constants alone become the layer's own rows, one per line. A column the aes binds reads the
|
|
219
|
+
* layer's rows, and a constant beside it lands on each row, a list of labels one per row. The aes
|
|
220
|
+
* wins a position or a label stated both ways.
|
|
221
|
+
*/
|
|
222
|
+
private rule;
|
|
223
|
+
point3d(...args: LayerCall<"point3d", A>): PlotBuilder<Data, A>;
|
|
224
|
+
surface(...args: LayerCall<"surface", A>): PlotBuilder<Data, A>;
|
|
225
|
+
mesh3d(...args: LayerCall<"mesh3d", A>): PlotBuilder<Data, A>;
|
|
226
|
+
isosurface(...args: LayerCall<"isosurface", A>): PlotBuilder<Data, A>;
|
|
227
|
+
volume(...args: LayerCall<"volume", A>): PlotBuilder<Data, A>;
|
|
228
|
+
/**
|
|
229
|
+
* A curve through the points, drawn without them.
|
|
230
|
+
*
|
|
231
|
+
* The `Fitter` the chart was given answers it. A chart with none draws the other layers and no
|
|
232
|
+
* curve.
|
|
233
|
+
*/
|
|
234
|
+
smooth(options: SmoothOptions<A>): PlotBuilder<Data, A>;
|
|
235
|
+
/**
|
|
236
|
+
* A parametric model, over a geom that draws the readings it was fitted through.
|
|
237
|
+
*
|
|
238
|
+
* A property of the layer, and the curve takes those readings' color and split.
|
|
239
|
+
*/
|
|
240
|
+
fit(options: FitOptions<A>): PlotBuilder<Data, A>;
|
|
241
|
+
/**
|
|
242
|
+
* The figure's words, ggplot's `labs()`: the claim, the line under it, the caption, and each
|
|
243
|
+
* aesthetic's title.
|
|
244
|
+
*
|
|
245
|
+
* The headline is a sentence the critic holds to the axis titles. A title writes
|
|
246
|
+
* `scales.<aesthetic>.title`, the field `scale()` writes.
|
|
247
|
+
*/
|
|
248
|
+
labs({ headline, subtitle, caption, ...titles }: Labs): PlotBuilder<Data, A>;
|
|
249
|
+
/**
|
|
250
|
+
* One panel per value of `by`, `columns` of them to a row.
|
|
251
|
+
*
|
|
252
|
+
* ggplot's `facet_wrap(~by, ncol =)`. Absent, the width divides by the narrowest panel worth
|
|
253
|
+
* cutting a column for.
|
|
254
|
+
*/
|
|
255
|
+
facet(by: string, { columns }?: {
|
|
256
|
+
columns?: number;
|
|
257
|
+
}): PlotBuilder<Data, A>;
|
|
258
|
+
/**
|
|
259
|
+
* Draws the shared pair of scales the other way round, which is ggplot's `coord_flip()`.
|
|
260
|
+
*
|
|
261
|
+
* The names stay with the data. `x` is still whatever the aes bound to it.
|
|
262
|
+
*/
|
|
263
|
+
flip(): PlotBuilder<Data, A>;
|
|
264
|
+
/** Units of y per unit of x on screen, in transformed space. ggplot's `coord_fixed()`. */
|
|
265
|
+
fixed(ratio?: number): PlotBuilder<Data, A>;
|
|
266
|
+
/**
|
|
267
|
+
* What the author states on one aesthetic's scale, ggplot's `scale_*()`.
|
|
268
|
+
*
|
|
269
|
+
* Merged over what an earlier call stated, and this composes with `scales` and `labs` in any order.
|
|
270
|
+
*/
|
|
271
|
+
scale<K extends keyof ChartScales>(aesthetic: K, options: NonNullable<ChartScales[K]>): PlotBuilder<Data, A>;
|
|
272
|
+
/** Each scale at once, for a caller that already has the object. Merged per aesthetic. */
|
|
273
|
+
scales(options: ChartScales): PlotBuilder<Data, A>;
|
|
274
|
+
/** A `log10` transform on one scale, the override asked for most. The vertical by default. */
|
|
275
|
+
log(aesthetic?: "x" | "y" | "y2" | "color" | "fill"): PlotBuilder<Data, A>;
|
|
276
|
+
legend(options: LegendOptions): PlotBuilder<Data, A>;
|
|
277
|
+
/**
|
|
278
|
+
* Columns the tooltip adds after the bound aesthetics, in order.
|
|
279
|
+
*
|
|
280
|
+
* Copied, and a caller that goes on mutating its own array cannot edit a spec it handed over.
|
|
281
|
+
*/
|
|
282
|
+
tooltip(fields: readonly string[]): PlotBuilder<Data, A>;
|
|
283
|
+
side(...panels: SidePanel[]): PlotBuilder<Data, A>;
|
|
284
|
+
/**
|
|
285
|
+
* Anything the figure states in its own words, or ggplot's `annotate()`.
|
|
286
|
+
*
|
|
287
|
+
* A kind and its values make a one-off layer. A list of values makes a row each.
|
|
288
|
+
*/
|
|
289
|
+
annotate<K extends PlotKind>(kind: K, values: AnnotateValues<K>): PlotBuilder<Data, A>;
|
|
290
|
+
annotate(...found: Annotation[]): PlotBuilder<Data, A>;
|
|
291
|
+
/** The figure's size and how it takes its room. `width` and `height` are the whole figure's. */
|
|
292
|
+
canvas(options: Pick<ChartSpec, "width" | "height" | "aspect" | "sizing">): PlotBuilder<Data, A>;
|
|
293
|
+
/** A critic finding this figure is allowed to keep. */
|
|
294
|
+
override(...codes: WaivableCode[]): PlotBuilder<Data, A>;
|
|
295
|
+
/**
|
|
296
|
+
* The document a store saves, in objects of its own. Editing one spec leaves the builder and each
|
|
297
|
+
* other spec as they were.
|
|
298
|
+
*
|
|
299
|
+
* A figure with no claim builds and draws, and `blocking` refuses it. A headline of whitespace
|
|
300
|
+
* is dropped.
|
|
301
|
+
*/
|
|
302
|
+
spec(): ChartSpec;
|
|
303
|
+
/** The document and its rows, for spreading onto `Viz`. */
|
|
304
|
+
props(): {
|
|
305
|
+
spec: ChartSpec;
|
|
306
|
+
data: Data;
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* A chart under construction. `plot()` makes one, and each method returns a new one.
|
|
311
|
+
*
|
|
312
|
+
* Exported as a type. The class has no public constructor and no subclass.
|
|
313
|
+
*/
|
|
314
|
+
export type { PlotBuilder };
|
|
315
|
+
/**
|
|
316
|
+
* A chart, and the aes its layers inherit.
|
|
317
|
+
*
|
|
318
|
+
* `data` is any table `toPlotData` reads. `id` names the document. A key outside `Aesthetic` fails
|
|
319
|
+
* to compile here, and a required aesthetic the aes leaves unbound is asked for at the layer method.
|
|
320
|
+
*/
|
|
321
|
+
export declare function plot<Data extends VizData, const A extends Aes>(data: Data, aes: A & Record<Exclude<keyof A, Aesthetic>, never>, id?: string): PlotBuilder<Data, A>;
|
|
322
|
+
export declare function plot<Data extends VizData>(data: Data): PlotBuilder<Data, Record<never, never>>;
|