@walterra/pi-charts 0.0.1 → 0.0.3

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 CHANGED
@@ -5,16 +5,10 @@ Vega-Lite chart extension for [pi coding agent](https://github.com/badlogic/pi-m
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pi install @walterra/pi-charts
8
+ pi install npm:@walterra/pi-charts
9
9
  ```
10
10
 
11
- Or add to your pi config manually:
12
-
13
- ```bash
14
- npm install @walterra/pi-charts
15
- ```
16
-
17
- Then in your pi config, add the extension path.
11
+ This installs the package globally and adds it to your pi settings.
18
12
 
19
13
  ## Features
20
14
 
@@ -29,13 +23,13 @@ Renders a Vega-Lite specification as a PNG image.
29
23
 
30
24
  ### Parameters
31
25
 
32
- | Parameter | Type | Required | Description |
33
- |-----------|------|----------|-------------|
34
- | `spec` | string | ✅ | Vega-Lite JSON specification |
35
- | `tsv_data` | string | | Optional TSV data to replace spec.data.values |
36
- | `width` | number | | Chart width in pixels (default: 600) |
37
- | `height` | number | | Chart height in pixels (default: 400) |
38
- | `save_path` | string | | Optional file path to save the PNG |
26
+ | Parameter | Type | Required | Description |
27
+ | ----------- | ------ | -------- | --------------------------------------------- |
28
+ | `spec` | string | ✅ | Vega-Lite JSON specification |
29
+ | `tsv_data` | string | | Optional TSV data to replace spec.data.values |
30
+ | `width` | number | | Chart width in pixels (default: 600) |
31
+ | `height` | number | | Chart height in pixels (default: 400) |
32
+ | `save_path` | string | | Optional file path to save the PNG |
39
33
 
40
34
  ### Example
41
35
 
@@ -44,22 +38,22 @@ Renders a Vega-Lite specification as a PNG image.
44
38
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
45
39
  "data": {
46
40
  "values": [
47
- {"category": "A", "value": 28},
48
- {"category": "B", "value": 55},
49
- {"category": "C", "value": 43}
41
+ { "category": "A", "value": 28 },
42
+ { "category": "B", "value": 55 },
43
+ { "category": "C", "value": 43 }
50
44
  ]
51
45
  },
52
46
  "mark": "bar",
53
47
  "encoding": {
54
- "x": {"field": "category", "type": "nominal"},
55
- "y": {"field": "value", "type": "quantitative"}
48
+ "x": { "field": "category", "type": "nominal" },
49
+ "y": { "field": "value", "type": "quantitative" }
56
50
  }
57
51
  }
58
52
  ```
59
53
 
60
54
  ## Reference Documentation
61
55
 
62
- See [vega-lite-reference.md](./extensions/vega-chart/vega-lite-reference.md) for comprehensive documentation on:
56
+ See [vega-lite-reference.md](./extensions/vega-chart/vega-lite-reference.md) for documentation on:
63
57
 
64
58
  - Data types and encoding channels
65
59
  - All mark types and properties
@@ -10,13 +10,13 @@
10
10
  * - Data-driven: Inline data or separate TSV input
11
11
  */
12
12
 
13
- import type { ExtensionAPI } from '@mariozechner/pi-coding-agent';
14
- import { Type } from '@sinclair/typebox';
15
13
  import { execSync } from 'node:child_process';
16
14
  import { readFileSync, unlinkSync, writeFileSync } from 'node:fs';
17
15
  import { tmpdir } from 'node:os';
18
16
  import { dirname, join } from 'node:path';
19
17
  import { fileURLToPath } from 'node:url';
18
+ import type { ExtensionAPI } from '@mariozechner/pi-coding-agent';
19
+ import { Type } from '@sinclair/typebox';
20
20
 
21
21
  // Compute reference path using ESM import.meta.url
22
22
  const VEGA_REFERENCE_PATH = join(dirname(fileURLToPath(import.meta.url)), 'vega-lite-reference.md');
@@ -72,14 +72,14 @@ Reference: https://vega.github.io/vega-lite/docs/`,
72
72
  tsv_data: Type.Optional(
73
73
  Type.String({
74
74
  description: 'Optional TSV data - if provided, replaces spec.data.values',
75
- }),
75
+ })
76
76
  ),
77
77
  width: Type.Optional(Type.Number({ description: 'Chart width in pixels (default: 600)' })),
78
78
  height: Type.Optional(Type.Number({ description: 'Chart height in pixels (default: 400)' })),
79
79
  save_path: Type.Optional(
80
80
  Type.String({
81
81
  description: 'Optional file path to save the PNG chart (in addition to displaying it)',
82
- }),
82
+ })
83
83
  ),
84
84
  }),
85
85
 
@@ -239,7 +239,7 @@ print('OK')
239
239
  encoding: 'utf-8',
240
240
  timeout: 60000, // Longer timeout for first run when uv downloads packages
241
241
  maxBuffer: 10 * 1024 * 1024,
242
- },
242
+ }
243
243
  );
244
244
 
245
245
  if (!result.includes('OK')) {
@@ -1,6 +1,6 @@
1
1
  # Vega-Lite Visualization Reference
2
2
 
3
- A comprehensive reference for creating data visualizations using Vega-Lite specifications. This guide follows best practices from the [UW Interactive Data Lab Visualization Curriculum](https://idl.uw.edu/visualization-curriculum/intro.html) and established visualization research.
3
+ Reference for creating data visualizations using Vega-Lite specifications. This guide follows best practices from the [UW Interactive Data Lab Visualization Curriculum](https://idl.uw.edu/visualization-curriculum/intro.html) and established visualization research.
4
4
 
5
5
  ## Prerequisites
6
6
 
@@ -23,7 +23,7 @@ If dependencies cannot be installed, the tool returns an error with instructions
23
23
 
24
24
  ## Philosophy
25
25
 
26
- > "A visualization is a mapping from data to visual properties. The key insight is that this mapping should be **declarative** rather than imperative."
26
+ At its core, a visualization maps data to visual properties. Instead of specifying step-by-step drawing instructions (imperative), you describe what the visualization should represent (declarative).
27
27
 
28
28
  Vega-Lite embodies a **grammar of graphics**: you describe _what_ you want to visualize, not _how_ to draw it. This enables:
29
29
 
@@ -648,7 +648,12 @@ Control how scales/axes/legends are shared or independent.
648
648
  },
649
649
  "mark": { "type": "bar", "cornerRadius": 3 },
650
650
  "encoding": {
651
- "x": { "field": "month", "type": "ordinal", "title": null, "axis": { "labelAngle": 0 } },
651
+ "x": {
652
+ "field": "month",
653
+ "type": "ordinal",
654
+ "title": null,
655
+ "axis": { "labelAngle": 0 }
656
+ },
652
657
  "y": {
653
658
  "field": "revenue",
654
659
  "type": "quantitative",
@@ -664,7 +669,11 @@ Control how scales/axes/legends are shared or independent.
664
669
  ```json
665
670
  {
666
671
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
667
- "title": { "text": "Daily Temperature", "subtitle": "December 2025", "anchor": "start" },
672
+ "title": {
673
+ "text": "Daily Temperature",
674
+ "subtitle": "December 2025",
675
+ "anchor": "start"
676
+ },
668
677
  "width": 600,
669
678
  "height": 200,
670
679
  "data": {
@@ -679,14 +688,26 @@ Control how scales/axes/legends are shared or independent.
679
688
  "layer": [
680
689
  { "mark": { "type": "area", "opacity": 0.2, "color": "#e45756" } },
681
690
  { "mark": { "type": "line", "color": "#e45756", "strokeWidth": 2 } },
682
- { "mark": { "type": "point", "color": "#e45756", "filled": true, "size": 50 } },
691
+ {
692
+ "mark": {
693
+ "type": "point",
694
+ "color": "#e45756",
695
+ "filled": true,
696
+ "size": 50
697
+ }
698
+ },
683
699
  {
684
700
  "mark": { "type": "rule", "strokeDash": [4, 4], "color": "#999" },
685
701
  "encoding": { "y": { "datum": 20 } }
686
702
  }
687
703
  ],
688
704
  "encoding": {
689
- "x": { "field": "date", "type": "temporal", "title": null, "axis": { "format": "%b %d" } },
705
+ "x": {
706
+ "field": "date",
707
+ "type": "temporal",
708
+ "title": null,
709
+ "axis": { "format": "%b %d" }
710
+ },
690
711
  "y": {
691
712
  "field": "temp",
692
713
  "type": "quantitative",
@@ -718,11 +739,21 @@ Control how scales/axes/legends are shared or independent.
718
739
  },
719
740
  "layer": [
720
741
  {
721
- "mark": { "type": "line", "strokeWidth": 2.5, "point": { "filled": true, "size": 50 } }
742
+ "mark": {
743
+ "type": "line",
744
+ "strokeWidth": 2.5,
745
+ "point": { "filled": true, "size": 50 }
746
+ }
722
747
  },
723
748
  {
724
749
  "transform": [{ "filter": "datum.date == '2025-03'" }],
725
- "mark": { "type": "text", "align": "left", "dx": 8, "fontSize": 12, "fontWeight": "bold" },
750
+ "mark": {
751
+ "type": "text",
752
+ "align": "left",
753
+ "dx": 8,
754
+ "fontSize": 12,
755
+ "fontWeight": "bold"
756
+ },
726
757
  "encoding": { "text": { "field": "team" } }
727
758
  }
728
759
  ],
@@ -824,7 +855,12 @@ Control how scales/axes/legends are shared or independent.
824
855
  "mark": "bar",
825
856
  "encoding": {
826
857
  "x": { "field": "month", "type": "ordinal", "title": null },
827
- "y": { "field": "sales", "type": "quantitative", "stack": "zero", "title": "Sales" },
858
+ "y": {
859
+ "field": "sales",
860
+ "type": "quantitative",
861
+ "stack": "zero",
862
+ "title": "Sales"
863
+ },
828
864
  "color": { "field": "category", "type": "nominal", "title": null }
829
865
  }
830
866
  }
@@ -961,14 +997,22 @@ Use sorted bar chart instead - see "Never Use Pie or Donut Charts" in Best Pract
961
997
  "mark": "bar",
962
998
  "encoding": {
963
999
  "x": { "field": "date", "type": "temporal" },
964
- "y": { "field": "precipitation", "type": "quantitative", "title": "Precipitation (mm)" }
1000
+ "y": {
1001
+ "field": "precipitation",
1002
+ "type": "quantitative",
1003
+ "title": "Precipitation (mm)"
1004
+ }
965
1005
  }
966
1006
  },
967
1007
  {
968
1008
  "mark": { "type": "line", "color": "firebrick" },
969
1009
  "encoding": {
970
1010
  "x": { "field": "date", "type": "temporal" },
971
- "y": { "field": "temperature", "type": "quantitative", "title": "Temperature (°C)" }
1011
+ "y": {
1012
+ "field": "temperature",
1013
+ "type": "quantitative",
1014
+ "title": "Temperature (°C)"
1015
+ }
972
1016
  }
973
1017
  }
974
1018
  ],
@@ -1108,7 +1152,12 @@ Legends force eye movement. Label directly on the chart:
1108
1152
  "encoding": { "color": { "field": "series", "legend": null } }
1109
1153
  },
1110
1154
  {
1111
- "mark": { "type": "text", "align": "left", "dx": 8, "fontWeight": "bold" },
1155
+ "mark": {
1156
+ "type": "text",
1157
+ "align": "left",
1158
+ "dx": 8,
1159
+ "fontWeight": "bold"
1160
+ },
1112
1161
  "transform": [{ "filter": "datum.date == '2025-12-29'" }],
1113
1162
  "encoding": {
1114
1163
  "x": { "field": "date", "type": "temporal" },
@@ -1588,10 +1637,3 @@ Before finalizing any chart, verify:
1588
1637
  - [Vega-Lite Examples](https://vega.github.io/vega-lite/examples/)
1589
1638
  - [UW Visualization Curriculum](https://idl.uw.edu/visualization-curriculum/intro.html)
1590
1639
  - [Altair Documentation](https://altair-viz.github.io/)
1591
-
1592
- ### Visual Design References
1593
-
1594
- - _Sémiologie Graphique_ (1967) — semiotics of graphics, visual variables
1595
- - _The Visual Display of Quantitative Information_ (1983) — data-ink ratio, minimalist approach
1596
- - _The Functional Art_, _How Charts Lie_ — clarity over minimalism, communicative approach
1597
- - _Visualization Analysis and Design_ (2014) — systematic approach to visualization design
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walterra/pi-charts",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Vega-Lite chart extension for pi coding agent - render data visualizations as inline images",
5
5
  "type": "module",
6
6
  "files": [
@@ -18,6 +18,7 @@
18
18
  "directory": "packages/pi-charts"
19
19
  },
20
20
  "keywords": [
21
+ "pi-package",
21
22
  "pi",
22
23
  "pi-coding-agent",
23
24
  "extension",