Files
2026-07-13 21:37:14 +08:00

2.6 KiB
Raw Permalink Blame History

name, description
name description
chart-generation 图表生成能力

chart-generation 能力

提供方:chart-generation 技能:chart-image

方法

lineChart(折线图)

输入:

  • data:数据点数组(包含 x/y、time/value 或 time/price 字段的对象)
  • title:(可选)图表标题
  • groupBy:(可选)用于多系列图表的分组字段
  • options:(可选)附加选项
    • darkboolean - 使用深色主题
    • focusRecentnumber - 缩放到最近 N 个数据点
    • showChangeboolean - 显示百分比变化标注
    • showValuesboolean - 在数据点上显示值标签

实现方式:

# 将数据写入临时文件
echo '${JSON.stringify(data)}' > /tmp/chart-data.json

# 生成图表
node /data/clawd/skills/chart-image/scripts/chart.mjs \
  --type line \
  --data "$(cat /tmp/chart-data.json)" \
  --title "${title}" \
  ${options.dark ? '--dark' : ''} \
  ${options.focusRecent ? '--focus-recent ' + options.focusRecent : ''} \
  ${options.showChange ? '--show-change' : ''} \
  ${options.showValues ? '--show-values' : ''} \
  --output /tmp/chart-${Date.now()}.png

输出:{ path: string } - 生成的 PNG 文件路径


barChart(柱状图)

输入:

  • data:包含 label 和 value 字段的对象数组
  • title:(可选)图表标题
  • options:(可选)附加选项
    • darkboolean - 使用深色主题
    • showValuesboolean - 在柱子上显示值标签

实现方式:

# 将数据写入临时文件
echo '${JSON.stringify(data)}' > /tmp/chart-data.json

# 生成图表
node /data/clawd/skills/chart-image/scripts/chart.mjs \
  --type bar \
  --data "$(cat /tmp/chart-data.json)" \
  --title "${title}" \
  ${options.dark ? '--dark' : ''} \
  ${options.showValues ? '--show-values' : ''} \
  --output /tmp/chart-${Date.now()}.png

输出:{ path: string } - 生成的 PNG 文件路径


areaChart(面积图)

输入:

  • data:数据点数组
  • title:(可选)图表标题
  • options:(可选)与 lineChart 相同

实现方式:

node /data/clawd/skills/chart-image/scripts/chart.mjs \
  --type area \
  --data '${JSON.stringify(data)}' \
  --title "${title}" \
  --output /tmp/chart-${Date.now()}.png

输出:{ path: string } - 生成的 PNG 文件路径


说明

  • 所有方法默认将 PNG 图片输出到 /tmp 目录
  • 在本地时间 20:00–07:00 之间使用 --dark 标志可获得更好的夜间模式视觉效果
  • 对于时间序列,数据点应包含 ISO 格式或可读字符串形式的 timex 字段
  • 该技能底层使用 Vega-Lite — 完整选项请参见 SKILL.md