@antv/gpt-vis 0.1.0 → 0.2.1

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.
Files changed (71) hide show
  1. package/README.md +75 -12
  2. package/README.zh-CN.md +73 -12
  3. package/dist/cjs/ConfigProvider/hooks/useConfig.js +2 -1
  4. package/dist/cjs/FishboneDiagram/index.d.ts +6 -0
  5. package/dist/cjs/FishboneDiagram/index.js +49 -0
  6. package/dist/cjs/GPTVis/Lite.d.ts +10 -0
  7. package/dist/cjs/GPTVis/Lite.js +54 -0
  8. package/dist/cjs/GPTVis/index.d.ts +2 -6
  9. package/dist/cjs/GPTVis/index.js +3 -12
  10. package/dist/cjs/Text/VisText.js +7 -1
  11. package/dist/cjs/Text/config.js +14 -14
  12. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +2 -2
  13. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +3 -3
  14. package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +2 -2
  15. package/dist/cjs/Text/mini-charts/line/useLineCompute.js +2 -2
  16. package/dist/cjs/Text/mini-charts/proportion/index.js +2 -3
  17. package/dist/cjs/Text/theme.d.ts +24 -0
  18. package/dist/cjs/Text/{constants.js → theme.js} +25 -10
  19. package/dist/cjs/Text/utils/getThemeColor.d.ts +11 -0
  20. package/dist/cjs/Text/utils/getThemeColor.js +46 -0
  21. package/dist/cjs/Text/utils/index.d.ts +2 -0
  22. package/dist/cjs/Text/utils/index.js +25 -0
  23. package/dist/cjs/Text/utils/useAntdDarkAlgorithm.d.ts +2 -0
  24. package/dist/cjs/Text/utils/useAntdDarkAlgorithm.js +40 -0
  25. package/dist/cjs/export.d.ts +11 -7
  26. package/dist/cjs/export.js +11 -10
  27. package/dist/cjs/index.d.ts +7 -2
  28. package/dist/cjs/index.js +8 -2
  29. package/dist/cjs/types/chart.d.ts +3 -2
  30. package/dist/cjs/types/chart.js +3 -2
  31. package/dist/cjs/types/config.d.ts +5 -0
  32. package/dist/cjs/version.d.ts +1 -1
  33. package/dist/cjs/version.js +1 -1
  34. package/dist/esm/ConfigProvider/hooks/useConfig.js +4 -2
  35. package/dist/esm/FishboneDiagram/index.d.ts +6 -0
  36. package/dist/esm/FishboneDiagram/index.js +23 -0
  37. package/dist/esm/GPTVis/Lite.d.ts +10 -0
  38. package/dist/esm/GPTVis/Lite.js +18 -0
  39. package/dist/esm/GPTVis/index.d.ts +2 -6
  40. package/dist/esm/GPTVis/index.js +4 -8
  41. package/dist/esm/Text/VisText.js +12 -1
  42. package/dist/esm/Text/config.js +14 -14
  43. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +1 -1
  44. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +1 -1
  45. package/dist/esm/Text/mini-charts/line/SingleLineChart.js +3 -3
  46. package/dist/esm/Text/mini-charts/line/useLineCompute.js +1 -1
  47. package/dist/esm/Text/mini-charts/proportion/index.js +4 -5
  48. package/dist/esm/Text/theme.d.ts +24 -0
  49. package/dist/esm/Text/theme.js +24 -0
  50. package/dist/esm/Text/utils/getThemeColor.d.ts +11 -0
  51. package/dist/esm/Text/utils/getThemeColor.js +29 -0
  52. package/dist/esm/Text/utils/index.d.ts +2 -0
  53. package/dist/esm/Text/utils/index.js +2 -0
  54. package/dist/esm/Text/utils/useAntdDarkAlgorithm.d.ts +2 -0
  55. package/dist/esm/Text/utils/useAntdDarkAlgorithm.js +13 -0
  56. package/dist/esm/export.d.ts +11 -7
  57. package/dist/esm/export.js +17 -9
  58. package/dist/esm/index.d.ts +7 -2
  59. package/dist/esm/index.js +9 -2
  60. package/dist/esm/types/chart.d.ts +3 -2
  61. package/dist/esm/types/chart.js +3 -2
  62. package/dist/esm/types/config.d.ts +5 -0
  63. package/dist/esm/version.d.ts +1 -1
  64. package/dist/esm/version.js +1 -1
  65. package/dist/umd/558.async.js +1 -0
  66. package/dist/umd/index.min.js +1 -1
  67. package/package.json +2 -2
  68. package/dist/cjs/Text/constants.d.ts +0 -9
  69. package/dist/esm/Text/constants.d.ts +0 -9
  70. package/dist/esm/Text/constants.js +0 -9
  71. package/dist/umd/861.async.js +0 -1
package/README.md CHANGED
@@ -4,13 +4,12 @@
4
4
 
5
5
  <div align="center">
6
6
 
7
- Components for GPTs, generative AI, and LLM projects. Not only UI Components.
7
+ Components for GPTs, generative AI, and LLM projects. **Not only UI Components**.
8
8
 
9
9
  <p align="center">
10
- <a href="https://gpt-vis.antv.com" target="_blank">Document</a> •
10
+ <a href="https://gpt-vis.antv.vision" target="_blank">Document</a> •
11
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>
12
+ <a href="https://tbox.alipay.com/experience/202410APr1n200110168?id=20241120WZh400101995" target="_blank">Agent Demo</a>
14
13
  </p>
15
14
 
16
15
  <div align="center">
@@ -42,7 +41,21 @@ const markdownContent = `
42
41
  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
42
 
44
43
  \`\`\`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}] }
44
+ {
45
+ "type": "line",
46
+ "data": [
47
+ { "time":2013,"value":59.3 },
48
+ { "time":2014,"value":64.4 },
49
+ { "time":2015,"value":68.9 },
50
+ { "time":2016,"value":74.4 },
51
+ { "time":2017,"value":82.7 },
52
+ { "time":2018,"value":91.9 },
53
+ { "time":2019,"value":99.1 },
54
+ { "time":2020,"value":101.6 },
55
+ { "time":2021,"value":114.4 },
56
+ { "time":2022,"value":121 }
57
+ ]
58
+ }
46
59
  \`\`\`
47
60
  `;
48
61
 
@@ -51,30 +64,80 @@ export default () => {
51
64
  };
52
65
  ```
53
66
 
54
- ## 🛠 Custom renderer
67
+ <details>
68
+ <summary>🛠 Custom renderer</summary>
55
69
 
56
70
  ```jsx
57
- import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
71
+ import { GPTVisLite, withChartCode, ChartType, Pie } from '@antv/gpt-vis';
58
72
 
59
73
  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
74
  \`\`\`my-ui
63
75
  my data
64
76
  \`\`\`
77
+
78
+ \`\`\`vis-chart
79
+ {
80
+ "type": "pie",
81
+ "data": [
82
+ { "category": "category 1", "value": 27 },
83
+ { "category": "category 2", "value": 25 },
84
+ { "category": "category 3", "value": 18 },
85
+ { "category": "other", "value": 5 }
86
+ ]
87
+ }
88
+ \`\`\`
65
89
  `;
66
90
 
67
91
  const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
68
92
  const components = {
69
- 'vis-text': VisText,
70
- code: withDefaultChartCode({ languageRenderers: customRenderers }),
93
+ code: withChartCode({
94
+ languageRenderers: customRenderers, // register custom block renderer
95
+ components: { [ChartType.Pie]: Pie }, // register a pie chart
96
+ }),
71
97
  };
72
98
 
73
99
  export default () => {
74
- return <GPTVis components={components}>{markdownContent}</GPTVis>;
100
+ return <GPTVisLite components={components}>{markdownContent}</GPTVisLite>;
75
101
  };
76
102
  ```
77
103
 
104
+ </details>
105
+
106
+ ## 🐍 Streamlit
107
+
108
+ ```python
109
+ import streamlit as st
110
+ from streamlit_gpt_vis import set_gpt_vis
111
+
112
+ content = '''
113
+ 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.
114
+
115
+ \`\`\`vis-chart
116
+ {"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}]}
117
+ \`\`\`
118
+ '''
119
+
120
+ set_gpt_vis(content)
121
+ ```
122
+
123
+ Learn more 👉 [streamlit-gpt-vis](https://github.com/antvis/GPT-Vis/tree/main/bindings/streamlit-gpt-vis)
124
+
125
+ ## Visual Knowledge
126
+
127
+ The purpose of the [Visual Knowledge Base](https://github.com/antvis/GPT-Vis/tree/main/knowledges) is to provide a comprehensive and systematic resource to help Agents understand, select, create various data visualization charts. Below are the metrics for generating accurate chart protocols based on the [evaluation dataset](https://github.com/antvis/GPT-Vis/tree/main/evaluations/datastes/chart) through the RAG.
128
+
129
+ | | | | | | | |
130
+ | ------------- | ----------------------- | -------------------- | ------------- | -------------------- | --------------- | ------- |
131
+ | Line(Multi) | Column(Grouped/Stacked) | Pie | Area(Stacked) | Bar(Grouped/Stacked) | Scatter(Bubble) | Heatmap |
132
+ | 40/40 | 25/27 | 13/14 | 18/18 | 18/20 | 10/10 | 9/10 |
133
+ | Histogram | Tree Map | Word Cloud | Radar | Dual Axis | Rich Text NTV | Pin Map |
134
+ | 15/16 | 13/15 | 11/12 | 23/23 | 13/14 | 7.3/10 | 10/11 |
135
+ | Network Graph | Mind Map | Organizational Chart | Flow Diagram | Fishbone Diagram | | |
136
+ | 8/10 | 12/14 | 10/12 | 10/11 | 10/12 | | |
137
+ | | | | | | | |
138
+
139
+ Note: The numbers in the format of X/Y represent the metrics of the respective chart types when evaluated against the dataset.
140
+
78
141
  ## 💻 Development
79
142
 
80
143
  ```bash
package/README.zh-CN.md CHANGED
@@ -4,13 +4,12 @@
4
4
 
5
5
  <div align="center">
6
6
 
7
- Components for GPTs, generative AI, and LLM projects. Not only UI Components.
7
+ Components for GPTs, generative AI, and LLM projects. **Not only UI Components**.
8
8
 
9
9
  <p align="center">
10
- <a href="https://gpt-vis.antv.com" target="_blank">文档</a> •
10
+ <a href="https://gpt-vis.antv.vision" target="_blank">文档</a> •
11
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>
12
+ <a href="https://tbox.alipay.com/experience/202410APr1n200110168?id=20241120WZh400101995" target="_blank">体验 Agent</a>
14
13
  </p>
15
14
 
16
15
  <div align="center">
@@ -42,7 +41,21 @@ const markdownContent = `
42
41
  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
42
 
44
43
  \`\`\`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}] }
44
+ {
45
+ "type": "line",
46
+ "data": [
47
+ { "time":2013,"value":59.3 },
48
+ { "time":2014,"value":64.4 },
49
+ { "time":2015,"value":68.9 },
50
+ { "time":2016,"value":74.4 },
51
+ { "time":2017,"value":82.7 },
52
+ { "time":2018,"value":91.9 },
53
+ { "time":2019,"value":99.1 },
54
+ { "time":2020,"value":101.6 },
55
+ { "time":2021,"value":114.4 },
56
+ { "time":2022,"value":121 }
57
+ ]
58
+ }
46
59
  \`\`\`
47
60
  `;
48
61
 
@@ -51,30 +64,78 @@ export default () => {
51
64
  };
52
65
  ```
53
66
 
54
- ## 🛠 定制渲染器
67
+ <details>
68
+ <summary>🛠 定制渲染器</summary>
55
69
 
56
70
  ```jsx
57
- import { GPTVis, withDefaultChartCode, VisText } from '@antv/gpt-vis';
71
+ import { GPTVisLite, withChartCode, ChartType, Pie } from '@antv/gpt-vis';
58
72
 
59
73
  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
74
  \`\`\`my-ui
63
75
  my data
64
76
  \`\`\`
77
+
78
+ \`\`\`vis-chart
79
+ {
80
+ "type": "pie",
81
+ "data": [
82
+ { "category": "分类一", "value": 27 },
83
+ { "category": "分类二", "value": 25 },
84
+ { "category": "分类三", "value": 18 },
85
+ { "category": "其他", "value": 5 }
86
+ ]
87
+ }
88
+ \`\`\`
65
89
  `;
66
90
 
67
91
  const customRenderers = { 'my-ui': ({ children }) => <div>{children}</div> };
68
92
  const components = {
69
- 'vis-text': VisText,
70
- code: withDefaultChartCode({ languageRenderers: customRenderers }),
93
+ code: withChartCode({
94
+ languageRenderers: customRenderers, // register custom block renderer
95
+ components: { [ChartType.Pie]: Pie }, // register a pie chart
96
+ }),
71
97
  };
72
98
 
73
99
  export default () => {
74
- return <GPTVis components={components}>{markdownContent}</GPTVis>;
100
+ return <GPTVisLite components={components}>{markdownContent}</GPTVisLite>;
75
101
  };
76
102
  ```
77
103
 
104
+ </details>
105
+
106
+ ## 🐍 Streamlit
107
+
108
+ ```python
109
+ import streamlit as st
110
+ from streamlit_gpt_vis import set_gpt_vis
111
+
112
+ content = '''
113
+ 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.
114
+
115
+ \`\`\`vis-chart
116
+ {"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}]}
117
+ \`\`\`
118
+ '''
119
+
120
+ set_gpt_vis(content)
121
+ ```
122
+
123
+ 更多了解 👉 [streamlit-gpt-vis](https://github.com/antvis/GPT-Vis/tree/main/bindings/streamlit-gpt-vis)
124
+
125
+ ## 🗂 可视化知识库
126
+
127
+ [可视化知识库](https://github.com/antvis/GPT-Vis/tree/main/knowledges)的目的是为了提供一个全面、系统的资源,帮助 Agent 理解、选择、创建各种数据可视化图表,以下是 Agent 通过 RAG 方式接入知识,根据[评测数据集](https://github.com/antvis/GPT-Vis/tree/main/evaluations/datastes/chart)生成准确图表协议的指标。
128
+
129
+ | | | | | | | |
130
+ | ------------- | ----------------------- | -------------------- | ------------- | -------------------- | --------------- | ------- |
131
+ | Line(Multi) | Column(Grouped/Stacked) | Pie | Area(Stacked) | Bar(Grouped/Stacked) | Scatter(Bubble) | Heatmap |
132
+ | 40/40 | 25/27 | 13/14 | 18/18 | 18/20 | 10/10 | 9/10 |
133
+ | Histogram | Tree Map | Word Cloud | Radar | Dual Axis | Rich Text NTV | Pin Map |
134
+ | 15/16 | 13/15 | 11/12 | 23/23 | 13/14 | 7.3/10 | 10/11 |
135
+ | Network Graph | Mind Map | Organizational Chart | Flow Diagram | Fishbone Diagram | | |
136
+ | 8/10 | 12/14 | 10/12 | 10/11 | 10/12 | | |
137
+ | | | | | | | |
138
+
78
139
  ## 💻 本地开发
79
140
 
80
141
  ```bash
@@ -91,8 +91,9 @@ function useMapConfig(name, props) {
91
91
  return mapConfig;
92
92
  }
93
93
  function useGraphGlobalConfig(name) {
94
+ const { graph: graphConfig = {} } = useConfig();
94
95
  const componentConfig = useComponentGlobalConfig(name);
95
- return componentConfig || {};
96
+ return (0, import_config.mergeGraphOptions)(graphConfig, componentConfig || {});
96
97
  }
97
98
  function useGraphConfig(name, defaultConfig, props) {
98
99
  const globalConfig = useGraphGlobalConfig(name);
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import type { TreeGraphProps } from '../types';
3
+ export interface FishboneDiagramProps extends TreeGraphProps {
4
+ }
5
+ declare const FishboneDiagram: React.FC<FishboneDiagramProps>;
6
+ export default FishboneDiagram;
@@ -0,0 +1,49 @@
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/FishboneDiagram/index.tsx
30
+ var FishboneDiagram_exports = {};
31
+ __export(FishboneDiagram_exports, {
32
+ default: () => FishboneDiagram_default
33
+ });
34
+ module.exports = __toCommonJS(FishboneDiagram_exports);
35
+ var import_graphs = require("@ant-design/graphs");
36
+ var import_react = __toESM(require("react"));
37
+ var import_hooks = require("../ConfigProvider/hooks");
38
+ var import_graph = require("../utils/graph");
39
+ var defaultConfig = {
40
+ autoFit: "view",
41
+ autoResize: true
42
+ };
43
+ var FishboneDiagram = (props) => {
44
+ const { data: propsData, ...restProps } = props;
45
+ const data = (0, import_react.useMemo)(() => (0, import_graph.visTreeData2GraphData)(propsData), [propsData]);
46
+ const config = (0, import_hooks.useGraphConfig)("FishboneDiagram", defaultConfig, restProps);
47
+ return /* @__PURE__ */ import_react.default.createElement(import_graphs.Fishbone, { data, ...config });
48
+ };
49
+ var FishboneDiagram_default = FishboneDiagram;
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { Options } from 'react-markdown';
3
+ export interface GPTVisLiteProps extends Options {
4
+ /** 自定义 markdown components样式 */
5
+ components?: Options['components'] | {
6
+ [key: string]: (props: any) => React.ReactNode;
7
+ };
8
+ }
9
+ declare const _default: React.NamedExoticComponent<GPTVisLiteProps>;
10
+ export default _default;
@@ -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/GPTVis/Lite.tsx
30
+ var Lite_exports = {};
31
+ __export(Lite_exports, {
32
+ default: () => Lite_default
33
+ });
34
+ module.exports = __toCommonJS(Lite_exports);
35
+ var import_react = __toESM(require("react"));
36
+ var import_react_markdown = __toESM(require("react-markdown"));
37
+ var import_rehype_raw = __toESM(require("rehype-raw"));
38
+ var GPTVisLite = ({
39
+ children,
40
+ components,
41
+ rehypePlugins,
42
+ ...rest
43
+ }) => {
44
+ return /* @__PURE__ */ import_react.default.createElement(
45
+ import_react_markdown.default,
46
+ {
47
+ components,
48
+ rehypePlugins: [import_rehype_raw.default, ...rehypePlugins ? rehypePlugins : []],
49
+ ...rest
50
+ },
51
+ children
52
+ );
53
+ };
54
+ var Lite_default = (0, import_react.memo)(GPTVisLite);
@@ -1,10 +1,6 @@
1
1
  import React from 'react';
2
- import type { Options } from 'react-markdown';
3
- export interface GPTVisProps extends Options {
4
- /** 自定义 markdown components样式 */
5
- components?: Options['components'] | {
6
- [key: string]: (props: any) => React.ReactNode;
7
- };
2
+ import { type GPTVisLiteProps } from './Lite';
3
+ export interface GPTVisProps extends GPTVisLiteProps {
8
4
  }
9
5
  declare const _default: React.NamedExoticComponent<GPTVisProps>;
10
6
  export default _default;
@@ -33,19 +33,10 @@ __export(GPTVis_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(GPTVis_exports);
35
35
  var import_react = __toESM(require("react"));
36
- var import_react_markdown = __toESM(require("react-markdown"));
37
- var import_rehype_raw = __toESM(require("rehype-raw"));
38
36
  var import_ChartCodeRender = require("../ChartCodeRender");
37
+ var import_Lite = __toESM(require("./Lite"));
39
38
  var CodeBlock = (0, import_ChartCodeRender.withDefaultChartCode)();
40
- var GPTVis = ({ children, components, rehypePlugins, ...rest }) => {
41
- return /* @__PURE__ */ import_react.default.createElement(
42
- import_react_markdown.default,
43
- {
44
- components: { code: CodeBlock, ...components },
45
- rehypePlugins: [import_rehype_raw.default, ...rehypePlugins ? rehypePlugins : []],
46
- ...rest
47
- },
48
- children
49
- );
39
+ var GPTVis = ({ children, components, ...rest }) => {
40
+ return /* @__PURE__ */ import_react.default.createElement(import_Lite.default, { components: { code: CodeBlock, ...components }, ...rest }, children);
50
41
  };
51
42
  var GPTVis_default = (0, import_react.memo)(GPTVis);
@@ -37,6 +37,7 @@ var import_lodash = require("lodash");
37
37
  var import_react = __toESM(require("react"));
38
38
  var import_hooks = require("../ConfigProvider/hooks");
39
39
  var import_config = require("./config");
40
+ var import_utils = require("./utils");
40
41
  var { Text } = import_antd.Typography;
41
42
  function renderPrefixSuffix(symbol, staticsConfig, props) {
42
43
  if (!symbol)
@@ -48,6 +49,7 @@ function renderPrefixSuffix(symbol, staticsConfig, props) {
48
49
  }
49
50
  var VisText = (props) => {
50
51
  const { children, className, style, type, origin } = props;
52
+ const isDark = (0, import_utils.useAntdDarkAlgorithm)();
51
53
  const textConfig = (0, import_hooks.useComponentGlobalConfig)("VisText");
52
54
  const encoding = type ? textConfig == null ? void 0 : textConfig[type] : {};
53
55
  const staticsConfig = textConfig == null ? void 0 : textConfig[import_config.STATICS_KEY];
@@ -58,8 +60,12 @@ var VisText = (props) => {
58
60
  {
59
61
  className,
60
62
  style: {
63
+ // antd Text 组件写死了 14px,在段落定义了 font-size 的情况下,显示很突兀,这里不设置,跟随上级容器字体大小改变。
64
+ // TODO @羽熙 之后看能否通过 antd ConfigProvider 统一配置
65
+ fontSize: "unset",
66
+ color: (0, import_utils.getThemeColor)({ type, color: encoding == null ? void 0 : encoding.color, theme: isDark ? "dark" : "light" }),
61
67
  ...style,
62
- ...(0, import_lodash.pick)(encoding, ["color", "backgroundColor", "fontWeight"])
68
+ ...(0, import_lodash.pick)(encoding, ["backgroundColor", "fontWeight"])
63
69
  }
64
70
  },
65
71
  renderPrefixSuffix(encoding == null ? void 0 : encoding.prefix, staticsConfig, props),
@@ -23,9 +23,9 @@ __export(config_exports, {
23
23
  STATICS_KEY: () => STATICS_KEY
24
24
  });
25
25
  module.exports = __toCommonJS(config_exports);
26
- var import_constants = require("./constants");
27
26
  var import_custom_icons = require("./custom-icons");
28
27
  var import_mini_charts = require("./mini-charts");
28
+ var import_theme = require("./theme");
29
29
  var STATICS_KEY = "__statics";
30
30
  var DEFAULT_VIS_TEXT_CONFIG = {
31
31
  [STATICS_KEY]: {
@@ -36,49 +36,49 @@ var DEFAULT_VIS_TEXT_CONFIG = {
36
36
  "mini-chart:line": import_mini_charts.SingleLineChart
37
37
  },
38
38
  metric_name: {
39
- color: import_constants.TEXT_THEME.black88,
39
+ color: import_theme.TEXT_THEME.light.default88Color,
40
40
  fontWeight: 500
41
41
  },
42
42
  metric_value: {
43
- color: import_constants.TEXT_THEME.primaryColor
43
+ color: import_theme.TEXT_THEME.light.primaryColor
44
44
  },
45
45
  other_metric_value: {
46
- color: import_constants.TEXT_THEME.black65
46
+ color: import_theme.TEXT_THEME.light.default65Color
47
47
  },
48
48
  delta_value: {
49
- color: import_constants.TEXT_THEME.black65
49
+ color: import_theme.TEXT_THEME.light.default65Color
50
50
  },
51
51
  ratio_value: {
52
- color: import_constants.TEXT_THEME.black65
52
+ color: import_theme.TEXT_THEME.light.default65Color
53
53
  },
54
54
  delta_value_pos: {
55
- color: import_constants.TEXT_THEME.posColor,
55
+ color: import_theme.TEXT_THEME.light.posColor,
56
56
  prefix: "+"
57
57
  },
58
58
  delta_value_neg: {
59
- color: import_constants.TEXT_THEME.negColor,
59
+ color: import_theme.TEXT_THEME.light.negColor,
60
60
  prefix: "-"
61
61
  },
62
62
  ratio_value_pos: {
63
- color: import_constants.TEXT_THEME.posColor,
63
+ color: import_theme.TEXT_THEME.light.posColor,
64
64
  prefix: "icon:arrow-up"
65
65
  },
66
66
  ratio_value_neg: {
67
- color: import_constants.TEXT_THEME.negColor,
67
+ color: import_theme.TEXT_THEME.light.negColor,
68
68
  prefix: "icon:arrow-down"
69
69
  },
70
70
  contribute_ratio: {
71
- color: import_constants.TEXT_THEME.statisticsInsightColor
71
+ color: import_theme.TEXT_THEME.light.conclusionColor
72
72
  },
73
73
  trend_desc: {
74
- color: import_constants.TEXT_THEME.statisticsInsightColor,
74
+ color: import_theme.TEXT_THEME.light.conclusionColor,
75
75
  suffix: "mini-chart:line"
76
76
  },
77
77
  dim_value: {
78
- color: import_constants.TEXT_THEME.black88
78
+ color: import_theme.TEXT_THEME.light.default88Color
79
79
  },
80
80
  time_desc: {
81
- color: import_constants.TEXT_THEME.black88
81
+ color: import_theme.TEXT_THEME.light.default88Color
82
82
  },
83
83
  proportion: {
84
84
  suffix: "mini-chart:proportion"
@@ -22,7 +22,7 @@ __export(getElementFontSize_exports, {
22
22
  getElementFontSize: () => getElementFontSize
23
23
  });
24
24
  module.exports = __toCommonJS(getElementFontSize_exports);
25
- var import_constants = require("../../constants");
25
+ var import_theme = require("../../theme");
26
26
  function getStyle(ele, style) {
27
27
  var _a;
28
28
  return window.getComputedStyle ? (
@@ -43,7 +43,7 @@ function getPxNumber(str) {
43
43
  return resultNumber;
44
44
  return void 0;
45
45
  }
46
- function getElementFontSize(ele, defaultSize = import_constants.TEXT_THEME.fontSizeBase) {
46
+ function getElementFontSize(ele, defaultSize = import_theme.TEXT_THEME.fontSizeBase) {
47
47
  const FONT_SIZE = "font-size";
48
48
  const eleFontSizeStr = getStyle(ele, FONT_SIZE);
49
49
  if (eleFontSizeStr && isAbsoluteUnitPx(eleFontSizeStr)) {
@@ -33,14 +33,14 @@ __export(useSvgWrapper_exports, {
33
33
  });
34
34
  module.exports = __toCommonJS(useSvgWrapper_exports);
35
35
  var import_react = __toESM(require("react"));
36
- var import_constants = require("../../constants");
36
+ var import_theme = require("../../theme");
37
37
  var import_getElementFontSize = require("./getElementFontSize");
38
38
  var useSvgWrapper = () => {
39
39
  const ele = (0, import_react.useRef)(null);
40
- const [fontSize, setFontSize] = (0, import_react.useState)(import_constants.TEXT_THEME.fontSizeBase);
40
+ const [fontSize, setFontSize] = (0, import_react.useState)(import_theme.TEXT_THEME.fontSizeBase);
41
41
  (0, import_react.useLayoutEffect)(() => {
42
42
  if (ele.current) {
43
- setFontSize((0, import_getElementFontSize.getElementFontSize)(ele.current, import_constants.TEXT_THEME.fontSizeBase));
43
+ setFontSize((0, import_getElementFontSize.getElementFontSize)(ele.current, import_theme.TEXT_THEME.fontSizeBase));
44
44
  }
45
45
  }, []);
46
46
  const Svg = ({ children, ...otherProps }) => {
@@ -34,10 +34,10 @@ __export(SingleLineChart_exports, {
34
34
  module.exports = __toCommonJS(SingleLineChart_exports);
35
35
  var import_lodash = require("lodash");
36
36
  var import_react = __toESM(require("react"));
37
+ var import_theme = require("../../theme");
37
38
  var import_hooks = require("../hooks");
38
39
  var import_useLineCompute = require("./useLineCompute");
39
40
  var LINEAR_FILL_COLOR_ID = "wsc-line-fill";
40
- var LINE_STROKE_COLOR = "#5B8FF9";
41
41
  function getLineChartData(origin) {
42
42
  if ((0, import_lodash.isArray)(origin))
43
43
  return origin;
@@ -55,7 +55,7 @@ var SingleLineChart = ({ origin }) => {
55
55
  const [Svg, fontSize] = (0, import_hooks.useSvgWrapper)();
56
56
  const data = (0, import_react.useMemo)(() => getLineChartData(origin), [origin]);
57
57
  const { width, height, linePath, polygonPath } = (0, import_useLineCompute.useLineCompute)(fontSize, data);
58
- return (0, import_lodash.size)(data) > 0 && /* @__PURE__ */ import_react.default.createElement(Svg, { width, height }, /* @__PURE__ */ import_react.default.createElement("defs", null, /* @__PURE__ */ import_react.default.createElement("linearGradient", { x1: "50%", y1: "0%", x2: "50%", y2: "122.389541%", id: LINEAR_FILL_COLOR_ID }, /* @__PURE__ */ import_react.default.createElement("stop", { stopColor: LINE_STROKE_COLOR, offset: "0%" }), /* @__PURE__ */ import_react.default.createElement("stop", { stopColor: "#FFFFFF", stopOpacity: "0", offset: "100%" }))), linePath && /* @__PURE__ */ import_react.default.createElement("path", { d: linePath, stroke: LINE_STROKE_COLOR, fill: "transparent" }), polygonPath && /* @__PURE__ */ import_react.default.createElement("polygon", { points: polygonPath, fill: `url(#${LINEAR_FILL_COLOR_ID})` }));
58
+ return (0, import_lodash.size)(data) > 0 && /* @__PURE__ */ import_react.default.createElement(Svg, { width, height }, /* @__PURE__ */ import_react.default.createElement("defs", null, /* @__PURE__ */ import_react.default.createElement("linearGradient", { x1: "50%", y1: "0%", x2: "50%", y2: "122.389541%", id: LINEAR_FILL_COLOR_ID }, /* @__PURE__ */ import_react.default.createElement("stop", { stopColor: import_theme.TEXT_THEME.chart.lineStrokeColor, offset: "0%" }), /* @__PURE__ */ import_react.default.createElement("stop", { stopColor: "#FFFFFF", stopOpacity: "0", offset: "100%" }))), linePath && /* @__PURE__ */ import_react.default.createElement("path", { d: linePath, stroke: import_theme.TEXT_THEME.chart.lineStrokeColor, fill: "transparent" }), polygonPath && /* @__PURE__ */ import_react.default.createElement("polygon", { points: polygonPath, fill: `url(#${LINEAR_FILL_COLOR_ID})` }));
59
59
  };
60
60
  // Annotate the CommonJS export names for ESM import in node:
61
61
  0 && (module.exports = {
@@ -23,13 +23,13 @@ __export(useLineCompute_exports, {
23
23
  });
24
24
  module.exports = __toCommonJS(useLineCompute_exports);
25
25
  var import_react = require("react");
26
- var import_constants = require("../../constants");
26
+ var import_theme = require("../../theme");
27
27
  var import_scaleLinear = require("./scaleLinear");
28
28
  var SCALE_ADJUST = 2;
29
29
  var Line = class {
30
30
  constructor(size, data) {
31
31
  this.data = [];
32
- this.size = import_constants.TEXT_THEME.fontSizeBase;
32
+ this.size = import_theme.TEXT_THEME.fontSizeBase;
33
33
  this.height = this.size;
34
34
  this.width = this.getWidth();
35
35
  this.points = [];
@@ -34,10 +34,9 @@ __export(proportion_exports, {
34
34
  module.exports = __toCommonJS(proportion_exports);
35
35
  var import_lodash = require("lodash");
36
36
  var import_react = __toESM(require("react"));
37
+ var import_theme = require("../../theme");
37
38
  var import_useSvgWrapper = require("../hooks/useSvgWrapper");
38
39
  var import_getArcPath = require("./getArcPath");
39
- var SHADOW_COLOR = "#CDDDFD";
40
- var FILL_COLOR = "#3471F9";
41
40
  function getProportionNumber(children, origin) {
42
41
  var _a;
43
42
  let result;
@@ -64,7 +63,7 @@ var ProportionChart = ({ origin, children }) => {
64
63
  const data = (0, import_react.useMemo)(() => getProportionNumber(children, origin), [children, origin]);
65
64
  const [Svg, fontSize] = (0, import_useSvgWrapper.useSvgWrapper)();
66
65
  const r = fontSize / 2;
67
- return data && /* @__PURE__ */ import_react.default.createElement(Svg, { width: fontSize, height: fontSize }, /* @__PURE__ */ import_react.default.createElement("circle", { cx: r, cy: r, r, fill: SHADOW_COLOR }), data >= 1 ? /* @__PURE__ */ import_react.default.createElement("circle", { cx: r, cy: r, r, fill: FILL_COLOR }) : /* @__PURE__ */ import_react.default.createElement("path", { d: (0, import_getArcPath.getArcPath)(fontSize, data), fill: FILL_COLOR }));
66
+ return data && /* @__PURE__ */ import_react.default.createElement(Svg, { width: fontSize, height: fontSize }, /* @__PURE__ */ import_react.default.createElement("circle", { cx: r, cy: r, r, fill: import_theme.TEXT_THEME.chart.proportionShadowColor }), data >= 1 ? /* @__PURE__ */ import_react.default.createElement("circle", { cx: r, cy: r, r, fill: import_theme.TEXT_THEME.chart.proportionFillColor }) : /* @__PURE__ */ import_react.default.createElement("path", { d: (0, import_getArcPath.getArcPath)(fontSize, data), fill: import_theme.TEXT_THEME.chart.proportionFillColor }));
68
67
  };
69
68
  // Annotate the CommonJS export names for ESM import in node:
70
69
  0 && (module.exports = {