From de11dd8aef20b0398d89f8aa7cee577ae22fef9d Mon Sep 17 00:00:00 2001 From: ulleo Date: Mon, 16 Jun 2025 16:50:41 +0800 Subject: [PATCH] feat: column, bar and line axis title --- backend/template.yaml | 2 +- frontend/src/views/chat/component/charts/Bar.ts | 4 ++++ frontend/src/views/chat/component/charts/Column.ts | 4 ++++ frontend/src/views/chat/component/charts/Line.ts | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/template.yaml b/backend/template.yaml index 9eb4dd00..80219baa 100644 --- a/backend/template.yaml +++ b/backend/template.yaml @@ -59,7 +59,7 @@ template: {{"type":"line", "title": "标题", "axis": {{"x": {{"name":"x轴的中文名称","value": "SQL 查询 x 轴的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}, "y": {{"name":"y轴的中文名称","value": "SQL 查询 y 轴的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}, "series": {{"name":"分类的中文名称","value":"SQL 查询分类的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}}}}} 其中“x”和“y”必须从SQL查询列中提取。 - 如果需要饼图,则生成的 JSON 格式应为: - {{"type":"pie", "title": "标题", "axis": {{"y": {{"值轴的中文名称","value":"SQL 查询数值的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}, "series": {{"name":"分类的中文名称","value":"SQL 查询分类的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}}} + {{"type":"pie", "title": "标题", "axis": {{"y": {{"name":"值轴的中文名称","value":"SQL 查询数值的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}, "series": {{"name":"分类的中文名称","value":"SQL 查询分类的列(有别名用别名,去掉外层的反引号、双引号、方括号)"}}}}}} 其中“y”和“series”必须从SQL查询列中提取。 - 如果答案未知或者与生成JSON无关,则生成的 JSON 格式应为: {{"type":"error", "reason": "抱歉,我无法回答您的问题。"}} diff --git a/frontend/src/views/chat/component/charts/Bar.ts b/frontend/src/views/chat/component/charts/Bar.ts index 144f7c7a..8df6cbc2 100644 --- a/frontend/src/views/chat/component/charts/Bar.ts +++ b/frontend/src/views/chat/component/charts/Bar.ts @@ -23,6 +23,10 @@ export class Bar extends BaseG2Chart { .data(data) .encode('x', x[0].value) .encode('y', y[0].value) + .axis({ + x: { title: x[0].name }, + y: { title: y[0].name }, + }) .scale('x', { nice: true, }) diff --git a/frontend/src/views/chat/component/charts/Column.ts b/frontend/src/views/chat/component/charts/Column.ts index d49821b8..31e93a33 100644 --- a/frontend/src/views/chat/component/charts/Column.ts +++ b/frontend/src/views/chat/component/charts/Column.ts @@ -22,6 +22,10 @@ export class Column extends BaseG2Chart { .data(data) .encode('x', x[0].value) .encode('y', y[0].value) + .axis({ + x: { title: x[0].name }, + y: { title: y[0].name }, + }) .scale('x', { nice: true, }) diff --git a/frontend/src/views/chat/component/charts/Line.ts b/frontend/src/views/chat/component/charts/Line.ts index b88cfdb4..6618592f 100644 --- a/frontend/src/views/chat/component/charts/Line.ts +++ b/frontend/src/views/chat/component/charts/Line.ts @@ -21,6 +21,10 @@ export class Line extends BaseG2Chart { ?.data(data) .encode('x', x[0].value) .encode('y', y[0].value) + .axis({ + x: { title: x[0].name }, + y: { title: y[0].name }, + }) .scale('x', { nice: true, })