@antv/gpt-vis 0.0.4 → 0.0.6

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 (61) hide show
  1. package/dist/cjs/ChartCodeRender/index.d.ts +0 -1
  2. package/dist/cjs/ChartCodeRender/index.js +21 -3
  3. package/dist/cjs/Column/index.js +2 -2
  4. package/dist/cjs/ConfigProvider/index.d.ts +10 -0
  5. package/dist/cjs/ConfigProvider/index.js +37 -0
  6. package/dist/cjs/GPTVis/index.js +2 -16
  7. package/dist/cjs/HeatMap/index.d.ts +2 -2
  8. package/dist/cjs/HeatMap/index.js +6 -16
  9. package/dist/cjs/Line/index.d.ts +6 -2
  10. package/dist/cjs/Line/index.js +2 -3
  11. package/dist/cjs/PathMap/index.d.ts +2 -2
  12. package/dist/cjs/PathMap/index.js +16 -18
  13. package/dist/cjs/Pie/index.js +0 -3
  14. package/dist/cjs/PinMap/index.d.ts +2 -2
  15. package/dist/cjs/PinMap/index.js +16 -18
  16. package/dist/cjs/constants/index.d.ts +2 -0
  17. package/dist/cjs/constants/index.js +18 -6
  18. package/dist/cjs/index.d.ts +4 -5
  19. package/dist/cjs/index.js +12 -3
  20. package/dist/cjs/types/chart.d.ts +30 -0
  21. package/dist/cjs/types/chart.js +39 -0
  22. package/dist/cjs/types/config.d.ts +9 -0
  23. package/dist/cjs/types/config.js +17 -0
  24. package/dist/cjs/types/index.d.ts +2 -26
  25. package/dist/cjs/types/index.js +6 -13
  26. package/dist/cjs/utils/config.d.ts +5 -0
  27. package/dist/cjs/utils/config.js +59 -0
  28. package/dist/cjs/utils/index.d.ts +1 -0
  29. package/dist/cjs/utils/index.js +33 -0
  30. package/dist/esm/ChartCodeRender/index.d.ts +0 -1
  31. package/dist/esm/ChartCodeRender/index.js +11 -3
  32. package/dist/esm/Column/index.js +2 -2
  33. package/dist/esm/ConfigProvider/index.d.ts +10 -0
  34. package/dist/esm/ConfigProvider/index.js +16 -0
  35. package/dist/esm/GPTVis/index.js +2 -6
  36. package/dist/esm/HeatMap/index.d.ts +2 -2
  37. package/dist/esm/HeatMap/index.js +9 -16
  38. package/dist/esm/Line/index.d.ts +6 -2
  39. package/dist/esm/Line/index.js +4 -5
  40. package/dist/esm/PathMap/index.d.ts +2 -2
  41. package/dist/esm/PathMap/index.js +13 -18
  42. package/dist/esm/Pie/index.js +0 -5
  43. package/dist/esm/PinMap/index.d.ts +2 -2
  44. package/dist/esm/PinMap/index.js +13 -18
  45. package/dist/esm/constants/index.d.ts +2 -0
  46. package/dist/esm/constants/index.js +11 -1
  47. package/dist/esm/index.d.ts +4 -5
  48. package/dist/esm/index.js +4 -10
  49. package/dist/esm/types/chart.d.ts +30 -0
  50. package/dist/esm/types/chart.js +11 -0
  51. package/dist/esm/types/config.d.ts +9 -0
  52. package/dist/esm/types/config.js +1 -0
  53. package/dist/esm/types/index.d.ts +2 -26
  54. package/dist/esm/types/index.js +2 -11
  55. package/dist/esm/utils/config.d.ts +5 -0
  56. package/dist/esm/utils/config.js +26 -0
  57. package/dist/esm/utils/index.d.ts +1 -0
  58. package/dist/esm/utils/index.js +1 -0
  59. package/package.json +2 -3
  60. package/dist/cjs/ChartCodeRender/index.css +0 -19
  61. package/dist/esm/ChartCodeRender/index.css +0 -19
@@ -14,26 +14,19 @@ var __copyProps = (to, from, except, desc) => {
14
14
  }
15
15
  return to;
16
16
  };
17
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
19
 
19
20
  // src/types/index.ts
20
21
  var types_exports = {};
21
22
  __export(types_exports, {
22
- ChartType: () => ChartType
23
+ GlobalConfig: () => import_config.GlobalConfig
23
24
  });
24
25
  module.exports = __toCommonJS(types_exports);
25
- var ChartType = /* @__PURE__ */ ((ChartType2) => {
26
- ChartType2["Pie"] = "pie";
27
- ChartType2["Column"] = "column";
28
- ChartType2["Line"] = "line";
29
- ChartType2["Area"] = "area";
30
- ChartType2["WordCloud"] = "word-cloud";
31
- ChartType2["PinMap"] = "pin-map";
32
- ChartType2["PathMap"] = "path-map";
33
- ChartType2["HeatMap"] = "heat-map";
34
- return ChartType2;
35
- })(ChartType || {});
26
+ __reExport(types_exports, require("./chart"), module.exports);
27
+ var import_config = require("./config");
36
28
  // Annotate the CommonJS export names for ESM import in node:
37
29
  0 && (module.exports = {
38
- ChartType
30
+ GlobalConfig,
31
+ ...require("./chart")
39
32
  });
@@ -0,0 +1,5 @@
1
+ import type { LarkMapProps } from '../types';
2
+ import { GlobalConfig } from '../types';
3
+ export declare const setGlobalConfig: (config: GlobalConfig) => void;
4
+ export declare const getGlobalConfig: () => GlobalConfig;
5
+ export declare const getMapConfig: (props: LarkMapProps) => LarkMapProps;
@@ -0,0 +1,59 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/config.ts
20
+ var config_exports = {};
21
+ __export(config_exports, {
22
+ getGlobalConfig: () => getGlobalConfig,
23
+ getMapConfig: () => getMapConfig,
24
+ setGlobalConfig: () => setGlobalConfig
25
+ });
26
+ module.exports = __toCommonJS(config_exports);
27
+ var import_lodash = require("lodash");
28
+ var import_constants = require("../constants");
29
+ var globalConfig = import_constants.DEFAULT_GLOBAL_CONFIG;
30
+ var setGlobalConfig = (config) => {
31
+ globalConfig = (0, import_lodash.mergeWith)(globalConfig, config, (objValue) => {
32
+ if (Array.isArray(objValue)) {
33
+ return objValue;
34
+ }
35
+ });
36
+ };
37
+ var getGlobalConfig = () => {
38
+ return globalConfig;
39
+ };
40
+ var getMapConfig = (props) => {
41
+ const { map: mapConfig } = getGlobalConfig();
42
+ const config = {
43
+ ...props,
44
+ mapOptions: {
45
+ center: [120.210792, 30.246026],
46
+ zoom: 12,
47
+ maxZoom: 18,
48
+ ...mapConfig,
49
+ ...props.mapOptions
50
+ }
51
+ };
52
+ return config;
53
+ };
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ getGlobalConfig,
57
+ getMapConfig,
58
+ setGlobalConfig
59
+ });
@@ -0,0 +1 @@
1
+ export { getGlobalConfig, getMapConfig, setGlobalConfig } from './config';
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/utils/index.ts
20
+ var utils_exports = {};
21
+ __export(utils_exports, {
22
+ getGlobalConfig: () => import_config.getGlobalConfig,
23
+ getMapConfig: () => import_config.getMapConfig,
24
+ setGlobalConfig: () => import_config.setGlobalConfig
25
+ });
26
+ module.exports = __toCommonJS(utils_exports);
27
+ var import_config = require("./config");
28
+ // Annotate the CommonJS export names for ESM import in node:
29
+ 0 && (module.exports = {
30
+ getGlobalConfig,
31
+ getMapConfig,
32
+ setGlobalConfig
33
+ });
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
- import './index.css';
3
2
  import { WithChartCodeOptions } from './type';
4
3
  export declare const withChartCode: (options: WithChartCodeOptions) => keyof JSX.IntrinsicElements | import("hast-util-to-jsx-runtime/lib/components").Component<React.ClassAttributes<HTMLElement> & React.HTMLAttributes<HTMLElement> & import("hast-util-to-jsx-runtime/lib/components").ExtraProps> | undefined;
5
4
  /**
@@ -7,10 +7,18 @@ var _excluded = ["children", "className", "node"];
7
7
  import { LoadingOutlined } from '@ant-design/icons';
8
8
  import { get } from 'lodash';
9
9
  import React, { useRef, useState } from 'react';
10
+ import styled from 'styled-components';
10
11
  import { DEFAULT_CHART_COMPONENTS } from "../constants";
11
- import "./index.css";
12
+ var StyledGPTVis = styled.div.withConfig({
13
+ displayName: "StyledGPTVis",
14
+ componentId: "gpt-vis-ed04__sc-1osp6pj-0"
15
+ })(["min-width:600px;max-width:100%;"]);
16
+ var StyledLoading = styled.div.withConfig({
17
+ displayName: "StyledLoading",
18
+ componentId: "gpt-vis-ed04__sc-1osp6pj-1"
19
+ })(["display:flex;align-items:center;justify-content:center;flex-direction:column;width:400px;height:400px;background-image:linear-gradient(135deg,#e3f3ff 0%,#f1eeff 100%);color:rgba(0,0,0,88%);&-icon{margin-bottom:6px;}"]);
12
20
  var Loading = function Loading() {
13
- return /*#__PURE__*/React.createElement("div", {
21
+ return /*#__PURE__*/React.createElement(StyledLoading, {
14
22
  className: "gpt-vis-loading"
15
23
  }, /*#__PURE__*/React.createElement("div", {
16
24
  className: "gpt-vis-loading-icon"
@@ -79,7 +87,7 @@ var withCodeBlock = function withCodeBlock(options) {
79
87
 
80
88
  // Render the supported chart component with data
81
89
 
82
- return /*#__PURE__*/React.createElement("div", {
90
+ return /*#__PURE__*/React.createElement(StyledGPTVis, {
83
91
  className: "gpt-vis"
84
92
  }, /*#__PURE__*/React.createElement(ChartComponent, chartJson));
85
93
  }
@@ -18,8 +18,8 @@ var Column = function Column(props) {
18
18
  } : {};
19
19
  var config = _objectSpread({
20
20
  data: data,
21
- xField: xField || 'x',
22
- yField: yField || 'y',
21
+ xField: xField,
22
+ yField: yField,
23
23
  style: {
24
24
  // 圆角样式
25
25
  radiusTopLeft: 10,
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { GlobalConfig } from '../types';
3
+ import { setGlobalConfig } from '../utils';
4
+ export type ConfigProviderProps = {
5
+ children?: React.ReactNode;
6
+ } & GlobalConfig;
7
+ declare const ConfigProvider: React.FC<ConfigProviderProps> & {
8
+ config: typeof setGlobalConfig;
9
+ };
10
+ export default ConfigProvider;
@@ -0,0 +1,16 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
2
+ var _excluded = ["children"];
3
+ import { useRef } from 'react';
4
+ import { setGlobalConfig } from "../utils";
5
+ var ConfigProvider = function ConfigProvider(props) {
6
+ var children = props.children,
7
+ config = _objectWithoutProperties(props, _excluded);
8
+ var firstRef = useRef(true);
9
+ if (firstRef.current) {
10
+ setGlobalConfig(config);
11
+ firstRef.current = false;
12
+ }
13
+ return children;
14
+ };
15
+ ConfigProvider.config = setGlobalConfig;
16
+ export default ConfigProvider;
@@ -1,23 +1,19 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
3
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
4
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
- var _excluded = ["children", "components", "rehypePlugins"];
4
+ var _excluded = ["children", "components"];
6
5
  import React from 'react';
7
6
  import Markdown from 'react-markdown';
8
- import rehypeRaw from 'rehype-raw';
9
7
  import { withDefaultChartCode } from "../ChartCodeRender";
10
8
  var GPTVis = function GPTVis(_ref) {
11
9
  var children = _ref.children,
12
10
  components = _ref.components,
13
- rehypePlugins = _ref.rehypePlugins,
14
11
  rest = _objectWithoutProperties(_ref, _excluded);
15
12
  var CodeBlock = withDefaultChartCode();
16
13
  return /*#__PURE__*/React.createElement(Markdown, _extends({
17
14
  components: _objectSpread({
18
15
  code: CodeBlock
19
- }, components),
20
- rehypePlugins: [rehypeRaw].concat(_toConsumableArray(rehypePlugins || []))
16
+ }, components)
21
17
  }, rest), children);
22
18
  };
23
19
  export default GPTVis;
@@ -1,11 +1,11 @@
1
1
  import { type FC } from 'react';
2
- import { BaseChartProps } from '../types';
2
+ import { BaseMapProps } from '../types';
3
3
  type GeoData = {
4
4
  lng: number;
5
5
  lat: number;
6
6
  size: number;
7
7
  };
8
- export interface HeatMapProps extends BaseChartProps<GeoData> {
8
+ export interface HeatMapProps extends BaseMapProps<GeoData> {
9
9
  className?: string;
10
10
  }
11
11
  declare const HeatMap: FC<HeatMapProps>;
@@ -1,21 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["className", "style", "children", "data"];
4
6
  import { HeatmapLayer, LarkMap } from '@antv/larkmap';
5
7
  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
- };
8
+ import { getMapConfig } from "../utils/config";
19
9
  var heapLayerOptions = {
20
10
  autoFit: true,
21
11
  shape: 'heatmap',
@@ -36,8 +26,10 @@ var heapLayerOptions = {
36
26
  var HeatMap = function HeatMap(props) {
37
27
  var className = props.className,
38
28
  style = props.style,
29
+ children = props.children,
39
30
  _props$data = props.data,
40
- data = _props$data === void 0 ? [] : _props$data;
31
+ data = _props$data === void 0 ? [] : _props$data,
32
+ mapConfigRest = _objectWithoutProperties(props, _excluded);
41
33
  var _useState = useState({
42
34
  data: data,
43
35
  parser: {
@@ -48,13 +40,14 @@ var HeatMap = function HeatMap(props) {
48
40
  }),
49
41
  _useState2 = _slicedToArray(_useState, 1),
50
42
  heapSource = _useState2[0];
43
+ var mapConfig = getMapConfig(mapConfigRest);
51
44
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(LarkMap, _extends({
52
45
  className: className,
53
46
  style: _objectSpread({
54
47
  height: '300px'
55
48
  }, style)
56
- }, CONFIG), /*#__PURE__*/React.createElement(HeatmapLayer, _extends({}, heapLayerOptions, {
49
+ }, mapConfig), /*#__PURE__*/React.createElement(HeatmapLayer, _extends({}, heapLayerOptions, {
57
50
  source: heapSource
58
- }))));
51
+ })), children));
59
52
  };
60
53
  export default HeatMap;
@@ -1,5 +1,9 @@
1
1
  import React from 'react';
2
- import { StackableChartProps } from '../types';
3
- export type LineProps = StackableChartProps;
2
+ import { BaseChartProps, XYAxis } from '../types';
3
+ export interface LineProps extends BaseChartProps<XYAxis> {
4
+ xField?: string;
5
+ yField?: string;
6
+ categoryFiled?: string;
7
+ }
4
8
  declare const Line: (props: LineProps) => React.JSX.Element;
5
9
  export default Line;
@@ -9,13 +9,13 @@ var Line = function Line(props) {
9
9
  xField = _props$xField === void 0 ? 'x' : _props$xField,
10
10
  _props$yField = props.yField,
11
11
  yField = _props$yField === void 0 ? 'y' : _props$yField,
12
- stackField = props.stackField,
12
+ categoryFiled = props.categoryFiled,
13
13
  className = props.className,
14
14
  style = props.style;
15
15
 
16
16
  // 如果有 stackField,则使用 seriesField 进行分组显示,否则不分组
17
- var stackConfig = stackField ? {
18
- colorField: stackField
17
+ var stackConfig = categoryFiled ? {
18
+ colorField: categoryFiled
19
19
  } : {};
20
20
  var config = _objectSpread({
21
21
  data: data,
@@ -26,8 +26,7 @@ var Line = function Line(props) {
26
26
  name: d[xField],
27
27
  value: d[yField]
28
28
  };
29
- },
30
- smooth: true
29
+ }
31
30
  }, stackConfig);
32
31
  return /*#__PURE__*/React.createElement(ADCLine, _extends({
33
32
  className: className,
@@ -1,11 +1,11 @@
1
1
  import { type FC } from 'react';
2
- import { BaseChartProps } from '../types';
2
+ import { BaseMapProps } from '../types';
3
3
  type GeoData = {
4
4
  originName?: string;
5
5
  destinationName?: string;
6
6
  coordinates: [number, number][];
7
7
  };
8
- export interface PathMapProps extends BaseChartProps<GeoData> {
8
+ export interface PathMapProps extends BaseMapProps<GeoData> {
9
9
  className?: string;
10
10
  }
11
11
  declare const PathMap: FC<PathMapProps>;
@@ -1,21 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
4
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
5
+ var _excluded = ["className", "style", "data", "children", "onSceneLoaded"];
4
6
  import { LarkMap, LineLayer, PointLayer, TextLayer } from '@antv/larkmap';
5
7
  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
- };
8
+ import { getMapConfig } from "../utils/config";
19
9
  var lineLayerOptions = {
20
10
  autoFit: false,
21
11
  shape: 'line',
@@ -81,7 +71,10 @@ var PathMap = function PathMap(props) {
81
71
  var className = props.className,
82
72
  style = props.style,
83
73
  _props$data = props.data,
84
- data = _props$data === void 0 ? [] : _props$data;
74
+ data = _props$data === void 0 ? [] : _props$data,
75
+ children = props.children,
76
+ onSceneLoaded = props.onSceneLoaded,
77
+ mapConfigRest = _objectWithoutProperties(props, _excluded);
85
78
  var _useState = useState({
86
79
  data: data,
87
80
  parser: {
@@ -112,7 +105,9 @@ var PathMap = function PathMap(props) {
112
105
  }),
113
106
  _useState4 = _slicedToArray(_useState3, 1),
114
107
  dotSource = _useState4[0];
115
- var onSceneLoaded = function onSceneLoaded(scene) {
108
+ var mapConfig = getMapConfig(mapConfigRest);
109
+ var onMapSceneLoaded = function onMapSceneLoaded(scene) {
110
+ onSceneLoaded === null || onSceneLoaded === void 0 || onSceneLoaded(scene);
116
111
  if (!data.length) return;
117
112
  var bounds = bbox(data);
118
113
  if (scene.getType() === 'amap') {
@@ -127,14 +122,14 @@ var PathMap = function PathMap(props) {
127
122
  style: _objectSpread({
128
123
  height: 300
129
124
  }, style)
130
- }, CONFIG, {
131
- onSceneLoaded: onSceneLoaded
125
+ }, mapConfig, {
126
+ onSceneLoaded: onMapSceneLoaded
132
127
  }), /*#__PURE__*/React.createElement(LineLayer, _extends({}, lineLayerOptions, {
133
128
  source: lineSource
134
129
  })), /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
135
130
  source: dotSource
136
131
  })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
137
132
  source: dotSource
138
- }))));
133
+ })), children));
139
134
  };
140
135
  export default PathMap;
@@ -23,11 +23,6 @@ var Pie = function Pie(props) {
23
23
  data: data,
24
24
  angleField: 'value',
25
25
  colorField: 'name',
26
- state: {
27
- selected: {
28
- offset: 8
29
- }
30
- },
31
26
  tooltip: function tooltip(d) {
32
27
  return {
33
28
  name: d.name,
@@ -1,11 +1,11 @@
1
1
  import { type FC } from 'react';
2
- import { BaseChartProps } from '../types';
2
+ import { BaseMapProps } from '../types';
3
3
  type GeoData = {
4
4
  address: string;
5
5
  lng: number;
6
6
  lat: number;
7
7
  };
8
- export interface PinMapProps extends BaseChartProps<GeoData> {
8
+ export interface PinMapProps extends BaseMapProps<GeoData> {
9
9
  className?: string;
10
10
  }
11
11
  declare const PinMap: FC<PinMapProps>;
@@ -1,21 +1,11 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
4
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
5
+ var _excluded = ["className", "style", "onSceneLoaded", "children", "data"];
4
6
  import { LarkMap, PointLayer, TextLayer } from '@antv/larkmap';
5
7
  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
- };
8
+ import { getMapConfig } from "../utils";
19
9
 
20
10
  // const SVG_BLOB = new Blob(
21
11
  // [
@@ -69,8 +59,11 @@ function bbox(data) {
69
59
  var PinMap = function PinMap(props) {
70
60
  var className = props.className,
71
61
  style = props.style,
62
+ onSceneLoaded = props.onSceneLoaded,
63
+ children = props.children,
72
64
  _props$data = props.data,
73
- data = _props$data === void 0 ? [] : _props$data;
65
+ data = _props$data === void 0 ? [] : _props$data,
66
+ mapConfigRest = _objectWithoutProperties(props, _excluded);
74
67
  var _useState = useState(false),
75
68
  _useState2 = _slicedToArray(_useState, 2),
76
69
  loadedImages = _useState2[0],
@@ -85,7 +78,9 @@ var PinMap = function PinMap(props) {
85
78
  }),
86
79
  _useState4 = _slicedToArray(_useState3, 1),
87
80
  source = _useState4[0];
88
- var onSceneLoaded = function onSceneLoaded(scene) {
81
+ var mapConfig = getMapConfig(mapConfigRest);
82
+ var onMapSceneLoaded = function onMapSceneLoaded(scene) {
83
+ onSceneLoaded === null || onSceneLoaded === void 0 || onSceneLoaded(scene);
89
84
  scene.addImage('marker', SVG_URL).then(function () {
90
85
  setLoadedImages(true);
91
86
  });
@@ -103,12 +98,12 @@ var PinMap = function PinMap(props) {
103
98
  style: _objectSpread({
104
99
  height: 300
105
100
  }, style)
106
- }, CONFIG, {
107
- onSceneLoaded: onSceneLoaded
101
+ }, mapConfig, {
102
+ onSceneLoaded: onMapSceneLoaded
108
103
  }), loadedImages && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(PointLayer, _extends({}, makerLayerOptions, {
109
104
  source: source
110
105
  })), /*#__PURE__*/React.createElement(TextLayer, _extends({}, labelLayerOptions, {
111
106
  source: source
112
- })))));
107
+ }))), children));
113
108
  };
114
109
  export default PinMap;
@@ -1,2 +1,4 @@
1
1
  /// <reference types="react" />
2
+ import { GlobalConfig } from '../types';
2
3
  export declare const DEFAULT_CHART_COMPONENTS: Record<string, React.FC<any>>;
4
+ export declare const DEFAULT_GLOBAL_CONFIG: GlobalConfig;
@@ -1,8 +1,18 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import Area from "../Area";
3
3
  import Column from "../Column";
4
+ import HeatMap from "../HeatMap";
4
5
  import Line from "../Line";
6
+ import PathMap from "../PathMap";
5
7
  import Pie from "../Pie";
8
+ import PinMap from "../PinMap";
6
9
  import { ChartType } from "../types";
7
10
  import WordCloud from "../WordCloud";
8
- export var DEFAULT_CHART_COMPONENTS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, ChartType.Pie, Pie), ChartType.Area, Area), ChartType.Column, Column), ChartType.Line, Line), ChartType.WordCloud, 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);
12
+ export var DEFAULT_GLOBAL_CONFIG = {
13
+ map: {
14
+ style: 'normal',
15
+ // TODO: next step remove
16
+ token: 'f0230f884bbd54e2913c890cdf45aa7e'
17
+ }
18
+ };
@@ -3,11 +3,10 @@ export { default as Column, type ColumnProps } from './Column';
3
3
  export { default as Line, type LineProps } from './Line';
4
4
  export { default as Pie, type PieProps } from './Pie';
5
5
  export { default as WordCloud, type WordCloudProps } from './WordCloud';
6
+ export { default as HeatMap, type HeatMapProps } from './HeatMap';
7
+ export { default as PathMap, type PathMapProps } from './PathMap';
8
+ export { default as PinMap, type PinMapProps } from './PinMap';
6
9
  export { withChartCode, withDefaultChartCode } from './ChartCodeRender';
10
+ export { default as ConfigProvider, type ConfigProviderProps, } from './ConfigProvider';
7
11
  export { default as GPTVis } from './GPTVis';
8
- /**
9
- * @deprecated
10
- * 请使用 GPTVis
11
- */
12
- export { default as MarkdownVis } from './GPTVis';
13
12
  export * from './types';
package/dist/esm/index.js CHANGED
@@ -3,16 +3,10 @@ export { default as Column } from "./Column";
3
3
  export { default as Line } from "./Line";
4
4
  export { default as Pie } from "./Pie";
5
5
  export { default as WordCloud } from "./WordCloud";
6
-
7
- // export { default as HeatMap, type HeatMapProps } from './HeatMap';
8
- // export { default as PathMap, type PathMapProps } from './PathMap';
9
- // export { default as PinMap, type PinMapProps } from './PinMap';
10
-
6
+ export { default as HeatMap } from "./HeatMap";
7
+ export { default as PathMap } from "./PathMap";
8
+ export { default as PinMap } from "./PinMap";
11
9
  export { withChartCode, withDefaultChartCode } from "./ChartCodeRender";
10
+ export { default as ConfigProvider } from "./ConfigProvider";
12
11
  export { default as GPTVis } from "./GPTVis";
13
- /**
14
- * @deprecated
15
- * 请使用 GPTVis
16
- */
17
- export { default as MarkdownVis } from "./GPTVis";
18
12
  export * from "./types";
@@ -0,0 +1,30 @@
1
+ import type { LarkMapProps } from '@antv/larkmap';
2
+ import type { CSSProperties } from 'react';
3
+ export type { LarkMapProps };
4
+ export declare enum ChartType {
5
+ Pie = "pie",
6
+ Column = "column",
7
+ Line = "line",
8
+ Area = "area",
9
+ WordCloud = "word-cloud",
10
+ PinMap = "pin-map",
11
+ PathMap = "path-map",
12
+ HeatMap = "heat-map"
13
+ }
14
+ export interface BaseChartProps<T> {
15
+ data: T[];
16
+ style?: CSSProperties;
17
+ className?: string;
18
+ }
19
+ export interface XYAxis {
20
+ x: string | number;
21
+ y: number;
22
+ [key: string]: string | number;
23
+ }
24
+ export interface StackableChartProps extends BaseChartProps<XYAxis> {
25
+ xField?: string;
26
+ yField?: string;
27
+ stackField?: string;
28
+ }
29
+ export interface BaseMapProps<T> extends BaseChartProps<T>, LarkMapProps {
30
+ }
@@ -0,0 +1,11 @@
1
+ export var ChartType = /*#__PURE__*/function (ChartType) {
2
+ ChartType["Pie"] = "pie";
3
+ ChartType["Column"] = "column";
4
+ ChartType["Line"] = "line";
5
+ ChartType["Area"] = "area";
6
+ ChartType["WordCloud"] = "word-cloud";
7
+ ChartType["PinMap"] = "pin-map";
8
+ ChartType["PathMap"] = "path-map";
9
+ ChartType["HeatMap"] = "heat-map";
10
+ return ChartType;
11
+ }({});
@@ -0,0 +1,9 @@
1
+ type MapGlobalConfig = {
2
+ style?: 'normal' | 'light' | 'dark' | string;
3
+ token?: string;
4
+ [key: string]: any;
5
+ };
6
+ export type GlobalConfig = {
7
+ map?: MapGlobalConfig;
8
+ };
9
+ export {};
@@ -0,0 +1 @@
1
+ export {};