@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,397 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a plot kind is, decomposed.
|
|
3
|
+
*
|
|
4
|
+
* A kind names a row in the table below -- a statistic, a geometry, a coordinate system, and how
|
|
5
|
+
* its extent reads.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* One row per member of `PlotKind`.
|
|
9
|
+
*
|
|
10
|
+
* `as const satisfies` keeps the literal geometry and statistic, which lets `GeomOf<K>` and
|
|
11
|
+
* `StatOf<K>` narrow a layer's options on the kind.
|
|
12
|
+
*/
|
|
13
|
+
export const GRAMMAR = {
|
|
14
|
+
point: {
|
|
15
|
+
stat: [],
|
|
16
|
+
geom: "point",
|
|
17
|
+
coord: "cartesian",
|
|
18
|
+
proportional: false,
|
|
19
|
+
aggregated: false,
|
|
20
|
+
},
|
|
21
|
+
line: {
|
|
22
|
+
stat: [],
|
|
23
|
+
geom: "line",
|
|
24
|
+
coord: "cartesian",
|
|
25
|
+
proportional: false,
|
|
26
|
+
aggregated: "axis",
|
|
27
|
+
},
|
|
28
|
+
area: {
|
|
29
|
+
stat: ["summary"],
|
|
30
|
+
geom: "area",
|
|
31
|
+
coord: "cartesian",
|
|
32
|
+
proportional: true,
|
|
33
|
+
aggregated: true,
|
|
34
|
+
},
|
|
35
|
+
/*
|
|
36
|
+
Two bound columns and no statistic. The band an author already has, such as a mean with a
|
|
37
|
+
confidence interval per row. `Fit.band` answers the fitted case.
|
|
38
|
+
*/
|
|
39
|
+
ribbon: {
|
|
40
|
+
stat: [],
|
|
41
|
+
geom: "ribbon",
|
|
42
|
+
coord: "cartesian",
|
|
43
|
+
proportional: false,
|
|
44
|
+
aggregated: false,
|
|
45
|
+
},
|
|
46
|
+
/*
|
|
47
|
+
The same two bounds as the band above, drawn as a mark per reading.
|
|
48
|
+
|
|
49
|
+
ggplot's four interval geoms share this geometry and differ in the glyph the kind names.
|
|
50
|
+
*/
|
|
51
|
+
errorbar: {
|
|
52
|
+
stat: [],
|
|
53
|
+
geom: "range",
|
|
54
|
+
coord: "cartesian",
|
|
55
|
+
proportional: false,
|
|
56
|
+
aggregated: false,
|
|
57
|
+
},
|
|
58
|
+
linerange: {
|
|
59
|
+
stat: [],
|
|
60
|
+
geom: "range",
|
|
61
|
+
coord: "cartesian",
|
|
62
|
+
proportional: false,
|
|
63
|
+
aggregated: false,
|
|
64
|
+
},
|
|
65
|
+
pointrange: {
|
|
66
|
+
stat: [],
|
|
67
|
+
geom: "range",
|
|
68
|
+
coord: "cartesian",
|
|
69
|
+
proportional: false,
|
|
70
|
+
aggregated: false,
|
|
71
|
+
},
|
|
72
|
+
crossbar: {
|
|
73
|
+
stat: [],
|
|
74
|
+
geom: "range",
|
|
75
|
+
coord: "cartesian",
|
|
76
|
+
proportional: false,
|
|
77
|
+
aggregated: false,
|
|
78
|
+
},
|
|
79
|
+
/*
|
|
80
|
+
Four bound columns, and the geom is a pair of positions. A before-and-after pair and a drift
|
|
81
|
+
vector are one shape. Unproportional -- a segment's length is a displacement.
|
|
82
|
+
*/
|
|
83
|
+
segment: {
|
|
84
|
+
stat: [],
|
|
85
|
+
geom: "segment",
|
|
86
|
+
coord: "cartesian",
|
|
87
|
+
proportional: false,
|
|
88
|
+
aggregated: false,
|
|
89
|
+
},
|
|
90
|
+
/*
|
|
91
|
+
A conditional mean through the points, drawn as a curve and no geoms.
|
|
92
|
+
|
|
93
|
+
The statistic is empty. This row says what the kind draws and the service supplies the
|
|
94
|
+
numbers.
|
|
95
|
+
*/
|
|
96
|
+
smooth: {
|
|
97
|
+
stat: [],
|
|
98
|
+
geom: "smooth",
|
|
99
|
+
coord: "cartesian",
|
|
100
|
+
proportional: false,
|
|
101
|
+
aggregated: false,
|
|
102
|
+
},
|
|
103
|
+
bar: {
|
|
104
|
+
stat: ["summary"],
|
|
105
|
+
geom: "bar",
|
|
106
|
+
coord: "cartesian",
|
|
107
|
+
proportional: true,
|
|
108
|
+
aggregated: true,
|
|
109
|
+
},
|
|
110
|
+
/*
|
|
111
|
+
Signed steps on a running total. The floor is arithmetic.
|
|
112
|
+
|
|
113
|
+
A step starts where the one before it finished, and the geom paints a rise apart from a fall.
|
|
114
|
+
*/
|
|
115
|
+
waterfall: {
|
|
116
|
+
stat: ["summary"],
|
|
117
|
+
geom: "waterfall",
|
|
118
|
+
coord: "cartesian",
|
|
119
|
+
proportional: true,
|
|
120
|
+
aggregated: true,
|
|
121
|
+
},
|
|
122
|
+
histogram: {
|
|
123
|
+
stat: ["bin", "count"],
|
|
124
|
+
geom: "bar",
|
|
125
|
+
coord: "cartesian",
|
|
126
|
+
proportional: true,
|
|
127
|
+
aggregated: false,
|
|
128
|
+
},
|
|
129
|
+
hex: {
|
|
130
|
+
stat: ["bin2d", "count"],
|
|
131
|
+
geom: "hex",
|
|
132
|
+
coord: "cartesian",
|
|
133
|
+
proportional: false,
|
|
134
|
+
aggregated: false,
|
|
135
|
+
},
|
|
136
|
+
boxplot: {
|
|
137
|
+
stat: ["boxplot"],
|
|
138
|
+
geom: "boxplot",
|
|
139
|
+
coord: "cartesian",
|
|
140
|
+
proportional: false,
|
|
141
|
+
aggregated: false,
|
|
142
|
+
},
|
|
143
|
+
violin: {
|
|
144
|
+
stat: ["boxplot", "ydensity"],
|
|
145
|
+
geom: "violin",
|
|
146
|
+
coord: "cartesian",
|
|
147
|
+
proportional: false,
|
|
148
|
+
aggregated: false,
|
|
149
|
+
},
|
|
150
|
+
/*
|
|
151
|
+
A histogram's count under a bin, drawn as a run between the bin centers.
|
|
152
|
+
|
|
153
|
+
Three overlapping distributions read as three curves and as one muddle of bars.
|
|
154
|
+
*/
|
|
155
|
+
freqpoly: {
|
|
156
|
+
stat: ["bin", "count"],
|
|
157
|
+
geom: "freqpoly",
|
|
158
|
+
coord: "cartesian",
|
|
159
|
+
proportional: true,
|
|
160
|
+
aggregated: false,
|
|
161
|
+
},
|
|
162
|
+
/*
|
|
163
|
+
A one-dimensional kernel density in the main panel.
|
|
164
|
+
|
|
165
|
+
Proportional -- the vertical scale reads a density from zero. Its own geometry.
|
|
166
|
+
*/
|
|
167
|
+
density: {
|
|
168
|
+
stat: ["density"],
|
|
169
|
+
geom: "density",
|
|
170
|
+
coord: "cartesian",
|
|
171
|
+
proportional: true,
|
|
172
|
+
aggregated: false,
|
|
173
|
+
},
|
|
174
|
+
heatmap: {
|
|
175
|
+
stat: ["summary"],
|
|
176
|
+
geom: "heatmap",
|
|
177
|
+
coord: "cartesian",
|
|
178
|
+
proportional: false,
|
|
179
|
+
aggregated: true,
|
|
180
|
+
},
|
|
181
|
+
contour: {
|
|
182
|
+
stat: ["density2d"],
|
|
183
|
+
geom: "contour",
|
|
184
|
+
coord: "cartesian",
|
|
185
|
+
proportional: false,
|
|
186
|
+
aggregated: false,
|
|
187
|
+
},
|
|
188
|
+
parcoords: {
|
|
189
|
+
stat: [],
|
|
190
|
+
geom: "parcoords",
|
|
191
|
+
coord: "parallel",
|
|
192
|
+
proportional: false,
|
|
193
|
+
aggregated: false,
|
|
194
|
+
},
|
|
195
|
+
/*
|
|
196
|
+
A genome round a circle. One sector per chromosome and one tile per band.
|
|
197
|
+
|
|
198
|
+
The sectors carry their own base-pair ranges, so a track plots a reading at its own position.
|
|
199
|
+
*/
|
|
200
|
+
ideogram: {
|
|
201
|
+
stat: [],
|
|
202
|
+
geom: "ideogram",
|
|
203
|
+
coord: "polar",
|
|
204
|
+
proportional: false,
|
|
205
|
+
aggregated: false,
|
|
206
|
+
},
|
|
207
|
+
/*
|
|
208
|
+
A flow closed into a circle. One sector per name and one ribbon per pair.
|
|
209
|
+
|
|
210
|
+
The sankey's channels, read round a center. A sector is sized by everything touching it.
|
|
211
|
+
*/
|
|
212
|
+
chord: {
|
|
213
|
+
stat: ["summary"],
|
|
214
|
+
geom: "chord",
|
|
215
|
+
coord: "polar",
|
|
216
|
+
proportional: true,
|
|
217
|
+
aggregated: false,
|
|
218
|
+
},
|
|
219
|
+
sankey: {
|
|
220
|
+
stat: ["summary", "flow"],
|
|
221
|
+
geom: "sankey",
|
|
222
|
+
coord: "flow",
|
|
223
|
+
proportional: true,
|
|
224
|
+
aggregated: false,
|
|
225
|
+
},
|
|
226
|
+
treemap: {
|
|
227
|
+
stat: ["summary"],
|
|
228
|
+
geom: "treemap",
|
|
229
|
+
coord: "packed",
|
|
230
|
+
proportional: true,
|
|
231
|
+
aggregated: true,
|
|
232
|
+
},
|
|
233
|
+
/*
|
|
234
|
+
The same nesting with a row per level, trading a dimension for a shared baseline. Packed. A
|
|
235
|
+
cell's width is a length from zero.
|
|
236
|
+
*/
|
|
237
|
+
icicle: {
|
|
238
|
+
stat: ["summary"],
|
|
239
|
+
geom: "icicle",
|
|
240
|
+
coord: "packed",
|
|
241
|
+
proportional: true,
|
|
242
|
+
aggregated: true,
|
|
243
|
+
},
|
|
244
|
+
/*
|
|
245
|
+
The same nesting turned round a center, drawing one ring per level.
|
|
246
|
+
|
|
247
|
+
Polar, and the condition it pays is a number on each slice. It reads the icicle's own layout.
|
|
248
|
+
*/
|
|
249
|
+
sunburst: {
|
|
250
|
+
stat: ["summary"],
|
|
251
|
+
geom: "sunburst",
|
|
252
|
+
coord: "polar",
|
|
253
|
+
proportional: true,
|
|
254
|
+
aggregated: true,
|
|
255
|
+
},
|
|
256
|
+
/*
|
|
257
|
+
The polar three. Each draws a share of one total as an angle.
|
|
258
|
+
|
|
259
|
+
A pie asks its horizontal channel for categories. `LayerStyle.innerRadius` above zero draws a donut.
|
|
260
|
+
*/
|
|
261
|
+
pie: {
|
|
262
|
+
stat: ["summary"],
|
|
263
|
+
geom: "pie",
|
|
264
|
+
coord: "polar",
|
|
265
|
+
proportional: true,
|
|
266
|
+
aggregated: true,
|
|
267
|
+
},
|
|
268
|
+
/* One reduction over the whole table, read against a stated range. */
|
|
269
|
+
gauge: {
|
|
270
|
+
stat: ["summary"],
|
|
271
|
+
geom: "gauge",
|
|
272
|
+
coord: "polar",
|
|
273
|
+
proportional: true,
|
|
274
|
+
aggregated: true,
|
|
275
|
+
},
|
|
276
|
+
/*
|
|
277
|
+
The parallel plot turned round a center, with the rules running out as spokes.
|
|
278
|
+
|
|
279
|
+
A radar owes its axis order to the author and `dimensions` is an ordered list.
|
|
280
|
+
*/
|
|
281
|
+
radar: {
|
|
282
|
+
stat: [],
|
|
283
|
+
geom: "radar",
|
|
284
|
+
coord: "polar",
|
|
285
|
+
proportional: false,
|
|
286
|
+
aggregated: false,
|
|
287
|
+
},
|
|
288
|
+
point3d: {
|
|
289
|
+
stat: [],
|
|
290
|
+
geom: "point3d",
|
|
291
|
+
coord: "cube",
|
|
292
|
+
proportional: false,
|
|
293
|
+
aggregated: false,
|
|
294
|
+
},
|
|
295
|
+
/* A relief reduces a measure over a grid of two dimensions. A bin, then a statistic. */
|
|
296
|
+
surface: {
|
|
297
|
+
stat: ["bin2d", "summary"],
|
|
298
|
+
geom: "surface",
|
|
299
|
+
coord: "cube",
|
|
300
|
+
proportional: false,
|
|
301
|
+
aggregated: true,
|
|
302
|
+
},
|
|
303
|
+
/* A mesh arrives as vertices and faces. The rows are the geometry and nothing reduces them. */
|
|
304
|
+
mesh3d: {
|
|
305
|
+
stat: [],
|
|
306
|
+
geom: "mesh3d",
|
|
307
|
+
coord: "cube",
|
|
308
|
+
proportional: false,
|
|
309
|
+
aggregated: false,
|
|
310
|
+
},
|
|
311
|
+
isosurface: {
|
|
312
|
+
stat: [],
|
|
313
|
+
geom: "isosurface",
|
|
314
|
+
coord: "cube",
|
|
315
|
+
proportional: false,
|
|
316
|
+
aggregated: false,
|
|
317
|
+
},
|
|
318
|
+
volume: {
|
|
319
|
+
stat: [],
|
|
320
|
+
geom: "volume",
|
|
321
|
+
coord: "cube",
|
|
322
|
+
proportional: false,
|
|
323
|
+
aggregated: false,
|
|
324
|
+
},
|
|
325
|
+
/*
|
|
326
|
+
ggplot's three reference geoms. A line across the plot area that leaves the scales alone.
|
|
327
|
+
|
|
328
|
+
`abline` reads its slope and intercept in the scales' transformed space.
|
|
329
|
+
*/
|
|
330
|
+
hline: {
|
|
331
|
+
stat: [],
|
|
332
|
+
geom: "hline",
|
|
333
|
+
coord: "cartesian",
|
|
334
|
+
proportional: false,
|
|
335
|
+
aggregated: false,
|
|
336
|
+
},
|
|
337
|
+
vline: {
|
|
338
|
+
stat: [],
|
|
339
|
+
geom: "vline",
|
|
340
|
+
coord: "cartesian",
|
|
341
|
+
proportional: false,
|
|
342
|
+
aggregated: false,
|
|
343
|
+
},
|
|
344
|
+
abline: {
|
|
345
|
+
stat: [],
|
|
346
|
+
geom: "abline",
|
|
347
|
+
coord: "cartesian",
|
|
348
|
+
proportional: false,
|
|
349
|
+
aggregated: false,
|
|
350
|
+
},
|
|
351
|
+
/* ggplot's `geom_text` and `geom_label`. A label per row at its reading. The second draws a box behind it. */
|
|
352
|
+
text: {
|
|
353
|
+
stat: [],
|
|
354
|
+
geom: "text",
|
|
355
|
+
coord: "cartesian",
|
|
356
|
+
proportional: false,
|
|
357
|
+
aggregated: false,
|
|
358
|
+
},
|
|
359
|
+
label: {
|
|
360
|
+
stat: [],
|
|
361
|
+
geom: "text",
|
|
362
|
+
coord: "cartesian",
|
|
363
|
+
proportional: false,
|
|
364
|
+
aggregated: false,
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
/** Each layer kind, in the grammar table's order. A chart-type picker offers these. */
|
|
368
|
+
export const KINDS = Object.freeze(Object.keys(GRAMMAR));
|
|
369
|
+
export const resolve = (kind) => GRAMMAR[kind];
|
|
370
|
+
/** Coordinate systems that position against the frame's shared pair of scales. */
|
|
371
|
+
const AXIAL = ["cartesian", "flip"];
|
|
372
|
+
export const isAxial = (coord) => AXIAL.includes(coord);
|
|
373
|
+
const BY_GEOM = new Map(Object.keys(GRAMMAR).map((kind) => {
|
|
374
|
+
const { geom, coord, proportional } = GRAMMAR[kind];
|
|
375
|
+
return [geom, { coord, proportional }];
|
|
376
|
+
}));
|
|
377
|
+
export const geomGrammar = (geom) => BY_GEOM.get(geom);
|
|
378
|
+
/**
|
|
379
|
+
* Whether the vertical scale these geoms share has to include zero.
|
|
380
|
+
*
|
|
381
|
+
* True where one reads its extent as a length from zero. A treemap and a sankey answer false.
|
|
382
|
+
*/
|
|
383
|
+
export const groundedGeoms = (geoms) => geoms.some((geom) => {
|
|
384
|
+
const grammar = geomGrammar(geom);
|
|
385
|
+
return grammar ? grammar.proportional && isAxial(grammar.coord) : false;
|
|
386
|
+
});
|
|
387
|
+
/** The same question asked of kinds, for a caller with a spec and no frame. */
|
|
388
|
+
export const groundedKinds = (kinds) => groundedGeoms(kinds.map((kind) => GRAMMAR[kind]?.geom).filter((geom) => geom != null));
|
|
389
|
+
/**
|
|
390
|
+
* Whether an aggregate the author set reaches this kind's statistic, given the scale its X runs.
|
|
391
|
+
*
|
|
392
|
+
* The `aggregated` column with `"axis"` resolved against the horizontal scale.
|
|
393
|
+
*/
|
|
394
|
+
export const readsAggregate = (kind, axisKind) => {
|
|
395
|
+
const { aggregated } = GRAMMAR[kind];
|
|
396
|
+
return aggregated === "axis" ? axisKind === "band" : aggregated;
|
|
397
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three reductions that produce a grid. Each answers in `HeatCell[]`.
|
|
3
|
+
*
|
|
4
|
+
* The axes are positions inside a string, a list of measures, or two bands.
|
|
5
|
+
*/
|
|
6
|
+
import type { PlotData, PlotField } from "./plot-data.js";
|
|
7
|
+
import type { HeatCell } from "./geom-types.js";
|
|
8
|
+
/**
|
|
9
|
+
* Positions an occupancy grid draws.
|
|
10
|
+
*
|
|
11
|
+
* A heavy chain runs past a hundred residues and a grid that wide has columns narrower than their
|
|
12
|
+
* own labels.
|
|
13
|
+
*/
|
|
14
|
+
export declare const POSITION_CAP = 40;
|
|
15
|
+
/**
|
|
16
|
+
* Residue frequency per position, over a column with a sequence.
|
|
17
|
+
*
|
|
18
|
+
* The fraction is taken per position and the columns are comparable. A short row contributes to
|
|
19
|
+
* the positions it has.
|
|
20
|
+
*/
|
|
21
|
+
export declare function occupancyCells(data: PlotData, sequenceId: string): HeatCell[];
|
|
22
|
+
/**
|
|
23
|
+
* Each cell's most common category, over two bands.
|
|
24
|
+
*
|
|
25
|
+
* `value` is its share and `n` counts the rows. A tie goes to the first category met.
|
|
26
|
+
*/
|
|
27
|
+
export declare function modeCells(data: PlotData, xId: string, yId: string, fillId: string): (HeatCell & {
|
|
28
|
+
category: string;
|
|
29
|
+
})[];
|
|
30
|
+
/**
|
|
31
|
+
* Fraction of a category's rows clearing each measure's cut.
|
|
32
|
+
*
|
|
33
|
+
* The cut is the field's target and a measure with none is dropped. A row with no value counts
|
|
34
|
+
* neither way.
|
|
35
|
+
*/
|
|
36
|
+
export declare function gateCells(data: PlotData, categoryId: string, measures: PlotField[]): HeatCell[];
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Three reductions that produce a grid. Each answers in `HeatCell[]`.
|
|
3
|
+
*
|
|
4
|
+
* The axes are positions inside a string, a list of measures, or two bands.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Positions an occupancy grid draws.
|
|
8
|
+
*
|
|
9
|
+
* A heavy chain runs past a hundred residues and a grid that wide has columns narrower than their
|
|
10
|
+
* own labels.
|
|
11
|
+
*/
|
|
12
|
+
export const POSITION_CAP = 40;
|
|
13
|
+
/**
|
|
14
|
+
* Residue frequency per position, over a column with a sequence.
|
|
15
|
+
*
|
|
16
|
+
* The fraction is taken per position and the columns are comparable. A short row contributes to
|
|
17
|
+
* the positions it has.
|
|
18
|
+
*/
|
|
19
|
+
export function occupancyCells(data, sequenceId) {
|
|
20
|
+
/** Count per position per residue, and the rows each position was measured over. */
|
|
21
|
+
const counts = new Map();
|
|
22
|
+
const measured = new Map();
|
|
23
|
+
for (let row = 0; row < data.rowCount; row += 1) {
|
|
24
|
+
const tokens = data.text(row, sequenceId);
|
|
25
|
+
if (tokens == null)
|
|
26
|
+
continue;
|
|
27
|
+
const width = Math.min(tokens.length, POSITION_CAP);
|
|
28
|
+
for (let at = 0; at < width; at += 1) {
|
|
29
|
+
const residue = tokens[at];
|
|
30
|
+
let column = counts.get(at);
|
|
31
|
+
if (!column) {
|
|
32
|
+
column = new Map();
|
|
33
|
+
counts.set(at, column);
|
|
34
|
+
}
|
|
35
|
+
column.set(residue, (column.get(residue) ?? 0) + 1);
|
|
36
|
+
measured.set(at, (measured.get(at) ?? 0) + 1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const cells = [];
|
|
40
|
+
for (const [at, column] of [...counts.entries()].sort((a, b) => a[0] - b[0])) {
|
|
41
|
+
const total = measured.get(at) ?? 0;
|
|
42
|
+
if (total === 0)
|
|
43
|
+
continue;
|
|
44
|
+
for (const [residue, count] of column) {
|
|
45
|
+
cells.push({ x: String(at + 1), y: residue, value: count / total, n: count });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return cells;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Each cell's most common category, over two bands.
|
|
52
|
+
*
|
|
53
|
+
* `value` is its share and `n` counts the rows. A tie goes to the first category met.
|
|
54
|
+
*/
|
|
55
|
+
export function modeCells(data, xId, yId, fillId) {
|
|
56
|
+
const running = new Map();
|
|
57
|
+
for (let row = 0; row < data.rowCount; row += 1) {
|
|
58
|
+
const x = data.text(row, xId);
|
|
59
|
+
const y = data.text(row, yId);
|
|
60
|
+
const category = data.text(row, fillId);
|
|
61
|
+
if (x == null || y == null || category == null)
|
|
62
|
+
continue;
|
|
63
|
+
const key = `${x}\u0000${y}`;
|
|
64
|
+
let cell = running.get(key);
|
|
65
|
+
if (!cell) {
|
|
66
|
+
cell = { x, y, n: 0, counts: new Map() };
|
|
67
|
+
running.set(key, cell);
|
|
68
|
+
}
|
|
69
|
+
cell.n += 1;
|
|
70
|
+
cell.counts.set(category, (cell.counts.get(category) ?? 0) + 1);
|
|
71
|
+
}
|
|
72
|
+
return [...running.values()].map(({ x, y, n, counts }) => {
|
|
73
|
+
let category = "";
|
|
74
|
+
let most = 0;
|
|
75
|
+
for (const [one, count] of counts) {
|
|
76
|
+
if (count > most) {
|
|
77
|
+
category = one;
|
|
78
|
+
most = count;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return { x, y, value: most / n, n, category };
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Fraction of a category's rows clearing each measure's cut.
|
|
86
|
+
*
|
|
87
|
+
* The cut is the field's target and a measure with none is dropped. A row with no value counts
|
|
88
|
+
* neither way.
|
|
89
|
+
*/
|
|
90
|
+
export function gateCells(data, categoryId, measures) {
|
|
91
|
+
const gated = measures.filter((measure) => measure.target != null);
|
|
92
|
+
if (gated.length === 0)
|
|
93
|
+
return [];
|
|
94
|
+
/*
|
|
95
|
+
Per measure, then per category. Nested, and a category is free text -- any separator is a
|
|
96
|
+
character a cluster name can hold.
|
|
97
|
+
*/
|
|
98
|
+
const running = new Map();
|
|
99
|
+
for (const measure of gated)
|
|
100
|
+
running.set(measure.id, new Map());
|
|
101
|
+
for (let row = 0; row < data.rowCount; row += 1) {
|
|
102
|
+
const category = data.text(row, categoryId);
|
|
103
|
+
if (category == null)
|
|
104
|
+
continue;
|
|
105
|
+
for (const measure of gated) {
|
|
106
|
+
const value = data.number(row, measure.id);
|
|
107
|
+
if (value == null)
|
|
108
|
+
continue;
|
|
109
|
+
const byCategory = running.get(measure.id);
|
|
110
|
+
let cell = byCategory.get(category);
|
|
111
|
+
if (!cell) {
|
|
112
|
+
cell = { passed: 0, measured: 0 };
|
|
113
|
+
byCategory.set(category, cell);
|
|
114
|
+
}
|
|
115
|
+
cell.measured += 1;
|
|
116
|
+
const clears = measure.direction === "lower" ? value <= measure.target : value >= measure.target;
|
|
117
|
+
if (clears)
|
|
118
|
+
cell.passed += 1;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const cells = [];
|
|
122
|
+
for (const measure of gated) {
|
|
123
|
+
for (const [category, cell] of running.get(measure.id)) {
|
|
124
|
+
cells.push({
|
|
125
|
+
x: measure.label,
|
|
126
|
+
y: category,
|
|
127
|
+
value: cell.passed / cell.measured,
|
|
128
|
+
n: cell.measured,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return cells;
|
|
133
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binning a cloud into cells, on either tiling.
|
|
3
|
+
*
|
|
4
|
+
* The geom above 50,000 records. A hexagon has six neighbors at one distance. A square
|
|
5
|
+
* cross-references against the two axes.
|
|
6
|
+
*/
|
|
7
|
+
import { type Bin2dOptions } from "./binning.js";
|
|
8
|
+
export interface Bin {
|
|
9
|
+
key: string;
|
|
10
|
+
/** Center in pixel space. */
|
|
11
|
+
cx: number;
|
|
12
|
+
cy: number;
|
|
13
|
+
count: number;
|
|
14
|
+
/** Mean of the weight channel, when one is supplied. */
|
|
15
|
+
mean?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A cell lattice in pixel space, resolved from stated bin parameters.
|
|
19
|
+
*
|
|
20
|
+
* With no lattice handed over, both binners anchor at the pixel origin and size off the geom's
|
|
21
|
+
* radius.
|
|
22
|
+
*/
|
|
23
|
+
export interface Lattice {
|
|
24
|
+
/** Cell width in pixels. */
|
|
25
|
+
width: number;
|
|
26
|
+
/** Cell height in pixels. Square unless stated. */
|
|
27
|
+
height?: number;
|
|
28
|
+
/** Pixel the first edge sits at, across and down. */
|
|
29
|
+
origin?: readonly [number, number];
|
|
30
|
+
/** Which end of a cell takes a reading on its edge. The high end unless stated. */
|
|
31
|
+
closed?: "right" | "left";
|
|
32
|
+
/**
|
|
33
|
+
* Cells across and down, where the caller resolved the lattice's extent.
|
|
34
|
+
*
|
|
35
|
+
* A reading on the outer edge joins the cell beside it. R's `cut` calls this `include.lowest`.
|
|
36
|
+
*/
|
|
37
|
+
cells?: readonly [number, number];
|
|
38
|
+
/**
|
|
39
|
+
* Draws each cell of that extent and a count of zero sits at the bottom of the ramp.
|
|
40
|
+
*
|
|
41
|
+
* ggplot's `drop = FALSE`. Absent returns the occupied cells alone.
|
|
42
|
+
*/
|
|
43
|
+
whole?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface BinPoint {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
weight?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A pixel lattice off stated bin parameters.
|
|
52
|
+
*
|
|
53
|
+
* Projecting the first two edges gives the size and anchor in pixels. A vertical scale anchors at
|
|
54
|
+
* the smaller pixel.
|
|
55
|
+
*/
|
|
56
|
+
export declare function latticeFor(xRange: readonly [number, number], yRange: readonly [number, number], scales: {
|
|
57
|
+
x: (value: number) => number;
|
|
58
|
+
y: (value: number) => number;
|
|
59
|
+
}, options: Bin2dOptions): Lattice | null;
|
|
60
|
+
/** The radius a hexagon takes to sit on a lattice of this width. */
|
|
61
|
+
export declare const hexRadiusFor: (lattice: Lattice) => number;
|
|
62
|
+
/** The hexagon outline, centered on the origin. */
|
|
63
|
+
export declare function hexPath(radius: number): string;
|
|
64
|
+
/**
|
|
65
|
+
* Bins points already projected into pixel space.
|
|
66
|
+
*
|
|
67
|
+
* Binning after projection keeps the hexagons regular on screen. Binning in data space would
|
|
68
|
+
* skew them on a log axis.
|
|
69
|
+
*/
|
|
70
|
+
export declare function hexbin(points: BinPoint[], radius: number, origin?: readonly [number, number]): Bin[];
|
|
71
|
+
/**
|
|
72
|
+
* The cell outline, centered on the origin.
|
|
73
|
+
*
|
|
74
|
+
* Square where the height goes unstated. A stated width per axis makes a cell one interval of x
|
|
75
|
+
* by one of y.
|
|
76
|
+
*/
|
|
77
|
+
export declare function rectPath(size: number, height?: number): string;
|
|
78
|
+
/**
|
|
79
|
+
* Bins points already projected into pixel space, onto a square lattice.
|
|
80
|
+
*
|
|
81
|
+
* `Math.floor` over `Math.round`. A cell covers one half-open interval on each axis and the
|
|
82
|
+
* center falls in its middle.
|
|
83
|
+
*/
|
|
84
|
+
export declare function rectbin(points: BinPoint[], size: number | Lattice): Bin[];
|