+
+
+
+ {{ message.record.sql }}
+
+
-
-
- SQL Generation:
-
-
-
-
- Chart Generation:
-
-
-
-
-
-
-
-
-
- {{ message.record.sql }}
+
+
-
-
-
-
-
-
- {{ chartObject }}
+
+ {{ message.record.error }}
-
-
- {{ message.record.error }}
-
-
-
-
-
- {{ dataObject.fields }}
- {{ dataObject.data }}
-
-
-
-
-
-
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/BaseChart.ts b/frontend/src/views/chat/component/BaseChart.ts
new file mode 100644
index 00000000..d2ad74c7
--- /dev/null
+++ b/frontend/src/views/chat/component/BaseChart.ts
@@ -0,0 +1,22 @@
+export abstract class BaseChart {
+ id: string;
+ _name: string = 'base-chart';
+ axis: Array<{ name: string, value: string, type?: 'x' | 'y' }> = [];
+ data: Array<{ [key: string]: any }> = [];
+
+ constructor(id: string, name: string) {
+ this.id = id;
+ this._name = name;
+ }
+
+ init(axis: Array<{ name: string, value: string, type?: 'x' | 'y' }>, data: Array<{ [key: string]: any }>): void {
+ this.axis = axis;
+ this.data = data;
+ }
+
+ abstract render(): void
+
+ abstract destroy(): void
+
+
+}
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/BaseG2Chart.ts b/frontend/src/views/chat/component/BaseG2Chart.ts
new file mode 100644
index 00000000..88177f88
--- /dev/null
+++ b/frontend/src/views/chat/component/BaseG2Chart.ts
@@ -0,0 +1,25 @@
+import {BaseChart} from "@/views/chat/component/BaseChart.ts";
+import {Chart} from '@antv/g2';
+
+export abstract class BaseG2Chart extends BaseChart {
+
+ chart: Chart;
+
+ constructor(id: string, name: string) {
+ super(id, name)
+ this.chart = new Chart({
+ container: id,
+ autoFit: true,
+ })
+ }
+
+ render() {
+ this.chart?.render()
+ }
+
+ destroy() {
+ this.chart?.destroy()
+ }
+
+
+}
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/Component.vue b/frontend/src/views/chat/component/Component.vue
new file mode 100644
index 00000000..9b8e9f54
--- /dev/null
+++ b/frontend/src/views/chat/component/Component.vue
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/charts/Bar.ts b/frontend/src/views/chat/component/charts/Bar.ts
new file mode 100644
index 00000000..c1ff190e
--- /dev/null
+++ b/frontend/src/views/chat/component/charts/Bar.ts
@@ -0,0 +1,33 @@
+import {BaseG2Chart} from "@/views/chat/component/BaseG2Chart.ts";
+
+export class Bar extends BaseG2Chart {
+
+ constructor(id: string) {
+ super(id, "bar");
+ }
+
+ init(axis: Array<{ name: string; value: string; type: "x" | "y" }>, data: Array<{ name: string; value: string }>) {
+ super.init(axis, data);
+ const x = this.axis.filter(item => item.type === "x");
+ const y = this.axis.filter(item => item.type === "y");
+
+ if (x.length == 0 || y.length == 0) {
+ return;
+ }
+
+ this.chart?.interval()
+ .coordinate({transform: [{type: 'transpose'}]})
+ .data(data)
+ .encode('x', x[0].value)
+ .encode('y', y[0].value)
+ .scale('x', {
+ nice: true,
+ })
+ .scale('y', {
+ nice: true,
+ })
+ .interaction('elementHighlight', { background: true });
+
+ }
+
+}
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/charts/Column.ts b/frontend/src/views/chat/component/charts/Column.ts
new file mode 100644
index 00000000..54d6c577
--- /dev/null
+++ b/frontend/src/views/chat/component/charts/Column.ts
@@ -0,0 +1,33 @@
+import {BaseG2Chart} from "@/views/chat/component/BaseG2Chart.ts";
+
+export class Column extends BaseG2Chart {
+
+ constructor(id: string) {
+ super(id, "column");
+ }
+
+ init(axis: Array<{ name: string; value: string; type: "x" | "y" }>, data: Array<{ name: string; value: string }>) {
+ super.init(axis, data);
+
+ const x = this.axis.filter(item => item.type === "x");
+ const y = this.axis.filter(item => item.type === "y");
+
+ if (x.length == 0 || y.length == 0) {
+ return;
+ }
+
+ this.chart?.interval()
+ .data(data)
+ .encode('x', x[0].value)
+ .encode('y', y[0].value)
+ .scale('x', {
+ nice: true,
+ })
+ .scale('y', {
+ nice: true,
+ })
+ .interaction('elementHighlight', { background: true });
+
+ }
+
+}
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/charts/Line.ts b/frontend/src/views/chat/component/charts/Line.ts
new file mode 100644
index 00000000..8269215d
--- /dev/null
+++ b/frontend/src/views/chat/component/charts/Line.ts
@@ -0,0 +1,43 @@
+import {BaseG2Chart} from "@/views/chat/component/BaseG2Chart.ts";
+
+export class Line extends BaseG2Chart {
+
+ constructor(id: string) {
+ super(id, "line");
+ }
+
+ init(axis: Array<{ name: string; value: string; type: "x" | "y" }>, data: Array<{ name: string; value: string }>) {
+ super.init(axis, data);
+
+ const x = this.axis.filter(item => item.type === "x");
+ const y = this.axis.filter(item => item.type === "y");
+
+ if (x.length == 0 || y.length == 0) {
+ return;
+ }
+
+ this.chart?.data(data)
+ .encode('x', x[0].value)
+ .encode('y', y[0].value)
+ .scale('x', {
+ nice: true,
+ })
+ .scale('y', {
+ nice: true,
+ });
+
+ this.chart?.line().label({
+ text: 'value',
+ style: {
+ dx: -10,
+ dy: -12,
+ },
+ });
+
+ this.chart?.point()
+ .style('fill', 'white')
+ .tooltip(false);
+
+ }
+
+}
\ No newline at end of file
diff --git a/frontend/src/views/chat/component/index.ts b/frontend/src/views/chat/component/index.ts
new file mode 100644
index 00000000..85cb1b15
--- /dev/null
+++ b/frontend/src/views/chat/component/index.ts
@@ -0,0 +1,29 @@
+import {BaseChart} from "@/views/chat/component/BaseChart.ts";
+import {Bar} from "@/views/chat/component/charts/Bar.ts";
+import {Column} from "@/views/chat/component/charts/Column.ts";
+import {Line} from "@/views/chat/component/charts/Line.ts";
+
+const CHART_TYPE_MAP: { [key: string]: any } = {
+ "column": Column,
+ "bar": Bar,
+ "line": Line,
+}
+
+const isParent = (type: any, parentType: any) => {
+ let _type = type
+ while (_type) {
+ if (_type === parentType) {
+ return true
+ }
+ _type = _type.__proto__
+ }
+ return false
+}
+
+export function getChartInstance(type: string, id: string): BaseChart | undefined {
+ if (isParent(CHART_TYPE_MAP[type], BaseChart)) {
+ return new CHART_TYPE_MAP[type](id) as BaseChart;
+ }
+ return undefined
+}
+
diff --git a/frontend/src/views/chat/index.vue b/frontend/src/views/chat/index.vue
index 14972ac9..33d38991 100644
--- a/frontend/src/views/chat/index.vue
+++ b/frontend/src/views/chat/index.vue
@@ -294,6 +294,9 @@ const sendMessage = async () => {
const data = JSON.parse(str);
switch (data.type) {
+ case "id":
+ currentChat.value.records[currentChat.value.records.length - 1].id = data.id;
+ break;
case "info":
console.log(data.msg);
break;
diff --git a/frontend/src/views/system/model/index.vue b/frontend/src/views/system/model/index.vue
index fe57f259..9afa061f 100644
--- a/frontend/src/views/system/model/index.vue
+++ b/frontend/src/views/system/model/index.vue
@@ -80,6 +80,7 @@
v-model:page-size="state.pageInfo.pageSize"
:page-sizes="[10, 20, 30]"
:background="true"
+ :pager-count="5"
layout="total, sizes, prev, pager, next, jumper"
:total="state.pageInfo.total"
@size-change="handleSizeChange"