mviz 1.5.0 → 1.5.2

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.
Files changed (2) hide show
  1. package/README.md +392 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,392 @@
1
+ # mviz
2
+
3
+ Generate beautiful static reports for ad hoc analysis. A Claude skill that turns compact JSON specs into professional HTML visualizations.
4
+
5
+ ![Light Mode Dashboard](LightMode.png)
6
+
7
+ ![Dark Mode Dashboard](DarkMode.png)
8
+
9
+ ## Why mviz?
10
+
11
+ **The highest-value analysis in any company is point-in-time, highly contextual, and not reused once the decision is made.**
12
+
13
+ Traditional BI tools optimize for reusability instead of usefulness. Useful analysis, the kind that drives critical decisions, needs something more:
14
+
15
+ - **Fast iteration**: Query data → visualize → refine → share
16
+ - **AI-native workflow**: Works seamlessly with Claude for data exploration
17
+ - **Static output**: Beautiful HTML/PDF reports, no infrastructure required
18
+ - **Minimal tokens**: Compact specs instead of verbose chart code
19
+
20
+ Instead of writing 50-100 lines of chart boilerplate, write a compact JSON spec that gets expanded into a full HTML artifact with ECharts.
21
+
22
+ ## Quick Start
23
+
24
+ ### 1. Connect Your Database
25
+
26
+ Connect Claude to your data using an MCP server:
27
+
28
+ - **[MotherDuck MCP](https://motherduck.com/docs/sql-reference/mcp/)** - Cloud data warehouse with DuckDB compatibility
29
+ - **[Local DuckDB MCP](https://github.com/motherduckdb/mcp-server-motherduck)** - Query local `.duckdb` files, Parquet, CSV, or S3 data
30
+
31
+ If you do not have a database available, you can also load CSV files directly, although the amount of data you can fit in context can be quite limiting.
32
+
33
+ ### 2. Add the Skill
34
+
35
+ **Claude Web or Desktop:** Download [`mviz.skill`](https://gist.github.com/matsonj/1c13b656bca20b1d2cc6260309d8eb40) and add it to your project knowledge.
36
+
37
+ **Claude Code:** Run `npx add-skill matsonj/mviz` or clone this repo and work from the directory.
38
+
39
+ ### 3. Effective Use Tips
40
+
41
+ The best analysis follows four steps:
42
+
43
+ 1. **Build context** — Get the data right. Query, filter, and explore until you understand what you're looking at.
44
+ 2. **Develop narrative** — What's the story? What question are you answering? What pattern matters?
45
+ 3. **First pass on viz** — Create an initial visualization. Don't overthink it.
46
+ 4. **Refine based on what doesn't work** — Iterate. Change chart types, adjust formatting, add context.
47
+
48
+ Start by exploring your data with natural questions. Claude writes SQL queries behind the scenes and brings the results into context:
49
+
50
+ > *"Show me revenue by region for Q4"*
51
+
52
+ > *"What are our top 10 customers by lifetime value?"*
53
+
54
+ > *"Are there any anomalies in last month's sales data?"*
55
+
56
+ Once you've built up context and are ready to visualize, tell Claude to **"use mviz to report on this analysis"**. Claude generates a polished HTML report from the data you've explored.
57
+
58
+ ### 4. Iterate
59
+
60
+ Refine your analysis by asking follow-up questions:
61
+
62
+ > *"Change that bar chart to a line chart"*
63
+
64
+ > *"Drill into the APAC region—what's driving that spike?"*
65
+
66
+ > *"Add a table showing the top 5 products by growth rate"*
67
+
68
+ ### mviz Specific Guidance
69
+
70
+ mviz uses a 16-column grid.
71
+
72
+ > *"Make the bar chart wider"*
73
+
74
+ > *"Show two charts side by side at size=[8,6] each"*
75
+
76
+ > *"Make the KPIs smaller: size=[3,2] so 5 fit in a row"*
77
+
78
+ By default, it will use `size=auto` to let mviz calculate appropriate dimensions based on your data.
79
+
80
+ > [!TIP]
81
+ > There are more chart types available in the library than are included in the skill.md. You can tell Claude to look at the TypeScript source for more chart types if you really need them.
82
+
83
+ Each iteration builds on your existing context. When you're done, save the HTML or print to PDF.
84
+
85
+ ## Supported Chart Types
86
+
87
+ | Type | Description | mviz.skill |
88
+ |------|-------------|:----------:|
89
+ | `bar` | Vertical/horizontal, grouped, stacked | ✓ |
90
+ | `line` | Single or multi-series with linear interpolation | ✓ |
91
+ | `area` | Simple or stacked area charts | |
92
+ | `pie` | Pie or donut charts | |
93
+ | `scatter` | 2D scatter plots | ✓ |
94
+ | `bubble` | Scatter with size dimension (auto-detects categorical axes) | |
95
+ | `boxplot` | Statistical box plots | |
96
+ | `histogram` | Distribution visualization | |
97
+ | `sankey` | Flow diagrams | |
98
+ | `funnel` | Conversion funnels | |
99
+ | `heatmap` | 2D color matrices | |
100
+ | `calendar` | GitHub-style calendar heatmaps | |
101
+ | `sparkline` | Compact inline charts | |
102
+ | `combo` | Combined bar + line with dual axes | |
103
+ | `waterfall` | Cumulative effect charts | |
104
+ | `xmr` | Statistical control charts (supports `yMin`/`yMax`) | |
105
+ | `dumbbell` | Before/after comparisons with directional color-coding | |
106
+
107
+ ## UI Components
108
+
109
+ | Type | Description | mviz.skill |
110
+ |------|-------------|:----------:|
111
+ | `big_value` | Large KPI metric display | |
112
+ | `delta` | Change indicator with arrow | |
113
+ | `table` | Data tables with formatting and inline sparklines | ✓ |
114
+ | `alert` | Colored notification banners | |
115
+ | `note` | Information callout boxes | ✓ |
116
+ | `text` | Styled paragraphs | |
117
+ | `textarea` | Markdown-rendered text blocks | ✓ |
118
+ | `empty_space` | Layout spacing component | ✓ |
119
+
120
+ ## File References (JSON and CSV)
121
+
122
+ Reference external files instead of embedding large JSON specs:
123
+
124
+ ````markdown
125
+ ```bar file=data/monthly-sales.json
126
+ ```
127
+ ````
128
+
129
+ ### DuckDB Workflow
130
+
131
+ CSV files work great for data exploration with DuckDB:
132
+
133
+ ```bash
134
+ # Export query results
135
+ duckdb -csv -c "SELECT month, revenue FROM sales GROUP BY 1" > data/monthly.csv
136
+ ```
137
+
138
+ ````markdown
139
+ ```bar file=data/monthly.csv
140
+ {"title": "Monthly Revenue", "x": "month", "y": "revenue"}
141
+ ```
142
+ ````
143
+
144
+ CSV provides data, inline JSON provides chart options. Auto-detects x/y from first two columns if no options given.
145
+
146
+ ## Report Markdown Format
147
+
148
+ ````markdown
149
+ ---
150
+ theme: light
151
+ title: My Report
152
+ ---
153
+
154
+ # Page Title
155
+
156
+ ## Section Name
157
+
158
+ ```big_value size=[4,2]
159
+ {"value": 125000, "label": "Revenue", "format": "usd0m"}
160
+ ```
161
+ ```delta size=[4,2]
162
+ {"value": 0.15, "label": "vs Last Month", "format": "pct0"}
163
+ ```
164
+
165
+ ```bar size=[8,6] file=data/sales.json
166
+ ```
167
+ ```line size=[8,6] file=data/trend.json
168
+ ```
169
+ ````
170
+
171
+ ### Layout Rules
172
+
173
+ - `# Title` creates a new section (first one also sets page title)
174
+ - `## Section` creates a subsection title (no visual divider)
175
+ - `---` creates a visual section divider
176
+ - `===` creates a page break for printing
177
+ - `size=[cols,rows]` controls 16-column grid layout
178
+ - `size=auto` auto-calculates size based on data
179
+ - `file=path` references external JSON
180
+ - Multiple blocks on same line = same row
181
+ - Empty lines = new rows
182
+
183
+ ## 16-Column Grid System
184
+
185
+ | Component | Default Size | Notes |
186
+ |-----------|-------------|-------|
187
+ | `big_value`, `delta`, `sparkline` | [4, 2] | Fits 4 per row |
188
+ | `bar`, `line`, `area`, `pie` | [8, 5] | Half width |
189
+ | `scatter`, `bubble`, `combo`, `funnel` | [8, 5] | Half width |
190
+ | `dumbbell` | [12, 6] | 3/4 width for comparisons |
191
+ | `table`, `heatmap` | [16, 4-10] | Full width |
192
+ | `xmr`, `calendar` | [16, 6] | Full width, tall |
193
+
194
+ ## Table with Sparklines
195
+
196
+ Tables support inline sparkline columns for trend visualization:
197
+
198
+ ```json
199
+ {
200
+ "type": "table",
201
+ "columns": [
202
+ {"id": "product", "title": "Product"},
203
+ {"id": "sales", "title": "Sales", "fmt": "usd"},
204
+ {"id": "trend", "title": "Trend", "type": "sparkline", "sparkType": "line"},
205
+ {"id": "progress", "title": "Goal", "type": "sparkline", "sparkType": "pct_bar", "width": 100}
206
+ ],
207
+ "data": [
208
+ {"product": "Widget", "sales": 125000, "trend": [85, 92, 88, 95, 102, 110, 125], "progress": 0.85}
209
+ ]
210
+ }
211
+ ```
212
+
213
+ Sparkline types: `line`, `bar`, `area`, `pct_bar` (progress bar), `dumbbell` (before/after)
214
+
215
+ ## Format Options
216
+
217
+ | Format | Output | Description |
218
+ |--------|--------|-------------|
219
+ | `auto` | 1.000m, 10.00k | **Smart auto-format (default)** |
220
+ | `usd_auto` | $1.000m, $10.00k | Smart auto-format with $ |
221
+ | `usd0m` | $1.2m | Millions |
222
+ | `usd0k` | $125k | Compact thousands |
223
+ | `usd` | $1,250,000 | Full dollars |
224
+ | `pct0` | 15% | Percentage integer |
225
+ | `pct` | 15.0% | Percentage with decimal |
226
+ | `pct1` | 15.0% | Percentage with 1 decimal |
227
+ | `num0` | 1,250 | Number with commas |
228
+
229
+ Smart formatting automatically picks the right suffix (k, m, b) based on magnitude and shows 4 significant digits. Negative values display in parentheses: `(1.000m)`.
230
+
231
+ ### Auto-Detected Formatting
232
+
233
+ Chart axes automatically detect the appropriate format based on field names:
234
+
235
+ | Field Pattern | Auto Format | Example |
236
+ |---------------|-------------|---------|
237
+ | revenue, sales, price, cost, profit | `usd_auto` | $1.250m |
238
+ | pct, percent, rate, ratio | `pct` or `pct0` | 15.0% |
239
+ | All other fields | `auto` | 1.250m |
240
+
241
+ Override with an explicit `format` field in the chart spec.
242
+
243
+ ## Theme Toggle
244
+
245
+ Reports include a theme toggle button (top right) that switches between light and dark modes. All charts dynamically update when the theme changes.
246
+
247
+ Set the default theme in frontmatter:
248
+
249
+ ```yaml
250
+ ---
251
+ theme: dark
252
+ title: My Report
253
+ ---
254
+ ```
255
+
256
+ ## Print and PDF Support
257
+
258
+ Charts are optimized for printing to PDF:
259
+
260
+ - **High-Quality Rendering**: Uses SVG renderer for crisp vector graphics at any zoom level
261
+ - **No Page Breaks in Charts**: CSS prevents charts and tables from being split across pages
262
+ - **All Labels Visible**: Category labels are always shown (with 45° rotation to fit)
263
+
264
+ When printing reports to PDF, all content stays intact without visual elements being cut off.
265
+
266
+ ## Visual Style (mdsinabox theme)
267
+
268
+ Clean, data-focused styling:
269
+
270
+ - **Font**: Helvetica Neue (system sans-serif)
271
+ - **Signature**: Orange accent line at top of reports
272
+ - **Background**: Paper (`#f8f8f8`) for light, dark (`#231f20`) for dark
273
+
274
+ ### Color Palette
275
+
276
+ | Color | Hex | Use |
277
+ |-------|-----|-----|
278
+ | Primary Blue | `#0777b3` | Primary series |
279
+ | Secondary Orange | `#bd4e35` | Secondary series, accent |
280
+ | Info Blue | `#638CAD` | Tertiary |
281
+ | Positive Green | `#2d7a00` | Success, positive values |
282
+ | Warning Amber | `#e18727` | Warnings |
283
+ | Error Red | `#bc1200` | Errors, negative emphasis |
284
+
285
+ ## Project Structure
286
+
287
+ ```
288
+ chart-skill/
289
+ ├── ts-src/ # TypeScript implementation
290
+ │ ├── cli.ts # CLI entry point
291
+ │ ├── index.ts # Library exports
292
+ │ ├── types.ts # TypeScript type definitions
293
+ │ ├── core/ # Shared utilities
294
+ │ │ ├── themes.ts # Colors, palettes, theme config
295
+ │ │ ├── formatting.ts # Number formatting
296
+ │ │ └── css.ts # CSS generation
297
+ │ ├── charts/ # 17 chart type modules
298
+ │ │ ├── bar.ts, line.ts, area.ts, pie.ts, scatter.ts, bubble.ts
299
+ │ │ ├── boxplot.ts, histogram.ts, waterfall.ts, xmr.ts
300
+ │ │ ├── sankey.ts, funnel.ts, heatmap.ts, calendar.ts
301
+ │ │ └── sparkline.ts, combo.ts, dumbbell.ts
302
+ │ ├── components/ # 8 UI component modules
303
+ │ │ ├── big_value.ts, delta.ts, alert.ts, note.ts
304
+ │ │ ├── text.ts, textarea.ts, empty_space.ts, table.ts
305
+ │ └── layout/ # Report parser
306
+ │ ├── parser.ts # Markdown layout parsing
307
+ │ └── templates.ts # HTML templates
308
+ ├── build_skill.py # Builds .skill package for distribution
309
+ ├── tests/
310
+ │ ├── harness/ # Visual test harness markdown
311
+ │ ├── dashboard-inline/ # Test dashboard with inline JSON
312
+ │ └── dashboard-with-refs/ # Test dashboard with file references
313
+ ├── docs/
314
+ │ ├── MD-CHARTS-PROJECT.md # Original project specification
315
+ │ └── agents.md # Skill authoring reference
316
+ └── skill-bundle/ # Source files for the skill
317
+ ├── SKILL.md # Skill instructions (with YAML frontmatter)
318
+ ├── reference/
319
+ │ └── chart-types.md # Complete API reference
320
+ └── examples/ # JSON and markdown examples
321
+ ```
322
+
323
+ ## Warning Messages
324
+
325
+ The chart generator outputs helpful warnings to stderr when issues are detected:
326
+
327
+ | Warning | Cause | Solution |
328
+ |---------|-------|----------|
329
+ | `Invalid JSON in 'bar' block` | Malformed JSON syntax | Check JSON syntax, ensure proper quoting |
330
+ | `Unknown component type 'bars'` | Typo in chart type | Use suggested type (e.g., `bar` not `bars`) |
331
+ | `Cannot resolve 'file=...'` | File reference without base directory | Use file path argument or inline JSON |
332
+ | `Row exceeds 16 columns` | Too many components in one row | Reduce component widths or split into rows |
333
+ | `Invalid value for 'value' in big_value` | Wrong data type (e.g., string instead of number) | Ensure values match expected types |
334
+
335
+ Warnings include context like content previews, suggestions for similar types, and section/row information to help locate issues.
336
+
337
+ ## CLI Options
338
+
339
+ ```bash
340
+ npx mviz dashboard.md -o output.html # Generate HTML (requires -o flag)
341
+ npx mviz --lint dashboard.md # Validate only (no output)
342
+ npx mviz -l spec.json # Short form of --lint
343
+ ```
344
+
345
+ The `-o` flag is required and specifies the output file. The `--lint` flag validates your spec without generating HTML output. Useful for CI/CD pipelines or quick validation.
346
+
347
+ ## Running Tests
348
+
349
+ ```bash
350
+ cd ts-src
351
+ npm test # TypeScript tests (vitest)
352
+ npm run build # Build TypeScript
353
+ npm run typecheck # Type checking only
354
+ ```
355
+
356
+ ## Skill Bundle
357
+
358
+ The skill bundle (`skill-bundle-compact/`) is optimized for Claude for Web with minimal token usage (~750 tokens). Supports essential types:
359
+ - **Charts:** bar, line, scatter
360
+ - **Components:** table (with sparklines), note, textarea, empty_space
361
+
362
+ For additional chart types (pie, area, heatmap, sankey, etc.), Claude can reference the TypeScript source code in this repository. See `Best_practices.md` for layout guidance and visualization principles.
363
+
364
+ ## Using with Claude
365
+
366
+ ### Claude Code (CLI)
367
+
368
+ The skill is automatically available when working in this project directory.
369
+
370
+ ### Claude Web (claude.ai)
371
+
372
+ 1. Create a new Claude project
373
+ 2. Upload the `.skill` file or all files from `skill-bundle/` to the project knowledge base
374
+ 3. Claude will have access to the skill, examples, and generator
375
+
376
+ ## Dependencies
377
+
378
+ - Node.js 20+
379
+
380
+ ## Design Philosophy
381
+
382
+ Data visualization best practices:
383
+ - Maximize data-ink ratio (minimal non-data elements)
384
+ - Tight, dense layouts for reports
385
+ - No gratuitous animations or visual clutter
386
+ - Clean, minimal axes (no domain lines, subtle grid)
387
+ - Linear interpolation for accurate data representation
388
+ - Focus on data clarity over decoration
389
+
390
+ ## License
391
+
392
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mviz",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "A chart & report builder designed for use by AI.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",