plotters-skill 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +212 -0
- package/SKILL.md +535 -0
- package/index.js +153 -0
- package/node/index.d.ts +372 -0
- package/node/index.js +586 -0
- package/node/plotters-skill-addon.darwin-arm64.node +0 -0
- package/node/plotters-skill-addon.darwin-x64.node +0 -0
- package/node/plotters-skill-addon.linux-arm64-gnu.node +0 -0
- package/node/plotters-skill-addon.linux-x64-gnu.node +0 -0
- package/node/plotters-skill-addon.win32-x64-msvc.node +0 -0
- package/package.json +39 -0
- package/wasm/plotters_skill_wasm.d.ts +422 -0
- package/wasm/plotters_skill_wasm.js +1483 -0
- package/wasm/plotters_skill_wasm_bg.wasm +0 -0
package/node/index.d.ts
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* A flexible Cartesian axes that supports mixed series (line, scatter, bar,
|
|
5
|
+
* step, area) — similar to matplotlib's `Axes` object.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Axes {
|
|
8
|
+
title(t: string): void
|
|
9
|
+
xlabel(l: string): void
|
|
10
|
+
ylabel(l: string): void
|
|
11
|
+
figsize(w: number, h: number): void
|
|
12
|
+
xlim(lo: number, hi: number): void
|
|
13
|
+
ylim(lo: number, hi: number): void
|
|
14
|
+
/** `ChartBuilder::build_cartesian_2d(x_min..x_max, y_min..y_max)` shorthand. */
|
|
15
|
+
buildCartesian2d(xMin: number, xMax: number, yMin: number, yMax: number): void
|
|
16
|
+
margin(px: number): void
|
|
17
|
+
marginTop(px: number): void
|
|
18
|
+
marginBottom(px: number): void
|
|
19
|
+
marginLeft(px: number): void
|
|
20
|
+
marginRight(px: number): void
|
|
21
|
+
xLabelAreaSize(px: number): void
|
|
22
|
+
yLabelAreaSize(px: number): void
|
|
23
|
+
topXLabelAreaSize(px: number): void
|
|
24
|
+
rightYLabelAreaSize(px: number): void
|
|
25
|
+
captionFontSize(size: number): void
|
|
26
|
+
captionFontFamily(family: string): void
|
|
27
|
+
grid(show: boolean): void
|
|
28
|
+
legend(show: boolean): void
|
|
29
|
+
clear(): void
|
|
30
|
+
/** Configure mesh/grid — maps to plotters' `chart.configure_mesh()`. */
|
|
31
|
+
configureMesh(options: MeshOptions): void
|
|
32
|
+
/** Configure legend — maps to plotters' `chart.configure_series_labels()`. */
|
|
33
|
+
configureSeriesLabels(options: SeriesLabelOptions): void
|
|
34
|
+
/** Add a line series, similar to `ax.plot(x, y)`. */
|
|
35
|
+
plot(x: Array<number>, y: Array<number>, options?: PlotOptions | undefined | null): void
|
|
36
|
+
/** Add a scatter series, similar to `ax.scatter(x, y)`. */
|
|
37
|
+
scatter(x: Array<number>, y: Array<number>, options?: ScatterOptions | undefined | null): void
|
|
38
|
+
/** Add a vertical bar series, similar to `ax.bar(x, height)`. */
|
|
39
|
+
bar(x: Array<number>, heights: Array<number>, options?: BarOptions | undefined | null): void
|
|
40
|
+
/** Add a step-function series, similar to `ax.step(x, y)`. */
|
|
41
|
+
step(x: Array<number>, y: Array<number>, options?: StepOptions | undefined | null): void
|
|
42
|
+
/** Add a filled-area series, similar to `ax.fill_between(x, y1)`. */
|
|
43
|
+
fillBetween(x: Array<number>, y1: Array<number>, options?: FillBetweenOptions | undefined | null): void
|
|
44
|
+
/** Save to a PNG file. */
|
|
45
|
+
savefig(path: string): void
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A figure/canvas for creating plots, mirroring matplotlib's pyplot interface. */
|
|
49
|
+
export declare class Figure {
|
|
50
|
+
/** Add an area chart, similar to `plt.fill_between(x, y1, y2=0, color=..., alpha=...)`. */
|
|
51
|
+
fillBetween(x: Array<number>, y1: Array<number>, options?: AreaOptions | undefined | null): void
|
|
52
|
+
/**
|
|
53
|
+
* Add a box plot, similar to `plt.boxplot(datasets, tick_labels=..., showmeans=...)`.
|
|
54
|
+
*
|
|
55
|
+
* `datasets` is a list of data arrays — each inner array produces one box.
|
|
56
|
+
*/
|
|
57
|
+
boxplot(datasets: Array<Array<number>>, options?: BoxPlotOptions | undefined | null): void
|
|
58
|
+
/**
|
|
59
|
+
* Add a candlestick chart, similar to `mplfinance.plot(df, type='candle')`.
|
|
60
|
+
*
|
|
61
|
+
* `data` is a list of `[open, high, low, close]` arrays.
|
|
62
|
+
*/
|
|
63
|
+
candlestick(data: Array<Array<number>>, options?: CandlestickOptions | undefined | null): void
|
|
64
|
+
/** Add a histogram, similar to `plt.hist(data, bins=10, color=..., alpha=...)`. */
|
|
65
|
+
hist(data: Array<number>, options?: HistOptions | undefined | null): void
|
|
66
|
+
/** Add a line series, similar to `plt.plot(x, y, color=..., label=...)`. */
|
|
67
|
+
plot(x: Array<number>, y: Array<number>, options?: LineOptions | undefined | null): void
|
|
68
|
+
/** Remove all plot elements, keeping title / labels / dimensions. */
|
|
69
|
+
clear(): void
|
|
70
|
+
/**
|
|
71
|
+
* Save an animated GIF where each frame is a line chart snapshot.
|
|
72
|
+
*
|
|
73
|
+
* ```js
|
|
74
|
+
* fig.savegif('animation.gif', {
|
|
75
|
+
* frames: [
|
|
76
|
+
* [{ x: [0,1,2], y: [10,20,15] }],
|
|
77
|
+
* [{ x: [0,1,2,3], y: [10,20,15,25] }],
|
|
78
|
+
* ],
|
|
79
|
+
* delayMs: 200,
|
|
80
|
+
* });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
savegif(path: string, options: GifOptions): void
|
|
84
|
+
/** Add a pie or donut chart, similar to `plt.pie(values, labels=..., colors=...)`. */
|
|
85
|
+
pie(values: Array<number>, options?: PieOptions | undefined | null): void
|
|
86
|
+
/** Set the figure title. */
|
|
87
|
+
title(title: string): void
|
|
88
|
+
/** Set the x-axis label. */
|
|
89
|
+
xlabel(label: string): void
|
|
90
|
+
/** Set the y-axis label. */
|
|
91
|
+
ylabel(label: string): void
|
|
92
|
+
/** Set figure dimensions in pixels. */
|
|
93
|
+
figsize(width: number, height: number): void
|
|
94
|
+
/** Set explicit x-axis limits, similar to `ax.set_xlim(min, max)`. */
|
|
95
|
+
xlim(min: number, max: number): void
|
|
96
|
+
/** Set explicit y-axis limits, similar to `ax.set_ylim(min, max)`. */
|
|
97
|
+
ylim(min: number, max: number): void
|
|
98
|
+
/** Set chart margin in pixels. */
|
|
99
|
+
margin(pixels: number): void
|
|
100
|
+
/** Show or hide grid lines. */
|
|
101
|
+
grid(show: boolean): void
|
|
102
|
+
/** Save the figure to a PNG file. */
|
|
103
|
+
savefig(path: string): void
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* A flexible multi-row figure layout where each row can have a different
|
|
108
|
+
* number of columns.
|
|
109
|
+
*/
|
|
110
|
+
export declare class GridFigure {
|
|
111
|
+
/** Set the overall figure size in pixels. */
|
|
112
|
+
figsize(width: number, height: number): void
|
|
113
|
+
/** Set the overall super-title for the grid. */
|
|
114
|
+
suptitle(title: string): void
|
|
115
|
+
/** Add a new row with `ncols` columns. */
|
|
116
|
+
addRow(ncols: number): void
|
|
117
|
+
/** Number of rows in the grid. */
|
|
118
|
+
get nrows(): number
|
|
119
|
+
/** Number of columns in a specific row. */
|
|
120
|
+
ncols(row: number): number
|
|
121
|
+
/**
|
|
122
|
+
* Get the figure at `(row, col)` as a standalone `Figure`.
|
|
123
|
+
*
|
|
124
|
+
* Configure it, then put it back with `setAx(row, col, fig)`.
|
|
125
|
+
*/
|
|
126
|
+
ax(row: number, col: number): Figure
|
|
127
|
+
/** Put a configured figure back into the grid at `(row, col)`. */
|
|
128
|
+
setAx(row: number, col: number, fig: Figure): void
|
|
129
|
+
/** Save the grid figure to a PNG file. */
|
|
130
|
+
savefig(path: string): void
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** A grid of sub-figures, similar to matplotlib's `fig, axes = plt.subplots(nrows, ncols)`. */
|
|
134
|
+
export declare class SubPlots {
|
|
135
|
+
/** Set the overall figure size in pixels. */
|
|
136
|
+
figsize(width: number, height: number): void
|
|
137
|
+
/** Set the overall super-title for the grid. */
|
|
138
|
+
suptitle(title: string): void
|
|
139
|
+
/** Number of rows in the grid. */
|
|
140
|
+
get nrows(): number
|
|
141
|
+
/** Number of columns in the grid. */
|
|
142
|
+
get ncols(): number
|
|
143
|
+
/**
|
|
144
|
+
* Get the figure at `(row, col)` as a standalone `Figure`.
|
|
145
|
+
*
|
|
146
|
+
* **Note:** this extracts the figure from the grid. Configure it via
|
|
147
|
+
* the returned `Figure`, then put it back with `setAx(row, col, fig)`.
|
|
148
|
+
*/
|
|
149
|
+
ax(row: number, col: number): Figure
|
|
150
|
+
/** Put a configured figure back into the grid at `(row, col)`. */
|
|
151
|
+
setAx(row: number, col: number, fig: Figure): void
|
|
152
|
+
/** Save the subplot grid to a PNG file. */
|
|
153
|
+
savefig(path: string): void
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** Area chart options matching matplotlib's `plt.fill_between()` keyword arguments. */
|
|
157
|
+
export interface AreaOptions {
|
|
158
|
+
/** Baseline y-value, similar to `y2=0` (default: 0.0). */
|
|
159
|
+
y2?: number
|
|
160
|
+
/** Fill colour name or hex code. */
|
|
161
|
+
color?: string
|
|
162
|
+
/** Opacity from 0.0 (transparent) to 1.0 (opaque), default 0.3. */
|
|
163
|
+
alpha?: number
|
|
164
|
+
/** Legend label. */
|
|
165
|
+
label?: string
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Create a new flexible Axes, similar to `fig, ax = plt.subplots()`. */
|
|
169
|
+
export declare function axes(): Axes
|
|
170
|
+
|
|
171
|
+
export interface BarOptions {
|
|
172
|
+
color?: string
|
|
173
|
+
barWidth?: number
|
|
174
|
+
label?: string
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Box plot options matching matplotlib's `plt.boxplot()` keyword arguments. */
|
|
178
|
+
export interface BoxPlotOptions {
|
|
179
|
+
/** Category labels for the x-axis, similar to `tick_labels=[...]`. */
|
|
180
|
+
tickLabels?: Array<string>
|
|
181
|
+
/** Box colour name or hex code. */
|
|
182
|
+
color?: string
|
|
183
|
+
/** Legend label. */
|
|
184
|
+
label?: string
|
|
185
|
+
/** Whether to show mean markers, similar to `showmeans=True`. */
|
|
186
|
+
showMeans?: boolean
|
|
187
|
+
/** Whether to show outlier points beyond whiskers, similar to `showfliers=True`. */
|
|
188
|
+
showFliers?: boolean
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Candlestick chart options matching mplfinance-style keyword arguments. */
|
|
192
|
+
export interface CandlestickOptions {
|
|
193
|
+
/** X-axis tick labels (e.g. date strings). */
|
|
194
|
+
labels?: Array<string>
|
|
195
|
+
/** Colour for bullish (close >= open) candles. */
|
|
196
|
+
upColor?: string
|
|
197
|
+
/** Colour for bearish (close < open) candles. */
|
|
198
|
+
downColor?: string
|
|
199
|
+
/** Candle body width in pixels (default: 15). */
|
|
200
|
+
width?: number
|
|
201
|
+
/** Legend label. */
|
|
202
|
+
label?: string
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/** Create a new figure, equivalent to `plt.figure()`. */
|
|
206
|
+
export declare function figure(): Figure
|
|
207
|
+
|
|
208
|
+
export interface FillBetweenOptions {
|
|
209
|
+
color?: string
|
|
210
|
+
y2?: number
|
|
211
|
+
alpha?: number
|
|
212
|
+
label?: string
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** Options for `savegif()`. */
|
|
216
|
+
export interface GifOptions {
|
|
217
|
+
/** Each element is a frame; each frame is a list of `{ x, y }` line series. */
|
|
218
|
+
frames: Array<Array<GifSeries>>
|
|
219
|
+
/** Delay between frames in milliseconds (default: 100). */
|
|
220
|
+
delayMs?: number
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** A single `(x, y)` series used as one frame in an animated GIF. */
|
|
224
|
+
export interface GifSeries {
|
|
225
|
+
x: Array<number>
|
|
226
|
+
y: Array<number>
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Create an empty grid figure. Add rows with `addRow(ncols)`.
|
|
231
|
+
*
|
|
232
|
+
* Unlike `subplots(nrows, ncols)` which creates a uniform grid, `gridFigure()`
|
|
233
|
+
* lets each row have a different number of columns.
|
|
234
|
+
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* const grid = gridFigure();
|
|
237
|
+
* grid.addRow(2); // row 0: two columns
|
|
238
|
+
* grid.addRow(1); // row 1: one full-width column
|
|
239
|
+
* grid.figsize(1200, 800);
|
|
240
|
+
* grid.suptitle("Mixed Layout");
|
|
241
|
+
*
|
|
242
|
+
* const ax = grid.ax(0, 0);
|
|
243
|
+
* ax.hist(data, { bins: 10 });
|
|
244
|
+
* grid.setAx(0, 0, ax);
|
|
245
|
+
* grid.savefig("grid.png");
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export declare function gridFigure(): GridFigure
|
|
249
|
+
|
|
250
|
+
/** Histogram options matching matplotlib's `plt.hist()` keyword arguments. */
|
|
251
|
+
export interface HistOptions {
|
|
252
|
+
/** Number of bins (default: 10). */
|
|
253
|
+
bins?: number
|
|
254
|
+
/** Bar colour name or hex code, e.g. `"steelblue"` or `"#4682B4"`. */
|
|
255
|
+
color?: string
|
|
256
|
+
/** Transparency from 0.0 (transparent) to 1.0 (opaque). */
|
|
257
|
+
alpha?: number
|
|
258
|
+
/** Legend label. */
|
|
259
|
+
label?: string
|
|
260
|
+
/** Minimum value of the data range. */
|
|
261
|
+
rangeMin?: number
|
|
262
|
+
/** Maximum value of the data range. */
|
|
263
|
+
rangeMax?: number
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/** Line chart options matching matplotlib's `plt.plot()` keyword arguments. */
|
|
267
|
+
export interface LineOptions {
|
|
268
|
+
/** Colour name or hex code, e.g. `"steelblue"` or `"#1f77b4"`. */
|
|
269
|
+
color?: string
|
|
270
|
+
/** Line width in pixels (default: 2). */
|
|
271
|
+
lineWidth?: number
|
|
272
|
+
/** Legend label. */
|
|
273
|
+
label?: string
|
|
274
|
+
/** Fix the y-axis lower bound (useful for animation). */
|
|
275
|
+
yRangeMin?: number
|
|
276
|
+
/** Fix the y-axis upper bound (useful for animation). */
|
|
277
|
+
yRangeMax?: number
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Options for `configureMesh()` — maps to plotters' `MeshStyle`. */
|
|
281
|
+
export interface MeshOptions {
|
|
282
|
+
xLabels?: number
|
|
283
|
+
yLabels?: number
|
|
284
|
+
xLabelOffset?: number
|
|
285
|
+
yLabelOffset?: number
|
|
286
|
+
disableXMesh?: boolean
|
|
287
|
+
disableYMesh?: boolean
|
|
288
|
+
disableAxes?: boolean
|
|
289
|
+
disableXAxis?: boolean
|
|
290
|
+
disableYAxis?: boolean
|
|
291
|
+
xMaxLightLines?: number
|
|
292
|
+
yMaxLightLines?: number
|
|
293
|
+
boldLineColor?: string
|
|
294
|
+
boldLineAlpha?: number
|
|
295
|
+
lightLineColor?: string
|
|
296
|
+
lightLineAlpha?: number
|
|
297
|
+
axisColor?: string
|
|
298
|
+
labelFontSize?: number
|
|
299
|
+
axisDescFontSize?: number
|
|
300
|
+
xLabelFontSize?: number
|
|
301
|
+
yLabelFontSize?: number
|
|
302
|
+
tickMarkSize?: number
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Pie chart options matching pyplot-style `pie()` keyword arguments. */
|
|
306
|
+
export interface PieOptions {
|
|
307
|
+
/** Labels for each slice. */
|
|
308
|
+
labels?: Array<string>
|
|
309
|
+
/** Slice colours by CSS-style name or hex code. */
|
|
310
|
+
colors?: Array<string>
|
|
311
|
+
/** Starting angle in degrees. */
|
|
312
|
+
startAngle?: number
|
|
313
|
+
/** Inner radius for drawing a donut chart. */
|
|
314
|
+
donutHole?: number
|
|
315
|
+
/** Label offset relative to the pie radius. */
|
|
316
|
+
labelOffset?: number
|
|
317
|
+
/** Whether to draw percentage labels inside slices. */
|
|
318
|
+
showPercentages?: boolean
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export interface PlotOptions {
|
|
322
|
+
color?: string
|
|
323
|
+
lineWidth?: number
|
|
324
|
+
label?: string
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
export interface ScatterOptions {
|
|
328
|
+
color?: string
|
|
329
|
+
markerSize?: number
|
|
330
|
+
label?: string
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/** Options for `configureSeriesLabels()`. */
|
|
334
|
+
export interface SeriesLabelOptions {
|
|
335
|
+
position?: string
|
|
336
|
+
margin?: number
|
|
337
|
+
legendAreaSize?: number
|
|
338
|
+
backgroundColor?: string
|
|
339
|
+
backgroundAlpha?: number
|
|
340
|
+
borderColor?: string
|
|
341
|
+
fontSize?: number
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export interface StepOptions {
|
|
345
|
+
color?: string
|
|
346
|
+
lineWidth?: number
|
|
347
|
+
label?: string
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Create a subplot grid, equivalent to `plt.subplots(nrows, ncols)`.
|
|
352
|
+
*
|
|
353
|
+
* Returns a grid of figures that can each hold their own chart.
|
|
354
|
+
*
|
|
355
|
+
* ```ts
|
|
356
|
+
* const grid = subplots(2, 2);
|
|
357
|
+
* grid.figsize(1200, 800);
|
|
358
|
+
* grid.suptitle("2×2 Grid");
|
|
359
|
+
*
|
|
360
|
+
* let ax = grid.ax(0, 0);
|
|
361
|
+
* ax.hist(data, { bins: 10 });
|
|
362
|
+
* ax.title("Distribution");
|
|
363
|
+
* grid.setAx(0, 0, ax);
|
|
364
|
+
*
|
|
365
|
+
* ax = grid.ax(1, 0);
|
|
366
|
+
* ax.pie(values);
|
|
367
|
+
* grid.setAx(1, 0, ax);
|
|
368
|
+
*
|
|
369
|
+
* grid.savefig("grid.png");
|
|
370
|
+
* ```
|
|
371
|
+
*/
|
|
372
|
+
export declare function subplots(nrows: number, ncols: number): SubPlots
|