@taylorwong/ichartjs 2.0.4 → 2.0.6

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.
@@ -48,7 +48,7 @@ iChart.js 默认在所有图表右下角显示低对比度的品牌署名(`Pow
48
48
  ## 导出与下载
49
49
 
50
50
  iChart.js 导出采用**双底层单源架构**,所有产物共享 `buildScene()` 生成的同一份 Scene Graph,**画面显示用的 renderer 和导出底层完全解耦**:
51
- 1. **PNG/JPEG(光栅)**:底层用 `CanvasRenderer` 重绘 Scene Graph,同步输出真光栅文件;无头环境安装 `canvas` npm 包即可支持。
51
+ 1. **PNG/JPEG(光栅)**:底层用 `CanvasRenderer` 重绘 Scene Graph;浏览器同步输出真光栅文件,无头环境通过 `exportAsync()` 加载可选的 `canvas` npm 包。
52
52
  2. **SVG(矢量)**:底层用 `SVGRenderer` DOM 序列化(浏览器)或纯字符串拼装(无头零依赖),支持 XML 1.0 头部、字体拆分、无障碍属性。
53
53
  3. **JSON(可重建)**:序列化当前 `spec` + `getState()` 结果,用于持久化、Agent 自检和跨端重建。
54
54
 
@@ -62,21 +62,21 @@ iChart.js 导出采用**双底层单源架构**,所有产物共享 `buildScene
62
62
  |------------|----------------------------|----------------|--------------------------|
63
63
  | JSON | ✅ | ✅ | ✅ |
64
64
  | SVG | ✅ | ✅ | ✅ |
65
- | PNG / JPEG | ✅ 同步真光栅 | ❌ 返回结构化 `HEADLESS_EXPORT_UNSUPPORTED` | ✅ |
65
+ | PNG / JPEG | ✅ 同步真光栅 | ❌ 返回结构化 `HEADLESS_EXPORT_UNSUPPORTED` | ✅ 通过 `exportAsync()` |
66
66
 
67
67
  ### 公共导出 API
68
68
 
69
69
  - `chart.toDataURL(type='image/png')` → data URL 字符串或结构化 ExportError。
70
- - `chart.toBlob(type='image/png')` → Blob 或 ExportError(无头返回 `BLOB_HEADLESS`)。
70
+ - `chart.toBlob(type='image/png')` → Blob 或 ExportError(无头同步路径不提供光栅 Blob)。
71
71
  - `chart.export({ type, as })` → 同步返回字符串 / JSON 对象 / Blob / ExportError,`as` 支持 `string`、`dataurl`、`blob`、`object`(仅 JSON)。
72
- - `chart.exportAsync({ type, as })` → Promise 包装,适配未来异步场景。
72
+ - `chart.exportAsync({ type, as })` → Promise 导出路径;Node 无头环境可通过可选 `canvas` 依赖生成 PNG/JPEG。
73
73
  - `chart.download({ type })` / `downloadPNG()` / `downloadSVG()` / `downloadJSON()` → 触发浏览器保存(无头回落到返回字符串或结构化错误)。
74
74
 
75
75
  ### 错误结构
76
76
 
77
77
  所有导出/下载方法失败时统一返回 `{ valid:false, code, message?, suggestion?, rasterCode? }` 稳定结构,便于 Agent 自动化判断,常见 `code`:
78
78
  - `HEADLESS_EXPORT_UNSUPPORTED`:当前无头环境缺少光栅所需依赖(`canvas`)。
79
- - `BLOB_HEADLESS`:`toBlob` / `as=blob` 需要浏览器 Blob。
79
+ - `BLOB_HEADLESS`:同步 `toBlob` 无法在当前无头 renderer 上生成光栅 Blob;Node 光栅场景改用 `exportAsync()`。
80
80
  - `DOWNLOAD_HEADLESS`:`chart.download*()` 仅在浏览器有 DOM 时可用,无头用 `export`。
81
81
  - `EXPORT_TYPE_UNSUPPORTED`:不支持的导出类型。
82
82
 
@@ -48,3 +48,34 @@ const resolved = chart.getTheme();
48
48
 
49
49
  预览与验收:`http://localhost:3000/playground/theme-gallery.html`。
50
50
 
51
+ ## 单图表与页面级偏好
52
+
53
+ 偏好用于图表创建后的视觉调整,适合用户操作和 Agent 对话调整。业务数据、编码和图表类型不应放进这个配置面。
54
+
55
+ ```js
56
+ import { createChart, createPreferencesStore, mountChartSettings } from '@taylorwong/ichartjs';
57
+
58
+ const pagePreferences = createPreferencesStore({
59
+ storage: 'localStorage',
60
+ storageKey: 'my-app:chart-preferences'
61
+ });
62
+ const chart = createChart({
63
+ chartId: 'revenue',
64
+ container: '#revenue',
65
+ type: 'line',
66
+ data: { values: rows },
67
+ preferences: pagePreferences
68
+ });
69
+ mountChartSettings(chart, { locale: 'zh-CN' });
70
+
71
+ // Agent 对话也使用同一套 API。
72
+ chart.setPreferences({
73
+ theme: { preset: 'dashboard', palette: 'status' },
74
+ typography: { scale: 1.15 },
75
+ components: { grid: false }
76
+ }, { source: 'agent' });
77
+ ```
78
+
79
+ 单图表快捷菜单使用紧凑的汉堡图标,只保留高频操作:主题模式、配色、字号,以及当前图表真正支持的图例、数据标签和网格线。能力检测会自动隐藏无效设置;修改即时生效,并支持 `zh-CN`、`en` 和按文档语言自动识别。
80
+
81
+ 低频选项和页面级配置应放在图表弹出菜单之外的独立设置页。页面内图表共享同一个 store,并使用 `store.setGlobal()` 或 `chart.setPreferences(patch, { scope: 'global' })` 更新全局。完整设置页可提供 preset、密度、署名等白名单能力,而不挤占每张图表。Node/SSR 默认使用内存,浏览器需要显式选择 `localStorage` 或宿主存储适配器。快捷菜单验收地址:`http://localhost:3000/playground/project-gallery.html`;完整页面设置验收地址:`http://localhost:3000/playground/preferences-lab.html`。
@@ -0,0 +1,189 @@
1
+ # iChart.js 使用场景
2
+
3
+ iChart.js 可以分成三层:
4
+
5
+ 1. **Runtime**:`@taylorwong/ichartjs`,负责规划、校验、渲染、交互、编辑和导出。
6
+ 2. **Skill**:`skills/ichartjs/SKILL.md`,负责指导 Agent 选择图表、保留数据 lineage、校验 Spec 和交付结果。
7
+ 3. **宿主项目**:用户自己的 Web 项目、Node 脚本、CI 任务或 Agent 工作区,负责数据、生命周期、路由、存储和交付。
8
+
9
+ Skill 不是第二套渲染器,也不是服务端。使用 Skill 的 Agent 仍然需要 JavaScript 宿主,才能生成交互页面或文件。
10
+
11
+ ## 场景选择
12
+
13
+ | 需求 | 使用方式 | 运行位置 | 常见输出 |
14
+ | --- | --- | --- | --- |
15
+ | 在产品中增加图表 | 前端项目集成 | 用户自己的浏览器应用 | 交互式 SVG 或 Canvas 图表 |
16
+ | 让 Codex 修改已有项目 | Coding Agent + Runtime | 代码仓库和项目开发服务器 | 代码、Spec、测试结果、预览地址 |
17
+ | 让多个 Agent 复用图表能力 | Skill + Runtime | Agent 工作区和目标项目 | 校验后的代码、文件、解释结果 |
18
+ | 一次性生成可视化 | Node 脚本或独立 HTML | Node.js 或浏览器 | SVG、PNG/JPEG、JSON、HTML |
19
+ | 项目进度和交付分析 | 项目场景 + Runtime | 项目看板 | Gantt、Burndown、Timeline、分析结果 |
20
+ | 流程或架构图 | Diagram 场景 + Runtime | Web 应用或文档流程 | Flow/Swimlane 页面、SVG、JSON |
21
+ | 定时生成报告 | Node 脚本 + Runtime | CI 或报表任务 | SVG/PNG 文件和 JSON 快照 |
22
+
23
+ ## 输出契约
24
+
25
+ | 输出 | 适用场景 | API 或交付方式 |
26
+ | --- | --- | --- |
27
+ | 交互式页面 | 产品看板、编辑器、分析页面 | `createChart()` 挂载到 DOM |
28
+ | SVG DOM | 无障碍、键盘交互、Diagram、打印 | `renderer: 'svg'` |
29
+ | SVG 文件/字符串 | 文档、邮件、矢量交付、无头环境 | `chart.export({ type: 'svg' })` |
30
+ | PNG/JPEG | 汇报、聊天附件、图片报告 | 浏览器 `toDataURL()`,或 Node `exportAsync()` + 可选 `canvas` |
31
+ | JSON Spec/state | 持久化、Agent 快照、跨环境重建 | `chart.export({ type: 'json' })` |
32
+ | Data URL/Blob | 页面嵌入或浏览器下载 | `as: 'dataurl'` 或浏览器下载 API |
33
+ | 代码片段 | 开发者集成或生成页面 | `createChart()` 集成代码 |
34
+ | 解释和状态 | Agent 自检和用户审计 | `chart.explain()`、`chart.getState()` |
35
+
36
+ JSON 是机器可读的事实来源;SVG 和 PNG/JPEG 是视觉交付物;代码是集成交付物;交互页面是产品交付物。
37
+
38
+ ## 视觉偏好:界面与 Agent
39
+
40
+ 图表创建后需要调整视觉样式时,可让页面图表共享 `createPreferencesStore()`。浏览器中只有在宿主希望刷新后保留配置时,才显式使用 `storage: 'localStorage'`。`mountChartSettings(chart)` 会在导出区域之外增加可访问的快捷设置按钮;完整的页面级设置中心应作为宿主的独立路由。
41
+
42
+ 宿主交互和 Agent 对话使用同一个 patch 合约:
43
+
44
+ ```js
45
+ chart.setPreferences({
46
+ theme: { preset: 'dashboard', palette: 'status' },
47
+ typography: { scale: 1.15 },
48
+ components: { grid: false }
49
+ }, { source: 'agent' });
50
+ ```
51
+
52
+ 快捷菜单只保留主题、配色、字号和当前图表支持的显示开关。使用 `scope: 'global'` 修改页面全部图表;默认只修改当前图表;使用 `chart.getState().preferences` 获取可审计的最终配置。两层体验可在 `http://localhost:3000/playground/project-gallery.html` 和 `http://localhost:3000/playground/preferences-lab.html` 验收。
53
+
54
+ ## 场景一:集成到 Web 项目
55
+
56
+ 在宿主项目中安装 Runtime:
57
+
58
+ ```bash
59
+ npm install @taylorwong/ichartjs@^2
60
+ ```
61
+
62
+ ```js
63
+ import { createChart } from '@taylorwong/ichartjs';
64
+
65
+ const chart = createChart({
66
+ container: '#chart',
67
+ type: 'line',
68
+ renderer: 'svg',
69
+ data: { values: rows },
70
+ encoding: {
71
+ x: { field: 'month', type: 'category' },
72
+ y: { field: 'sales', type: 'quantitative' }
73
+ },
74
+ accessibility: { enabled: true }
75
+ });
76
+ ```
77
+
78
+ 宿主项目负责数据加载、认证、路由、持久化和状态管理。数据变化使用 `setData()`,Spec 变化使用 `update()`,替换组件前调用 `destroy()`。
79
+
80
+ 适用于管理后台、数据看板、项目管理、流程编辑和嵌入式分析页面。
81
+
82
+ ## 场景二:让 Coding Agent 修改项目
83
+
84
+ 可以这样向 Codex 提需求:
85
+
86
+ ```text
87
+ 在当前项目中使用 @taylorwong/ichartjs。检查订单数据,选择并校验月度销售图表,
88
+ 把它加入现有分析页面,运行相关测试,并返回准确的预览地址。保留假设、警告、
89
+ record lineage 和不支持请求。
90
+ ```
91
+
92
+ Agent 应返回:
93
+
94
+ - 修改文件和已校验的 Spec;
95
+ - 字段映射和选图原因;
96
+ - 假设、警告和不支持请求;
97
+ - 测试结果和运行时自检;
98
+ - 宿主项目的准确预览地址和人工验收步骤。
99
+
100
+ 仓库内的 Playground 只用于 iChart.js 示例:`npm run playground` → `http://localhost:3000/playground/project-gallery.html`。如果修改的是其他项目,应返回其他项目自己的开发地址。
101
+
102
+ ## 场景三:作为官方 Skill 使用
103
+
104
+ 使用标准 Agent Skills CLI 安装最新版:
105
+
106
+ ```bash
107
+ npx skills add wanghetommy/ichartjs --skill ichartjs
108
+ ```
109
+
110
+ 无交互地全局安装到 Codex:
111
+
112
+ ```bash
113
+ npx skills add wanghetommy/ichartjs --skill ichartjs --agent codex --global --yes
114
+ ```
115
+
116
+ 需要固定发布版本时,直接安装已发布的 Skill 目录:
117
+
118
+ ```bash
119
+ npx skills add https://github.com/wanghetommy/ichartjs/tree/v2.0.6/skills/ichartjs \
120
+ --agent codex --global --yes
121
+ ```
122
+
123
+ WorkBuddy 用户可以通过宿主的 Skill 界面导入同一个带 Tag 的 GitHub 目录。在当前 Skills CLI 没有明确声明适配器时,不要假设存在 `--agent workbuddy`。具有自定义 Skill 目录的宿主仍可从 `node_modules/@taylorwong/ichartjs/skills/ichartjs` 手动复制。
124
+
125
+ 安装或选择 `ichartjs` 后可以这样提问:
126
+
127
+ ```text
128
+ 使用 iChart.js Skill。读取这份数据,生成项目 Burndown,校验 Spec,
129
+ 生成浏览器预览,并额外导出 SVG 和 JSON。返回预览地址、文件路径、
130
+ 警告、假设和 lineage。
131
+ ```
132
+
133
+ Skill 会把任务路由到公开 Runtime API 和场景文档。它不会替代 npm 包、增加服务端点,也不会维护第二套选图逻辑。
134
+
135
+ 如果宿主可以编辑并运行 JavaScript 项目,输出可以是交互页面;如果不能运行 JavaScript,应要求输出 SVG、JSON 或代码文件。
136
+
137
+ ## 场景四:一次性生成文件
138
+
139
+ Agent 可以创建一个 ESM 脚本或独立 HTML 页面,输出:
140
+
141
+ - `chart.svg`:矢量文档和零额外依赖的无头输出;
142
+ - `chart.json`:可复现的 Spec 和运行时快照;
143
+ - `chart.png` 或 `chart.jpeg`:汇报和图片分享;
144
+ - `index.html` 加 JavaScript:需要交互时使用。
145
+
146
+ 无头 SVG 和 JSON 不需要额外生产依赖;无头 PNG/JPEG 使用 `chart.exportAsync()`,并安装可选 `canvas`。一次性制图不应额外引入 Python、MCP、HTTP 服务或 CLI。
147
+
148
+ ## 场景五:项目和 Diagram
149
+
150
+ - `gantt`、`timeline`、`milestone`、`burndown`:项目进度和交付计划;
151
+ - 项目分析:capacity、velocity、release forecast、risk、issue aging;
152
+ - `flow`、`swimlane`:流程、责任、分组、Port 和受控编辑。
153
+
154
+ 保留稳定的 record、node、edge、lane、group、port ID。业务编辑先返回 preview,确认后再 commit,并返回审计结果。
155
+
156
+ ## 场景六:CI 和定时报表
157
+
158
+ 在 Node ESM 脚本中生成:
159
+
160
+ ```js
161
+ const svg = chart.export({ type: 'svg' });
162
+ const json = chart.export({ type: 'json' });
163
+ const png = await chart.exportAsync({ type: 'png' });
164
+ ```
165
+
166
+ 建议把 JSON 作为可复现快照,把 SVG/PNG 作为视觉交付物。导出失败时返回结构化错误,不要静默替换格式。
167
+
168
+ ## 边界
169
+
170
+ - iChart.js 是 JavaScript UI/Runtime,不是数据服务。
171
+ - Skill 只提供 Agent 工作流指导;没有 JavaScript 宿主时不能直接渲染。
172
+ - 宿主项目负责认证、存储、分享和应用路由。
173
+ - 普通使用不需要核心 CLI、MCP、HTTP 服务或 Python API。
174
+ - 如果数据在 Python 中准备,输出 JSON/CSV,再由 JavaScript 进程渲染。
175
+ - 除非 `getCapabilities()` 明确声明,否则不要生成地图或 3D 图表。
176
+
177
+ ## Agent 交付清单
178
+
179
+ 每次 Agent 返回结果都应包含:
180
+
181
+ 1. 选择的图表/视图及原因;
182
+ 2. 输入字段、转换和稳定 ID;
183
+ 3. 已校验 Spec 或结构化修复请求;
184
+ 4. 假设、警告、不支持请求和无障碍选择;
185
+ 5. `explain/state` 自检结果;
186
+ 6. 准确预览地址、代码文件或产物路径;
187
+ 7. 导出格式和可选依赖。
188
+
189
+ 相关文档:[快速上手](quickstart.md)、[前端集成](frontend-integration.md)、[Coding Agent 集成](coding-agent-integration.md)、[Runtime 契约](runtime-contract.md)、[项目场景](project-scenario.md)、[Diagram 场景](diagram-scenario.md)。
@@ -6,6 +6,7 @@
6
6
  "agentPlanning": "src/index.mjs#planChart",
7
7
  "agentExplanation": "Chart#explain",
8
8
  "agentQuickstart": "docs/agent/quickstart.md",
9
+ "usageScenarios": "docs/agent/usage-scenarios.md",
9
10
  "agentWorkflowExample": "examples/agent-workflow.mjs",
10
11
  "officialSkill": "skills/ichartjs/SKILL.md",
11
12
  "scenarios": {
@@ -22,22 +23,22 @@
22
23
  "preview": true,
23
24
  "json": true,
24
25
  "svg": true,
25
- "png": "Node headless PNG requires the optional `canvas` npm package (createCanvas). Otherwise use chart.export({type:\"svg\"})."
26
+ "png": "Node headless PNG requires the optional `canvas` npm package and chart.exportAsync({type:\"png\"}). Otherwise use chart.export({type:\"svg\"})."
26
27
  },
27
28
  "export": {
28
29
  "types": ["png", "jpeg", "svg", "json"],
29
30
  "mime": { "png": "image/png", "jpeg": "image/jpeg", "svg": "image/svg+xml", "json": "application/json" },
30
31
  "browser": { "png": true, "jpeg": true, "svg": true, "json": true },
31
32
  "headless": {
32
- "png": "optional: install the `canvas` npm package for createCanvas",
33
+ "png": "optional: install the `canvas` npm package for createCanvas and use exportAsync",
33
34
  "jpeg": "same as png",
34
35
  "svg": true,
35
36
  "json": true
36
37
  },
37
38
  "methods": {
38
- "exportPNG": "chart.export({ type:\"png\" }) returns base64 data URL (browser); pass as:\"blob\" for a Blob. In Node headless either install the canvas package or fall back to SVG.",
39
+ "exportPNG": "chart.export({ type:\"png\" }) returns a browser data URL. In Node headless use chart.exportAsync({ type:\"png\" }) after installing the optional canvas package, or fall back to SVG.",
39
40
  "exportSVG": "chart.export({ type:\"svg\" }) returns the SVG string in both browser and headless; as:\"dataurl\" for embeds, as:\"blob\" for a Blob (browser).",
40
- "exportJSON": "chart.export({ type:\"json\" }) returns pretty JSON; use as:\"object\" to get the parsed {version,spec,state}.",
41
+ "exportJSON": "chart.export({ type:\"json\" }) returns pretty JSON; use as:\"object\", as:\"dataurl\", or as:\"blob\" for the corresponding representation.",
41
42
  "downloadPNG": "chart.downloadPNG() triggers a browser save-as dialog (filename derived from title + timestamp).",
42
43
  "downloadSVG": "chart.downloadSVG() same semantics as downloadPNG but for SVG.",
43
44
  "downloadJSON": "chart.downloadJSON() saves {version,spec,state} as a .json document.",
@@ -58,7 +59,15 @@
58
59
  "projectIntelligenceDemo": "playground/project-intelligence.html",
59
60
  "foundationalGallery": "playground/foundational-gallery.html",
60
61
  "themeGallery": "playground/theme-gallery.html",
62
+ "preferencesLab": "playground/preferences-lab.html",
61
63
  "themeGuide": "docs/agent/theme-guide.md",
64
+ "preferences": {
65
+ "version": "1.0",
66
+ "scopes": ["global", "chart"],
67
+ "persistence": ["memory", "localStorage", "adapter"],
68
+ "agentAdjustable": true,
69
+ "interactiveSettingsUI": true
70
+ },
62
71
  "styleSystem": {
63
72
  "modes": ["auto", "light", "dark", "contrast"],
64
73
  "presets": ["auto", "analysis", "dashboard", "report", "presentation", "project", "diagram"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taylorwong/ichartjs",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "description": "Agent-first, renderer-independent charting and project visualization runtime",
5
5
  "type": "module",
6
6
  "main": "./src/index.mjs",
@@ -7,12 +7,22 @@ description: Plan, validate, render, explain, and safely edit iChart.js visualiz
7
7
 
8
8
  Use the public Agent contract as the source of truth. Do not infer capabilities from renderer internals or duplicate chart-selection logic in generated code.
9
9
 
10
+ Read the [usage scenarios](https://github.com/wanghetommy/ichartjs/blob/master/docs/agent/usage-scenarios.md) when the request is ambiguous about whether the output should be a live project component, a Coding Agent change, a Skill-generated artifact, or a scheduled report.
11
+
10
12
  ## Source and Runtime Setup
11
13
 
12
14
  - Official repository: `https://github.com/wanghetommy/ichartjs`
13
15
  - Official Skill source: `https://github.com/wanghetommy/ichartjs/tree/master/skills/ichartjs`
14
16
  - Supported Skill hosts include Codex, WorkBuddy, and other Agent Skills-compatible environments.
15
17
 
18
+ Recommended installation:
19
+
20
+ ```bash
21
+ npx skills add wanghetommy/ichartjs --skill ichartjs
22
+ ```
23
+
24
+ Use `--agent codex --global --yes` for global non-interactive Codex installation. Use the tagged directory `https://github.com/wanghetommy/ichartjs/tree/v2.0.6/skills/ichartjs` when reproducibility matters. WorkBuddy can import the same directory through its Skill interface; do not assume a `--agent workbuddy` adapter unless the installed CLI declares it.
25
+
16
26
  The Skill is a workflow adapter, not the chart runtime. If the current JavaScript or TypeScript project does not already depend on iChart.js, install the matching runtime from GitHub:
17
27
 
18
28
  ```bash
@@ -39,12 +49,20 @@ Use `@taylorwong/ichartjs` for package imports. Use `examples/agent-workflow.mjs
39
49
 
40
50
  ## Task Routing
41
51
 
52
+ Route by requested output:
53
+
54
+ - **Live product component**: modify the host JavaScript project and mount `createChart()`; return changed files and the host preview URL.
55
+ - **Coding Agent change**: inspect the repository, use the Runtime, run focused checks, and return the validated Spec plus changed files.
56
+ - **One-off artifact**: generate SVG/JSON directly; use browser PNG export or `exportAsync()` with optional `canvas` for Node PNG/JPEG.
57
+ - **Project or Diagram workflow**: load the matching scenario guide and preserve all stable IDs.
58
+ - **CI/report output**: keep JSON as the reproducible checkpoint and SVG/PNG as presentation artifacts.
59
+
42
60
  - For standard data analysis, read `references/chart-selection.md` and use foundational recipes.
43
61
  - For Gantt, Timeline, Milestone, Burndown, capacity, release, risk, or aging, use project capabilities and `agent-recipes/project-management.json`.
44
62
  - For Flow or Swimlane, preserve node, edge, lane, group, and port IDs; use diagram recipes and validated edit commands.
45
63
  - For business edits, preview first, preserve the preview ID and revision, require confirmation when declared, then commit or reject atomically.
46
64
  - For browser deliverables, start `npm run playground` and return the exact maintained Playground URL.
47
- - Release workflow (npm publish + develop→master merge) is **AUTHOR ONLY**. Read the release SOP in [`docs/agent/development/release-sop.md`](../../docs/agent/development/release-sop.md). Never initiate any release step unless the author explicitly instructs.
65
+ - Release workflow (npm publish + develop→master merge) is **AUTHOR ONLY**. Read the [release SOP](https://github.com/wanghetommy/ichartjs/blob/master/docs/agent/development/release-sop.md). Never initiate any release step unless the author explicitly instructs.
48
66
 
49
67
  ## Guardrails
50
68
 
@@ -137,15 +137,15 @@ export function getCapabilities() {
137
137
  mime: { png: 'image/png', jpeg: 'image/jpeg', svg: 'image/svg+xml', json: 'application/json' },
138
138
  browser: { png: true, jpeg: true, svg: true, json: true },
139
139
  headless: {
140
- png: 'optional: install the `canvas` npm package for createCanvas',
140
+ png: 'optional: install the `canvas` npm package for createCanvas and use exportAsync',
141
141
  jpeg: 'same as png',
142
142
  svg: true,
143
143
  json: true,
144
144
  },
145
145
  methods: {
146
- exportPNG: 'chart.export({ type:"png" }) returns base64 data URL (browser); pass as:"blob" for a Blob. In Node headless either install the canvas package or fall back to SVG.',
146
+ exportPNG: 'chart.export({ type:"png" }) returns a browser data URL. In Node headless use chart.exportAsync({ type:"png" }) after installing the optional canvas package, or fall back to SVG.',
147
147
  exportSVG: 'chart.export({ type:"svg" }) returns the SVG string in both browser and headless; as:"dataurl" for embeds, as:"blob" for a Blob (browser).',
148
- exportJSON: 'chart.export({ type:"json" }) returns pretty JSON; use as:"object" to get the parsed {version,spec,state}.',
148
+ exportJSON: 'chart.export({ type:"json" }) returns pretty JSON; use as:"object", as:"dataurl", or as:"blob" for the corresponding representation.',
149
149
  downloadPNG: 'chart.downloadPNG() triggers a browser save-as dialog (filename derived from title + timestamp).',
150
150
  downloadSVG: 'chart.downloadSVG() same semantics as downloadPNG but for SVG.',
151
151
  downloadJSON: 'chart.downloadJSON() saves {version,spec,state} as a .json document.',
@@ -184,6 +184,15 @@ export function getCapabilities() {
184
184
  data: ['normalize', 'inspect', 'filter', 'sort', 'groupBy', 'sum', 'average', 'topN', 'percentage', 'bin'],
185
185
  themes: [...styleCapabilities.modes],
186
186
  styleSystem: JSON.parse(JSON.stringify(styleCapabilities)),
187
+ preferences: {
188
+ version: '1.0',
189
+ scopes: ['global', 'chart'],
190
+ persistence: ['memory', 'localStorage', 'adapter'],
191
+ fields: ['theme', 'typography.scale', 'density', 'components.legend', 'components.labels', 'components.grid', 'branding.enabled', 'motion'],
192
+ agentAdjustable: true,
193
+ interactiveSettingsUI: true,
194
+ precedence: ['defaults', 'global', 'chart', 'temporary-agent-patch']
195
+ },
187
196
  plugins: true,
188
197
  branding: { defaultEnabled: true, signature: 'Powered by iChart.js', options: [{ name: 'enabled', type: 'boolean', default: true }] },
189
198
  };