Files
terminal-chart-server/skills/picoclaw-chart/references/CHART_API.md

160 lines
2.9 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Chart API 详细文档
## 端点
| 项目 | 值 |
|------|-----|
| 地址 | `https://aipi.gaomia.site/api/v1/chart` |
| 方法 | `POST` |
| Content-Type | `application/json` |
## 请求结构
```json
{
"type": "bar",
"title": "图表标题",
"data": {
"labels": ["标签1", "标签2", "标签3"],
"datasets": [
{
"name": "数据系列名称",
"values": [100, 150, 120],
"color": "#4CAF50"
}
],
"options": {
"width": 600,
"height": 400
}
}
}
```
## 响应结构
```json
{
"chart_id": "abc123",
"text": "纯文本描述",
"ansi": "\u001b[31m红色文本\u001b[0m",
"svg": "<svg>...</svg>",
"png_url": "https://aipi.gaomia.site/chart/abc123.png",
"markdown": "![月度销售额](https://aipi.gaomia.site/chart/abc123.png)"
}
```
## 图表类型示例
### 柱状图 (bar)
```json
{
"type": "bar",
"title": "月度销售额",
"data": {
"labels": ["一月", "二月", "三月", "四月"],
"datasets": [
{ "name": "销售额", "values": [100, 150, 120, 180], "color": "#4CAF50" }
]
}
}
```
### 饼图 (pie)
```json
{
"type": "pie",
"title": "市场份额",
"data": {
"labels": ["苹果", "三星", "华为", "其他"],
"datasets": [
{ "name": "销量", "values": [35, 25, 20, 20] }
]
}
}
```
### 圆环图 (donut)
```json
{
"type": "donut",
"title": "预算分配",
"data": {
"labels": ["人力", "设备", "营销", "研发"],
"datasets": [
{ "name": "预算", "values": [40, 20, 25, 15], "color": "#2196F3" }
]
}
}
```
### 雷达图 (radar)
```json
{
"type": "radar",
"title": "员工能力评估",
"data": {
"labels": ["速度", "力量", "耐力", "智力", "敏捷"],
"datasets": [
{ "name": "张三", "values": [80, 70, 90, 85, 75] }
]
}
}
```
### 气泡图 (bubble)
```json
{
"type": "bubble",
"title": "产品分析",
"data": {
"labels": ["产品A", "产品B", "产品C", "产品D"],
"datasets": [
{ "name": "销量/利润", "values": [100, 250, 150, 300] }
]
}
}
```
### 混合图 (mixed)
```json
{
"type": "mixed",
"title": "销售与目标对比",
"data": {
"labels": ["一月", "二月", "三月", "四月"],
"datasets": [
{ "name": "实际", "values": [100, 150, 120, 180] },
{ "name": "目标", "values": [120, 140, 130, 160] }
]
}
}
```
### 极区图 (polar)
```json
{
"type": "polar",
"title": "风向分布",
"data": {
"labels": ["北", "东北", "东", "东南", "南"],
"datasets": [
{ "name": "风速", "values": [10, 20, 15, 25, 30] }
]
}
}
```
## 注意事项
1. 每次请求生<E6B182><E7949F><EFBFBD>新的图表图表会缓存在服务器内存中
2. 图表数据通过 `datasets[].values` 传递,支持多系列
3. 颜色使用十六进制格式,如 `#FF5722`
4. 终端使用 ANSI 格式Web 使用 Markdown 格式