@antv/gpt-vis 0.0.5 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +57 -60
- package/README.zh-CN.md +93 -0
- package/dist/cjs/Area/index.d.ts +8 -2
- package/dist/cjs/Area/index.js +17 -16
- package/dist/cjs/Bar/index.d.ts +11 -0
- package/dist/cjs/Bar/index.js +65 -0
- package/dist/cjs/ChartCodeRender/Loading.d.ts +3 -0
- package/dist/cjs/ChartCodeRender/Loading.js +54 -0
- package/dist/cjs/ChartCodeRender/VisChart.d.ts +11 -0
- package/dist/cjs/ChartCodeRender/VisChart.js +84 -0
- package/dist/cjs/ChartCodeRender/index.d.ts +3 -4
- package/dist/cjs/ChartCodeRender/index.js +24 -68
- package/dist/cjs/ChartCodeRender/type.d.ts +9 -11
- package/dist/cjs/Column/index.d.ts +8 -2
- package/dist/cjs/Column/index.js +21 -29
- package/dist/cjs/ConfigProvider/context.d.ts +3 -0
- package/dist/cjs/ConfigProvider/context.js +41 -0
- package/dist/cjs/ConfigProvider/hooks/index.d.ts +1 -0
- package/dist/cjs/ConfigProvider/hooks/index.js +23 -0
- package/dist/cjs/ConfigProvider/hooks/useConfig.d.ts +13 -0
- package/dist/cjs/ConfigProvider/hooks/useConfig.js +107 -0
- package/dist/cjs/ConfigProvider/index.d.ts +7 -0
- package/dist/cjs/ConfigProvider/index.js +43 -0
- package/dist/cjs/DualAxes/index.d.ts +15 -0
- package/dist/cjs/DualAxes/index.js +71 -0
- package/dist/cjs/DualAxes/util.d.ts +9 -0
- package/dist/cjs/DualAxes/util.js +73 -0
- package/dist/cjs/FlowDiagram/index.d.ts +6 -0
- package/dist/cjs/FlowDiagram/index.js +100 -0
- package/dist/cjs/GPTVis/index.d.ts +7 -7
- package/dist/cjs/GPTVis/index.js +4 -9
- package/dist/cjs/HeatMap/index.d.ts +7 -7
- package/dist/cjs/HeatMap/index.js +13 -36
- package/dist/cjs/Histogram/index.d.ts +10 -0
- package/dist/cjs/Histogram/index.js +51 -0
- package/dist/cjs/IndentedTree/index.d.ts +6 -0
- package/dist/cjs/IndentedTree/index.js +63 -0
- package/dist/cjs/Line/index.d.ts +8 -2
- package/dist/cjs/Line/index.js +15 -17
- package/dist/cjs/Map/data.json +305 -0
- package/dist/cjs/Map/index.d.ts +5 -0
- package/dist/cjs/Map/index.js +68 -0
- package/dist/cjs/MindMap/index.d.ts +6 -0
- package/dist/cjs/MindMap/index.js +64 -0
- package/dist/cjs/NetworkGraph/index.d.ts +6 -0
- package/dist/cjs/NetworkGraph/index.js +72 -0
- package/dist/cjs/OrganizationChart/index.d.ts +6 -0
- package/dist/cjs/OrganizationChart/index.js +93 -0
- package/dist/cjs/PathMap/index.d.ts +3 -9
- package/dist/cjs/PathMap/index.js +19 -111
- package/dist/cjs/Pie/index.d.ts +7 -5
- package/dist/cjs/Pie/index.js +17 -16
- package/dist/cjs/PinMap/index.d.ts +3 -9
- package/dist/cjs/PinMap/index.js +6 -87
- package/dist/cjs/Radar/index.d.ts +11 -0
- package/dist/cjs/Radar/index.js +84 -0
- package/dist/cjs/Scatter/index.d.ts +11 -0
- package/dist/cjs/Scatter/index.js +57 -0
- package/dist/cjs/Text/VisText.d.ts +4 -0
- package/dist/cjs/Text/VisText.js +71 -0
- package/dist/cjs/Text/config.d.ts +18 -0
- package/dist/cjs/Text/config.js +91 -0
- package/dist/cjs/Text/constants.d.ts +9 -0
- package/dist/cjs/Text/constants.js +37 -0
- package/dist/cjs/Text/custom-icons/index.d.ts +3 -0
- package/dist/cjs/Text/custom-icons/index.js +66 -0
- package/dist/cjs/Text/index.d.ts +3 -0
- package/dist/cjs/Text/index.js +42 -0
- package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +65 -0
- package/dist/cjs/Text/mini-charts/hooks/index.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/hooks/index.js +29 -0
- package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
- package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +65 -0
- package/dist/cjs/Text/mini-charts/index.d.ts +2 -0
- package/dist/cjs/Text/mini-charts/index.js +25 -0
- package/dist/cjs/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
- package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +63 -0
- package/dist/cjs/Text/mini-charts/line/index.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/line/index.js +29 -0
- package/dist/cjs/Text/mini-charts/line/scaleLinear.d.ts +4 -0
- package/dist/cjs/Text/mini-charts/line/scaleLinear.js +35 -0
- package/dist/cjs/Text/mini-charts/line/useLineCompute.d.ts +6 -0
- package/dist/cjs/Text/mini-charts/line/useLineCompute.js +103 -0
- package/dist/cjs/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/proportion/getArcPath.js +51 -0
- package/dist/cjs/Text/mini-charts/proportion/index.d.ts +3 -0
- package/dist/cjs/Text/mini-charts/proportion/index.js +72 -0
- package/dist/cjs/Text/types.d.ts +20 -0
- package/dist/cjs/Text/types.js +17 -0
- package/dist/cjs/Treemap/index.d.ts +11 -0
- package/dist/cjs/Treemap/index.js +73 -0
- package/dist/cjs/WordCloud/index.d.ts +4 -5
- package/dist/cjs/WordCloud/index.js +7 -15
- package/dist/cjs/constants/index.d.ts +2 -2
- package/dist/cjs/constants/index.js +8 -27
- package/dist/cjs/export.d.ts +25 -0
- package/dist/cjs/export.js +119 -0
- package/dist/cjs/index.d.ts +4 -11
- package/dist/cjs/index.js +5 -18
- package/dist/cjs/types/chart.d.ts +65 -0
- package/dist/cjs/types/chart.js +51 -0
- package/dist/cjs/types/config.d.ts +20 -0
- package/dist/cjs/types/config.js +17 -0
- package/dist/cjs/types/index.d.ts +2 -26
- package/dist/cjs/types/index.js +3 -19
- package/dist/cjs/types/map.d.ts +242 -0
- package/dist/cjs/types/map.js +17 -0
- package/dist/cjs/utils/config.d.ts +5 -0
- package/dist/cjs/utils/config.js +76 -0
- package/dist/cjs/utils/graph.d.ts +18 -0
- package/dist/cjs/utils/graph.js +64 -0
- package/dist/cjs/utils/index.d.ts +1 -0
- package/dist/cjs/utils/index.js +23 -0
- package/dist/cjs/utils/map/context.d.ts +3 -0
- package/dist/cjs/utils/map/context.js +42 -0
- package/dist/cjs/utils/map/controls.d.ts +0 -0
- package/dist/cjs/utils/map/controls.js +0 -0
- package/dist/cjs/utils/map/index.d.ts +6 -0
- package/dist/cjs/utils/map/index.js +33 -0
- package/dist/cjs/utils/map/markers.d.ts +2 -0
- package/dist/cjs/utils/map/markers.js +88 -0
- package/dist/cjs/utils/map/polyline.d.ts +2 -0
- package/dist/cjs/utils/map/polyline.js +52 -0
- package/dist/cjs/utils/map/style.d.ts +45 -0
- package/dist/cjs/utils/map/style.js +112 -0
- package/dist/cjs/utils/map/util.d.ts +1 -0
- package/dist/cjs/utils/map/util.js +38 -0
- package/dist/cjs/utils/map/view.d.ts +3 -0
- package/dist/cjs/utils/map/view.js +93 -0
- package/dist/cjs/utils/plot.d.ts +4 -0
- package/dist/cjs/utils/plot.js +69 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +25 -0
- package/dist/esm/Area/index.d.ts +8 -2
- package/dist/esm/Area/index.js +21 -27
- package/dist/esm/Bar/index.d.ts +11 -0
- package/dist/esm/Bar/index.js +35 -0
- package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
- package/dist/esm/ChartCodeRender/Loading.js +20 -0
- package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
- package/dist/esm/ChartCodeRender/VisChart.js +65 -0
- package/dist/esm/ChartCodeRender/index.d.ts +3 -4
- package/dist/esm/ChartCodeRender/index.js +28 -84
- package/dist/esm/ChartCodeRender/type.d.ts +9 -11
- package/dist/esm/Column/index.d.ts +8 -2
- package/dist/esm/Column/index.js +24 -29
- package/dist/esm/ConfigProvider/context.d.ts +3 -0
- package/dist/esm/ConfigProvider/context.js +3 -0
- package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
- package/dist/esm/ConfigProvider/hooks/index.js +1 -0
- package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
- package/dist/esm/ConfigProvider/hooks/useConfig.js +55 -0
- package/dist/esm/ConfigProvider/index.d.ts +7 -0
- package/dist/esm/ConfigProvider/index.js +16 -0
- package/dist/esm/DualAxes/index.d.ts +15 -0
- package/dist/esm/DualAxes/index.js +44 -0
- package/dist/esm/DualAxes/util.d.ts +9 -0
- package/dist/esm/DualAxes/util.js +61 -0
- package/dist/esm/FlowDiagram/index.d.ts +6 -0
- package/dist/esm/FlowDiagram/index.js +75 -0
- package/dist/esm/GPTVis/index.d.ts +7 -7
- package/dist/esm/GPTVis/index.js +4 -4
- package/dist/esm/HeatMap/index.d.ts +7 -7
- package/dist/esm/HeatMap/index.js +21 -36
- package/dist/esm/Histogram/index.d.ts +10 -0
- package/dist/esm/Histogram/index.js +25 -0
- package/dist/esm/IndentedTree/index.d.ts +6 -0
- package/dist/esm/IndentedTree/index.js +47 -0
- package/dist/esm/Line/index.d.ts +8 -2
- package/dist/esm/Line/index.js +18 -25
- package/dist/esm/Map/data.json +305 -0
- package/dist/esm/Map/index.d.ts +5 -0
- package/dist/esm/Map/index.js +60 -0
- package/dist/esm/MindMap/index.d.ts +6 -0
- package/dist/esm/MindMap/index.js +48 -0
- package/dist/esm/NetworkGraph/index.d.ts +6 -0
- package/dist/esm/NetworkGraph/index.js +57 -0
- package/dist/esm/OrganizationChart/index.d.ts +6 -0
- package/dist/esm/OrganizationChart/index.js +64 -0
- package/dist/esm/PathMap/index.d.ts +3 -9
- package/dist/esm/PathMap/index.js +33 -135
- package/dist/esm/Pie/index.d.ts +7 -5
- package/dist/esm/Pie/index.js +24 -25
- package/dist/esm/PinMap/index.d.ts +3 -9
- package/dist/esm/PinMap/index.js +19 -110
- package/dist/esm/Radar/index.d.ts +11 -0
- package/dist/esm/Radar/index.js +54 -0
- package/dist/esm/Scatter/index.d.ts +11 -0
- package/dist/esm/Scatter/index.js +30 -0
- package/dist/esm/Text/VisText.d.ts +4 -0
- package/dist/esm/Text/VisText.js +34 -0
- package/dist/esm/Text/config.d.ts +18 -0
- package/dist/esm/Text/config.js +79 -0
- package/dist/esm/Text/constants.d.ts +9 -0
- package/dist/esm/Text/constants.js +9 -0
- package/dist/esm/Text/custom-icons/index.d.ts +3 -0
- package/dist/esm/Text/custom-icons/index.js +37 -0
- package/dist/esm/Text/index.d.ts +3 -0
- package/dist/esm/Text/index.js +2 -0
- package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
- package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
- package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
- package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
- package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
- package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
- package/dist/esm/Text/mini-charts/index.d.ts +2 -0
- package/dist/esm/Text/mini-charts/index.js +2 -0
- package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
- package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
- package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
- package/dist/esm/Text/mini-charts/line/index.js +1 -0
- package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
- package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
- package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
- package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
- package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
- package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
- package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
- package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
- package/dist/esm/Text/types.d.ts +20 -0
- package/dist/esm/Text/types.js +1 -0
- package/dist/esm/Treemap/index.d.ts +11 -0
- package/dist/esm/Treemap/index.js +52 -0
- package/dist/esm/WordCloud/index.d.ts +4 -5
- package/dist/esm/WordCloud/index.js +8 -18
- package/dist/esm/constants/index.d.ts +2 -2
- package/dist/esm/constants/index.js +9 -8
- package/dist/esm/export.d.ts +25 -0
- package/dist/esm/export.js +27 -0
- package/dist/esm/index.d.ts +4 -11
- package/dist/esm/index.js +2 -15
- package/dist/esm/types/chart.d.ts +65 -0
- package/dist/esm/types/chart.js +23 -0
- package/dist/esm/types/config.d.ts +20 -0
- package/dist/esm/types/config.js +1 -0
- package/dist/esm/types/index.d.ts +2 -26
- package/dist/esm/types/index.js +2 -11
- package/dist/esm/types/map.d.ts +242 -0
- package/dist/esm/types/map.js +1 -0
- package/dist/esm/utils/config.d.ts +5 -0
- package/dist/esm/utils/config.js +48 -0
- package/dist/esm/utils/graph.d.ts +18 -0
- package/dist/esm/utils/graph.js +49 -0
- package/dist/esm/utils/index.d.ts +1 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/esm/utils/map/context.d.ts +3 -0
- package/dist/esm/utils/map/context.js +34 -0
- package/dist/esm/utils/map/controls.d.ts +0 -0
- package/dist/esm/utils/map/controls.js +0 -0
- package/dist/esm/utils/map/index.d.ts +6 -0
- package/dist/esm/utils/map/index.js +6 -0
- package/dist/esm/utils/map/markers.d.ts +2 -0
- package/dist/esm/utils/map/markers.js +64 -0
- package/dist/esm/utils/map/polyline.d.ts +2 -0
- package/dist/esm/utils/map/polyline.js +26 -0
- package/dist/esm/utils/map/style.d.ts +45 -0
- package/dist/esm/utils/map/style.js +76 -0
- package/dist/esm/utils/map/util.d.ts +1 -0
- package/dist/esm/utils/map/util.js +11 -0
- package/dist/esm/utils/map/view.d.ts +3 -0
- package/dist/esm/utils/map/view.js +81 -0
- package/dist/esm/utils/plot.d.ts +4 -0
- package/dist/esm/utils/plot.js +65 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +1 -0
- package/dist/umd/861.async.js +1 -0
- package/dist/umd/index.min.js +1 -0
- package/package.json +97 -59
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 AntV
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,58 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
<img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> English | [简体中文](./README.zh-CN.md)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<h1 align="center">GPT-Vis</h1>
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
<div align="center">
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
$ npm install @antv/gpt-vis@0.x --save
|
|
9
|
-
```
|
|
7
|
+
Components for GPTs, generative AI, and LLM projects. Not only UI Components.
|
|
10
8
|
|
|
11
|
-
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://gpt-vis.antv.com" target="_blank">Document</a> •
|
|
11
|
+
<a href="/knowledges" target="_blank">Knowledge</a> •
|
|
12
|
+
<a href="https://huggingface.co/antvis" target="_blank">Huggingface</a> •
|
|
13
|
+
<a href="https://tbox.alipay.com/share/202410APr1n200110168?platform=WebService" target="_blank">Agent Demo</a>
|
|
14
|
+
</p>
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
<div align="center">
|
|
17
|
+
<img src="https://github.com/eosphoros-ai/GPT-Vis/assets/17919400/c8804ffb-d3d6-45d3-846f-cf217681ab05" width=500">
|
|
18
|
+
</div>
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
import React from 'react';
|
|
17
|
-
import { Pie } from '@antv/gpt-vis';
|
|
20
|
+
</div>
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
{ name: '分类一', value: 27 },
|
|
21
|
-
{ name: '分类二', value: 25 },
|
|
22
|
-
{ name: '分类三', value: 18 },
|
|
23
|
-
{ name: '分类四', value: 15 },
|
|
24
|
-
{ name: '分类五', value: 10 },
|
|
25
|
-
{ name: '其他', value: 5 },
|
|
26
|
-
];
|
|
22
|
+
## ✨ Features
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
```
|
|
24
|
+
- 🤖 **LLM Protocol**: A visual protocol for LLM Agent cards, designed for LLM conversational interaction and service serialized output, to facilitate rapid integration into AI applications.
|
|
25
|
+
- 🍡 **LLM Component**: Developed components for LLM applications, with 20+ commonly used VIS components built-in, providing convenient expansion mechanism and architecture design for customized UI requirements.
|
|
26
|
+
- 📈 **LLM access**: Chart knowledge base and chart recommendation model for seamless access to LLM, directly output visual cards for LLM, and provide knowledge base and recommended model solutions for Agent.
|
|
32
27
|
|
|
33
|
-
|
|
28
|
+
## 📦 Installation
|
|
34
29
|
|
|
35
|
-
|
|
30
|
+
```bash
|
|
31
|
+
$ npm i @antv/gpt-vis --save
|
|
32
|
+
```
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
## 🔨 Usage
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
39
37
|
import { GPTVis } from '@antv/gpt-vis';
|
|
40
38
|
|
|
41
39
|
const markdownContent = `
|
|
42
40
|
# GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
|
|
43
41
|
|
|
42
|
+
Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *growth* particularly in recent years.
|
|
43
|
+
|
|
44
44
|
\`\`\`vis-chart
|
|
45
|
-
{
|
|
46
|
-
"type": "pie",
|
|
47
|
-
"data": [
|
|
48
|
-
{ "name": "分类一", "value": 27 },
|
|
49
|
-
{ "name": "分类二", "value": 25 },
|
|
50
|
-
{ "name": "分类三", "value": 18 },
|
|
51
|
-
{ "name": "分类四", "value": 15 },
|
|
52
|
-
{ "name": "分类五", "value": 10 },
|
|
53
|
-
{ "name": "其他", "value": 5 }
|
|
54
|
-
]
|
|
55
|
-
}
|
|
45
|
+
{ "type": "line","data": [{"time":2013,"value":59.3},{"time":2014,"value":64.4},{"time":2015,"value":68.9},{"time":2016,"value":74.4},{"time":2017,"value":82.7},{"time":2018,"value":91.9},{"time":2019,"value":99.1},{"time":2020,"value":101.6},{"time":2021,"value":114.4},{"time":2022,"value":121}] }
|
|
56
46
|
\`\`\`
|
|
57
47
|
`;
|
|
58
48
|
|
|
@@ -61,36 +51,43 @@ export default () => {
|
|
|
61
51
|
};
|
|
62
52
|
```
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
## 🛠 Custom renderer
|
|
65
55
|
|
|
66
|
-
```
|
|
67
|
-
import
|
|
68
|
-
import Markdown from 'react-markdown';
|
|
69
|
-
import { withDefaultChartCode } from '@antv/gpt-vis';
|
|
56
|
+
```jsx
|
|
57
|
+
import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
|
|
70
58
|
|
|
71
59
|
const markdownContent = `
|
|
72
|
-
|
|
60
|
+
<vis-text type="time_desc">本月</vis-text>共产生<vis-text type="metric_name">决策数量</vis-text><vis-text type="metric_value">2,783</vis-text>个,环比<vis-text type="trend_desc">增长</vis-text><vis-text type="ratio_value_pos">15.2%</vis-text>。<vis-text type="dim_name">高优先级决策</vis-text>占比<vis-text type="proportion">56.2%</vis-text>,呈现稳定<vis-text type="trend_desc" origin="[1, 2, 6, 18, 24, 48]">上升</vis-text>趋势,预计<vis-text type="time_desc">下月</vis-text>将突破<vis-text type="metric_value">3,000</vis-text>大关。
|
|
73
61
|
|
|
74
|
-
\`\`\`
|
|
75
|
-
|
|
76
|
-
"type": "pie",
|
|
77
|
-
"data": [
|
|
78
|
-
{ "name": "分类一", "value": 27 },
|
|
79
|
-
{ "name": "分类二", "value": 25 },
|
|
80
|
-
{ "name": "分类三", "value": 18 },
|
|
81
|
-
{ "name": "分类四", "value": 15 },
|
|
82
|
-
{ "name": "分类五", "value": 10 },
|
|
83
|
-
{ "name": "其他", "value": 5 }
|
|
84
|
-
]
|
|
85
|
-
}
|
|
62
|
+
\`\`\`my-ui
|
|
63
|
+
my data
|
|
86
64
|
\`\`\`
|
|
87
65
|
`;
|
|
88
66
|
|
|
89
|
-
const
|
|
67
|
+
const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
|
|
68
|
+
const components = {
|
|
69
|
+
'vis-text': VisText,
|
|
70
|
+
code: withDefaultChartCode({ languageRenderers: customRenderers }),
|
|
71
|
+
};
|
|
90
72
|
|
|
91
73
|
export default () => {
|
|
92
|
-
return
|
|
93
|
-
<Markdown components={{ code: CodeBlock }}>{markdownContent}</Markdown>
|
|
94
|
-
);
|
|
74
|
+
return <GPTVis components={components}>{markdownContent}</GPTVis>;
|
|
95
75
|
};
|
|
96
76
|
```
|
|
77
|
+
|
|
78
|
+
## 💻 Development
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# install dependencies
|
|
82
|
+
$ pnpm install
|
|
83
|
+
|
|
84
|
+
# develop library by docs demo
|
|
85
|
+
$ pnpm dev
|
|
86
|
+
|
|
87
|
+
# build library source code
|
|
88
|
+
$ pnpm build
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
[MIT](./LICENSE)
|
package/README.zh-CN.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
<img src="https://gw.alipayobjects.com/zos/antfincdn/R8sN%24GNdh6/language.svg" width="18"> [English](./README.md) | 简体中文
|
|
2
|
+
|
|
3
|
+
<h1 align="center">GPT-Vis</h1>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
7
|
+
Components for GPTs, generative AI, and LLM projects. Not only UI Components.
|
|
8
|
+
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://gpt-vis.antv.com" target="_blank">文档</a> •
|
|
11
|
+
<a href="/knowledges" target="_blank">知识库</a> •
|
|
12
|
+
<a href="https://huggingface.co/antvis" target="_blank">Huggingface</a> •
|
|
13
|
+
<a href="https://tbox.alipay.com/share/202410APr1n200110168?platform=WebService" target="_blank">体验 Agent</a>
|
|
14
|
+
</p>
|
|
15
|
+
|
|
16
|
+
<div align="center">
|
|
17
|
+
<img src="https://github.com/eosphoros-ai/GPT-Vis/assets/17919400/c8804ffb-d3d6-45d3-846f-cf217681ab05" width=500">
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
## 特性
|
|
23
|
+
|
|
24
|
+
- 🤖 **LLM 协议**:面向 LLM Agent 卡片的可视化协议,针对 LLM 对话式交互,以及服务序列化输出而设计,方便快速集成到 AI 应用中。
|
|
25
|
+
- 🍡 **LLM 组件**:面向 LLM 应用研发组件, 内置有 20+ 常用 VIS 组件,对于定制 UI 需求,提供方便的扩展机制和架构设计。
|
|
26
|
+
- 📈 **LLM 接入**:面向 LLM 无缝接入的图表知识库和图表推荐模型,针对 LLM 直接输出可视化卡片,为 Agent 提供知识库以及推荐模型方案。
|
|
27
|
+
|
|
28
|
+
## 📦 安装
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
$ npm i @antv/gpt-vis --save
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 🔨 使用
|
|
35
|
+
|
|
36
|
+
```jsx
|
|
37
|
+
import { GPTVis } from '@antv/gpt-vis';
|
|
38
|
+
|
|
39
|
+
const markdownContent = `
|
|
40
|
+
# GPT-VIS \n\nComponents for GPTs, generative AI, and LLM projects. Not only UI Components.
|
|
41
|
+
|
|
42
|
+
Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. You can see a steady increase over the years, with notable *growth* particularly in recent years.
|
|
43
|
+
|
|
44
|
+
\`\`\`vis-chart
|
|
45
|
+
{ "type": "line","data": [{"time":2013,"value":59.3},{"time":2014,"value":64.4},{"time":2015,"value":68.9},{"time":2016,"value":74.4},{"time":2017,"value":82.7},{"time":2018,"value":91.9},{"time":2019,"value":99.1},{"time":2020,"value":101.6},{"time":2021,"value":114.4},{"time":2022,"value":121}] }
|
|
46
|
+
\`\`\`
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export default () => {
|
|
50
|
+
return <GPTVis>{markdownContent}</GPTVis>;
|
|
51
|
+
};
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 🛠 定制渲染器
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
|
|
58
|
+
|
|
59
|
+
const markdownContent = `
|
|
60
|
+
<vis-text type="time_desc">本月</vis-text>共产生<vis-text type="metric_name">决策数量</vis-text><vis-text type="metric_value">2,783</vis-text>个,环比<vis-text type="trend_desc">增长</vis-text><vis-text type="ratio_value_pos">15.2%</vis-text>。<vis-text type="dim_name">高优先级决策</vis-text>占比<vis-text type="proportion">56.2%</vis-text>,呈现稳定<vis-text type="trend_desc" origin="[1, 2, 6, 18, 24, 48]">上升</vis-text>趋势,预计<vis-text type="time_desc">下月</vis-text>将突破<vis-text type="metric_value">3,000</vis-text>大关。
|
|
61
|
+
|
|
62
|
+
\`\`\`my-ui
|
|
63
|
+
my data
|
|
64
|
+
\`\`\`
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
|
|
68
|
+
const components = {
|
|
69
|
+
'vis-text': VisText,
|
|
70
|
+
code: withDefaultChartCode({ languageRenderers: customRenderers }),
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default () => {
|
|
74
|
+
return <GPTVis components={components}>{markdownContent}</GPTVis>;
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 💻 本地开发
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# install dependencies
|
|
82
|
+
$ pnpm install
|
|
83
|
+
|
|
84
|
+
# develop library by docs demo
|
|
85
|
+
$ pnpm dev
|
|
86
|
+
|
|
87
|
+
# build library source code
|
|
88
|
+
$ pnpm build
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## License
|
|
92
|
+
|
|
93
|
+
[MIT](./LICENSE)
|
package/dist/cjs/Area/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { AreaConfig } from '@ant-design/plots';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import type { BasePlotProps } from '../types';
|
|
4
|
+
type AreaDataItem = {
|
|
5
|
+
time: string | number;
|
|
6
|
+
value: number;
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type AreaProps = BasePlotProps<AreaDataItem> & Partial<AreaConfig>;
|
|
4
10
|
declare const Area: (props: AreaProps) => React.JSX.Element;
|
|
5
11
|
export default Area;
|
package/dist/cjs/Area/index.js
CHANGED
|
@@ -33,29 +33,30 @@ __export(Area_exports, {
|
|
|
33
33
|
});
|
|
34
34
|
module.exports = __toCommonJS(Area_exports);
|
|
35
35
|
var import_plots = require("@ant-design/plots");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
36
37
|
var import_react = __toESM(require("react"));
|
|
37
|
-
var
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
style
|
|
45
|
-
} = props;
|
|
46
|
-
const stackConfig = stackField ? { colorField: stackField, isStack: true } : {};
|
|
47
|
-
const config = {
|
|
48
|
-
data,
|
|
38
|
+
var import_hooks = require("../ConfigProvider/hooks");
|
|
39
|
+
var defaultConfig = (props) => {
|
|
40
|
+
const { data, xField = "time", yField = "value" } = props;
|
|
41
|
+
const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
|
|
42
|
+
const axisYTitle = (0, import_lodash.get)(props, "axis.y.title");
|
|
43
|
+
const defalutStyle = hasGroupField ? {} : { opacity: 0.6 };
|
|
44
|
+
return {
|
|
49
45
|
xField,
|
|
50
46
|
yField,
|
|
47
|
+
style: defalutStyle,
|
|
48
|
+
colorField: hasGroupField ? "group" : void 0,
|
|
51
49
|
tooltip: (d) => {
|
|
50
|
+
const tooltipName = axisYTitle || d[xField];
|
|
52
51
|
return {
|
|
53
|
-
name:
|
|
52
|
+
name: tooltipName,
|
|
54
53
|
value: d[yField]
|
|
55
54
|
};
|
|
56
|
-
}
|
|
57
|
-
...stackConfig
|
|
55
|
+
}
|
|
58
56
|
};
|
|
59
|
-
|
|
57
|
+
};
|
|
58
|
+
var Area = (props) => {
|
|
59
|
+
const config = (0, import_hooks.usePlotConfig)("Area", defaultConfig, props);
|
|
60
|
+
return /* @__PURE__ */ import_react.default.createElement(import_plots.Area, { ...config });
|
|
60
61
|
};
|
|
61
62
|
var Area_default = Area;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BarConfig } from '@ant-design/plots';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BasePlotProps } from '../types';
|
|
4
|
+
type BarDataItem = {
|
|
5
|
+
category: string;
|
|
6
|
+
value: number;
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type BarProps = BasePlotProps<BarDataItem> & Partial<BarConfig>;
|
|
10
|
+
declare const Bar: (props: BarProps) => React.JSX.Element;
|
|
11
|
+
export default Bar;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/Bar/index.tsx
|
|
30
|
+
var Bar_exports = {};
|
|
31
|
+
__export(Bar_exports, {
|
|
32
|
+
default: () => Bar_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Bar_exports);
|
|
35
|
+
var import_plots = require("@ant-design/plots");
|
|
36
|
+
var import_lodash = require("lodash");
|
|
37
|
+
var import_react = __toESM(require("react"));
|
|
38
|
+
var import_hooks = require("../ConfigProvider/hooks");
|
|
39
|
+
var defaultConfig = (props) => {
|
|
40
|
+
const { data, xField = "category", yField = "value" } = props;
|
|
41
|
+
const hasGroupField = (0, import_lodash.get)(data, "[0].group") !== void 0;
|
|
42
|
+
const axisYTitle = (0, import_lodash.get)(props, "axis.y.title");
|
|
43
|
+
return {
|
|
44
|
+
xField,
|
|
45
|
+
yField,
|
|
46
|
+
colorField: hasGroupField ? "group" : void 0,
|
|
47
|
+
tooltip: (d) => {
|
|
48
|
+
const tooltipName = axisYTitle || d[xField];
|
|
49
|
+
return {
|
|
50
|
+
name: tooltipName,
|
|
51
|
+
value: d[yField]
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
style: {
|
|
55
|
+
// 圆角样式
|
|
56
|
+
radiusTopLeft: 5,
|
|
57
|
+
radiusTopRight: 5
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
var Bar = (props) => {
|
|
62
|
+
const config = (0, import_hooks.usePlotConfig)("Bar", defaultConfig, props);
|
|
63
|
+
return /* @__PURE__ */ import_react.default.createElement(import_plots.Bar, { ...config });
|
|
64
|
+
};
|
|
65
|
+
var Bar_default = Bar;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/ChartCodeRender/Loading.tsx
|
|
30
|
+
var Loading_exports = {};
|
|
31
|
+
__export(Loading_exports, {
|
|
32
|
+
default: () => Loading_default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(Loading_exports);
|
|
35
|
+
var import_icons = require("@ant-design/icons");
|
|
36
|
+
var import_react = __toESM(require("react"));
|
|
37
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
38
|
+
var StyledLoading = import_styled_components.default.div`
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
height: 300px;
|
|
44
|
+
background-image: linear-gradient(135deg, #e3f3ff 0%, #f1eeff 100%);
|
|
45
|
+
color: rgba(0, 0, 0, 88%);
|
|
46
|
+
|
|
47
|
+
&-icon {
|
|
48
|
+
margin-bottom: 6px;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
var Loading = () => {
|
|
52
|
+
return /* @__PURE__ */ import_react.default.createElement(StyledLoading, { className: "gpt-vis-loading" }, /* @__PURE__ */ import_react.default.createElement("div", { className: "gpt-vis-loading-icon" }, /* @__PURE__ */ import_react.default.createElement(import_icons.LoadingOutlined, { style: { fontSize: "24px", color: "rgb(56, 177, 246)" } })), /* @__PURE__ */ import_react.default.createElement("p", null, "数据生成中"));
|
|
53
|
+
};
|
|
54
|
+
var Loading_default = Loading;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartComponents } from './type';
|
|
3
|
+
type RenderVisChartProps = {
|
|
4
|
+
content: string;
|
|
5
|
+
components: ChartComponents;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
loadingTimeout: number;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare const RenderVisChart: React.FC<RenderVisChartProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
|
|
29
|
+
// src/ChartCodeRender/VisChart.tsx
|
|
30
|
+
var VisChart_exports = {};
|
|
31
|
+
__export(VisChart_exports, {
|
|
32
|
+
RenderVisChart: () => RenderVisChart
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(VisChart_exports);
|
|
35
|
+
var import_react = __toESM(require("react"));
|
|
36
|
+
var import_styled_components = __toESM(require("styled-components"));
|
|
37
|
+
var import_Loading = __toESM(require("./Loading"));
|
|
38
|
+
var StyledGPTVis = import_styled_components.default.div`
|
|
39
|
+
min-width: 300px;
|
|
40
|
+
height: 300px;
|
|
41
|
+
max-width: 100%;
|
|
42
|
+
`;
|
|
43
|
+
var GlobalStyles = import_styled_components.createGlobalStyle`
|
|
44
|
+
pre:has(.gpt-vis) {
|
|
45
|
+
overflow: hidden;
|
|
46
|
+
}
|
|
47
|
+
`;
|
|
48
|
+
var RenderVisChart = (0, import_react.memo)(
|
|
49
|
+
({ style, content, components, debug, loadingTimeout }) => {
|
|
50
|
+
const timeoutRef = (0, import_react.useRef)();
|
|
51
|
+
const [loading, setLoading] = (0, import_react.useState)(true);
|
|
52
|
+
let chartJson;
|
|
53
|
+
try {
|
|
54
|
+
chartJson = JSON.parse(content);
|
|
55
|
+
} catch (e) {
|
|
56
|
+
if (timeoutRef.current) {
|
|
57
|
+
clearTimeout(timeoutRef.current);
|
|
58
|
+
if (debug) {
|
|
59
|
+
console.warn("GPT-Vis withChartCode parse content timeout");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
timeoutRef.current = setTimeout(() => {
|
|
63
|
+
setLoading(false);
|
|
64
|
+
}, loadingTimeout);
|
|
65
|
+
if (loading) {
|
|
66
|
+
return /* @__PURE__ */ import_react.default.createElement(StyledGPTVis, { className: "gpt-vis", style }, /* @__PURE__ */ import_react.default.createElement(import_Loading.default, null));
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ import_react.default.createElement("p", null, "Chart generation timeout.");
|
|
69
|
+
}
|
|
70
|
+
const { type, ...chartProps } = chartJson;
|
|
71
|
+
const ChartComponent = components[type];
|
|
72
|
+
if (debug) {
|
|
73
|
+
console.log("GPT-Vis withChartCode get chartJson parse from vis-chart code block", chartJson);
|
|
74
|
+
}
|
|
75
|
+
if (!ChartComponent) {
|
|
76
|
+
return /* @__PURE__ */ import_react.default.createElement("p", null, `Chart type "${type}" is not supported.`);
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ import_react.default.createElement(StyledGPTVis, { className: "gpt-vis", style }, /* @__PURE__ */ import_react.default.createElement(GlobalStyles, null), /* @__PURE__ */ import_react.default.createElement(ChartComponent, { ...chartProps }));
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
82
|
+
0 && (module.exports = {
|
|
83
|
+
RenderVisChart
|
|
84
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export declare const withChartCode: (options: WithChartCodeOptions) => keyof JSX.IntrinsicElements | import("hast-util-to-jsx-runtime/lib/components").Component<React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement> & import("hast-util-to-jsx-runtime/lib/components").ExtraProps> | undefined;
|
|
1
|
+
import type { CodeBlockComponent, WithChartCodeOptions } from './type';
|
|
2
|
+
export declare const withChartCode: (options: WithChartCodeOptions) => CodeBlockComponent;
|
|
4
3
|
/**
|
|
5
4
|
* Includes built-in chart components such as line charts, pie charts, etc.
|
|
6
5
|
* @param componentsArray
|
|
7
6
|
* @returns
|
|
8
7
|
*/
|
|
9
|
-
export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) =>
|
|
8
|
+
export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) => CodeBlockComponent;
|