← Back to Skills Marketplace
cloudcba

chartjs-reporter

by 船长的虾 · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
105
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install chartjs-reporter
Description
This skill should be used when the user needs to turn structured data (query results, CSV summaries, JSON records, or Python dicts/lists) into a standalone H...
README (SKILL.md)

\r \r

chartjs-reporter — Chart.js HTML 可视化报告生成技能\r

\r

技能目的\r

\r 将结构化数据(SQL 查询结果、CSV 摘要、Python dict/list、手动提供的表格)转换为\r 自包含的 HTML 可视化报告,内嵌 Chart.js 图表和 KPI 卡片,无需服务器,\r 浏览器直接打开即可查看。\r \r

触发条件\r

\r 以下任意一种情况触发本技能:\r

  • 用户提供了数据并要求"出图"、"可视化"、"生成报告"\r
  • 用户已有 DuckDB / SQL / pandas 查询结果,需要图表化展示\r
  • 用户指定了图表类型(饼图、柱状图、折线图等)+ 数据\r
  • 与 chat2duckdb 技能配合:查询完成后生成可视化报告\r \r

操作步骤\r

\r

步骤 1:理解数据结构\r

\r 收到数据后,确认以下信息:\r

  • 数据形态:数值列 / 分类列 / 时间列\r
  • 分析目的:占比 / 趋势 / 对比 / 排名\r
  • 期望图表类型(用户未指定时,按照「图表选型规则」自动选择)\r \r

步骤 2:选择图表类型\r

\r | 分析目的 | 推荐图表 |\r |---------|---------|\r | 占比 / 构成 | doughnut(≤6类)/ pie |\r | 趋势 / 时间序列 | line(fill: true 显示面积) |\r | 分类对比(≤8项) | bar(垂直) |\r | 分类对比(>8项或标签长) | bar(水平,indexAxis: 'y') |\r | 多指标对比 | 分组 bar |\r | 排名 Top N | 水平 bar + 进度条 |\r | 关键指标摘要 | KPI 卡片(非图表) |\r \r

步骤 3:调用生成脚本\r

\r 使用 scripts/generate_report.py 生成 HTML 报告:\r \r

python scripts/generate_report.py \\r
  --title "报告标题" \\r
  --subtitle "副标题说明" \\r
  --data '{"charts": [...], "kpis": [...]}' \\r
  --output report.html\r
```\r
\r
也可以直接在 Python 中调用(适合与 chat2duckdb 配合):\r
\r
```python\r
from scripts.generate_report import build_report\r
html = build_report(title, subtitle, kpis, charts)\r
with open("report.html", "w", encoding="utf-8") as f:\r
    f.write(html)\r
```\r
\r
### 步骤 4:数据格式规范\r
\r
`kpis` 列表(可选,顶部 KPI 卡片):\r
```json\r
[\r
  {"label": "总营收", "value": "¥1,755,905", "sub": "全年累计", "color": "green"},\r
  {"label": "订单数", "value": "200",         "sub": "5 品类",  "color": "blue"}\r
]\r
```\r
`color` 可选值:`blue` | `green` | `yellow` | `purple` | `red`\r
\r
`charts` 列表(图表配置):\r
```json\r
[\r
  {\r
    "type": "doughnut",\r
    "title": "品类营收占比",\r
    "labels": ["Food", "Electronics", "Sports"],\r
    "datasets": [{"data": [456833, 351665, 349967]}]\r
  },\r
  {\r
    "type": "line",\r
    "title": "月度趋势",\r
    "labels": ["1月","2月","3月"],\r
    "datasets": [{"label": "营收", "data": [158495, 185560, 98369]}]\r
  }\r
]\r
```\r
\r
支持的 `type` 值:`bar` | `line` | `doughnut` | `pie` | `horizontalBar`(自动转 bar + indexAxis:y)\r
\r
### 步骤 5:布局规则\r
\r
- KPI 卡片行:最多 4 列,超出自动换行\r
- 图表区:默认 2 列网格;1 个图表时全宽;3 个图表时 3 列\r
- 每张图表高度固定 240px,响应式宽度\r
- 表格(Top N 排名):单独一行,全宽显示\r
- 页脚:说明数据来源和生成时间\r
\r
### 步骤 6:输出与展示\r
\r
- 输出路径默认为用户提供的路径,或 `./report_\x3Ctimestamp>.html`\r
- 生成后调用 `preview_url` 工具在浏览器中预览\r
- 所有依赖(Chart.js)通过 CDN 加载,无需本地安装\r
\r
## 与 chat2duckdb 配合的标准流程\r
\r
```\r
1. chat2duckdb 执行 SQL 查询 → 得到 DataFrame / 字典结果\r
2. chartjs-reporter 将结果转换为图表配置 JSON\r
3. 调用 generate_report.py 生成 HTML\r
4. 调用 preview_url 展示报告\r
```\r
\r
## 参考资源\r
\r
- 核心脚本:[scripts/generate_report.py](scripts/generate_report.py)\r
- 图表配置参考:[references/chart-config-guide.md](references/chart-config-guide.md)\r
- 样式主题参考:[references/theme-tokens.md](references/theme-tokens.md)\r
\r
## 注意事项\r
\r
- 报告为**深色主题**(dark mode),背景色 `#0f172a`,适合截图展示\r
- 数值超过 1000 时,自动格式化为千分位(¥1,234,567)\r
- 颜色序列已内置,无需手动指定每个数据点颜色\r
- Chart.js 版本固定为 4.4.0(CDN),确保稳定性\r
Usage Guidance
This skill appears to do what it says: generate self-contained Chart.js HTML reports from supplied JSON/structures. Before installing or running: 1) Review the local scripts/generate_report.py file yourself (it will write an HTML file to disk when used). 2) Be cautious about using the preview_url tool — confirm how your agent's preview tool works (it may upload the HTML to a remote preview service). 3) Do not copy-run the absolute path example in the reference docs (it is just an example and points at a user-specific path). 4) If your data is sensitive, avoid sending it to any external preview or CDN; you can host Chart.js locally and open the generated HTML offline if needed.
Capability Analysis
Type: OpenClaw Skill Name: chartjs-reporter Version: 1.0.0 The skill is classified as suspicious due to a Cross-Site Scripting (XSS) vulnerability in `scripts/generate_report.py`. The script constructs HTML reports by directly interpolating user-provided data (such as titles, labels, and table values) into the HTML structure and JavaScript configurations without any sanitization or escaping. While the skill's behavior is consistent with its stated purpose of generating Chart.js visualizations, the lack of output encoding allows for the execution of arbitrary scripts in the user's browser if the input data is sourced from untrusted or malicious origins.
Capability Assessment
Purpose & Capability
Name/description match the implementation: included Python script builds HTML using Chart.js CDN, KPI and chart config formats match the SKILL.md and reference docs. The skill does not request unrelated binaries, env vars, or config paths.
Instruction Scope
SKILL.md instructs running scripts/generating HTML and (optionally) calling a preview_url tool to open the report. preview_url is an external agent tool — depending on your agent implementation it may upload or expose the HTML to a remote preview service, which could leak sensitive data. A reference example shows subprocess.run with an absolute path in a user's home (documentation/example only); it's not required but could confuse an automated agent if followed literally.
Install Mechanism
No install spec — instruction-only plus a local Python script. No remote downloads or archive extraction; the HTML loads Chart.js via a well-known CDN (jsdelivr).
Credentials
The skill declares no environment variables, no credentials, and no config paths. The code does not attempt to read secrets or external credentials; input is taken via CLI args or function parameters.
Persistence & Privilege
Skill is not always-enabled and does not request persistent elevated privileges. It does not modify other skills or system-wide agent configuration.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install chartjs-reporter
  3. After installation, invoke the skill by name or use /chartjs-reporter
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
chartjs-reporter 1.0.0 — Initial release - Generate standalone, dark-themed Chart.js HTML reports from structured data. - Supports pie, doughnut, bar (vertical/horizontal), line, mixed charts, and KPI summary cards. - Accepts SQL/CSV/Python/tabular data as input. - Provides both command-line and Python script interfaces for report generation. - Designed for direct browser viewing with all dependencies loaded via CDN. - Includes automatic chart type selection and responsive grid layout for charts and KPIs.
Metadata
Slug chartjs-reporter
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is chartjs-reporter?

This skill should be used when the user needs to turn structured data (query results, CSV summaries, JSON records, or Python dicts/lists) into a standalone H... It is an AI Agent Skill for Claude Code / OpenClaw, with 105 downloads so far.

How do I install chartjs-reporter?

Run "/install chartjs-reporter" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is chartjs-reporter free?

Yes, chartjs-reporter is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does chartjs-reporter support?

chartjs-reporter is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created chartjs-reporter?

It is built and maintained by 船长的虾 (@cloudcba); the current version is v1.0.0.

💬 Comments