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 ADDED
@@ -0,0 +1,212 @@
1
+ # PlottersSkill
2
+
3
+ <p align="center">
4
+ <img src="assets/demo_01.gif" alt="PlottersSkill Demo" width="100%">
5
+ </p>
6
+
7
+ <p align="center">
8
+ <img src="assets/banner_1.png" alt="PlottersSkill Banner" width="50%">
9
+ </p>
10
+
11
+ High-performance plotting for TypeScript / JavaScript, powered by the Rust
12
+ [plotters](https://github.com/plotters-rs/plotters) crate with a
13
+ **matplotlib pyplot-like API**.
14
+
15
+ Works in **Node.js** (native addon via napi-rs) and the **browser**
16
+ (WASM + SVG / Canvas via wasm-bindgen).
17
+
18
+ ## Quick Start
19
+
20
+ ### Node.js
21
+
22
+ ```bash
23
+ npm install plotters-skill
24
+ ```
25
+
26
+ ```typescript
27
+ import { figure } from 'plotters-skill';
28
+
29
+ const fig = figure();
30
+ fig.title('Hello PlottersSkill');
31
+ fig.plot([0, 1, 2, 3, 4], [10, 25, 18, 30, 22], {
32
+ color: 'steelblue', label: 'Revenue',
33
+ });
34
+ fig.savefig('chart.png');
35
+ ```
36
+
37
+ ### Browser (WASM)
38
+
39
+ ```typescript
40
+ import init, { figure } from 'plotters-skill';
41
+
42
+ await init();
43
+ const fig = figure();
44
+ fig.hist([1, 2, 2, 3, 3, 3, 4, 5], { bins: 10, color: 'steelblue' });
45
+ fig.draw(canvas); // render to an HTML5 Canvas element
46
+ ```
47
+
48
+ ## Chart Types
49
+
50
+ | Chart | `figure()` | `axes()` | Node | WASM |
51
+ |-------|:----------:|:--------:|:----:|:----:|
52
+ | Histogram | ✅ | — | ✅ | ✅ |
53
+ | Pie / Donut | ✅ | — | ✅ | ✅ |
54
+ | Box Plot | ✅ | — | ✅ | ✅ |
55
+ | Area (fillBetween) | ✅ | ✅ | ✅ | ✅ |
56
+ | Candlestick (OHLC) | ✅ | — | ✅ | ✅ |
57
+ | Line | ✅ | ✅ | ✅ | ✅ |
58
+ | Scatter | — | ✅ | ✅ | ✅ |
59
+ | Bar | — | ✅ | ✅ | ✅ |
60
+ | Step | — | ✅ | ✅ | ✅ |
61
+
62
+ ## API Overview
63
+
64
+ | Function | pyplot Equivalent | Description |
65
+ |----------|-------------------|-------------|
66
+ | `figure()` | `plt.figure()` | Single figure — hist, pie, plot, fillBetween, candlestick, boxplot |
67
+ | `axes()` | `fig, ax = plt.subplots()` | Flexible Cartesian axes — mix plot, scatter, bar, step, fillBetween |
68
+ | `subplots(nrows, ncols)` | `plt.subplots(nrows, ncols)` | Uniform NxM subplot grid |
69
+ | `gridFigure()` | `plt.subplot_mosaic()` | Flexible grid — each row can have different column counts |
70
+
71
+ ## Examples
72
+
73
+ ### Multi-series overlay (auto-cycling colours)
74
+
75
+ ```typescript
76
+ import { figure } from 'plotters-skill';
77
+
78
+ const fig = figure();
79
+ fig.title('Sales Comparison');
80
+ fig.xlabel('Month');
81
+ fig.ylabel('Revenue');
82
+ fig.fillBetween(months, seriesA, { alpha: 0.3, label: 'Product A' });
83
+ fig.fillBetween(months, seriesB, { alpha: 0.3, label: 'Product B' });
84
+ fig.savefig('comparison.png');
85
+ ```
86
+
87
+ ### Mixed series with axes()
88
+
89
+ ```typescript
90
+ import { axes } from 'plotters-skill';
91
+
92
+ const ax = axes();
93
+ ax.figsize(900, 540);
94
+ ax.title('Trend vs Actual');
95
+ ax.xlabel('x');
96
+ ax.ylabel('y');
97
+ ax.plot([0, 1, 2, 3, 4], [10, 25, 18, 30, 22], {
98
+ color: 'steelblue', lineWidth: 2, label: 'Trend',
99
+ });
100
+ ax.scatter([0, 1, 2, 3, 4], [12, 20, 22, 28, 25], {
101
+ color: 'coral', markerSize: 6, label: 'Actual',
102
+ });
103
+ ax.legend(true);
104
+ ax.savefig('chart.png');
105
+ ```
106
+
107
+ ### Subplot grid
108
+
109
+ ```typescript
110
+ import { subplots } from 'plotters-skill';
111
+
112
+ const grid = subplots(1, 2);
113
+ grid.figsize(1200, 500);
114
+ grid.suptitle('Dashboard');
115
+
116
+ let ax = grid.ax(0, 0);
117
+ ax.hist(data, { bins: 25, color: 'steelblue' });
118
+ grid.setAx(0, 0, ax);
119
+
120
+ ax = grid.ax(0, 1);
121
+ ax.pie([40, 30, 20, 10], {
122
+ labels: ['Web', 'Mobile', 'Desktop', 'Other'],
123
+ });
124
+ grid.setAx(0, 1, ax);
125
+
126
+ grid.savefig('dashboard.png');
127
+ ```
128
+
129
+ ### Animated GIF (Node.js)
130
+
131
+ ```typescript
132
+ const frames = [];
133
+ for (let i = 2; i <= x.length; i++) {
134
+ frames.push([{ x: x.slice(0, i), y: y.slice(0, i) }]);
135
+ }
136
+ fig.savegif('animation.gif', { frames, delayMs: 200 });
137
+ ```
138
+
139
+ ## Output Formats
140
+
141
+ | Format | Node | WASM |
142
+ |--------|:----:|:----:|
143
+ | PNG file (`savefig`) | ✅ | — |
144
+ | Animated GIF (`savegif`) | ✅ | — |
145
+ | SVG string (`render`) | ✅ | ✅ |
146
+ | HTML5 Canvas (`draw`) | — | ✅ |
147
+
148
+ ## Colours
149
+
150
+ Supports **matplotlib tab10** palette (`c0`–`c9`), common **CSS** names
151
+ (`steelblue`, `coral`, `gold`, `teal`, …), and **hex** codes (`#RRGGBB`).
152
+ Colours auto-cycle through tab10 when omitted in multi-series charts.
153
+
154
+ ## VS Code Extension
155
+
156
+ The **PlottersSkill** extension brings chart generation directly into VS Code
157
+ via Copilot Chat. Install the `.vsix` or search for "PlottersSkill" in the
158
+ marketplace.
159
+
160
+ ### `@plotters` Chat Participant
161
+
162
+ Type `@plotters` in Copilot Chat followed by a natural language description:
163
+
164
+ ```
165
+ @plotters a histogram of 500 normally-distributed values with 30 bins
166
+ @plotters /pie revenue split: Web 40%, Mobile 30%, Desktop 20%, Other 10%
167
+ @plotters /line monthly sales for 2024 with three product lines
168
+ ```
169
+
170
+ Slash commands: `/histogram`, `/pie`, `/line`, `/scatter`, `/area`, `/boxplot`,
171
+ `/candlestick`, `/axes`, `/subplots`.
172
+
173
+ ### How it works
174
+
175
+ 1. Your prompt is sent to the Copilot LLM with the plotters-skill API reference
176
+ 2. The LLM generates a TypeScript script
177
+ 3. The script is **type-checked** against the `.d.ts` — errors are fed back for auto-fix (up to 3 retries)
178
+ 4. The passing script runs in a **sandboxed VM** — no filesystem or network access
179
+ 5. The rendered chart image is sent back to the LLM for **verification**
180
+ 6. The PNG is displayed inline in chat
181
+
182
+ ### Features
183
+
184
+ | Feature | Description |
185
+ |---------|-------------|
186
+ | **Chart History** | Gallery sidebar in Explorer — browse, re-render, or delete past charts |
187
+ | **Edit Script** | One-click button opens the generated TypeScript with a "▶ Render Chart" CodeLens |
188
+ | **LLM Verification** | Charts are verified against the original request; mismatches trigger automatic retry |
189
+ | **Inline Errors** | Type-check and runtime errors shown in chat during retries |
190
+ | **Feedback Tracking** | 👍/👎 on chat responses tracked for stats (`PlottersSkill: Show Feedback Stats`) |
191
+ | **Notebook Support** | `*.plotters-notebook` files — TypeScript cells execute with inline PNG output |
192
+ | **Render from Editor** | `PlottersSkill: Render Chart from Active Editor` — run any `.ts` script directly |
193
+ | **Configurable** | Settings for retry count, VM timeout, preferred model, and source visibility |
194
+
195
+ ### AI Skill Installation
196
+
197
+ The bundled `SKILL.md` can be installed into any project so Copilot, Claude, or
198
+ other AI tools automatically discover the plotters-skill API:
199
+
200
+ ```bash
201
+ npx plotters-skill install-skill # all tools
202
+ npx plotters-skill install-skill --target copilot # .github/skills/plotters-skill/
203
+ npx plotters-skill install-skill --target claude # .claude/skills/plotters-skill/
204
+ ```
205
+
206
+ ## Development
207
+
208
+ See [DEV.md](DEV.md) for prerequisites, build commands, tests, and project structure.
209
+
210
+ ## License
211
+
212
+ MIT