Install
openclaw skills install chartjs-reporterThis 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 HTML visualization report powered by Chart.js. It covers generating pie charts, doughnut charts, bar charts (vertical/horizontal), line charts, mixed charts, and KPI summary cards — all embedded in a dark-themed, self-contained HTML file that opens directly in any browser. Trigger when the user says things like "生成可视化报告", "数据出图", "生成HTML图表", "把查询结果可视化", "用 Chart.js 画图", or provides tabular data and asks for a visual output.
openclaw skills install chartjs-reporter将结构化数据(SQL 查询结果、CSV 摘要、Python dict/list、手动提供的表格)转换为 自包含的 HTML 可视化报告,内嵌 Chart.js 图表和 KPI 卡片,无需服务器, 浏览器直接打开即可查看。
以下任意一种情况触发本技能:
收到数据后,确认以下信息:
| 分析目的 | 推荐图表 |
|---|---|
| 占比 / 构成 | doughnut(≤6类)/ pie |
| 趋势 / 时间序列 | line(fill: true 显示面积) |
| 分类对比(≤8项) | bar(垂直) |
| 分类对比(>8项或标签长) | bar(水平,indexAxis: 'y') |
| 多指标对比 | 分组 bar |
| 排名 Top N | 水平 bar + 进度条 |
| 关键指标摘要 | KPI 卡片(非图表) |
使用 scripts/generate_report.py 生成 HTML 报告:
python scripts/generate_report.py \
--title "报告标题" \
--subtitle "副标题说明" \
--data '{"charts": [...], "kpis": [...]}' \
--output report.html
也可以直接在 Python 中调用(适合与 chat2duckdb 配合):
from scripts.generate_report import build_report
html = build_report(title, subtitle, kpis, charts)
with open("report.html", "w", encoding="utf-8") as f:
f.write(html)
kpis 列表(可选,顶部 KPI 卡片):
[
{"label": "总营收", "value": "¥1,755,905", "sub": "全年累计", "color": "green"},
{"label": "订单数", "value": "200", "sub": "5 品类", "color": "blue"}
]
color 可选值:blue | green | yellow | purple | red
charts 列表(图表配置):
[
{
"type": "doughnut",
"title": "品类营收占比",
"labels": ["Food", "Electronics", "Sports"],
"datasets": [{"data": [456833, 351665, 349967]}]
},
{
"type": "line",
"title": "月度趋势",
"labels": ["1月","2月","3月"],
"datasets": [{"label": "营收", "data": [158495, 185560, 98369]}]
}
]
支持的 type 值:bar | line | doughnut | pie | horizontalBar(自动转 bar + indexAxis:y)
./report_<timestamp>.htmlpreview_url 工具在浏览器中预览1. chat2duckdb 执行 SQL 查询 → 得到 DataFrame / 字典结果
2. chartjs-reporter 将结果转换为图表配置 JSON
3. 调用 generate_report.py 生成 HTML
4. 调用 preview_url 展示报告
#0f172a,适合截图展示