@antv/gpt-vis 0.0.5 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (270) 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 +21 -29
  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 +7 -0
  24. package/dist/cjs/ConfigProvider/index.js +43 -0
  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 +4 -9
  33. package/dist/cjs/HeatMap/index.d.ts +7 -7
  34. package/dist/cjs/HeatMap/index.js +13 -36
  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 -2
  40. package/dist/cjs/Line/index.js +15 -17
  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 -111
  52. package/dist/cjs/Pie/index.d.ts +7 -5
  53. package/dist/cjs/Pie/index.js +17 -16
  54. package/dist/cjs/PinMap/index.d.ts +3 -9
  55. package/dist/cjs/PinMap/index.js +6 -87
  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 +2 -2
  97. package/dist/cjs/constants/index.js +8 -27
  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 -11
  101. package/dist/cjs/index.js +5 -18
  102. package/dist/cjs/types/chart.d.ts +65 -0
  103. package/dist/cjs/types/chart.js +51 -0
  104. package/dist/cjs/types/config.d.ts +20 -0
  105. package/dist/cjs/types/config.js +17 -0
  106. package/dist/cjs/types/index.d.ts +2 -26
  107. package/dist/cjs/types/index.js +3 -19
  108. package/dist/cjs/types/map.d.ts +242 -0
  109. package/dist/cjs/types/map.js +17 -0
  110. package/dist/cjs/utils/config.d.ts +5 -0
  111. package/dist/cjs/utils/config.js +76 -0
  112. package/dist/cjs/utils/graph.d.ts +18 -0
  113. package/dist/cjs/utils/graph.js +64 -0
  114. package/dist/cjs/utils/index.d.ts +1 -0
  115. package/dist/cjs/utils/index.js +23 -0
  116. package/dist/cjs/utils/map/context.d.ts +3 -0
  117. package/dist/cjs/utils/map/context.js +42 -0
  118. package/dist/cjs/utils/map/controls.d.ts +0 -0
  119. package/dist/cjs/utils/map/controls.js +0 -0
  120. package/dist/cjs/utils/map/index.d.ts +6 -0
  121. package/dist/cjs/utils/map/index.js +33 -0
  122. package/dist/cjs/utils/map/markers.d.ts +2 -0
  123. package/dist/cjs/utils/map/markers.js +88 -0
  124. package/dist/cjs/utils/map/polyline.d.ts +2 -0
  125. package/dist/cjs/utils/map/polyline.js +52 -0
  126. package/dist/cjs/utils/map/style.d.ts +45 -0
  127. package/dist/cjs/utils/map/style.js +112 -0
  128. package/dist/cjs/utils/map/util.d.ts +1 -0
  129. package/dist/cjs/utils/map/util.js +38 -0
  130. package/dist/cjs/utils/map/view.d.ts +3 -0
  131. package/dist/cjs/utils/map/view.js +93 -0
  132. package/dist/cjs/utils/plot.d.ts +4 -0
  133. package/dist/cjs/utils/plot.js +69 -0
  134. package/dist/cjs/version.d.ts +2 -0
  135. package/dist/cjs/version.js +25 -0
  136. package/dist/esm/Area/index.d.ts +8 -2
  137. package/dist/esm/Area/index.js +21 -27
  138. package/dist/esm/Bar/index.d.ts +11 -0
  139. package/dist/esm/Bar/index.js +35 -0
  140. package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
  141. package/dist/esm/ChartCodeRender/Loading.js +20 -0
  142. package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
  143. package/dist/esm/ChartCodeRender/VisChart.js +65 -0
  144. package/dist/esm/ChartCodeRender/index.d.ts +3 -4
  145. package/dist/esm/ChartCodeRender/index.js +28 -84
  146. package/dist/esm/ChartCodeRender/type.d.ts +9 -11
  147. package/dist/esm/Column/index.d.ts +8 -2
  148. package/dist/esm/Column/index.js +24 -29
  149. package/dist/esm/ConfigProvider/context.d.ts +3 -0
  150. package/dist/esm/ConfigProvider/context.js +3 -0
  151. package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
  152. package/dist/esm/ConfigProvider/hooks/index.js +1 -0
  153. package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
  154. package/dist/esm/ConfigProvider/hooks/useConfig.js +55 -0
  155. package/dist/esm/ConfigProvider/index.d.ts +7 -0
  156. package/dist/esm/ConfigProvider/index.js +16 -0
  157. package/dist/esm/DualAxes/index.d.ts +15 -0
  158. package/dist/esm/DualAxes/index.js +44 -0
  159. package/dist/esm/DualAxes/util.d.ts +9 -0
  160. package/dist/esm/DualAxes/util.js +61 -0
  161. package/dist/esm/FlowDiagram/index.d.ts +6 -0
  162. package/dist/esm/FlowDiagram/index.js +75 -0
  163. package/dist/esm/GPTVis/index.d.ts +7 -7
  164. package/dist/esm/GPTVis/index.js +4 -4
  165. package/dist/esm/HeatMap/index.d.ts +7 -7
  166. package/dist/esm/HeatMap/index.js +21 -36
  167. package/dist/esm/Histogram/index.d.ts +10 -0
  168. package/dist/esm/Histogram/index.js +25 -0
  169. package/dist/esm/IndentedTree/index.d.ts +6 -0
  170. package/dist/esm/IndentedTree/index.js +47 -0
  171. package/dist/esm/Line/index.d.ts +8 -2
  172. package/dist/esm/Line/index.js +18 -25
  173. package/dist/esm/Map/data.json +305 -0
  174. package/dist/esm/Map/index.d.ts +5 -0
  175. package/dist/esm/Map/index.js +60 -0
  176. package/dist/esm/MindMap/index.d.ts +6 -0
  177. package/dist/esm/MindMap/index.js +48 -0
  178. package/dist/esm/NetworkGraph/index.d.ts +6 -0
  179. package/dist/esm/NetworkGraph/index.js +57 -0
  180. package/dist/esm/OrganizationChart/index.d.ts +6 -0
  181. package/dist/esm/OrganizationChart/index.js +64 -0
  182. package/dist/esm/PathMap/index.d.ts +3 -9
  183. package/dist/esm/PathMap/index.js +33 -135
  184. package/dist/esm/Pie/index.d.ts +7 -5
  185. package/dist/esm/Pie/index.js +24 -25
  186. package/dist/esm/PinMap/index.d.ts +3 -9
  187. package/dist/esm/PinMap/index.js +19 -110
  188. package/dist/esm/Radar/index.d.ts +11 -0
  189. package/dist/esm/Radar/index.js +54 -0
  190. package/dist/esm/Scatter/index.d.ts +11 -0
  191. package/dist/esm/Scatter/index.js +30 -0
  192. package/dist/esm/Text/VisText.d.ts +4 -0
  193. package/dist/esm/Text/VisText.js +34 -0
  194. package/dist/esm/Text/config.d.ts +18 -0
  195. package/dist/esm/Text/config.js +79 -0
  196. package/dist/esm/Text/constants.d.ts +9 -0
  197. package/dist/esm/Text/constants.js +9 -0
  198. package/dist/esm/Text/custom-icons/index.d.ts +3 -0
  199. package/dist/esm/Text/custom-icons/index.js +37 -0
  200. package/dist/esm/Text/index.d.ts +3 -0
  201. package/dist/esm/Text/index.js +2 -0
  202. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
  203. package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
  204. package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
  205. package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
  206. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
  207. package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
  208. package/dist/esm/Text/mini-charts/index.d.ts +2 -0
  209. package/dist/esm/Text/mini-charts/index.js +2 -0
  210. package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
  211. package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
  212. package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
  213. package/dist/esm/Text/mini-charts/line/index.js +1 -0
  214. package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
  215. package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
  216. package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
  217. package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
  218. package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
  219. package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
  220. package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
  221. package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
  222. package/dist/esm/Text/types.d.ts +20 -0
  223. package/dist/esm/Text/types.js +1 -0
  224. package/dist/esm/Treemap/index.d.ts +11 -0
  225. package/dist/esm/Treemap/index.js +52 -0
  226. package/dist/esm/WordCloud/index.d.ts +4 -5
  227. package/dist/esm/WordCloud/index.js +8 -18
  228. package/dist/esm/constants/index.d.ts +2 -2
  229. package/dist/esm/constants/index.js +9 -8
  230. package/dist/esm/export.d.ts +25 -0
  231. package/dist/esm/export.js +27 -0
  232. package/dist/esm/index.d.ts +4 -11
  233. package/dist/esm/index.js +2 -15
  234. package/dist/esm/types/chart.d.ts +65 -0
  235. package/dist/esm/types/chart.js +23 -0
  236. package/dist/esm/types/config.d.ts +20 -0
  237. package/dist/esm/types/config.js +1 -0
  238. package/dist/esm/types/index.d.ts +2 -26
  239. package/dist/esm/types/index.js +2 -11
  240. package/dist/esm/types/map.d.ts +242 -0
  241. package/dist/esm/types/map.js +1 -0
  242. package/dist/esm/utils/config.d.ts +5 -0
  243. package/dist/esm/utils/config.js +48 -0
  244. package/dist/esm/utils/graph.d.ts +18 -0
  245. package/dist/esm/utils/graph.js +49 -0
  246. package/dist/esm/utils/index.d.ts +1 -0
  247. package/dist/esm/utils/index.js +1 -0
  248. package/dist/esm/utils/map/context.d.ts +3 -0
  249. package/dist/esm/utils/map/context.js +34 -0
  250. package/dist/esm/utils/map/controls.d.ts +0 -0
  251. package/dist/esm/utils/map/controls.js +0 -0
  252. package/dist/esm/utils/map/index.d.ts +6 -0
  253. package/dist/esm/utils/map/index.js +6 -0
  254. package/dist/esm/utils/map/markers.d.ts +2 -0
  255. package/dist/esm/utils/map/markers.js +64 -0
  256. package/dist/esm/utils/map/polyline.d.ts +2 -0
  257. package/dist/esm/utils/map/polyline.js +26 -0
  258. package/dist/esm/utils/map/style.d.ts +45 -0
  259. package/dist/esm/utils/map/style.js +76 -0
  260. package/dist/esm/utils/map/util.d.ts +1 -0
  261. package/dist/esm/utils/map/util.js +11 -0
  262. package/dist/esm/utils/map/view.d.ts +3 -0
  263. package/dist/esm/utils/map/view.js +81 -0
  264. package/dist/esm/utils/plot.d.ts +4 -0
  265. package/dist/esm/utils/plot.js +65 -0
  266. package/dist/esm/version.d.ts +2 -0
  267. package/dist/esm/version.js +1 -0
  268. package/dist/umd/861.async.js +1 -0
  269. package/dist/umd/index.min.js +1 -0
  270. package/package.json +97 -59
@@ -1,140 +1,38 @@
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
- import { LarkMap, LineLayer, PointLayer, TextLayer } from '@antv/larkmap';
5
- import React, { useState } from 'react';
6
- window._AMapSecurityConfig = {
7
- securityJsCode: '8803c38931b6fddc9bbfeee69df8824d'
8
- };
9
- var CONFIG = {
10
- mapType: 'Gaode',
11
- mapOptions: {
12
- style: 'normal',
13
- center: [120.210792, 30.246026],
14
- zoom: 12,
15
- maxZoom: 18,
16
- token: 'f0230f884bbd54e2913c890cdf45aa7e'
17
- }
18
- };
19
- var lineLayerOptions = {
20
- autoFit: false,
21
- shape: 'line',
22
- size: 3,
23
- color: '#6808fed1',
24
- style: {
25
- opacity: 1,
26
- lineType: 'solid',
27
- stroke: '#6808FE',
28
- strokeWidth: 1
29
- }
30
- };
31
- var makerLayerOptions = {
32
- autoFit: false,
33
- shape: 'circle',
34
- color: '#fff',
35
- size: 4,
36
- style: {
37
- stroke: '#6808FE',
38
- strokeWidth: 3
39
- }
40
- };
41
- var labelLayerOptions = {
42
- autoFit: false,
43
- field: 'address',
44
- style: {
45
- fill: '#fff',
46
- opacity: 1,
47
- fontSize: 16,
48
- fontWeight: 'bold',
49
- stroke: '#6808FE',
50
- strokeWidth: 8,
51
- textAllowOverlap: false,
52
- padding: [5, 5],
53
- textOffset: [0, 30]
54
- }
55
- };
56
- function bbox(data) {
57
- var bounds = [Infinity, Infinity, -Infinity, -Infinity];
58
- data.forEach(function (_ref) {
59
- var coordinates = _ref.coordinates;
60
- coordinates.forEach(function (_ref2) {
61
- var _ref3 = _slicedToArray(_ref2, 2),
62
- lng = _ref3[0],
63
- lat = _ref3[1];
64
- if (bounds[0] > lng) {
65
- bounds[0] = lng;
66
- }
67
- if (bounds[1] > lat) {
68
- bounds[1] = lat;
69
- }
70
- if (bounds[2] < lng) {
71
- bounds[2] = lng;
72
- }
73
- if (bounds[3] < lat) {
74
- bounds[3] = lat;
75
- }
76
- });
77
- });
78
- return bounds;
79
- }
2
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
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";
80
9
  var PathMap = function PathMap(props) {
81
- var className = props.className,
82
- style = props.style,
83
- _props$data = props.data,
84
- data = _props$data === void 0 ? [] : _props$data;
85
- var _useState = useState({
86
- data: data,
87
- parser: {
88
- type: 'json',
89
- 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));
90
23
  }
91
- }),
92
- _useState2 = _slicedToArray(_useState, 1),
93
- lineSource = _useState2[0];
94
- var _useState3 = useState(function () {
95
- return {
96
- data: data.map(function (item) {
97
- return [{
98
- lngLat: item.coordinates[0],
99
- address: item === null || item === void 0 ? void 0 : item.originName
100
- }, {
101
- lngLat: item.coordinates[item.coordinates.length - 1],
102
- address: item === null || item === void 0 ? void 0 : item.destinationName
103
- }];
104
- }).flat().filter(function (item) {
105
- return item.address;
106
- }),
107
- parser: {
108
- type: 'json',
109
- coordinates: 'lngLat'
110
- }
111
- };
112
- }),
113
- _useState4 = _slicedToArray(_useState3, 1),
114
- dotSource = _useState4[0];
115
- var onSceneLoaded = function onSceneLoaded(scene) {
116
- if (!data.length) return;
117
- var bounds = bbox(data);
118
- if (scene.getType() === 'amap') {
119
- var _scene$map;
120
- (_scene$map = scene.map) === null || _scene$map === void 0 || _scene$map.setBounds(bounds, true, [60, 60, 60, 60]);
121
- } else {
122
- scene.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]]);
123
- }
124
- };
125
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LarkMap, _extends({
126
- className: className,
127
- style: _objectSpread({
128
- height: 300
129
- }, style)
130
- }, CONFIG, {
131
- onSceneLoaded: onSceneLoaded
132
- }), /*#__PURE__*/React.createElement(LineLayer, _extends({}, lineLayerOptions, {
133
- source: lineSource
134
- })), /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
135
- source: dotSource
136
- })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
137
- source: dotSource
138
- }))));
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));
139
37
  };
140
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,29 +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',
26
- state: {
27
- selected: {
28
- offset: 8
29
- }
30
- },
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,
31
29
  tooltip: function tooltip(d) {
32
30
  return {
33
- name: d.name,
34
- value: d.value
31
+ name: d[colorField],
32
+ value: d[angleField]
35
33
  };
36
34
  },
37
35
  label: {
38
- text: 'value',
39
- style: {
40
- 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), "%");
41
40
  }
42
41
  },
43
42
  legend: {
@@ -52,9 +51,9 @@ var Pie = function Pie(props) {
52
51
  }
53
52
  }
54
53
  };
55
- return /*#__PURE__*/React.createElement(ADCPie, _extends({
56
- className: className,
57
- containerStyle: _objectSpread({}, style)
58
- }, config));
54
+ };
55
+ var Pie = function Pie(props) {
56
+ var config = usePlotConfig('Pie', defaultConfig, props);
57
+ return /*#__PURE__*/React.createElement(ADCPie, config);
59
58
  };
60
59
  export default Pie;
@@ -1,12 +1,6 @@
1
1
  import { type FC } from 'react';
2
- import { BaseChartProps } from '../types';
3
- type GeoData = {
4
- address: string;
5
- lng: number;
6
- lat: number;
7
- };
8
- export interface PinMapProps extends BaseChartProps<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,114 +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
- import { LarkMap, PointLayer, TextLayer } from '@antv/larkmap';
5
- import React, { useState } from 'react';
6
- window._AMapSecurityConfig = {
7
- securityJsCode: '8803c38931b6fddc9bbfeee69df8824d'
8
- };
9
- var CONFIG = {
10
- mapType: 'Gaode',
11
- mapOptions: {
12
- style: 'normal',
13
- center: [120.210792, 30.246026],
14
- zoom: 12,
15
- maxZoom: 18,
16
- token: 'f0230f884bbd54e2913c890cdf45aa7e'
17
- }
18
- };
19
-
20
- // const SVG_BLOB = new Blob(
21
- // [
22
- // `<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>`,
23
- // ],
24
- // { type: 'image/svg+xml;charset=utf-8' },
25
- // );
26
- // const SVG_URL = URL.createObjectURL(SVG_BLOB);
27
- var SVG_URL = 'https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*yVhwTrhcKZAAAAAAAAAAAAAADmJ7AQ/original';
28
- var makerLayerOptions = {
29
- autoFit: false,
30
- shape: 'marker',
31
- size: 22,
32
- style: {}
33
- };
34
- var labelLayerOptions = {
35
- autoFit: false,
36
- field: 'address',
37
- style: {
38
- fill: '#fff',
39
- opacity: 1,
40
- fontSize: 16,
41
- fontWeight: 'bold',
42
- stroke: '#6808FE',
43
- strokeWidth: 8,
44
- textAllowOverlap: false,
45
- padding: [2, 2],
46
- textOffset: [0, 50]
47
- }
48
- };
49
- function bbox(data) {
50
- var bounds = [Infinity, Infinity, -Infinity, -Infinity];
51
- data.forEach(function (_ref) {
52
- var lng = _ref.lng,
53
- lat = _ref.lat;
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
- return bounds;
68
- }
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
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";
69
8
  var PinMap = function PinMap(props) {
70
- var className = props.className,
71
- style = props.style,
72
- _props$data = props.data,
73
- data = _props$data === void 0 ? [] : _props$data;
74
- var _useState = useState(false),
75
- _useState2 = _slicedToArray(_useState, 2),
76
- loadedImages = _useState2[0],
77
- setLoadedImages = _useState2[1];
78
- var _useState3 = useState({
79
- data: data,
80
- parser: {
81
- type: 'json',
82
- x: 'lng',
83
- y: 'lat'
84
- }
85
- }),
86
- _useState4 = _slicedToArray(_useState3, 1),
87
- source = _useState4[0];
88
- var onSceneLoaded = function onSceneLoaded(scene) {
89
- scene.addImage('marker', SVG_URL).then(function () {
90
- setLoadedImages(true);
91
- });
92
- if (!data.length) return;
93
- var bounds = bbox(data);
94
- if (scene.getType() === 'amap') {
95
- var _scene$map;
96
- (_scene$map = scene.map) === null || _scene$map === void 0 || _scene$map.setBounds(bounds, true, [50, 50, 50, 50]);
97
- } else {
98
- scene.fitBounds([[bounds[0], bounds[1]], [bounds[2], bounds[3]]]);
99
- }
100
- };
101
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LarkMap, _extends({
102
- className: className,
103
- style: _objectSpread({
104
- height: 300
105
- }, style)
106
- }, CONFIG, {
107
- onSceneLoaded: onSceneLoaded
108
- }), loadedImages && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
109
- source: source
110
- })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
111
- source: source
112
- })))));
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));
113
22
  };
114
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 {};