Files
SnapOtter/apps/docs/zh-CN/tools/files/chart-maker.md
T
SnapOtterandGitHub 4963ab3bbd feat(docs-i18n): translate all documentation into 20 languages
All 181 docs markdown files translated into 20 languages (apps/docs/<locale>/**). Companion to the i18n code PR; admin-merged because the file count exceeds GitHub's per-PR CI trigger limit. Validated by pnpm i18n:check (all surfaces, 0 stale/missing) and a clean all-locale docs build.
2026-07-11 13:52:47 +08:00

1.8 KiB
Raw Blame History

description, i18n_source_hash, i18n_provenance, i18n_output_hash
description i18n_source_hash i18n_provenance i18n_output_hash
根据 CSV 或 JSON 数据创建柱状图、折线图或饼图。 d3c39384457b human f386d98f072b

Chart Maker

根据 CSV 或 JSON 数据创建柱状图、折线图或饼图。返回渲染图表的 PNG 图片。

API Endpoint

POST /api/v1/tools/files/chart-maker

接受包含 CSV 或 JSON 文件和 JSON settings 字段的 multipart 表单数据。

Parameters

Parameter Type Required Default Description
kind string No "bar" 图表类型:barlinepie
title string No - 图表标题(最多 120 个字符)
width integer No 960 图表宽度(单位像素,320-2048
height integer No 540 图表高度(单位像素,240-1536

Example Request

curl -X POST http://localhost:1349/api/v1/tools/files/chart-maker \
  -H "Authorization: Bearer si_your-api-key" \
  -F "file=@sales.csv" \
  -F 'settings={"kind": "line", "title": "Monthly Sales", "width": 960, "height": 540}'

Example Response

{
  "jobId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "downloadUrl": "/api/v1/download/a1b2c3d4-e5f6-7890-abcd-ef1234567890/sales_chart.png",
  "originalSize": 1024,
  "processedSize": 48500
}

Notes

  • 输入必须是 .csv.json 文件。CSV 文件应带有包含列名的表头行。
  • 第一列用作类别标签;第二列必须为数值,用于提供数据值。只使用两列。
  • JSON 输入应为一组 {label, value} 对象,或一个普通对象,其键成为标签、值成为数据点。
  • 最多 100 个数据点。所有值必须大于或等于零。
  • 无论输入格式如何,输出始终是 PNG 图片。