@sipemu/ggplot-rs 0.0.0-stage → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +21 -0
- package/README.md +154 -2
- package/dist/ggplot_rs.d.ts +318 -0
- package/dist/ggplot_rs.js +640 -0
- package/dist/ggplot_rs_bg.wasm +0 -0
- package/dist/ggplot_rs_bg.wasm.d.ts +30 -0
- package/package.json +62 -4
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/** One data column: numbers → continuous, strings/booleans → categorical, null → missing. */
|
|
5
|
+
export type Column = (number | string | boolean | null)[];
|
|
6
|
+
/** Column-oriented data: `{ column: [values…] }`; all columns the same length. */
|
|
7
|
+
export type Data = Record<string, Column>;
|
|
8
|
+
|
|
9
|
+
export type Aesthetic =
|
|
10
|
+
| "x" | "y" | "color" | "colour" | "fill" | "size" | "shape" | "alpha" | "group"
|
|
11
|
+
| "linetype" | "linewidth" | "label" | "weight" | "xmin" | "xmax" | "ymin" | "ymax"
|
|
12
|
+
| "xend" | "yend" | "angle" | "radius" | "tooltip" | "from" | "to" | "subgroup"
|
|
13
|
+
| "open" | "high" | "low" | "close" | "lower" | "middle" | "upper" | "fontface" | "class";
|
|
14
|
+
/** Aesthetic → column name. */
|
|
15
|
+
export type AesMap = Partial<Record<Aesthetic, string>>;
|
|
16
|
+
|
|
17
|
+
export type GeomName =
|
|
18
|
+
| "point" | "jitter" | "line" | "path" | "step" | "area" | "ribbon" | "col" | "bar"
|
|
19
|
+
| "histogram" | "freqpoly" | "density" | "boxplot" | "violin" | "dotplot" | "smooth"
|
|
20
|
+
| "text" | "label" | "errorbar" | "linerange" | "pointrange" | "crossbar" | "segment"
|
|
21
|
+
| "rect" | "tile" | "raster" | "polygon" | "rug" | "count" | "bin2d" | "hex"
|
|
22
|
+
| "density2d" | "contour" | "qq" | "qq_line" | "hline" | "vline" | "abline" | "blank"
|
|
23
|
+
| "waterfall" | "pareto" | "sankey" | "chord" | "treemap" | "sunburst" | "icicle"
|
|
24
|
+
| "funnel" | "stream" | "lollipop" | "dumbbell" | "candlestick" | "ohlc" | "calendar";
|
|
25
|
+
|
|
26
|
+
export interface LayerParams {
|
|
27
|
+
/** histogram: bin count. */
|
|
28
|
+
bins?: number;
|
|
29
|
+
/** smooth: fitting method (default "lm"). */
|
|
30
|
+
method?: "lm" | "loess";
|
|
31
|
+
/** smooth (loess): span (default 0.75). */
|
|
32
|
+
span?: number;
|
|
33
|
+
/** smooth: draw the confidence ribbon (default true). */
|
|
34
|
+
se?: boolean;
|
|
35
|
+
/** hline (required). */
|
|
36
|
+
yintercept?: number;
|
|
37
|
+
/** vline (required). */
|
|
38
|
+
xintercept?: number;
|
|
39
|
+
/** abline (slope required, intercept default 0). */
|
|
40
|
+
slope?: number;
|
|
41
|
+
intercept?: number;
|
|
42
|
+
/** sunburst / icicle (required): hierarchy columns, outermost first. */
|
|
43
|
+
levels?: string[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export type PositionName = "identity" | "stack" | "fill" | "dodge" | "dodge2" | "jitter" | "nudge";
|
|
47
|
+
export type Position =
|
|
48
|
+
| PositionName
|
|
49
|
+
| { type: PositionName; width?: number; height?: number; padding?: number; x?: number; y?: number };
|
|
50
|
+
|
|
51
|
+
export interface Layer {
|
|
52
|
+
geom: GeomName;
|
|
53
|
+
/** Merged over the plot-level `aes` (layer wins). */
|
|
54
|
+
aes?: AesMap;
|
|
55
|
+
/** Layer-specific data, replacing the plot's. */
|
|
56
|
+
data?: Data;
|
|
57
|
+
params?: LayerParams;
|
|
58
|
+
/** Override the geom's default stat; only "identity" is supported. */
|
|
59
|
+
stat?: "identity";
|
|
60
|
+
position?: Position;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface PositionScale {
|
|
64
|
+
trans?: "identity" | "log10" | "log2" | "ln" | "log" | "sqrt" | "reverse" | "logit"
|
|
65
|
+
| "probit" | "pseudo_log" | "reciprocal" | "exp";
|
|
66
|
+
limits?: [number, number];
|
|
67
|
+
breaks?: number[];
|
|
68
|
+
/** Axis title. */
|
|
69
|
+
name?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ColorScale {
|
|
73
|
+
/** Discrete ("Set1", "Dark2", "Paired", "npg", "lancet", …) for a categorical
|
|
74
|
+
* column; "viridis" | "magma" | "plasma" | "inferno" for a numeric one. */
|
|
75
|
+
palette?: string;
|
|
76
|
+
/** Fixed level order for a categorical column. */
|
|
77
|
+
levels?: string[];
|
|
78
|
+
/** Manual colors: `{ level: "#rrggbb" }`. */
|
|
79
|
+
values?: Record<string, string>;
|
|
80
|
+
/** Two-color gradient `["#low", "#high"]` for a numeric column. */
|
|
81
|
+
gradient?: [string, string];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type Facet =
|
|
85
|
+
| { wrap: string; ncol?: number; scales?: "fixed" | "free" | "free_x" | "free_y" }
|
|
86
|
+
| { rows?: string; cols?: string; scales?: "fixed" | "free" | "free_x" | "free_y" };
|
|
87
|
+
|
|
88
|
+
export type CoordName = "cartesian" | "flip" | "polar" | "fixed" | "equal" | "radar";
|
|
89
|
+
export type Coord =
|
|
90
|
+
| CoordName
|
|
91
|
+
| { type: CoordName; ratio?: number; xlim?: [number, number]; ylim?: [number, number] };
|
|
92
|
+
|
|
93
|
+
export interface Labels {
|
|
94
|
+
title?: string;
|
|
95
|
+
subtitle?: string;
|
|
96
|
+
caption?: string;
|
|
97
|
+
tag?: string;
|
|
98
|
+
x?: string;
|
|
99
|
+
y?: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type ThemePreset = "gray" | "grey" | "bw" | "minimal" | "classic" | "dark" | "light" | "void" | "linedraw";
|
|
103
|
+
export interface TextElement {
|
|
104
|
+
family?: string; size?: number; color?: [number, number, number];
|
|
105
|
+
face?: "plain" | "bold" | "italic"; hjust?: number; vjust?: number; angle?: number; visible?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface LineElement {
|
|
108
|
+
color?: [number, number, number]; width?: number; visible?: boolean;
|
|
109
|
+
linetype?: "solid" | "dashed" | "dotted" | "dashdot" | "longdash" | "twodash";
|
|
110
|
+
}
|
|
111
|
+
export interface RectElement {
|
|
112
|
+
fill?: [number, number, number]; color?: [number, number, number]; width?: number; visible?: boolean;
|
|
113
|
+
}
|
|
114
|
+
/** A partial theme overlay (same schema as the CLI's `--theme-config`). */
|
|
115
|
+
export interface ThemeConfig {
|
|
116
|
+
/** Preset to start from (default "minimal"). */
|
|
117
|
+
base?: ThemePreset;
|
|
118
|
+
/** Brand color `[r, g, b]` for single-series geoms. */
|
|
119
|
+
primary?: [number, number, number];
|
|
120
|
+
/** Default discrete palette for categorical color/fill mappings. */
|
|
121
|
+
palette?: string;
|
|
122
|
+
aspect_ratio?: number;
|
|
123
|
+
panel_ontop?: boolean;
|
|
124
|
+
axis_minor_ticks?: boolean;
|
|
125
|
+
title_position?: "panel" | "plot";
|
|
126
|
+
tag_position?: "topleft" | "topright" | "bottomleft" | "bottomright";
|
|
127
|
+
legend_direction?: "vertical" | "horizontal";
|
|
128
|
+
text?: TextElement; title?: TextElement; subtitle?: TextElement; caption?: TextElement;
|
|
129
|
+
axis_title_x?: TextElement; axis_title_y?: TextElement;
|
|
130
|
+
axis_text_x?: TextElement; axis_text_y?: TextElement;
|
|
131
|
+
legend_title?: TextElement; legend_text?: TextElement; strip_text?: TextElement;
|
|
132
|
+
axis_line?: LineElement; axis_ticks?: LineElement;
|
|
133
|
+
panel_grid_major?: LineElement; panel_grid_minor?: LineElement; panel_border?: LineElement;
|
|
134
|
+
panel_background?: RectElement; plot_background?: RectElement;
|
|
135
|
+
legend_background?: RectElement; strip_background?: RectElement;
|
|
136
|
+
[key: string]: unknown;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** "inside" places the legend automatically in the emptiest panel corner. */
|
|
140
|
+
export type Legend = "right" | "left" | "top" | "bottom" | "none" | "inside" | [number, number];
|
|
141
|
+
|
|
142
|
+
/** A layered grammar-of-graphics plot, mirroring the ggplot-rs builder. */
|
|
143
|
+
export interface PlotSpec {
|
|
144
|
+
data: Data;
|
|
145
|
+
/** Plot-level mapping inherited by every layer. */
|
|
146
|
+
aes?: AesMap;
|
|
147
|
+
layers: Layer[];
|
|
148
|
+
scales?: { x?: PositionScale; y?: PositionScale; color?: ColorScale; colour?: ColorScale; fill?: ColorScale };
|
|
149
|
+
facet?: Facet;
|
|
150
|
+
coord?: Coord;
|
|
151
|
+
labels?: Labels;
|
|
152
|
+
/** A preset name or a theme overlay (default "minimal"). */
|
|
153
|
+
theme?: ThemePreset | ThemeConfig;
|
|
154
|
+
legend?: Legend;
|
|
155
|
+
/** Pixels (default 640 × 400). */
|
|
156
|
+
width?: number;
|
|
157
|
+
height?: number;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Axes/gridlines frame for a WebGL scatter overlay: the SVG (no marks) plus the
|
|
164
|
+
* panel rect in pixels and the expanded data domain that maps to the panel edges.
|
|
165
|
+
*/
|
|
166
|
+
export class Frame {
|
|
167
|
+
private constructor();
|
|
168
|
+
free(): void;
|
|
169
|
+
[Symbol.dispose](): void;
|
|
170
|
+
/**
|
|
171
|
+
* Panel rect `[x, y, width, height]` in pixels.
|
|
172
|
+
*/
|
|
173
|
+
readonly plot: Float64Array;
|
|
174
|
+
readonly svg: string;
|
|
175
|
+
/**
|
|
176
|
+
* Expanded x range `[min, max]` mapping to the panel's left/right edge.
|
|
177
|
+
*/
|
|
178
|
+
readonly xdom: Float64Array;
|
|
179
|
+
readonly ydom: Float64Array;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* An SVG plus the build warnings (rows dropped for non-finite values, layers
|
|
184
|
+
* whose stat produced no data, …).
|
|
185
|
+
*/
|
|
186
|
+
export class RenderResult {
|
|
187
|
+
private constructor();
|
|
188
|
+
free(): void;
|
|
189
|
+
[Symbol.dispose](): void;
|
|
190
|
+
readonly svg: string;
|
|
191
|
+
readonly warnings: string[];
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Bounding box `[minx, miny, maxx, maxy]` of a spec's `geometry` (WKT array) —
|
|
196
|
+
* so JS can initialise a pan/zoom (roam) window and zoom around the cursor.
|
|
197
|
+
*/
|
|
198
|
+
export function geo_bounds(spec_json: string): Float64Array;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The geom names {@link render} accepts.
|
|
202
|
+
*/
|
|
203
|
+
export function geoms(): string[];
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Render a layered plot spec (a {@link PlotSpec} object or its JSON text) to
|
|
207
|
+
* an SVG document. Throws an `Error` naming the offending field — unknown
|
|
208
|
+
* columns list the available ones.
|
|
209
|
+
*/
|
|
210
|
+
export function render(spec: PlotSpec | string): string;
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Like {@link render}, but also returns the build warnings.
|
|
214
|
+
*/
|
|
215
|
+
export function renderWithWarnings(spec: PlotSpec | string): RenderResult;
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Render a bar chart (SVG, hover tooltips) from `{ category: [String],
|
|
219
|
+
* value: [Number], width?, height?, title? }`. Bars are coloured by category
|
|
220
|
+
* with the Set1 palette — matching the scatter's groups for linked views.
|
|
221
|
+
*/
|
|
222
|
+
export function render_bar(spec_json: string): string;
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Render a `geom_sf` map from a JSON spec, returning an SVG document.
|
|
226
|
+
*
|
|
227
|
+
* Spec fields:
|
|
228
|
+
* - `geometry`: `[String]` — WKT (required)
|
|
229
|
+
* - `fill`: `[Number]` — choropleth values (optional)
|
|
230
|
+
* - `label`: `[String]` — hover labels (optional)
|
|
231
|
+
* - `fill_name`, `title`: `String` (optional)
|
|
232
|
+
* - `width`, `height`: `Number` (default 800×600)
|
|
233
|
+
* - `projection`: `"mercator"` | `"platecarree"` (default) | `"equal-earth"` |
|
|
234
|
+
* `"albers-usa"` | `"albers-europe"` | `"utm:<zone>"` / `"utm:<zone>s"` (south,
|
|
235
|
+
* zone 1-60)
|
|
236
|
+
*/
|
|
237
|
+
export function render_geo(spec_json: string): string;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Render a histogram (SVG) from a numeric array; `bins` sets the bin count —
|
|
241
|
+
* drive it from a slider for an interactive histogram. Feature `wasm`.
|
|
242
|
+
*/
|
|
243
|
+
export function render_hist(values: Float64Array, bins: number, width: number, height: number, title: string): string;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* General grammar-of-graphics renderer — expose most geoms to JS via a spec:
|
|
247
|
+
* `{ data: {col:[...]}, geom, aes:{x,y,color,fill,group,size}, title, width,
|
|
248
|
+
* height, flip, log_x, log_y, palette, bins, smooth:"lm"|"loess" }`. Returns an
|
|
249
|
+
* SVG document (with hover tooltips where the geom emits them).
|
|
250
|
+
*/
|
|
251
|
+
export function render_plot(spec_json: string): string;
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Render just the axes/gridlines (no marks, via `geom_blank`) for the given
|
|
255
|
+
* data ranges, returning the SVG plus the panel rect and expanded domain — the
|
|
256
|
+
* frame a WebGL/canvas layer draws points onto.
|
|
257
|
+
*/
|
|
258
|
+
export function scatter_frame(xmin: number, xmax: number, ymin: number, ymax: number, width: number, height: number, title: string): Frame;
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* The ggplot-rs version this package was built from.
|
|
262
|
+
*/
|
|
263
|
+
export function version(): string;
|
|
264
|
+
|
|
265
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
266
|
+
|
|
267
|
+
export interface InitOutput {
|
|
268
|
+
readonly memory: WebAssembly.Memory;
|
|
269
|
+
readonly __wbg_frame_free: (a: number, b: number) => void;
|
|
270
|
+
readonly __wbg_renderresult_free: (a: number, b: number) => void;
|
|
271
|
+
readonly frame_plot: (a: number) => [number, number];
|
|
272
|
+
readonly frame_svg: (a: number) => [number, number];
|
|
273
|
+
readonly frame_xdom: (a: number) => [number, number];
|
|
274
|
+
readonly frame_ydom: (a: number) => [number, number];
|
|
275
|
+
readonly geo_bounds: (a: number, b: number) => [number, number, number, number];
|
|
276
|
+
readonly geoms: () => [number, number];
|
|
277
|
+
readonly render: (a: any) => [number, number, number, number];
|
|
278
|
+
readonly renderWithWarnings: (a: any) => [number, number, number];
|
|
279
|
+
readonly render_bar: (a: number, b: number) => [number, number, number, number];
|
|
280
|
+
readonly render_geo: (a: number, b: number) => [number, number, number, number];
|
|
281
|
+
readonly render_hist: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number, number];
|
|
282
|
+
readonly render_plot: (a: number, b: number) => [number, number, number, number];
|
|
283
|
+
readonly renderresult_svg: (a: number) => [number, number];
|
|
284
|
+
readonly renderresult_warnings: (a: number) => [number, number];
|
|
285
|
+
readonly scatter_frame: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => [number, number, number];
|
|
286
|
+
readonly version: () => [number, number];
|
|
287
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
288
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
289
|
+
readonly __wbindgen_exn_store: (a: number) => void;
|
|
290
|
+
readonly __externref_table_alloc: () => number;
|
|
291
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
292
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
293
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
294
|
+
readonly __externref_drop_slice: (a: number, b: number) => void;
|
|
295
|
+
readonly __wbindgen_start: () => void;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
302
|
+
* a precompiled `WebAssembly.Module`.
|
|
303
|
+
*
|
|
304
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
305
|
+
*
|
|
306
|
+
* @returns {InitOutput}
|
|
307
|
+
*/
|
|
308
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
312
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
313
|
+
*
|
|
314
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
315
|
+
*
|
|
316
|
+
* @returns {Promise<InitOutput>}
|
|
317
|
+
*/
|
|
318
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|