@antv/gpt-vis 0.0.6 → 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.
Files changed (268) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -60
  3. package/README.zh-CN.md +93 -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 +107 -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/index.d.ts +7 -7
  32. package/dist/cjs/GPTVis/index.js +13 -4
  33. package/dist/cjs/HeatMap/index.d.ts +7 -7
  34. package/dist/cjs/HeatMap/index.js +13 -26
  35. package/dist/cjs/Histogram/index.d.ts +10 -0
  36. package/dist/cjs/Histogram/index.js +51 -0
  37. package/dist/cjs/IndentedTree/index.d.ts +6 -0
  38. package/dist/cjs/IndentedTree/index.js +63 -0
  39. package/dist/cjs/Line/index.d.ts +8 -6
  40. package/dist/cjs/Line/index.js +15 -16
  41. package/dist/cjs/Map/data.json +305 -0
  42. package/dist/cjs/Map/index.d.ts +5 -0
  43. package/dist/cjs/Map/index.js +68 -0
  44. package/dist/cjs/MindMap/index.d.ts +6 -0
  45. package/dist/cjs/MindMap/index.js +64 -0
  46. package/dist/cjs/NetworkGraph/index.d.ts +6 -0
  47. package/dist/cjs/NetworkGraph/index.js +72 -0
  48. package/dist/cjs/OrganizationChart/index.d.ts +6 -0
  49. package/dist/cjs/OrganizationChart/index.js +93 -0
  50. package/dist/cjs/PathMap/index.d.ts +3 -9
  51. package/dist/cjs/PathMap/index.js +19 -109
  52. package/dist/cjs/Pie/index.d.ts +7 -5
  53. package/dist/cjs/Pie/index.js +17 -13
  54. package/dist/cjs/PinMap/index.d.ts +3 -9
  55. package/dist/cjs/PinMap/index.js +6 -85
  56. package/dist/cjs/Radar/index.d.ts +11 -0
  57. package/dist/cjs/Radar/index.js +84 -0
  58. package/dist/cjs/Scatter/index.d.ts +11 -0
  59. package/dist/cjs/Scatter/index.js +57 -0
  60. package/dist/cjs/Text/VisText.d.ts +4 -0
  61. package/dist/cjs/Text/VisText.js +71 -0
  62. package/dist/cjs/Text/config.d.ts +18 -0
  63. package/dist/cjs/Text/config.js +91 -0
  64. package/dist/cjs/Text/constants.d.ts +9 -0
  65. package/dist/cjs/Text/constants.js +37 -0
  66. package/dist/cjs/Text/custom-icons/index.d.ts +3 -0
  67. package/dist/cjs/Text/custom-icons/index.js +66 -0
  68. package/dist/cjs/Text/index.d.ts +3 -0
  69. package/dist/cjs/Text/index.js +42 -0
  70. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  71. package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +65 -0
  72. package/dist/cjs/Text/mini-charts/hooks/index.d.ts +1 -0
  73. package/dist/cjs/Text/mini-charts/hooks/index.js +29 -0
  74. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  75. package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +65 -0
  76. package/dist/cjs/Text/mini-charts/index.d.ts +2 -0
  77. package/dist/cjs/Text/mini-charts/index.js +25 -0
  78. package/dist/cjs/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  79. package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +63 -0
  80. package/dist/cjs/Text/mini-charts/line/index.d.ts +1 -0
  81. package/dist/cjs/Text/mini-charts/line/index.js +29 -0
  82. package/dist/cjs/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  83. package/dist/cjs/Text/mini-charts/line/scaleLinear.js +35 -0
  84. package/dist/cjs/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  85. package/dist/cjs/Text/mini-charts/line/useLineCompute.js +103 -0
  86. package/dist/cjs/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  87. package/dist/cjs/Text/mini-charts/proportion/getArcPath.js +51 -0
  88. package/dist/cjs/Text/mini-charts/proportion/index.d.ts +3 -0
  89. package/dist/cjs/Text/mini-charts/proportion/index.js +72 -0
  90. package/dist/cjs/Text/types.d.ts +20 -0
  91. package/dist/cjs/Text/types.js +17 -0
  92. package/dist/cjs/Treemap/index.d.ts +11 -0
  93. package/dist/cjs/Treemap/index.js +73 -0
  94. package/dist/cjs/WordCloud/index.d.ts +4 -5
  95. package/dist/cjs/WordCloud/index.js +7 -15
  96. package/dist/cjs/constants/index.d.ts +1 -3
  97. package/dist/cjs/constants/index.js +4 -35
  98. package/dist/cjs/export.d.ts +25 -0
  99. package/dist/cjs/export.js +119 -0
  100. package/dist/cjs/index.d.ts +4 -10
  101. package/dist/cjs/index.js +5 -27
  102. package/dist/cjs/types/chart.d.ts +49 -14
  103. package/dist/cjs/types/chart.js +12 -0
  104. package/dist/cjs/types/config.d.ts +11 -0
  105. package/dist/cjs/types/index.d.ts +1 -1
  106. package/dist/cjs/types/index.js +0 -9
  107. package/dist/cjs/types/map.d.ts +242 -0
  108. package/dist/cjs/types/map.js +17 -0
  109. package/dist/cjs/utils/config.d.ts +5 -5
  110. package/dist/cjs/utils/config.js +41 -24
  111. package/dist/cjs/utils/graph.d.ts +18 -0
  112. package/dist/cjs/utils/graph.js +64 -0
  113. package/dist/cjs/utils/index.d.ts +1 -1
  114. package/dist/cjs/utils/index.js +3 -13
  115. package/dist/cjs/utils/map/context.d.ts +3 -0
  116. package/dist/cjs/utils/map/context.js +42 -0
  117. package/dist/cjs/utils/map/controls.d.ts +0 -0
  118. package/dist/cjs/utils/map/controls.js +0 -0
  119. package/dist/cjs/utils/map/index.d.ts +6 -0
  120. package/dist/cjs/utils/map/index.js +33 -0
  121. package/dist/cjs/utils/map/markers.d.ts +2 -0
  122. package/dist/cjs/utils/map/markers.js +88 -0
  123. package/dist/cjs/utils/map/polyline.d.ts +2 -0
  124. package/dist/cjs/utils/map/polyline.js +52 -0
  125. package/dist/cjs/utils/map/style.d.ts +45 -0
  126. package/dist/cjs/utils/map/style.js +112 -0
  127. package/dist/cjs/utils/map/util.d.ts +1 -0
  128. package/dist/cjs/utils/map/util.js +38 -0
  129. package/dist/cjs/utils/map/view.d.ts +3 -0
  130. package/dist/cjs/utils/map/view.js +93 -0
  131. package/dist/cjs/utils/plot.d.ts +4 -0
  132. package/dist/cjs/utils/plot.js +69 -0
  133. package/dist/cjs/version.d.ts +2 -0
  134. package/dist/cjs/version.js +25 -0
  135. package/dist/esm/Area/index.d.ts +8 -2
  136. package/dist/esm/Area/index.js +21 -27
  137. package/dist/esm/Bar/index.d.ts +11 -0
  138. package/dist/esm/Bar/index.js +35 -0
  139. package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
  140. package/dist/esm/ChartCodeRender/Loading.js +20 -0
  141. package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
  142. package/dist/esm/ChartCodeRender/VisChart.js +65 -0
  143. package/dist/esm/ChartCodeRender/index.d.ts +3 -4
  144. package/dist/esm/ChartCodeRender/index.js +28 -84
  145. package/dist/esm/ChartCodeRender/type.d.ts +9 -11
  146. package/dist/esm/Column/index.d.ts +8 -2
  147. package/dist/esm/Column/index.js +22 -27
  148. package/dist/esm/ConfigProvider/context.d.ts +3 -0
  149. package/dist/esm/ConfigProvider/context.js +3 -0
  150. package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
  151. package/dist/esm/ConfigProvider/hooks/index.js +1 -0
  152. package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
  153. package/dist/esm/ConfigProvider/hooks/useConfig.js +55 -0
  154. package/dist/esm/ConfigProvider/index.d.ts +2 -5
  155. package/dist/esm/ConfigProvider/index.js +9 -9
  156. package/dist/esm/DualAxes/index.d.ts +15 -0
  157. package/dist/esm/DualAxes/index.js +44 -0
  158. package/dist/esm/DualAxes/util.d.ts +9 -0
  159. package/dist/esm/DualAxes/util.js +61 -0
  160. package/dist/esm/FlowDiagram/index.d.ts +6 -0
  161. package/dist/esm/FlowDiagram/index.js +75 -0
  162. package/dist/esm/GPTVis/index.d.ts +7 -7
  163. package/dist/esm/GPTVis/index.js +9 -5
  164. package/dist/esm/HeatMap/index.d.ts +7 -7
  165. package/dist/esm/HeatMap/index.js +19 -27
  166. package/dist/esm/Histogram/index.d.ts +10 -0
  167. package/dist/esm/Histogram/index.js +25 -0
  168. package/dist/esm/IndentedTree/index.d.ts +6 -0
  169. package/dist/esm/IndentedTree/index.js +47 -0
  170. package/dist/esm/Line/index.d.ts +8 -6
  171. package/dist/esm/Line/index.js +17 -23
  172. package/dist/esm/Map/data.json +305 -0
  173. package/dist/esm/Map/index.d.ts +5 -0
  174. package/dist/esm/Map/index.js +60 -0
  175. package/dist/esm/MindMap/index.d.ts +6 -0
  176. package/dist/esm/MindMap/index.js +48 -0
  177. package/dist/esm/NetworkGraph/index.d.ts +6 -0
  178. package/dist/esm/NetworkGraph/index.js +57 -0
  179. package/dist/esm/OrganizationChart/index.d.ts +6 -0
  180. package/dist/esm/OrganizationChart/index.js +64 -0
  181. package/dist/esm/PathMap/index.d.ts +3 -9
  182. package/dist/esm/PathMap/index.js +32 -129
  183. package/dist/esm/Pie/index.d.ts +7 -5
  184. package/dist/esm/Pie/index.js +24 -20
  185. package/dist/esm/PinMap/index.d.ts +3 -9
  186. package/dist/esm/PinMap/index.js +18 -104
  187. package/dist/esm/Radar/index.d.ts +11 -0
  188. package/dist/esm/Radar/index.js +54 -0
  189. package/dist/esm/Scatter/index.d.ts +11 -0
  190. package/dist/esm/Scatter/index.js +30 -0
  191. package/dist/esm/Text/VisText.d.ts +4 -0
  192. package/dist/esm/Text/VisText.js +34 -0
  193. package/dist/esm/Text/config.d.ts +18 -0
  194. package/dist/esm/Text/config.js +79 -0
  195. package/dist/esm/Text/constants.d.ts +9 -0
  196. package/dist/esm/Text/constants.js +9 -0
  197. package/dist/esm/Text/custom-icons/index.d.ts +3 -0
  198. package/dist/esm/Text/custom-icons/index.js +37 -0
  199. package/dist/esm/Text/index.d.ts +3 -0
  200. package/dist/esm/Text/index.js +2 -0
  201. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  202. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
  203. package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
  204. package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
  205. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  206. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
  207. package/dist/esm/Text/mini-charts/index.d.ts +2 -0
  208. package/dist/esm/Text/mini-charts/index.js +2 -0
  209. package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  210. package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
  211. package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
  212. package/dist/esm/Text/mini-charts/line/index.js +1 -0
  213. package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  214. package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
  215. package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  216. package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
  217. package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  218. package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
  219. package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
  220. package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
  221. package/dist/esm/Text/types.d.ts +20 -0
  222. package/dist/esm/Text/types.js +1 -0
  223. package/dist/esm/Treemap/index.d.ts +11 -0
  224. package/dist/esm/Treemap/index.js +52 -0
  225. package/dist/esm/WordCloud/index.d.ts +4 -5
  226. package/dist/esm/WordCloud/index.js +8 -18
  227. package/dist/esm/constants/index.d.ts +1 -3
  228. package/dist/esm/constants/index.js +5 -14
  229. package/dist/esm/export.d.ts +25 -0
  230. package/dist/esm/export.js +27 -0
  231. package/dist/esm/index.d.ts +4 -10
  232. package/dist/esm/index.js +2 -9
  233. package/dist/esm/types/chart.d.ts +49 -14
  234. package/dist/esm/types/chart.js +12 -0
  235. package/dist/esm/types/config.d.ts +11 -0
  236. package/dist/esm/types/index.d.ts +1 -1
  237. package/dist/esm/types/index.js +1 -1
  238. package/dist/esm/types/map.d.ts +242 -0
  239. package/dist/esm/types/map.js +1 -0
  240. package/dist/esm/utils/config.d.ts +5 -5
  241. package/dist/esm/utils/config.js +40 -18
  242. package/dist/esm/utils/graph.d.ts +18 -0
  243. package/dist/esm/utils/graph.js +49 -0
  244. package/dist/esm/utils/index.d.ts +1 -1
  245. package/dist/esm/utils/index.js +1 -1
  246. package/dist/esm/utils/map/context.d.ts +3 -0
  247. package/dist/esm/utils/map/context.js +34 -0
  248. package/dist/esm/utils/map/controls.d.ts +0 -0
  249. package/dist/esm/utils/map/controls.js +0 -0
  250. package/dist/esm/utils/map/index.d.ts +6 -0
  251. package/dist/esm/utils/map/index.js +6 -0
  252. package/dist/esm/utils/map/markers.d.ts +2 -0
  253. package/dist/esm/utils/map/markers.js +64 -0
  254. package/dist/esm/utils/map/polyline.d.ts +2 -0
  255. package/dist/esm/utils/map/polyline.js +26 -0
  256. package/dist/esm/utils/map/style.d.ts +45 -0
  257. package/dist/esm/utils/map/style.js +76 -0
  258. package/dist/esm/utils/map/util.d.ts +1 -0
  259. package/dist/esm/utils/map/util.js +11 -0
  260. package/dist/esm/utils/map/view.d.ts +3 -0
  261. package/dist/esm/utils/map/view.js +81 -0
  262. package/dist/esm/utils/plot.d.ts +4 -0
  263. package/dist/esm/utils/plot.js +65 -0
  264. package/dist/esm/version.d.ts +2 -0
  265. package/dist/esm/version.js +1 -0
  266. package/dist/umd/861.async.js +1 -0
  267. package/dist/umd/index.min.js +1 -0
  268. package/package.json +97 -58
@@ -1,135 +1,38 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
- var _excluded = ["className", "style", "data", "children", "onSceneLoaded"];
6
- import { LarkMap, LineLayer, PointLayer, TextLayer } from '@antv/larkmap';
7
- import React, { useState } from 'react';
8
- import { getMapConfig } from "../utils/config";
9
- var lineLayerOptions = {
10
- autoFit: false,
11
- shape: 'line',
12
- size: 3,
13
- color: '#6808fed1',
14
- style: {
15
- opacity: 1,
16
- lineType: 'solid',
17
- stroke: '#6808FE',
18
- strokeWidth: 1
19
- }
20
- };
21
- var makerLayerOptions = {
22
- autoFit: false,
23
- shape: 'circle',
24
- color: '#fff',
25
- size: 4,
26
- style: {
27
- stroke: '#6808FE',
28
- strokeWidth: 3
29
- }
30
- };
31
- var labelLayerOptions = {
32
- autoFit: false,
33
- field: 'address',
34
- style: {
35
- fill: '#fff',
36
- opacity: 1,
37
- fontSize: 16,
38
- fontWeight: 'bold',
39
- stroke: '#6808FE',
40
- strokeWidth: 8,
41
- textAllowOverlap: false,
42
- padding: [5, 5],
43
- textOffset: [0, 30]
44
- }
45
- };
46
- function bbox(data) {
47
- var bounds = [Infinity, Infinity, -Infinity, -Infinity];
48
- data.forEach(function (_ref) {
49
- var coordinates = _ref.coordinates;
50
- coordinates.forEach(function (_ref2) {
51
- var _ref3 = _slicedToArray(_ref2, 2),
52
- lng = _ref3[0],
53
- lat = _ref3[1];
54
- if (bounds[0] > lng) {
55
- bounds[0] = lng;
56
- }
57
- if (bounds[1] > lat) {
58
- bounds[1] = lat;
59
- }
60
- if (bounds[2] < lng) {
61
- bounds[2] = lng;
62
- }
63
- if (bounds[3] < lat) {
64
- bounds[3] = lat;
65
- }
66
- });
67
- });
68
- return bounds;
69
- }
4
+ var _excluded = ["data", "markerStyle", "pathStyle"];
5
+ import React, { useMemo } from 'react';
6
+ import { useMapConfig } from "../ConfigProvider/hooks";
7
+ import Map from "../Map";
8
+ import { formatMakerStyle, formatPolylineStyle } from "../utils/map";
70
9
  var PathMap = function PathMap(props) {
71
- var className = props.className,
72
- style = props.style,
73
- _props$data = props.data,
74
- data = _props$data === void 0 ? [] : _props$data,
75
- children = props.children,
76
- onSceneLoaded = props.onSceneLoaded,
77
- mapConfigRest = _objectWithoutProperties(props, _excluded);
78
- var _useState = useState({
79
- data: data,
80
- parser: {
81
- type: 'json',
82
- coordinates: 'coordinates'
10
+ var _useMapConfig = useMapConfig('PathMap', props),
11
+ _useMapConfig$data = _useMapConfig.data,
12
+ data = _useMapConfig$data === void 0 ? [] : _useMapConfig$data,
13
+ _useMapConfig$markerS = _useMapConfig.markerStyle,
14
+ markerStyle = _useMapConfig$markerS === void 0 ? {} : _useMapConfig$markerS,
15
+ _useMapConfig$pathSty = _useMapConfig.pathStyle,
16
+ pathStyle = _useMapConfig$pathSty === void 0 ? {} : _useMapConfig$pathSty,
17
+ rest = _objectWithoutProperties(_useMapConfig, _excluded);
18
+ var markerdata = useMemo(function () {
19
+ var markers = [];
20
+ data.forEach(function (item) {
21
+ if (item.markers) {
22
+ markers.push.apply(markers, _toConsumableArray(item.markers));
83
23
  }
84
- }),
85
- _useState2 = _slicedToArray(_useState, 1),
86
- lineSource = _useState2[0];
87
- var _useState3 = useState(function () {
88
- return {
89
- data: data.map(function (item) {
90
- return [{
91
- lngLat: item.coordinates[0],
92
- address: item === null || item === void 0 ? void 0 : item.originName
93
- }, {
94
- lngLat: item.coordinates[item.coordinates.length - 1],
95
- address: item === null || item === void 0 ? void 0 : item.destinationName
96
- }];
97
- }).flat().filter(function (item) {
98
- return item.address;
99
- }),
100
- parser: {
101
- type: 'json',
102
- coordinates: 'lngLat'
103
- }
104
- };
105
- }),
106
- _useState4 = _slicedToArray(_useState3, 1),
107
- dotSource = _useState4[0];
108
- var mapConfig = getMapConfig(mapConfigRest);
109
- var onMapSceneLoaded = function onMapSceneLoaded(scene) {
110
- onSceneLoaded === null || onSceneLoaded === void 0 || onSceneLoaded(scene);
111
- if (!data.length) return;
112
- var bounds = bbox(data);
113
- if (scene.getType() === 'amap') {
114
- var _scene$map;
115
- (_scene$map = scene.map) === null || _scene$map === void 0 || _scene$map.setBounds(bounds, true, [60, 60, 60, 60]);
116
- } else {
117
- scene.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]]);
118
- }
119
- };
120
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LarkMap, _extends({
121
- className: className,
122
- style: _objectSpread({
123
- height: 300
124
- }, style)
125
- }, mapConfig, {
126
- onSceneLoaded: onMapSceneLoaded
127
- }), /*#__PURE__*/React.createElement(LineLayer, _extends({}, lineLayerOptions, {
128
- source: lineSource
129
- })), /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
130
- source: dotSource
131
- })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
132
- source: dotSource
133
- })), children));
24
+ });
25
+ return formatMakerStyle(markers, markerStyle);
26
+ }, [data, markerStyle]);
27
+ var linedata = useMemo(function () {
28
+ var lines = data.map(function (item) {
29
+ return item.path;
30
+ });
31
+ return formatPolylineStyle(lines, pathStyle);
32
+ }, [data, pathStyle]);
33
+ return /*#__PURE__*/React.createElement(Map, _extends({
34
+ markers: markerdata,
35
+ polyline: linedata
36
+ }, rest));
134
37
  };
135
38
  export default PathMap;
@@ -1,19 +1,21 @@
1
+ import type { PieConfig } from '@ant-design/plots';
1
2
  import React from 'react';
2
- import { BaseChartProps } from '../types';
3
+ import type { BasePlotProps } from '../types';
3
4
  /**
4
5
  * PieDataItem is the type for each data item in the pie chart.
5
6
  * It includes the name of the sector and its corresponding value.
6
- * @param name The name of the sector.
7
+ * @param category The name of the sector.
7
8
  * @param value The value of the sector.
8
9
  */
9
- export type PieDataItem = {
10
- name: string;
10
+ type PieDataItem = {
11
+ category: string;
11
12
  value: number;
13
+ [key: string]: string | number;
12
14
  };
13
15
  /**
14
16
  * the props for the Pie
15
17
  * @param data pie data
16
18
  */
17
- export type PieProps = BaseChartProps<PieDataItem>;
19
+ export type PieProps = BasePlotProps<PieDataItem> & Partial<PieConfig>;
18
20
  declare const Pie: (props: PieProps) => React.JSX.Element;
19
21
  export default Pie;
@@ -1,12 +1,12 @@
1
- import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
1
  import { Pie as ADCPie } from '@ant-design/plots';
2
+ import { round, sumBy } from 'lodash';
4
3
  import React from 'react';
4
+ import { usePlotConfig } from "../ConfigProvider/hooks";
5
5
 
6
6
  /**
7
7
  * PieDataItem is the type for each data item in the pie chart.
8
8
  * It includes the name of the sector and its corresponding value.
9
- * @param name The name of the sector.
9
+ * @param category The name of the sector.
10
10
  * @param value The value of the sector.
11
11
  */
12
12
 
@@ -15,24 +15,28 @@ import React from 'react';
15
15
  * @param data pie data
16
16
  */
17
17
 
18
- var Pie = function Pie(props) {
19
- var data = props.data,
20
- className = props.className,
21
- style = props.style;
22
- var config = {
23
- data: data,
24
- angleField: 'value',
25
- colorField: 'name',
18
+ var defaultConfig = function defaultConfig(props) {
19
+ var _props$data = props.data,
20
+ data = _props$data === void 0 ? [] : _props$data,
21
+ _props$angleField = props.angleField,
22
+ angleField = _props$angleField === void 0 ? 'value' : _props$angleField,
23
+ _props$colorField = props.colorField,
24
+ colorField = _props$colorField === void 0 ? 'category' : _props$colorField;
25
+ var sumValue = sumBy(data, angleField);
26
+ return {
27
+ angleField: angleField,
28
+ colorField: colorField,
26
29
  tooltip: function tooltip(d) {
27
30
  return {
28
- name: d.name,
29
- value: d.value
31
+ name: d[colorField],
32
+ value: d[angleField]
30
33
  };
31
34
  },
32
35
  label: {
33
- text: 'value',
34
- style: {
35
- fontWeight: 'bold'
36
+ position: 'outside',
37
+ // text: angleField,
38
+ text: function text(d) {
39
+ return "".concat(d[colorField], ": ").concat(round(d[angleField] / sumValue * 100, 1), "%");
36
40
  }
37
41
  },
38
42
  legend: {
@@ -47,9 +51,9 @@ var Pie = function Pie(props) {
47
51
  }
48
52
  }
49
53
  };
50
- return /*#__PURE__*/React.createElement(ADCPie, _extends({
51
- className: className,
52
- containerStyle: _objectSpread({}, style)
53
- }, config));
54
+ };
55
+ var Pie = function Pie(props) {
56
+ var config = usePlotConfig('Pie', defaultConfig, props);
57
+ return /*#__PURE__*/React.createElement(ADCPie, config);
54
58
  };
55
59
  export default Pie;
@@ -1,12 +1,6 @@
1
1
  import { type FC } from 'react';
2
- import { BaseMapProps } from '../types';
3
- type GeoData = {
4
- address: string;
5
- lng: number;
6
- lat: number;
7
- };
8
- export interface PinMapProps extends BaseMapProps<GeoData> {
9
- className?: string;
10
- }
2
+ import type { MapProps } from '../Map';
3
+ import type { PinMap as PinMapType } from '../types/map';
4
+ export type PinMapProps = PinMapType & MapProps;
11
5
  declare const PinMap: FC<PinMapProps>;
12
6
  export default PinMap;
@@ -1,109 +1,23 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["className", "style", "onSceneLoaded", "children", "data"];
6
- import { LarkMap, PointLayer, TextLayer } from '@antv/larkmap';
7
- import React, { useState } from 'react';
8
- import { getMapConfig } from "../utils";
9
-
10
- // const SVG_BLOB = new Blob(
11
- // [
12
- // `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" height="48px" width="48px" viewBox="0 0 1024 1024"><path d="M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z" fill="#6808FE"></path></svg>`,
13
- // ],
14
- // { type: 'image/svg+xml;charset=utf-8' },
15
- // );
16
- // const SVG_URL = URL.createObjectURL(SVG_BLOB);
17
- var SVG_URL = 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*yVhwTrhcKZAAAAAAAAAAAAAADmJ7AQ/original';
18
- var makerLayerOptions = {
19
- autoFit: false,
20
- shape: 'marker',
21
- size: 22,
22
- style: {}
23
- };
24
- var labelLayerOptions = {
25
- autoFit: false,
26
- field: 'address',
27
- style: {
28
- fill: '#fff',
29
- opacity: 1,
30
- fontSize: 16,
31
- fontWeight: 'bold',
32
- stroke: '#6808FE',
33
- strokeWidth: 8,
34
- textAllowOverlap: false,
35
- padding: [2, 2],
36
- textOffset: [0, 50]
37
- }
38
- };
39
- function bbox(data) {
40
- var bounds = [Infinity, Infinity, -Infinity, -Infinity];
41
- data.forEach(function (_ref) {
42
- var lng = _ref.lng,
43
- lat = _ref.lat;
44
- if (bounds[0] > lng) {
45
- bounds[0] = lng;
46
- }
47
- if (bounds[1] > lat) {
48
- bounds[1] = lat;
49
- }
50
- if (bounds[2] < lng) {
51
- bounds[2] = lng;
52
- }
53
- if (bounds[3] < lat) {
54
- bounds[3] = lat;
55
- }
56
- });
57
- return bounds;
58
- }
3
+ var _excluded = ["data", "markerStyle"];
4
+ import React, { useMemo } from 'react';
5
+ import { useMapConfig } from "../ConfigProvider/hooks";
6
+ import Map from "../Map";
7
+ import { formatMakerStyle } from "../utils/map";
59
8
  var PinMap = function PinMap(props) {
60
- var className = props.className,
61
- style = props.style,
62
- onSceneLoaded = props.onSceneLoaded,
63
- children = props.children,
64
- _props$data = props.data,
65
- data = _props$data === void 0 ? [] : _props$data,
66
- mapConfigRest = _objectWithoutProperties(props, _excluded);
67
- var _useState = useState(false),
68
- _useState2 = _slicedToArray(_useState, 2),
69
- loadedImages = _useState2[0],
70
- setLoadedImages = _useState2[1];
71
- var _useState3 = useState({
72
- data: data,
73
- parser: {
74
- type: 'json',
75
- x: 'lng',
76
- y: 'lat'
77
- }
78
- }),
79
- _useState4 = _slicedToArray(_useState3, 1),
80
- source = _useState4[0];
81
- var mapConfig = getMapConfig(mapConfigRest);
82
- var onMapSceneLoaded = function onMapSceneLoaded(scene) {
83
- onSceneLoaded === null || onSceneLoaded === void 0 || onSceneLoaded(scene);
84
- scene.addImage('marker', SVG_URL).then(function () {
85
- setLoadedImages(true);
86
- });
87
- if (!data.length) return;
88
- var bounds = bbox(data);
89
- if (scene.getType() === 'amap') {
90
- var _scene$map;
91
- (_scene$map = scene.map) === null || _scene$map === void 0 || _scene$map.setBounds(bounds, true, [50, 50, 50, 50]);
92
- } else {
93
- scene.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]]);
94
- }
95
- };
96
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LarkMap, _extends({
97
- className: className,
98
- style: _objectSpread({
99
- height: 300
100
- }, style)
101
- }, mapConfig, {
102
- onSceneLoaded: onMapSceneLoaded
103
- }), loadedImages && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
104
- source: source
105
- })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
106
- source: source
107
- }))), children));
9
+ var _useMapConfig = useMapConfig('PinMap', props),
10
+ _useMapConfig$data = _useMapConfig.data,
11
+ data = _useMapConfig$data === void 0 ? [] : _useMapConfig$data,
12
+ _useMapConfig$markerS = _useMapConfig.markerStyle,
13
+ markerStyle = _useMapConfig$markerS === void 0 ? {} : _useMapConfig$markerS,
14
+ rest = _objectWithoutProperties(_useMapConfig, _excluded);
15
+ var markerdata = useMemo(function () {
16
+ return formatMakerStyle(data, markerStyle);
17
+ }, [data, markerStyle]);
18
+ return /*#__PURE__*/React.createElement(Map, _extends({
19
+ markers: markerdata,
20
+ includePoints: markerdata
21
+ }, rest));
108
22
  };
109
23
  export default PinMap;
@@ -0,0 +1,11 @@
1
+ import type { RadarConfig } from '@ant-design/plots';
2
+ import React from 'react';
3
+ import type { BasePlotProps } from '../types';
4
+ export type RadarDataItem = {
5
+ name: string;
6
+ value: number;
7
+ [key: string]: string | number;
8
+ };
9
+ export type RadarProps = BasePlotProps<RadarDataItem> & Partial<RadarConfig>;
10
+ declare const Radar: (props: RadarProps) => React.JSX.Element;
11
+ export default Radar;
@@ -0,0 +1,54 @@
1
+ import { Radar as ADCRadar } from '@ant-design/plots';
2
+ import { get } from 'lodash';
3
+ import React from 'react';
4
+ import { usePlotConfig } from "../ConfigProvider/hooks";
5
+ var defaultConfig = function defaultConfig(props) {
6
+ var data = props.data,
7
+ _props$xField = props.xField,
8
+ xField = _props$xField === void 0 ? 'name' : _props$xField,
9
+ _props$yField = props.yField,
10
+ yField = _props$yField === void 0 ? 'value' : _props$yField;
11
+ var hasGroupField = get(data, '[0].group') !== undefined;
12
+ return {
13
+ xField: xField,
14
+ yField: yField,
15
+ colorField: hasGroupField ? 'group' : undefined,
16
+ area: {
17
+ style: {
18
+ fillOpacity: 0.5
19
+ }
20
+ },
21
+ scale: {
22
+ x: {
23
+ padding: 0.6,
24
+ align: 0
25
+ },
26
+ y: {
27
+ nice: true
28
+ }
29
+ },
30
+ axis: {
31
+ x: {
32
+ title: false,
33
+ grid: true
34
+ },
35
+ y: {
36
+ zIndex: 1,
37
+ title: false,
38
+ gridConnect: 'line',
39
+ gridLineWidth: 1
40
+ }
41
+ },
42
+ tooltip: function tooltip(d) {
43
+ return {
44
+ name: d[xField],
45
+ value: d[yField]
46
+ };
47
+ }
48
+ };
49
+ };
50
+ var Radar = function Radar(props) {
51
+ var config = usePlotConfig('Radar', defaultConfig, props);
52
+ return /*#__PURE__*/React.createElement(ADCRadar, config);
53
+ };
54
+ export default Radar;
@@ -0,0 +1,11 @@
1
+ import type { ScatterConfig } from '@ant-design/plots';
2
+ import React from 'react';
3
+ import type { BasePlotProps } from '../types';
4
+ type ScatterDataItem = {
5
+ x: number;
6
+ y: number;
7
+ [key: string]: string | number;
8
+ };
9
+ export type ScatterProps = BasePlotProps<ScatterDataItem> & Partial<ScatterConfig>;
10
+ declare const Scatter: (props: ScatterProps) => React.JSX.Element;
11
+ export default Scatter;
@@ -0,0 +1,30 @@
1
+ import { Scatter as ADCScatter } from '@ant-design/plots';
2
+ import { get } from 'lodash';
3
+ import React from 'react';
4
+ import { usePlotConfig } from "../ConfigProvider/hooks";
5
+ var defaultConfig = function defaultConfig(props) {
6
+ var data = props.data,
7
+ _props$xField = props.xField,
8
+ xField = _props$xField === void 0 ? 'x' : _props$xField,
9
+ _props$yField = props.yField,
10
+ yField = _props$yField === void 0 ? 'y' : _props$yField;
11
+ var axisXTitle = get(props, 'axis.x.title');
12
+ var axisYTitle = get(props, 'axis.y.title');
13
+ return {
14
+ data: data,
15
+ xField: xField,
16
+ yField: yField,
17
+ tooltip: [{
18
+ channel: 'x',
19
+ name: axisXTitle || 'x'
20
+ }, {
21
+ channel: 'y',
22
+ name: axisYTitle || 'y'
23
+ }]
24
+ };
25
+ };
26
+ var Scatter = function Scatter(props) {
27
+ var config = usePlotConfig('Scatter', defaultConfig, props);
28
+ return /*#__PURE__*/React.createElement(ADCScatter, config);
29
+ };
30
+ export default Scatter;
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { VisTextProps } from './types';
3
+ declare const VisText: (props: VisTextProps) => React.JSX.Element;
4
+ export default VisText;
@@ -0,0 +1,34 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import { Tooltip, Typography } from 'antd';
3
+ import { pick, toString } from 'lodash';
4
+ import React from 'react';
5
+ import { useComponentGlobalConfig } from "../ConfigProvider/hooks";
6
+ import { STATICS_KEY } from "./config";
7
+ var Text = Typography.Text;
8
+ function renderPrefixSuffix(symbol, staticsConfig, props) {
9
+ if (!symbol) return null;
10
+ var Component = staticsConfig === null || staticsConfig === void 0 ? void 0 : staticsConfig[symbol];
11
+ if (Component) return /*#__PURE__*/React.createElement(Component, props);
12
+ return symbol;
13
+ }
14
+ var VisText = function VisText(props) {
15
+ var children = props.children,
16
+ className = props.className,
17
+ style = props.style,
18
+ type = props.type,
19
+ origin = props.origin;
20
+ var textConfig = useComponentGlobalConfig('VisText');
21
+ var encoding = type ? textConfig === null || textConfig === void 0 ? void 0 : textConfig[type] : {};
22
+ var staticsConfig = textConfig === null || textConfig === void 0 ? void 0 : textConfig[STATICS_KEY];
23
+ return (
24
+ /*#__PURE__*/
25
+ // TODO @羽熙 暂时简单处理 tooltip 直接显示 origin,后续可以根据 origin 类型分类处理
26
+ React.createElement(Tooltip, {
27
+ title: toString(origin)
28
+ }, /*#__PURE__*/React.createElement(Text, {
29
+ className: className,
30
+ style: _objectSpread(_objectSpread({}, style), pick(encoding, ['color', 'backgroundColor', 'fontWeight']))
31
+ }, renderPrefixSuffix(encoding === null || encoding === void 0 ? void 0 : encoding.prefix, staticsConfig, props), children, renderPrefixSuffix(encoding === null || encoding === void 0 ? void 0 : encoding.suffix, staticsConfig, props)))
32
+ );
33
+ };
34
+ export default VisText;
@@ -0,0 +1,18 @@
1
+ import type { CSSProperties } from 'react';
2
+ import type { VisTextProps } from './types';
3
+ declare const INNER_ENTITY_TYPES: readonly ["metric_name", "metric_value", "other_metric_value", "time_desc", "dim_value", "trend_desc", "delta_value", "ratio_value", "delta_value_pos", "delta_value_neg", "ratio_value_pos", "ratio_value_neg", "proportion", "contribute_ratio"];
4
+ export type InnerEntityType = (typeof INNER_ENTITY_TYPES)[number];
5
+ export type TextEntityType = InnerEntityType | string;
6
+ export type TextEncoding = Partial<Pick<CSSProperties, 'color' | 'backgroundColor' | 'fontWeight'> & {
7
+ /** 前缀 */
8
+ prefix: string;
9
+ /** 后缀 */
10
+ suffix: string;
11
+ }>;
12
+ export declare const STATICS_KEY: "__statics";
13
+ /** 文本组件配置信息 */
14
+ export type TextConfig = Record<InnerEntityType & string, TextEncoding> & {
15
+ [STATICS_KEY]: Record<string, React.FC<VisTextProps>>;
16
+ };
17
+ export declare const DEFAULT_VIS_TEXT_CONFIG: TextConfig;
18
+ export {};
@@ -0,0 +1,79 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ var _DEFAULT_VIS_TEXT_CON;
3
+ import { TEXT_THEME } from "./constants";
4
+ import { ArrowDown, ArrowUp } from "./custom-icons";
5
+ import { ProportionChart, SingleLineChart } from "./mini-charts";
6
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
7
+ var INNER_ENTITY_TYPES = ['metric_name',
8
+ // 指标名
9
+ 'metric_value',
10
+ // 主指标值
11
+ 'other_metric_value',
12
+ // 其他指标值
13
+ 'time_desc',
14
+ // 时间描述
15
+ 'dim_value',
16
+ // 维值
17
+ 'trend_desc',
18
+ // 趋势描述
19
+ 'delta_value',
20
+ // 变化值(非正非负)
21
+ 'ratio_value',
22
+ // 变化率(非正非负)
23
+ 'delta_value_pos',
24
+ // 变化值正
25
+ 'delta_value_neg',
26
+ // 变化值负
27
+ 'ratio_value_pos',
28
+ // 变化率正
29
+ 'ratio_value_neg',
30
+ // 变化率负
31
+ 'proportion',
32
+ // 占比
33
+ 'contribute_ratio' // 贡献度
34
+ ];
35
+ export var STATICS_KEY = '__statics';
36
+
37
+ /** 文本组件配置信息 */
38
+
39
+ export var DEFAULT_VIS_TEXT_CONFIG = (_DEFAULT_VIS_TEXT_CON = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DEFAULT_VIS_TEXT_CON, STATICS_KEY, {
40
+ 'icon:arrow-up': ArrowUp,
41
+ 'icon:arrow-down': ArrowDown,
42
+ 'mini-chart:proportion': ProportionChart,
43
+ // TODO @羽熙 当前仅支持单折线图,之后可以考虑支持多折线图,在组件内实现分支判断
44
+ 'mini-chart:line': SingleLineChart
45
+ }), "metric_name", {
46
+ color: TEXT_THEME.black88,
47
+ fontWeight: 500
48
+ }), "metric_value", {
49
+ color: TEXT_THEME.primaryColor
50
+ }), "other_metric_value", {
51
+ color: TEXT_THEME.black65
52
+ }), "delta_value", {
53
+ color: TEXT_THEME.black65
54
+ }), "ratio_value", {
55
+ color: TEXT_THEME.black65
56
+ }), "delta_value_pos", {
57
+ color: TEXT_THEME.posColor,
58
+ prefix: '+'
59
+ }), "delta_value_neg", {
60
+ color: TEXT_THEME.negColor,
61
+ prefix: '-'
62
+ }), "ratio_value_pos", {
63
+ color: TEXT_THEME.posColor,
64
+ prefix: 'icon:arrow-up'
65
+ }), "ratio_value_neg", {
66
+ color: TEXT_THEME.negColor,
67
+ prefix: 'icon:arrow-down'
68
+ }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_DEFAULT_VIS_TEXT_CON, "contribute_ratio", {
69
+ color: TEXT_THEME.statisticsInsightColor
70
+ }), "trend_desc", {
71
+ color: TEXT_THEME.statisticsInsightColor,
72
+ suffix: 'mini-chart:line'
73
+ }), "dim_value", {
74
+ color: TEXT_THEME.black88
75
+ }), "time_desc", {
76
+ color: TEXT_THEME.black88
77
+ }), "proportion", {
78
+ suffix: 'mini-chart:proportion'
79
+ }));