feat: 数据方向(行=系列)+每系列类型/双轴 + 多图大标题/共享图例 v1.16.0
- 图表模式新增'数据方向':列=系列(默认)/行=系列(第一行是横坐标,每行一个系列),每行可独立设柱状/折线 + 左右轴量度 - 后端 buildChartOption/GET /api/chart 支持 rowsAsSeries + seriesAxis(按系列下标指定左右轴) - 多图合并每张小图新增:行=系列、双Y轴(左右量度不同)、每系列独立图表类型与坐标轴配置 - 多图合并新增图片大标题(bigTitle),居中显示在顶部 - 多图合并新增图例方式(legendMode):own 各自图例(默认)/shared-top 共用图例顶部/shared-bottom 共用图例底部,共用时各子图隐藏自己的图例、系列合并去重、超宽自动换行 - /api/combine 后端同步支持 bigTitle/legendMode(含深色主题文字适配) - 收藏功能完整支持新字段(combine 大标题/图例方式/每系列配置,chart 数据方向),编辑恢复正常 - 文档/API.md/README 更新,版本 1.16.0
This commit is contained in:
@@ -50,6 +50,8 @@ Content-Type: application/json
|
||||
| `leftAxisName` | string | — | `""` | 左轴名称(如 `"销售额(元)"`) |
|
||||
| `rightAxisName` | string | — | `""` | 右轴名称(如 `"增长率(%)"`) |
|
||||
| `seriesTypes` | array | — | `null` | 每系列图表类型,按系列顺序对应,如 `["bar","line"]`(`bar`/`line`/`auto`) |
|
||||
| `seriesAxis` | array | — | `null` | 每系列坐标轴,按系列顺序对应,如 `[0,1]`(`0`=左轴 `1`=右轴,配合 `dualYAxis`;优先于 `rightAxisSeries`) |
|
||||
| `rowsAsSeries` | boolean | — | `false` | 数据方向:`false`=列=系列(第一列是横坐标,每列一个系列);`true`=行=系列(第一行是横坐标,每行一个系列) |
|
||||
| `width` | number | — | `800` | 图片宽度(px) |
|
||||
| `height` | number | — | `500` | 图片高度(px) |
|
||||
| `pixelRatio` | number | — | `2` | 像素倍率(越大越清晰) |
|
||||
@@ -178,10 +180,33 @@ Content-Type: application/json
|
||||
| `gap` | number | 否 | 图间距(默认 24px) |
|
||||
| `pixelRatio` | number | 否 | 像素倍率,默认 2(越清晰文件越大) |
|
||||
| `background` | string | 否 | 背景色,默认 `#ffffff` |
|
||||
| `bigTitle` | string | 否 | 整张图片的大标题(可空),居中显示在顶部 |
|
||||
| `legendMode` | string | 否 | 图例方式:`own` 每个小图各自图例(默认)/ `shared-top` 共用一套图例放顶部 / `shared-bottom` 共用一套图例放底部(共用时各子图隐藏自己的图例,系列合并去重) |
|
||||
| `theme` | string | 否 | 大标题/共享图例文字颜色所属主题,默认 `default`(深色用 `dark`) |
|
||||
|
||||
> 兼容旧参数:`chart1` + `chart2` 仍可传(等价于 `charts: [chart1, chart2]`)。
|
||||
|
||||
每个子图配置支持:`data`(CSV)、`chartType`(bar/line/bar-line/pie/radar)、`title`、`theme`、`showLegend`、`showGrid`、`showLabel`、`stackMode`、`smoothLine`、`width`、`height`。
|
||||
每个子图配置支持:`data`(CSV)、`chartType`(bar/line/bar-line/pie/radar)、`title`、`theme`、`showLegend`、`showGrid`、`showLabel`、`stackMode`、`smoothLine`、`width`、`height`,以及**数据方向与多类型双轴**:`rowsAsSeries`(行=系列)、`dualYAxis`、`leftAxisName`、`rightAxisName`、`seriesTypes`、`seriesAxis`。
|
||||
|
||||
### 高级示例(大标题 + 底部共享图例 + 行=系列 + 柱状/折线双轴)
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:16016/api/combine \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"bigTitle": "经营总览大图",
|
||||
"legendMode": "shared-bottom",
|
||||
"direction": "grid",
|
||||
"cols": 2,
|
||||
"charts": [
|
||||
{"data": "指标, 2023, 2024, 2025\n营收(元), 1200, 1800, 2100\n销量(个), 100, 150, 130",
|
||||
"rowsAsSeries": true, "chartType": "bar", "title": "营收与销量",
|
||||
"dualYAxis": true, "leftAxisName": "元", "rightAxisName": "个",
|
||||
"seriesTypes": ["bar","line"], "seriesAxis": [0,1]},
|
||||
{"data": "产品, Q1, Q2\n手机, 1200, 1800\n平板, 800, 950", "chartType": "bar", "title": "季度销售"}
|
||||
]
|
||||
}' -o combine.png
|
||||
```
|
||||
|
||||
### curl 示例
|
||||
|
||||
@@ -248,7 +273,7 @@ curl http://192.168.0.101:16016/api/health
|
||||
{
|
||||
"status": "ok",
|
||||
"service": "data-chart-tool",
|
||||
"version": "1.1.0",
|
||||
"version": "1.16.0",
|
||||
"endpoints": {
|
||||
"POST /api/chart": "生成图表图片(JSON body)",
|
||||
"GET /api/chart": "生成图表图片(URL 参数)",
|
||||
|
||||
Reference in New Issue
Block a user