@antv/gpt-vis 0.0.6 → 0.2.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.
Files changed (272) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +92 -50
  3. package/README.zh-CN.md +138 -0
  4. package/dist/cjs/Area/index.d.ts +8 -2
  5. package/dist/cjs/Area/index.js +17 -16
  6. package/dist/cjs/Bar/index.d.ts +11 -0
  7. package/dist/cjs/Bar/index.js +65 -0
  8. package/dist/cjs/ChartCodeRender/Loading.d.ts +3 -0
  9. package/dist/cjs/ChartCodeRender/Loading.js +54 -0
  10. package/dist/cjs/ChartCodeRender/VisChart.d.ts +11 -0
  11. package/dist/cjs/ChartCodeRender/VisChart.js +84 -0
  12. package/dist/cjs/ChartCodeRender/index.d.ts +3 -4
  13. package/dist/cjs/ChartCodeRender/index.js +24 -68
  14. package/dist/cjs/ChartCodeRender/type.d.ts +9 -11
  15. package/dist/cjs/Column/index.d.ts +8 -2
  16. package/dist/cjs/Column/index.js +19 -27
  17. package/dist/cjs/ConfigProvider/context.d.ts +3 -0
  18. package/dist/cjs/ConfigProvider/context.js +41 -0
  19. package/dist/cjs/ConfigProvider/hooks/index.d.ts +1 -0
  20. package/dist/cjs/ConfigProvider/hooks/index.js +23 -0
  21. package/dist/cjs/ConfigProvider/hooks/useConfig.d.ts +13 -0
  22. package/dist/cjs/ConfigProvider/hooks/useConfig.js +108 -0
  23. package/dist/cjs/ConfigProvider/index.d.ts +2 -5
  24. package/dist/cjs/ConfigProvider/index.js +15 -9
  25. package/dist/cjs/DualAxes/index.d.ts +15 -0
  26. package/dist/cjs/DualAxes/index.js +71 -0
  27. package/dist/cjs/DualAxes/util.d.ts +9 -0
  28. package/dist/cjs/DualAxes/util.js +73 -0
  29. package/dist/cjs/FlowDiagram/index.d.ts +6 -0
  30. package/dist/cjs/FlowDiagram/index.js +100 -0
  31. package/dist/cjs/GPTVis/Lite.d.ts +10 -0
  32. package/dist/cjs/GPTVis/Lite.js +54 -0
  33. package/dist/cjs/GPTVis/index.d.ts +4 -8
  34. package/dist/cjs/GPTVis/index.js +4 -4
  35. package/dist/cjs/HeatMap/index.d.ts +7 -7
  36. package/dist/cjs/HeatMap/index.js +13 -26
  37. package/dist/cjs/Histogram/index.d.ts +10 -0
  38. package/dist/cjs/Histogram/index.js +51 -0
  39. package/dist/cjs/IndentedTree/index.d.ts +6 -0
  40. package/dist/cjs/IndentedTree/index.js +63 -0
  41. package/dist/cjs/Line/index.d.ts +8 -6
  42. package/dist/cjs/Line/index.js +15 -16
  43. package/dist/cjs/Map/data.json +305 -0
  44. package/dist/cjs/Map/index.d.ts +5 -0
  45. package/dist/cjs/Map/index.js +68 -0
  46. package/dist/cjs/MindMap/index.d.ts +6 -0
  47. package/dist/cjs/MindMap/index.js +64 -0
  48. package/dist/cjs/NetworkGraph/index.d.ts +6 -0
  49. package/dist/cjs/NetworkGraph/index.js +72 -0
  50. package/dist/cjs/OrganizationChart/index.d.ts +6 -0
  51. package/dist/cjs/OrganizationChart/index.js +93 -0
  52. package/dist/cjs/PathMap/index.d.ts +3 -9
  53. package/dist/cjs/PathMap/index.js +19 -109
  54. package/dist/cjs/Pie/index.d.ts +7 -5
  55. package/dist/cjs/Pie/index.js +17 -13
  56. package/dist/cjs/PinMap/index.d.ts +3 -9
  57. package/dist/cjs/PinMap/index.js +6 -85
  58. package/dist/cjs/Radar/index.d.ts +11 -0
  59. package/dist/cjs/Radar/index.js +84 -0
  60. package/dist/cjs/Scatter/index.d.ts +11 -0
  61. package/dist/cjs/Scatter/index.js +57 -0
  62. package/dist/cjs/Text/VisText.d.ts +4 -0
  63. package/dist/cjs/Text/VisText.js +74 -0
  64. package/dist/cjs/Text/config.d.ts +18 -0
  65. package/dist/cjs/Text/config.js +91 -0
  66. package/dist/cjs/Text/constants.d.ts +9 -0
  67. package/dist/cjs/Text/constants.js +37 -0
  68. package/dist/cjs/Text/custom-icons/index.d.ts +3 -0
  69. package/dist/cjs/Text/custom-icons/index.js +66 -0
  70. package/dist/cjs/Text/index.d.ts +3 -0
  71. package/dist/cjs/Text/index.js +42 -0
  72. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  73. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +65 -0
  74. package/dist/cjs/Text/mini-charts/hooks/index.d.ts +1 -0
  75. package/dist/cjs/Text/mini-charts/hooks/index.js +29 -0
  76. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  77. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +65 -0
  78. package/dist/cjs/Text/mini-charts/index.d.ts +2 -0
  79. package/dist/cjs/Text/mini-charts/index.js +25 -0
  80. package/dist/cjs/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  81. package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +63 -0
  82. package/dist/cjs/Text/mini-charts/line/index.d.ts +1 -0
  83. package/dist/cjs/Text/mini-charts/line/index.js +29 -0
  84. package/dist/cjs/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  85. package/dist/cjs/Text/mini-charts/line/scaleLinear.js +35 -0
  86. package/dist/cjs/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  87. package/dist/cjs/Text/mini-charts/line/useLineCompute.js +103 -0
  88. package/dist/cjs/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  89. package/dist/cjs/Text/mini-charts/proportion/getArcPath.js +51 -0
  90. package/dist/cjs/Text/mini-charts/proportion/index.d.ts +3 -0
  91. package/dist/cjs/Text/mini-charts/proportion/index.js +72 -0
  92. package/dist/cjs/Text/types.d.ts +20 -0
  93. package/dist/cjs/Text/types.js +17 -0
  94. package/dist/cjs/Treemap/index.d.ts +11 -0
  95. package/dist/cjs/Treemap/index.js +73 -0
  96. package/dist/cjs/WordCloud/index.d.ts +4 -5
  97. package/dist/cjs/WordCloud/index.js +7 -15
  98. package/dist/cjs/constants/index.d.ts +1 -3
  99. package/dist/cjs/constants/index.js +4 -35
  100. package/dist/cjs/export.d.ts +28 -0
  101. package/dist/cjs/export.js +116 -0
  102. package/dist/cjs/index.d.ts +10 -11
  103. package/dist/cjs/index.js +9 -25
  104. package/dist/cjs/types/chart.d.ts +49 -14
  105. package/dist/cjs/types/chart.js +12 -0
  106. package/dist/cjs/types/config.d.ts +16 -0
  107. package/dist/cjs/types/index.d.ts +1 -1
  108. package/dist/cjs/types/index.js +0 -9
  109. package/dist/cjs/types/map.d.ts +242 -0
  110. package/dist/cjs/types/map.js +17 -0
  111. package/dist/cjs/utils/config.d.ts +5 -5
  112. package/dist/cjs/utils/config.js +41 -24
  113. package/dist/cjs/utils/graph.d.ts +18 -0
  114. package/dist/cjs/utils/graph.js +64 -0
  115. package/dist/cjs/utils/index.d.ts +1 -1
  116. package/dist/cjs/utils/index.js +3 -13
  117. package/dist/cjs/utils/map/context.d.ts +3 -0
  118. package/dist/cjs/utils/map/context.js +42 -0
  119. package/dist/cjs/utils/map/controls.d.ts +0 -0
  120. package/dist/cjs/utils/map/controls.js +0 -0
  121. package/dist/cjs/utils/map/index.d.ts +6 -0
  122. package/dist/cjs/utils/map/index.js +33 -0
  123. package/dist/cjs/utils/map/markers.d.ts +2 -0
  124. package/dist/cjs/utils/map/markers.js +88 -0
  125. package/dist/cjs/utils/map/polyline.d.ts +2 -0
  126. package/dist/cjs/utils/map/polyline.js +52 -0
  127. package/dist/cjs/utils/map/style.d.ts +45 -0
  128. package/dist/cjs/utils/map/style.js +112 -0
  129. package/dist/cjs/utils/map/util.d.ts +1 -0
  130. package/dist/cjs/utils/map/util.js +38 -0
  131. package/dist/cjs/utils/map/view.d.ts +3 -0
  132. package/dist/cjs/utils/map/view.js +93 -0
  133. package/dist/cjs/utils/plot.d.ts +4 -0
  134. package/dist/cjs/utils/plot.js +69 -0
  135. package/dist/cjs/version.d.ts +2 -0
  136. package/dist/cjs/version.js +25 -0
  137. package/dist/esm/Area/index.d.ts +8 -2
  138. package/dist/esm/Area/index.js +21 -27
  139. package/dist/esm/Bar/index.d.ts +11 -0
  140. package/dist/esm/Bar/index.js +35 -0
  141. package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
  142. package/dist/esm/ChartCodeRender/Loading.js +20 -0
  143. package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
  144. package/dist/esm/ChartCodeRender/VisChart.js +65 -0
  145. package/dist/esm/ChartCodeRender/index.d.ts +3 -4
  146. package/dist/esm/ChartCodeRender/index.js +28 -84
  147. package/dist/esm/ChartCodeRender/type.d.ts +9 -11
  148. package/dist/esm/Column/index.d.ts +8 -2
  149. package/dist/esm/Column/index.js +22 -27
  150. package/dist/esm/ConfigProvider/context.d.ts +3 -0
  151. package/dist/esm/ConfigProvider/context.js +3 -0
  152. package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
  153. package/dist/esm/ConfigProvider/hooks/index.js +1 -0
  154. package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
  155. package/dist/esm/ConfigProvider/hooks/useConfig.js +57 -0
  156. package/dist/esm/ConfigProvider/index.d.ts +2 -5
  157. package/dist/esm/ConfigProvider/index.js +9 -9
  158. package/dist/esm/DualAxes/index.d.ts +15 -0
  159. package/dist/esm/DualAxes/index.js +44 -0
  160. package/dist/esm/DualAxes/util.d.ts +9 -0
  161. package/dist/esm/DualAxes/util.js +61 -0
  162. package/dist/esm/FlowDiagram/index.d.ts +6 -0
  163. package/dist/esm/FlowDiagram/index.js +75 -0
  164. package/dist/esm/GPTVis/Lite.d.ts +10 -0
  165. package/dist/esm/GPTVis/Lite.js +18 -0
  166. package/dist/esm/GPTVis/index.d.ts +4 -8
  167. package/dist/esm/GPTVis/index.js +5 -5
  168. package/dist/esm/HeatMap/index.d.ts +7 -7
  169. package/dist/esm/HeatMap/index.js +19 -27
  170. package/dist/esm/Histogram/index.d.ts +10 -0
  171. package/dist/esm/Histogram/index.js +25 -0
  172. package/dist/esm/IndentedTree/index.d.ts +6 -0
  173. package/dist/esm/IndentedTree/index.js +47 -0
  174. package/dist/esm/Line/index.d.ts +8 -6
  175. package/dist/esm/Line/index.js +17 -23
  176. package/dist/esm/Map/data.json +305 -0
  177. package/dist/esm/Map/index.d.ts +5 -0
  178. package/dist/esm/Map/index.js +60 -0
  179. package/dist/esm/MindMap/index.d.ts +6 -0
  180. package/dist/esm/MindMap/index.js +48 -0
  181. package/dist/esm/NetworkGraph/index.d.ts +6 -0
  182. package/dist/esm/NetworkGraph/index.js +57 -0
  183. package/dist/esm/OrganizationChart/index.d.ts +6 -0
  184. package/dist/esm/OrganizationChart/index.js +64 -0
  185. package/dist/esm/PathMap/index.d.ts +3 -9
  186. package/dist/esm/PathMap/index.js +32 -129
  187. package/dist/esm/Pie/index.d.ts +7 -5
  188. package/dist/esm/Pie/index.js +24 -20
  189. package/dist/esm/PinMap/index.d.ts +3 -9
  190. package/dist/esm/PinMap/index.js +18 -104
  191. package/dist/esm/Radar/index.d.ts +11 -0
  192. package/dist/esm/Radar/index.js +54 -0
  193. package/dist/esm/Scatter/index.d.ts +11 -0
  194. package/dist/esm/Scatter/index.js +30 -0
  195. package/dist/esm/Text/VisText.d.ts +4 -0
  196. package/dist/esm/Text/VisText.js +38 -0
  197. package/dist/esm/Text/config.d.ts +18 -0
  198. package/dist/esm/Text/config.js +79 -0
  199. package/dist/esm/Text/constants.d.ts +9 -0
  200. package/dist/esm/Text/constants.js +9 -0
  201. package/dist/esm/Text/custom-icons/index.d.ts +3 -0
  202. package/dist/esm/Text/custom-icons/index.js +37 -0
  203. package/dist/esm/Text/index.d.ts +3 -0
  204. package/dist/esm/Text/index.js +2 -0
  205. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  206. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
  207. package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
  208. package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
  209. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  210. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
  211. package/dist/esm/Text/mini-charts/index.d.ts +2 -0
  212. package/dist/esm/Text/mini-charts/index.js +2 -0
  213. package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  214. package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
  215. package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
  216. package/dist/esm/Text/mini-charts/line/index.js +1 -0
  217. package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  218. package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
  219. package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  220. package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
  221. package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  222. package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
  223. package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
  224. package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
  225. package/dist/esm/Text/types.d.ts +20 -0
  226. package/dist/esm/Text/types.js +1 -0
  227. package/dist/esm/Treemap/index.d.ts +11 -0
  228. package/dist/esm/Treemap/index.js +52 -0
  229. package/dist/esm/WordCloud/index.d.ts +4 -5
  230. package/dist/esm/WordCloud/index.js +8 -18
  231. package/dist/esm/constants/index.d.ts +1 -3
  232. package/dist/esm/constants/index.js +5 -14
  233. package/dist/esm/export.d.ts +28 -0
  234. package/dist/esm/export.js +33 -0
  235. package/dist/esm/index.d.ts +10 -11
  236. package/dist/esm/index.js +9 -9
  237. package/dist/esm/types/chart.d.ts +49 -14
  238. package/dist/esm/types/chart.js +12 -0
  239. package/dist/esm/types/config.d.ts +16 -0
  240. package/dist/esm/types/index.d.ts +1 -1
  241. package/dist/esm/types/index.js +1 -1
  242. package/dist/esm/types/map.d.ts +242 -0
  243. package/dist/esm/types/map.js +1 -0
  244. package/dist/esm/utils/config.d.ts +5 -5
  245. package/dist/esm/utils/config.js +40 -18
  246. package/dist/esm/utils/graph.d.ts +18 -0
  247. package/dist/esm/utils/graph.js +49 -0
  248. package/dist/esm/utils/index.d.ts +1 -1
  249. package/dist/esm/utils/index.js +1 -1
  250. package/dist/esm/utils/map/context.d.ts +3 -0
  251. package/dist/esm/utils/map/context.js +34 -0
  252. package/dist/esm/utils/map/controls.d.ts +0 -0
  253. package/dist/esm/utils/map/controls.js +0 -0
  254. package/dist/esm/utils/map/index.d.ts +6 -0
  255. package/dist/esm/utils/map/index.js +6 -0
  256. package/dist/esm/utils/map/markers.d.ts +2 -0
  257. package/dist/esm/utils/map/markers.js +64 -0
  258. package/dist/esm/utils/map/polyline.d.ts +2 -0
  259. package/dist/esm/utils/map/polyline.js +26 -0
  260. package/dist/esm/utils/map/style.d.ts +45 -0
  261. package/dist/esm/utils/map/style.js +76 -0
  262. package/dist/esm/utils/map/util.d.ts +1 -0
  263. package/dist/esm/utils/map/util.js +11 -0
  264. package/dist/esm/utils/map/view.d.ts +3 -0
  265. package/dist/esm/utils/map/view.js +81 -0
  266. package/dist/esm/utils/plot.d.ts +4 -0
  267. package/dist/esm/utils/plot.js +65 -0
  268. package/dist/esm/version.d.ts +2 -0
  269. package/dist/esm/version.js +1 -0
  270. package/dist/umd/895.async.js +1 -0
  271. package/dist/umd/index.min.js +1 -0
  272. package/package.json +97 -58
@@ -0,0 +1,9 @@
1
+ export declare const TEXT_THEME: {
2
+ fontSizeBase: number;
3
+ primaryColor: string;
4
+ black88: string;
5
+ black65: string;
6
+ posColor: string;
7
+ negColor: string;
8
+ statisticsInsightColor: string;
9
+ };
@@ -0,0 +1,9 @@
1
+ export var TEXT_THEME = {
2
+ fontSizeBase: 14,
3
+ primaryColor: '#1677FF',
4
+ black88: 'rgba(0, 0, 0, 0.88)',
5
+ black65: 'rgba(0, 0, 0, 0.65)',
6
+ posColor: '#FA541C',
7
+ negColor: '#13A8A8',
8
+ statisticsInsightColor: '#1F0352'
9
+ };
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export declare const ArrowUp: () => React.JSX.Element;
3
+ export declare const ArrowDown: () => React.JSX.Element;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ var MARGIN_RIGHT = 2;
3
+ export var ArrowUp = function ArrowUp() {
4
+ return /*#__PURE__*/React.createElement("svg", {
5
+ width: "8px",
6
+ height: "9px",
7
+ style: {
8
+ transform: 'rotate(180deg)',
9
+ marginRight: MARGIN_RIGHT
10
+ },
11
+ viewBox: "0 0 8 9",
12
+ version: "1.1",
13
+ xmlns: "http://www.w3.org/2000/svg"
14
+ }, /*#__PURE__*/React.createElement("g", {
15
+ transform: "translate(-2.000000, -2.000000)"
16
+ }, /*#__PURE__*/React.createElement("polygon", {
17
+ fill: "currentColor",
18
+ points: "6 11 9.5 2 2.5 2"
19
+ })));
20
+ };
21
+ export var ArrowDown = function ArrowDown() {
22
+ return /*#__PURE__*/React.createElement("svg", {
23
+ width: "8px",
24
+ height: "9px",
25
+ viewBox: "0 0 8 9",
26
+ style: {
27
+ marginRight: MARGIN_RIGHT
28
+ },
29
+ version: "1.1",
30
+ xmlns: "http://www.w3.org/2000/svg"
31
+ }, /*#__PURE__*/React.createElement("g", {
32
+ transform: "translate(-2.000000, -2.000000)"
33
+ }, /*#__PURE__*/React.createElement("polygon", {
34
+ fill: "currentColor",
35
+ points: "6 11 9.5 2 2.5 2"
36
+ })));
37
+ };
@@ -0,0 +1,3 @@
1
+ export { DEFAULT_VIS_TEXT_CONFIG } from './config';
2
+ export type { VisTextProps } from './types';
3
+ export { default as VisText } from './VisText';
@@ -0,0 +1,2 @@
1
+ export { DEFAULT_VIS_TEXT_CONFIG } from "./config";
2
+ export { default as VisText } from "./VisText";
@@ -0,0 +1 @@
1
+ export declare function getElementFontSize(ele: Element, defaultSize?: number): number;
@@ -0,0 +1,32 @@
1
+ import { TEXT_THEME } from "../../constants";
2
+ function getStyle(ele, style) {
3
+ var _ele$currentStyle;
4
+ return window.getComputedStyle ?
5
+ // @ts-ignore style as any
6
+ window.getComputedStyle(ele, null)[style] : // @ts-ignore currentStyle for IE
7
+ ele === null || ele === void 0 || (_ele$currentStyle = ele.currentStyle) === null || _ele$currentStyle === void 0 ? void 0 : _ele$currentStyle[style];
8
+ }
9
+ function isAbsoluteUnitPx(str) {
10
+ return str === null || str === void 0 ? void 0 : str.endsWith('px');
11
+ }
12
+ function getPxNumber(str) {
13
+ var removeUnit = str.replace(/px$/, '');
14
+ var resultNumber = Number(removeUnit);
15
+ if (!Number.isNaN(resultNumber)) return resultNumber;
16
+ return undefined;
17
+ }
18
+ export function getElementFontSize(ele) {
19
+ var defaultSize = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : TEXT_THEME.fontSizeBase;
20
+ var FONT_SIZE = 'font-size';
21
+ var eleFontSizeStr = getStyle(ele, FONT_SIZE);
22
+ if (eleFontSizeStr && isAbsoluteUnitPx(eleFontSizeStr)) {
23
+ var px = getPxNumber(eleFontSizeStr);
24
+ if (px) return px;
25
+ }
26
+ var bodyFontSizeStr = getStyle(window.document.body, FONT_SIZE);
27
+ if (bodyFontSizeStr && isAbsoluteUnitPx(bodyFontSizeStr)) {
28
+ var _px = getPxNumber(bodyFontSizeStr);
29
+ if (_px) return _px;
30
+ }
31
+ return defaultSize;
32
+ }
@@ -0,0 +1 @@
1
+ export { useSvgWrapper } from './useSvgWrapper';
@@ -0,0 +1 @@
1
+ export { useSvgWrapper } from "./useSvgWrapper";
@@ -0,0 +1,5 @@
1
+ import type { PropsWithChildren } from 'react';
2
+ import React from 'react';
3
+ type SvgProps = PropsWithChildren<React.SVGProps<SVGSVGElement>>;
4
+ export declare const useSvgWrapper: () => readonly [({ children, ...otherProps }: SvgProps) => React.JSX.Element, number];
5
+ export {};
@@ -0,0 +1,31 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ var _excluded = ["children"];
5
+ import React, { useLayoutEffect, useRef, useState } from 'react';
6
+ import { TEXT_THEME } from "../../constants";
7
+ import { getElementFontSize } from "./getElementFontSize";
8
+ export var useSvgWrapper = function useSvgWrapper() {
9
+ var ele = useRef(null);
10
+ var _useState = useState(TEXT_THEME.fontSizeBase),
11
+ _useState2 = _slicedToArray(_useState, 2),
12
+ fontSize = _useState2[0],
13
+ setFontSize = _useState2[1];
14
+ useLayoutEffect(function () {
15
+ if (ele.current) {
16
+ setFontSize(getElementFontSize(ele.current, TEXT_THEME.fontSizeBase));
17
+ }
18
+ }, []);
19
+ var Svg = function Svg(_ref) {
20
+ var children = _ref.children,
21
+ otherProps = _objectWithoutProperties(_ref, _excluded);
22
+ return /*#__PURE__*/React.createElement("svg", _extends({
23
+ style: {
24
+ margin: '0px 4px',
25
+ transform: 'translate(0px, 0.125em)'
26
+ },
27
+ ref: ele
28
+ }, otherProps), children);
29
+ };
30
+ return [Svg, fontSize];
31
+ };
@@ -0,0 +1,2 @@
1
+ export * from './line';
2
+ export * from './proportion';
@@ -0,0 +1,2 @@
1
+ export * from "./line";
2
+ export * from "./proportion";
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { VisTextProps } from '../../types';
3
+ export declare const SingleLineChart: React.FC<VisTextProps>;
@@ -0,0 +1,57 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { isArray, isString, size } from 'lodash';
3
+ import React, { useMemo } from 'react';
4
+ import { useSvgWrapper } from "../hooks";
5
+ import { useLineCompute } from "./useLineCompute";
6
+ var LINEAR_FILL_COLOR_ID = 'wsc-line-fill';
7
+ var LINE_STROKE_COLOR = '#5B8FF9';
8
+ function getLineChartData(origin) {
9
+ if (isArray(origin)) return origin;
10
+ if (isString(origin)) {
11
+ try {
12
+ var data = JSON.parse(origin);
13
+ if (isArray(data)) return data;
14
+ } catch (e) {
15
+ console.warn(e, "".concat(origin, " is not a valid json string"));
16
+ }
17
+ }
18
+ }
19
+ export var SingleLineChart = function SingleLineChart(_ref) {
20
+ var origin = _ref.origin;
21
+ var _useSvgWrapper = useSvgWrapper(),
22
+ _useSvgWrapper2 = _slicedToArray(_useSvgWrapper, 2),
23
+ Svg = _useSvgWrapper2[0],
24
+ fontSize = _useSvgWrapper2[1];
25
+ var data = useMemo(function () {
26
+ return getLineChartData(origin);
27
+ }, [origin]);
28
+ var _useLineCompute = useLineCompute(fontSize, data),
29
+ width = _useLineCompute.width,
30
+ height = _useLineCompute.height,
31
+ linePath = _useLineCompute.linePath,
32
+ polygonPath = _useLineCompute.polygonPath;
33
+ return size(data) > 0 && /*#__PURE__*/React.createElement(Svg, {
34
+ width: width,
35
+ height: height
36
+ }, /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
37
+ x1: "50%",
38
+ y1: "0%",
39
+ x2: "50%",
40
+ y2: "122.389541%",
41
+ id: LINEAR_FILL_COLOR_ID
42
+ }, /*#__PURE__*/React.createElement("stop", {
43
+ stopColor: LINE_STROKE_COLOR,
44
+ offset: "0%"
45
+ }), /*#__PURE__*/React.createElement("stop", {
46
+ stopColor: "#FFFFFF",
47
+ stopOpacity: "0",
48
+ offset: "100%"
49
+ }))), linePath && /*#__PURE__*/React.createElement("path", {
50
+ d: linePath,
51
+ stroke: LINE_STROKE_COLOR,
52
+ fill: "transparent"
53
+ }), polygonPath && /*#__PURE__*/React.createElement("polygon", {
54
+ points: polygonPath,
55
+ fill: "url(#".concat(LINEAR_FILL_COLOR_ID, ")")
56
+ }));
57
+ };
@@ -0,0 +1 @@
1
+ export { SingleLineChart } from './SingleLineChart';
@@ -0,0 +1 @@
1
+ export { SingleLineChart } from "./SingleLineChart";
@@ -0,0 +1,4 @@
1
+ export type Domain = [number, number];
2
+ export type Range = [number, number];
3
+ export type Scale = (n: number) => number;
4
+ export declare const scaleLinear: (domain: Domain, range: Range) => Scale;
@@ -0,0 +1,14 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ export var scaleLinear = function scaleLinear(domain, range) {
3
+ return function (n) {
4
+ var _domain = _slicedToArray(domain, 2),
5
+ d1 = _domain[0],
6
+ d2 = _domain[1];
7
+ var _range = _slicedToArray(range, 2),
8
+ r1 = _range[0],
9
+ r2 = _range[1];
10
+ // Returns the intermediate value when the range is zero.
11
+ if (r1 === r2) return (d2 - d1) / 2;
12
+ return n / (r2 - r1) * (d2 - d1);
13
+ };
14
+ };
@@ -0,0 +1,6 @@
1
+ export declare const useLineCompute: (size: number, data: undefined | number[]) => {
2
+ width: number;
3
+ height: number;
4
+ linePath: string | null;
5
+ polygonPath: string | null;
6
+ };
@@ -0,0 +1,106 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
5
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
6
+ import { useEffect, useState } from 'react';
7
+ import { TEXT_THEME } from "../../constants";
8
+ import { scaleLinear } from "./scaleLinear";
9
+
10
+ // adjust to draw line width
11
+ var SCALE_ADJUST = 2;
12
+ var Line = /*#__PURE__*/function () {
13
+ function Line(size, data) {
14
+ _classCallCheck(this, Line);
15
+ _defineProperty(this, "data", []);
16
+ _defineProperty(this, "size", TEXT_THEME.fontSizeBase);
17
+ _defineProperty(this, "height", this.size);
18
+ _defineProperty(this, "width", this.getWidth());
19
+ _defineProperty(this, "xScale", void 0);
20
+ _defineProperty(this, "yScale", void 0);
21
+ _defineProperty(this, "points", []);
22
+ this.size = size;
23
+ if (data) {
24
+ this.data = data;
25
+ this.compute();
26
+ }
27
+ }
28
+ _createClass(Line, [{
29
+ key: "getWidth",
30
+ value: function getWidth() {
31
+ var _this$data;
32
+ return Math.max(this.size * 2, ((_this$data = this.data) === null || _this$data === void 0 ? void 0 : _this$data.length) * 2);
33
+ }
34
+ }, {
35
+ key: "compute",
36
+ value: function compute() {
37
+ var _this$data2,
38
+ _this = this;
39
+ if (!this.data) return;
40
+ this.height = this.size;
41
+ this.width = this.getWidth();
42
+ this.xScale = scaleLinear([0, this.width], [0, ((_this$data2 = this.data) === null || _this$data2 === void 0 ? void 0 : _this$data2.length) - 1]);
43
+ var _ref = [Math.min.apply(Math, _toConsumableArray(this.data)), Math.max.apply(Math, _toConsumableArray(this.data))],
44
+ min = _ref[0],
45
+ max = _ref[1];
46
+ this.yScale = scaleLinear([SCALE_ADJUST, this.height - SCALE_ADJUST], [min, max]);
47
+ this.points = this.data.map(function (item, index) {
48
+ return [_this.xScale(index), _this.height - _this.yScale(item)];
49
+ });
50
+ }
51
+ }, {
52
+ key: "getLinePath",
53
+ value: function getLinePath() {
54
+ var _this$data3;
55
+ if (!((_this$data3 = this.data) !== null && _this$data3 !== void 0 && _this$data3.length) || !this.xScale || !this.yScale) return null;
56
+ var path = this.points.reduce(function (prev, _ref2, index) {
57
+ var _ref3 = _slicedToArray(_ref2, 2),
58
+ x = _ref3[0],
59
+ y = _ref3[1];
60
+ if (index === 0) return "M".concat(x, " ").concat(y);
61
+ return "".concat(prev, " L ").concat(x, " ").concat(y);
62
+ }, '');
63
+ return path;
64
+ }
65
+ }, {
66
+ key: "getPolygonPath",
67
+ value: function getPolygonPath() {
68
+ var _this$data4;
69
+ if (!((_this$data4 = this.data) !== null && _this$data4 !== void 0 && _this$data4.length) || !this.xScale || !this.yScale) return null;
70
+ var polygonPoints = _toConsumableArray(this.points);
71
+ var last = this.points[this.points.length - 1];
72
+ polygonPoints.push([last[0], this.height]);
73
+ polygonPoints.push([0, this.height]);
74
+ var startPoint = this.points[0];
75
+ polygonPoints.push(startPoint);
76
+ var path = polygonPoints.reduce(function (prev, _ref4) {
77
+ var _ref5 = _slicedToArray(_ref4, 2),
78
+ x = _ref5[0],
79
+ y = _ref5[1];
80
+ return "".concat(prev, " ").concat(x, ",").concat(y);
81
+ }, '');
82
+ return path;
83
+ }
84
+ }, {
85
+ key: "getContainer",
86
+ value: function getContainer() {
87
+ return [this.width, this.height];
88
+ }
89
+ }]);
90
+ return Line;
91
+ }();
92
+ export var useLineCompute = function useLineCompute(size, data) {
93
+ var _useState = useState(new Line(size, data)),
94
+ _useState2 = _slicedToArray(_useState, 2),
95
+ line = _useState2[0],
96
+ setLine = _useState2[1];
97
+ useEffect(function () {
98
+ setLine(new Line(size, data));
99
+ }, [size, data]);
100
+ return {
101
+ width: line.getContainer()[0],
102
+ height: line.getContainer()[1],
103
+ linePath: line.getLinePath(),
104
+ polygonPath: line.getPolygonPath()
105
+ };
106
+ };
@@ -0,0 +1 @@
1
+ export declare function getArcPath(size: number, data: number): string;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * make data between 0 ~ 1
3
+ */
4
+ function normalizeProportion(data) {
5
+ if (typeof data !== 'number') return 0;
6
+ if (data > 1) return 1;
7
+ if (data < 0) return 0;
8
+ return data;
9
+ }
10
+ export function getArcPath(size, data) {
11
+ var cx = size / 2;
12
+ var cy = size / 2;
13
+ var r = size / 2;
14
+ var angle = normalizeProportion(data) * 2 * Math.PI;
15
+ var dx = cx + r * Math.sin(angle);
16
+ var dy = cy - r * Math.cos(angle);
17
+ var path = "\n M".concat(cx, " ", 0, "\n A ").concat(cx, " ").concat(cy, " 0 ").concat(angle > Math.PI ? 1 : 0, " 1 ").concat(dx, " ").concat(dy, "\n L ").concat(cx, " ").concat(cy, " Z\n ");
18
+ return path;
19
+ }
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import type { VisTextProps } from '../../types';
3
+ export declare const ProportionChart: React.FC<VisTextProps>;
@@ -0,0 +1,60 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { isNaN, isString, toNumber } from 'lodash';
3
+ import React, { useMemo } from 'react';
4
+ import { useSvgWrapper } from "../hooks/useSvgWrapper";
5
+ import { getArcPath } from "./getArcPath";
6
+ var SHADOW_COLOR = '#CDDDFD';
7
+ var FILL_COLOR = '#3471F9';
8
+ function getProportionNumber(children,
9
+ // markdown 中传入的 children 文本为 string[]
10
+ origin) {
11
+ var result;
12
+ var originNumber = toNumber(origin);
13
+ if (!isNaN(originNumber)) {
14
+ result = originNumber;
15
+ } else {
16
+ var _text, _text$endsWith;
17
+ var text;
18
+ if (isString(children)) {
19
+ text = children;
20
+ } else if (Array.isArray(children) && isString(children[0])) {
21
+ text = children[0];
22
+ }
23
+ if ((_text = text) !== null && _text !== void 0 && (_text$endsWith = _text.endsWith) !== null && _text$endsWith !== void 0 && _text$endsWith.call(_text, '%')) {
24
+ var _text2;
25
+ var percentageStr = (_text2 = text) === null || _text2 === void 0 ? void 0 : _text2.replace(/%$/, '');
26
+ var proportionNumber = toNumber(percentageStr);
27
+ if (!isNaN(proportionNumber)) result = proportionNumber / 100;
28
+ }
29
+ }
30
+ return result;
31
+ }
32
+ export var ProportionChart = function ProportionChart(_ref) {
33
+ var origin = _ref.origin,
34
+ children = _ref.children;
35
+ var data = useMemo(function () {
36
+ return getProportionNumber(children, origin);
37
+ }, [children, origin]);
38
+ var _useSvgWrapper = useSvgWrapper(),
39
+ _useSvgWrapper2 = _slicedToArray(_useSvgWrapper, 2),
40
+ Svg = _useSvgWrapper2[0],
41
+ fontSize = _useSvgWrapper2[1];
42
+ var r = fontSize / 2;
43
+ return data && /*#__PURE__*/React.createElement(Svg, {
44
+ width: fontSize,
45
+ height: fontSize
46
+ }, /*#__PURE__*/React.createElement("circle", {
47
+ cx: r,
48
+ cy: r,
49
+ r: r,
50
+ fill: SHADOW_COLOR
51
+ }), data >= 1 ? /*#__PURE__*/React.createElement("circle", {
52
+ cx: r,
53
+ cy: r,
54
+ r: r,
55
+ fill: FILL_COLOR
56
+ }) : /*#__PURE__*/React.createElement("path", {
57
+ d: getArcPath(fontSize, data),
58
+ fill: FILL_COLOR
59
+ }));
60
+ };
@@ -0,0 +1,20 @@
1
+ import type { CSSProperties, PropsWithChildren } from 'react';
2
+ import type { TextEntityType } from './config';
3
+ /**
4
+ * the props for the Text
5
+ */
6
+ export type VisTextProps = PropsWithChildren<{
7
+ style?: CSSProperties;
8
+ className?: string;
9
+ children: string;
10
+ /** 类型,包括内置的类型,以及 string 用于用户自行扩展 */
11
+ type?: TextEntityType;
12
+ /**
13
+ * 原始数值
14
+ * 用于传递各种情况的原始数据值,比如:
15
+ * 1. metric_value: 未经过格式化的指标值,原始数据;eg 1.234
16
+ * 2. proportion: 百分比,eg 0.37
17
+ * 3. trend_desc: 趋势值,eg [1, 2, 6, 18, 24, 48]
18
+ */
19
+ origin?: any;
20
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,11 @@
1
+ import type { TreemapConfig } from '@ant-design/plots';
2
+ import React from 'react';
3
+ import type { BasePlotProps } from '../types';
4
+ type TreeNode = {
5
+ name: string;
6
+ value: number;
7
+ children?: TreeNode[];
8
+ };
9
+ export type TreemapProps = BasePlotProps<TreeNode> & Partial<TreemapConfig>;
10
+ declare const Treemap: (props: TreemapProps) => React.JSX.Element;
11
+ export default Treemap;
@@ -0,0 +1,52 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["data"];
4
+ import { Treemap as ADCTreemap } from '@ant-design/plots';
5
+ import React, { useMemo } from 'react';
6
+ import { usePlotConfig } from "../ConfigProvider/hooks";
7
+
8
+ // binNumber和binWidth为互斥属性,选其一即可
9
+
10
+ var defaultConfig = function defaultConfig(props) {
11
+ var _props$valueField = props.valueField,
12
+ valueField = _props$valueField === void 0 ? 'value' : _props$valueField;
13
+ return {
14
+ legend: false,
15
+ layout: {
16
+ tile: 'treemapBinary',
17
+ paddingInner: 3
18
+ },
19
+ valueField: valueField,
20
+ tooltip: {
21
+ items: [function (d) {
22
+ var _d$data;
23
+ return {
24
+ name: (_d$data = d.data) === null || _d$data === void 0 ? void 0 : _d$data.name,
25
+ value: d[valueField]
26
+ };
27
+ }]
28
+ },
29
+ style: {
30
+ fillOpacity: 0.8,
31
+ labelFontSize: 12
32
+ }
33
+ };
34
+ };
35
+ var transform = function transform(data) {
36
+ return {
37
+ name: 'root',
38
+ children: data
39
+ };
40
+ };
41
+ var Treemap = function Treemap(props) {
42
+ var config = usePlotConfig('Treemap', defaultConfig, props);
43
+ var data = config.data,
44
+ others = _objectWithoutProperties(config, _excluded);
45
+ var transformData = useMemo(function () {
46
+ return transform(data);
47
+ }, [data]);
48
+ return /*#__PURE__*/React.createElement(ADCTreemap, _extends({}, others, {
49
+ data: transformData
50
+ }));
51
+ };
52
+ export default Treemap;
@@ -1,11 +1,10 @@
1
+ import type { WordCloudConfig } from '@ant-design/plots';
1
2
  import { type FC } from 'react';
2
- import { BaseChartProps } from '../types';
3
- type PlotData = {
3
+ import type { BasePlotProps } from '../types';
4
+ type WordCloudDataItem = {
4
5
  text: string;
5
6
  value: number;
6
7
  };
7
- export interface WordCloudProps extends BaseChartProps<PlotData> {
8
- className?: string;
9
- }
8
+ export type WordCloudProps = BasePlotProps<WordCloudDataItem> & Partial<WordCloudConfig>;
10
9
  declare const WordCloud: FC<WordCloudProps>;
11
10
  export default WordCloud;
@@ -1,27 +1,17 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import { WordCloud as WordCloudPlot } from '@ant-design/plots';
1
+ import { WordCloud as ADCWordCloud } from '@ant-design/plots';
4
2
  import React from 'react';
5
- var config = {
3
+ import { usePlotConfig } from "../ConfigProvider/hooks";
4
+ var defaultConfig = {
6
5
  autoFit: true,
7
6
  layout: {
8
7
  fontSize: [20, 100]
9
8
  },
10
- encode: {
11
- color: 'text'
12
- },
13
- legend: false
9
+ colorField: 'text',
10
+ legend: false,
11
+ tooltip: false
14
12
  };
15
13
  var WordCloud = function WordCloud(props) {
16
- var className = props.className,
17
- style = props.style,
18
- _props$data = props.data,
19
- data = _props$data === void 0 ? [] : _props$data;
20
- return /*#__PURE__*/React.createElement(WordCloudPlot, _extends({
21
- className: className,
22
- containerStyle: _objectSpread({}, style)
23
- }, config, {
24
- data: data
25
- }));
14
+ var config = usePlotConfig('WordCloud', defaultConfig, props);
15
+ return /*#__PURE__*/React.createElement(ADCWordCloud, config);
26
16
  };
27
17
  export default WordCloud;
@@ -1,4 +1,2 @@
1
- /// <reference types="react" />
2
- import { GlobalConfig } from '../types';
3
- export declare const DEFAULT_CHART_COMPONENTS: Record<string, React.FC<any>>;
1
+ import type { GlobalConfig } from '../types';
4
2
  export declare const DEFAULT_GLOBAL_CONFIG: GlobalConfig;
@@ -1,18 +1,9 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import Area from "../Area";
3
- import Column from "../Column";
4
- import HeatMap from "../HeatMap";
5
- import Line from "../Line";
6
- import PathMap from "../PathMap";
7
- import Pie from "../Pie";
8
- import PinMap from "../PinMap";
9
- import { ChartType } from "../types";
10
- import WordCloud from "../WordCloud";
11
- export var DEFAULT_CHART_COMPONENTS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ChartType.Pie, Pie), ChartType.Area, Area), ChartType.Column, Column), ChartType.Line, Line), ChartType.WordCloud, WordCloud), ChartType.PinMap, PinMap), ChartType.PathMap, PathMap), ChartType.HeatMap, HeatMap);
1
+ import { DEFAULT_VIS_TEXT_CONFIG } from "../Text";
12
2
  export var DEFAULT_GLOBAL_CONFIG = {
13
3
  map: {
14
- style: 'normal',
15
- // TODO: next step remove
16
- token: 'f0230f884bbd54e2913c890cdf45aa7e'
4
+ style: 'light'
5
+ },
6
+ components: {
7
+ VisText: DEFAULT_VIS_TEXT_CONFIG
17
8
  }
18
9
  };