ggaction 0.0.5 → 0.0.7

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 (69) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/README.md +77 -14
  3. package/package.json +19 -2
  4. package/src/BasicChartProgram.js +10 -0
  5. package/src/actions/basic.js +21 -0
  6. package/src/actions/boxPlots/edit.js +455 -3
  7. package/src/actions/boxPlots/options.js +3 -3
  8. package/src/actions/canvas/actions.js +42 -0
  9. package/src/actions/canvas/index.js +5 -1
  10. package/src/actions/charts/basic.js +13 -0
  11. package/src/actions/composition/actions.js +13 -3
  12. package/src/actions/data/basic.js +11 -0
  13. package/src/actions/data/basicBin2d.js +43 -0
  14. package/src/actions/data/bin2d.js +138 -40
  15. package/src/actions/data/bin2dMaterialize.js +29 -0
  16. package/src/actions/data/index.js +6 -1
  17. package/src/actions/data/intervalEdit.js +76 -0
  18. package/src/actions/distributions/revision.js +326 -0
  19. package/src/actions/encodings/appearance.js +41 -3
  20. package/src/actions/encodings/basic.js +21 -0
  21. package/src/actions/encodings/density.js +215 -80
  22. package/src/actions/encodings/index.js +2 -0
  23. package/src/actions/encodings/position/index.js +5 -1
  24. package/src/actions/encodings/ranged.js +6 -2
  25. package/src/actions/encodings/remove.js +268 -0
  26. package/src/actions/errorBands/edit.js +121 -13
  27. package/src/actions/errorBars/edit.js +45 -8
  28. package/src/actions/errorBars/options.js +7 -1
  29. package/src/actions/facets/actions.js +136 -1
  30. package/src/actions/gradientPlots/edit.js +352 -4
  31. package/src/actions/guides/axes/edit.js +129 -47
  32. package/src/actions/guides/axes/index.js +10 -2
  33. package/src/actions/guides/basic.js +19 -0
  34. package/src/actions/guides/grids/grid.js +7 -3
  35. package/src/actions/guides/grids/index.js +1 -1
  36. package/src/actions/guides/legends/categorical/actions.js +19 -8
  37. package/src/actions/guides/legends/categorical/index.js +6 -2
  38. package/src/actions/guides/legends/continuous/common.js +3 -3
  39. package/src/actions/guides/legends/continuous/index.js +6 -2
  40. package/src/actions/guides/legends/edit.js +61 -3
  41. package/src/actions/guides/legends/remove.js +124 -23
  42. package/src/actions/guides/legends/strokeWidth.js +42 -14
  43. package/src/actions/marks/arc/actions.js +46 -14
  44. package/src/actions/marks/bar/index.js +5 -1
  45. package/src/actions/marks/basic.js +11 -0
  46. package/src/actions/marks/line/actions.js +5 -1
  47. package/src/actions/marks/line/index.js +4 -1
  48. package/src/actions/marks/point/edit.js +15 -3
  49. package/src/actions/marks/point/index.js +5 -1
  50. package/src/actions/marks/point/materialize.js +9 -3
  51. package/src/actions/marks/rect/actions.js +5 -1
  52. package/src/actions/marks/rect/index.js +4 -1
  53. package/src/actions/marks/rule/actions.js +4 -1
  54. package/src/actions/regression/edit.js +235 -74
  55. package/src/actions/scales/index.js +5 -1
  56. package/src/actions/selection/actions.js +122 -2
  57. package/src/actions/selection/index.js +6 -0
  58. package/src/basic.js +2 -0
  59. package/src/core/vocabulary.js +7 -0
  60. package/src/renderers/canvas/index.js +96 -60
  61. package/src/renderers/canvas/text.js +3 -14
  62. package/src/renderers/pdf.js +112 -0
  63. package/src/renderers/svg.js +559 -0
  64. package/src/renderers/text.js +11 -0
  65. package/types/basic.d.ts +107 -0
  66. package/types/index.d.ts +1 -0
  67. package/types/pdf.d.ts +26 -0
  68. package/types/program.d.ts +71 -7
  69. package/types/svg.d.ts +11 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,52 @@ All notable changes to `ggaction` are recorded in this file.
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## [0.0.7] - 2026-07-23
8
+
9
+ ### Added
10
+
11
+ - Added the browser-safe `ggaction/basic` entry for creation-focused scatter, line, bar, histogram, and heatmap
12
+ programs, with matching TypeScript declarations and an enforced 120,000-byte gzip bundle budget.
13
+ - Added browser-safe `ggaction/svg` output and Node-only `ggaction/pdf` single-page vector files, with matching
14
+ declarations, metadata/accessibility options, installed-consumer coverage, and Canvas/SVG/PNG/PDF visual evidence.
15
+
16
+ ### Changed
17
+
18
+ - Applied the documented numeric font-weight normalization consistently across Canvas, SVG, PNG, and PDF rendering.
19
+ - Generated the repository example index from the canonical chart catalog and reduced the LLM index to concise,
20
+ non-duplicated routes into exact runtime and support documentation.
21
+ - Simplified Getting Started, grouped the support limitations by topic, and clarified the complete documentation
22
+ verification workflow for contributors.
23
+
24
+ ### Fixed
25
+
26
+ - Corrected the Canvas target in troubleshooting guidance and documented complete, executable Canvas, SVG, PNG, and
27
+ PDF rendering flows with signatures generated from the public TypeScript declarations.
28
+
29
+ ## [0.0.6] - 2026-07-23
30
+
31
+ ### Added
32
+
33
+ - Added explicit edit and removal lifecycles for encodings, point appearance, selections, highlights, legends, and
34
+ Cartesian axis components while preserving immutable state and meaningful action traces.
35
+ - Added revision workflows for 2D bins, interval statistics, regression, density, box plots, gradient plots, and facet
36
+ policies, including deterministic rematerialization after data-role and layout changes.
37
+
38
+ ### Changed
39
+
40
+ - Expanded installed-package, Browser Canvas, Node PNG, TypeScript, action-contract, and cross-capability coverage for
41
+ the complete authoring lifecycle surface.
42
+ - Improved documentation entry points, navigation, chart discovery, gallery filtering, responsive presentation, and
43
+ generated API routing for the completed lifecycle actions.
44
+
45
+ ### Fixed
46
+
47
+ - Preserved unaffected shared-legend channels when selectively removing an encoding, and prevented removed resources
48
+ from returning after later rematerialization or facet replay.
49
+ - Kept documentation search results under the deployed `/ggaction/` base path and improved gallery text contrast.
50
+ - Allowed the approved Polar chart ink bounds to absorb the observed 1.5-pixel platform rasterization variance while
51
+ retaining exact primitive/public pixel comparisons and the existing density, color, and region checks.
52
+
7
53
  ## [0.0.5] - 2026-07-21
8
54
 
9
55
  ### Added
@@ -111,6 +157,8 @@ All notable changes to `ggaction` are recorded in this file.
111
157
  - Cartesian charts are the complete current path. Polar semantic tokens exist only where explicitly documented and do
112
158
  not imply complete polar rendering.
113
159
 
160
+ [0.0.7]: https://github.com/ggaction/ggaction/releases/tag/v0.0.7
161
+ [0.0.6]: https://github.com/ggaction/ggaction/releases/tag/v0.0.6
114
162
  [0.0.5]: https://github.com/ggaction/ggaction/releases/tag/v0.0.5
115
163
  [0.0.4]: https://github.com/ggaction/ggaction/releases/tag/v0.0.4
116
164
  [0.0.3]: https://github.com/ggaction/ggaction/releases/tag/v0.0.3
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ggaction
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/ggaction.svg)](https://www.npmjs.com/package/ggaction) [![license](https://img.shields.io/npm/l/ggaction.svg)](./LICENSE) [![documentation](https://img.shields.io/badge/docs-ggaction.github.io-2563eb)](https://ggaction.github.io/ggaction/)
3
+ [![npm version](https://img.shields.io/npm/v/ggaction.svg)](https://www.npmjs.com/package/ggaction) [![CI](https://github.com/ggaction/ggaction/actions/workflows/ci.yml/badge.svg)](https://github.com/ggaction/ggaction/actions/workflows/ci.yml) [![license](https://img.shields.io/npm/l/ggaction.svg)](./LICENSE) [![documentation](https://img.shields.io/badge/docs-ggaction.github.io-2563eb)](https://ggaction.github.io/ggaction/)
4
4
 
5
5
  ### A grammar for how charts are made.
6
6
 
@@ -12,11 +12,7 @@ Build, inspect, select, and revise charts one meaningful action at a time.
12
12
  <img src="./docs/assets/images/readme-authoring-sequence.gif" width="960" height="540" loading="eager" alt="A ggaction program progressively creates a scatterplot, adds grouped regression fits and confidence bands, highlights the Japan group across chart layers, and finishes with an R-squared annotation.">
13
13
  </p>
14
14
 
15
- Every frame is rendered from an immutable `ChartProgram`. The final R² label is a custom traceable action composed from ggaction's public extension primitives.
16
-
17
- ```bash
18
- npm install ggaction
19
- ```
15
+ Every frame is rendered from an immutable `ChartProgram`. The final R² label is a traceable action built from public extension primitives.
20
16
 
21
17
  ## A grammar of graphical action
22
18
 
@@ -57,12 +53,24 @@ const program = chart()
57
53
 
58
54
  ## Quick start
59
55
 
56
+ Install the current public release:
57
+
60
58
  ```bash
61
59
  npm install ggaction
62
60
  ```
63
61
 
62
+ Add the Canvas element that the rendering code targets. Its accessible name and
63
+ fallback text summarize the chart for contexts where Canvas pixels are not
64
+ available:
65
+
66
+ ```html
67
+ <canvas id="chart" aria-label="Scatterplot of displacement versus acceleration by origin">
68
+ Scatterplot of displacement versus acceleration by origin.
69
+ </canvas>
70
+ ```
71
+
64
72
  ```javascript
65
- import { chart, render } from "ggaction";
73
+ import { chart, render } from "ggaction/basic";
66
74
 
67
75
  const observations = [
68
76
  { displacement: 97, acceleration: 14.5, origin: "Japan" },
@@ -80,17 +88,58 @@ const program = chart()
80
88
  .createScatterPlot({
81
89
  x: "displacement",
82
90
  y: "acceleration",
83
- color: "origin"
91
+ color: "origin",
92
+ shape: "origin"
84
93
  });
85
94
 
86
95
  const context = document.querySelector("#chart").getContext("2d");
87
96
  render(program, context);
88
97
  ```
89
98
 
99
+ Matching color and shape encodings give each origin a redundant visual cue and
100
+ create a labeled categorical legend automatically.
101
+
102
+ The Quick Start uses the smaller `ggaction/basic` entry for the common creation
103
+ path. Import from `ggaction` when you need editing, selection, composition,
104
+ alternative coordinates, or statistical layers.
105
+
106
+ ### Branch revisions without mutation
107
+
108
+ Start a separate program without a shape encoding, then derive alternatives
109
+ without changing the checkpoint:
110
+
111
+ ```javascript
112
+ import { chart as editableChart } from "ggaction";
113
+
114
+ const checkpoint = editableChart()
115
+ .createCanvas({ width: 640, height: 400 })
116
+ .createData({ values: observations })
117
+ .createScatterPlot({
118
+ x: "displacement",
119
+ y: "acceleration",
120
+ color: "origin"
121
+ });
122
+
123
+ const outlined = checkpoint.editPointMark({
124
+ stroke: "#0f172a",
125
+ strokeWidth: 2
126
+ });
127
+ const muted = checkpoint.editPointMark({ opacity: 0.35 });
128
+
129
+ console.log(checkpoint === outlined); // false
130
+ console.log(checkpoint.trace.children.at(-1).op); // "createScatterPlot"
131
+ console.log(outlined.trace.children.at(-1).op); // "editPointMark"
132
+ ```
133
+
134
+ All three remain renderable and inspectable. They are immutable values, not an
135
+ automatic undo stack; the application chooses which to retain or render.
136
+
90
137
  Use `createLinePlot`, `createBarPlot`, `createHistogram`, and `createHeatmap` for
91
- the other basic Cartesian charts. Each facade records the regular mark,
92
- encoding, and guide actions as trace children, and the same resource-specific
93
- actions remain available for later edits. See the
138
+ the other basic Cartesian charts. The `ggaction/basic` entry keeps this common
139
+ creation path below a 120,000-byte gzip bundle budget while each facade still
140
+ records its mark, encoding, and guide actions as trace children. Import from
141
+ `ggaction` when you need editing, selection, composition, alternative
142
+ coordinates, or statistical layers. See the
94
143
  [Basic Charts API](https://ggaction.github.io/ggaction/api/basic-charts/).
95
144
 
96
145
  Use `createParallelCoordinates({ dimensions })` to connect each source row
@@ -115,7 +164,7 @@ open the [runnable Gapminder example](./examples/gapminder-horizon/).
115
164
  - Statistical layers and intervals
116
165
  - Faceting and program composition
117
166
  - Mark selection and coordinated highlighting
118
- - Browser Canvas and Node PNG output
167
+ - Browser Canvas, SVG, Node PNG, and vector PDF output
119
168
  - TypeScript declarations and traceable extension actions
120
169
 
121
170
  See the current [supported features](https://ggaction.github.io/ggaction/supported-features/), [tutorials and examples](https://ggaction.github.io/ggaction/tutorials/), and [action reference](https://ggaction.github.io/ggaction/reference/actions/) for exact coverage. Runnable programs are collected in [`examples/`](./examples/README.md).
@@ -127,10 +176,14 @@ The package is ESM-only and requires Node.js 20 or later.
127
176
  | Entry | Purpose |
128
177
  | --- | --- |
129
178
  | `ggaction` | Create chart programs and render them to Browser Canvas |
179
+ | `ggaction/basic` | Create and render scatter, line, bar, histogram, and heatmap charts with a smaller browser bundle |
130
180
  | `ggaction/extension` | Author wrapped actions with public low-level primitives |
131
181
  | `ggaction/png` | Render a completed program to a PNG file in Node.js |
182
+ | `ggaction/pdf` | Render a completed program to a single-page vector PDF file in Node.js |
183
+ | `ggaction/svg` | Serialize a completed program to browser-safe SVG |
132
184
 
133
- All entries include TypeScript declarations. The default entry is browser-safe; the PNG adapter is Node-only.
185
+ All entries include TypeScript declarations. The default, basic, extension, and
186
+ SVG entries are browser-safe; the PNG and PDF adapters are Node-only.
134
187
 
135
188
  ## Documentation
136
189
 
@@ -140,9 +193,15 @@ All entries include TypeScript declarations. The default entry is browser-safe;
140
193
  - [Concepts](https://ggaction.github.io/ggaction/concepts/chart-program/)
141
194
  - [Supported Features](https://ggaction.github.io/ggaction/supported-features/)
142
195
 
196
+ ## Contributing
197
+
198
+ Bug reports, documentation improvements, examples, and focused code changes are
199
+ welcome. Read [CONTRIBUTING.md](./CONTRIBUTING.md) for setup, scope, tests, and
200
+ the extra discussion required before public API or architecture changes.
201
+
143
202
  ## Status and development
144
203
 
145
- > **Status:** `0.0.5` is the current experimental public release. APIs may change before `1.0.0`; changes are recorded in the [changelog](./CHANGELOG.md).
204
+ > **Status:** `0.0.7` is the current experimental public release. APIs may change before `1.0.0`; changes are recorded in the [changelog](./CHANGELOG.md).
146
205
 
147
206
  ```bash
148
207
  npm install
@@ -151,3 +210,7 @@ npm test
151
210
  npm run test:render
152
211
  npm run test:docs
153
212
  ```
213
+
214
+ ## Related Links
215
+
216
+ - Action-trace demo: [Link](https://ggactionbot.github.io/action-trace-demo/)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ggaction",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Build charts through immutable, traceable graphical actions.",
5
5
  "license": "MIT",
6
6
  "author": "Hyeon Jeon",
@@ -20,6 +20,7 @@
20
20
  "data-visualization"
21
21
  ],
22
22
  "type": "module",
23
+ "sideEffects": false,
23
24
  "files": [
24
25
  "src/",
25
26
  "!src/**/AGENTS.md",
@@ -34,6 +35,10 @@
34
35
  "types": "./types/index.d.ts",
35
36
  "default": "./src/index.js"
36
37
  },
38
+ "./basic": {
39
+ "types": "./types/basic.d.ts",
40
+ "default": "./src/basic.js"
41
+ },
37
42
  "./extension": {
38
43
  "types": "./types/extension.d.ts",
39
44
  "default": "./src/extension.js"
@@ -41,6 +46,14 @@
41
46
  "./png": {
42
47
  "types": "./types/png.d.ts",
43
48
  "default": "./src/renderers/png.js"
49
+ },
50
+ "./pdf": {
51
+ "types": "./types/pdf.d.ts",
52
+ "default": "./src/renderers/pdf.js"
53
+ },
54
+ "./svg": {
55
+ "types": "./types/svg.d.ts",
56
+ "default": "./src/renderers/svg.js"
44
57
  }
45
58
  },
46
59
  "scripts": {
@@ -56,6 +69,7 @@
56
69
  "test:coverage": "node scripts/run-tests.js coverage",
57
70
  "test:render": "node scripts/run-render-tests.js",
58
71
  "assets:readme": "node scripts/generate-readme-demo.js",
72
+ "artifacts:renderers": "node scripts/generate-renderer-comparison.js",
59
73
  "artifacts:clean": "node test/support/artifacts.js",
60
74
  "artifacts:gallery": "node scripts/generate-artifact-gallery.js",
61
75
  "artifacts:gallery:test": "node scripts/test-artifact-gallery.js",
@@ -74,13 +88,16 @@
74
88
  "docs:preflight": "node scripts/check-docs-environment.js",
75
89
  "docs:signatures": "node scripts/generate-doc-signatures.js",
76
90
  "docs:signatures:check": "node scripts/generate-doc-signatures.js --check",
77
- "docs:generate": "npm run docs:signatures && npm run docs:capabilities && npm run docs:actions && npm run docs:reference && npm run docs:metadata && npm run docs:search && npm run docs:images && npm run docs:llms",
91
+ "examples:index": "node scripts/generate-examples-readme.js",
92
+ "examples:index:check": "node scripts/generate-examples-readme.js --check",
93
+ "docs:generate": "npm run examples:index && npm run docs:actions && npm run docs:reference && npm run docs:signatures && npm run docs:capabilities && npm run docs:metadata && npm run docs:search && npm run docs:images && npm run docs:llms",
78
94
  "docs:build": "bundle exec jekyll build --source docs --destination _site --baseurl /ggaction",
79
95
  "docs:verify": "npm run docs:preflight && npm run docs:generate && npm run test:docs && npm run docs:build && npm run test:docs:built && npm run test:docs:browser",
80
96
  "contracts:catalog": "node scripts/generate-action-catalog.js",
81
97
  "contracts:catalog:check": "node scripts/generate-action-catalog.js --check",
82
98
  "package:check": "node scripts/package-artifact.js --check",
83
99
  "package:pack": "node scripts/package-artifact.js --pack",
100
+ "package:bundle": "node scripts/measure-browser-bundle.js",
84
101
  "test:package": "node scripts/package-consumer.js",
85
102
  "release:notes": "node scripts/release-notes.js"
86
103
  },
@@ -0,0 +1,10 @@
1
+ import { registerBasicActions } from "./actions/basic.js";
2
+ import { ChartProgram as CoreChartProgram } from "./core/ChartProgram.js";
3
+
4
+ class BasicChartProgram extends CoreChartProgram {}
5
+
6
+ registerBasicActions(BasicChartProgram);
7
+
8
+ export function chart() {
9
+ return new BasicChartProgram();
10
+ }
@@ -0,0 +1,21 @@
1
+ import { registerBasicCanvasActions } from "./canvas/index.js";
2
+ import { registerBasicChartActions } from "./charts/basic.js";
3
+ import { registerCoordinateActions } from "./coordinates/index.js";
4
+ import { registerBasicDataActions } from "./data/basic.js";
5
+ import { registerBasicEncodingActions } from "./encodings/basic.js";
6
+ import { registerBasicGuideActions } from "./guides/basic.js";
7
+ import { registerBasicMarkActions } from "./marks/basic.js";
8
+ import { registerPrimitiveActions } from "./primitives/index.js";
9
+ import { registerBasicScaleActions } from "./scales/index.js";
10
+
11
+ export function registerBasicActions(ProgramClass) {
12
+ registerPrimitiveActions(ProgramClass);
13
+ registerBasicCanvasActions(ProgramClass);
14
+ registerBasicDataActions(ProgramClass);
15
+ registerBasicMarkActions(ProgramClass);
16
+ registerBasicScaleActions(ProgramClass);
17
+ registerBasicEncodingActions(ProgramClass);
18
+ registerCoordinateActions(ProgramClass);
19
+ registerBasicGuideActions(ProgramClass);
20
+ registerBasicChartActions(ProgramClass);
21
+ }