@antv/gpt-vis 0.0.6 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +92 -50
- package/README.zh-CN.md +138 -0
- package/dist/cjs/Area/index.d.ts +8 -2
- package/dist/cjs/Area/index.js +17 -16
- package/dist/cjs/Bar/index.d.ts +11 -0
- package/dist/cjs/Bar/index.js +65 -0
- package/dist/cjs/ChartCodeRender/Loading.d.ts +3 -0
- package/dist/cjs/ChartCodeRender/Loading.js +54 -0
- package/dist/cjs/ChartCodeRender/VisChart.d.ts +11 -0
- package/dist/cjs/ChartCodeRender/VisChart.js +84 -0
- package/dist/cjs/ChartCodeRender/index.d.ts +3 -4
- package/dist/cjs/ChartCodeRender/index.js +24 -68
- package/dist/cjs/ChartCodeRender/type.d.ts +9 -11
- package/dist/cjs/Column/index.d.ts +8 -2
- package/dist/cjs/Column/index.js +19 -27
- package/dist/cjs/ConfigProvider/context.d.ts +3 -0
- package/dist/cjs/ConfigProvider/context.js +41 -0
- package/dist/cjs/ConfigProvider/hooks/index.d.ts +1 -0
- package/dist/cjs/ConfigProvider/hooks/index.js +23 -0
- package/dist/cjs/ConfigProvider/hooks/useConfig.d.ts +13 -0
- package/dist/cjs/ConfigProvider/hooks/useConfig.js +108 -0
- package/dist/cjs/ConfigProvider/index.d.ts +2 -5
- package/dist/cjs/ConfigProvider/index.js +15 -9
- package/dist/cjs/DualAxes/index.d.ts +15 -0
- package/dist/cjs/DualAxes/index.js +71 -0
- package/dist/cjs/DualAxes/util.d.ts +9 -0
- package/dist/cjs/DualAxes/util.js +73 -0
- package/dist/cjs/FlowDiagram/index.d.ts +6 -0
- package/dist/cjs/FlowDiagram/index.js +100 -0
- package/dist/cjs/GPTVis/Lite.d.ts +10 -0
- package/dist/cjs/GPTVis/Lite.js +54 -0
- package/dist/cjs/GPTVis/index.d.ts +4 -8
- package/dist/cjs/GPTVis/index.js +4 -4
- package/dist/cjs/HeatMap/index.d.ts +7 -7
- package/dist/cjs/HeatMap/index.js +13 -26
- package/dist/cjs/Histogram/index.d.ts +10 -0
- package/dist/cjs/Histogram/index.js +51 -0
- package/dist/cjs/IndentedTree/index.d.ts +6 -0
- package/dist/cjs/IndentedTree/index.js +63 -0
- package/dist/cjs/Line/index.d.ts +8 -6
- package/dist/cjs/Line/index.js +15 -16
- package/dist/cjs/Map/data.json +305 -0
- package/dist/cjs/Map/index.d.ts +5 -0
- package/dist/cjs/Map/index.js +68 -0
- package/dist/cjs/MindMap/index.d.ts +6 -0
- package/dist/cjs/MindMap/index.js +64 -0
- package/dist/cjs/NetworkGraph/index.d.ts +6 -0
- package/dist/cjs/NetworkGraph/index.js +72 -0
- package/dist/cjs/OrganizationChart/index.d.ts +6 -0
- package/dist/cjs/OrganizationChart/index.js +93 -0
- package/dist/cjs/PathMap/index.d.ts +3 -9
- package/dist/cjs/PathMap/index.js +19 -109
- package/dist/cjs/Pie/index.d.ts +7 -5
- package/dist/cjs/Pie/index.js +17 -13
- package/dist/cjs/PinMap/index.d.ts +3 -9
- package/dist/cjs/PinMap/index.js +6 -85
- package/dist/cjs/Radar/index.d.ts +11 -0
- package/dist/cjs/Radar/index.js +84 -0
- package/dist/cjs/Scatter/index.d.ts +11 -0
- package/dist/cjs/Scatter/index.js +57 -0
- package/dist/cjs/Text/VisText.d.ts +4 -0
- package/dist/cjs/Text/VisText.js +74 -0
- package/dist/cjs/Text/config.d.ts +18 -0
- package/dist/cjs/Text/config.js +91 -0
- package/dist/cjs/Text/constants.d.ts +9 -0
- package/dist/cjs/Text/constants.js +37 -0
- package/dist/cjs/Text/custom-icons/index.d.ts +3 -0
- package/dist/cjs/Text/custom-icons/index.js +66 -0
- package/dist/cjs/Text/index.d.ts +3 -0
- package/dist/cjs/Text/index.js +42 -0
- package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/hooks/getElementFontSize.js +65 -0
- package/dist/cjs/Text/mini-charts/hooks/index.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/hooks/index.js +29 -0
- package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
- package/dist/cjs/Text/mini-charts/hooks/useSvgWrapper.js +65 -0
- package/dist/cjs/Text/mini-charts/index.d.ts +2 -0
- package/dist/cjs/Text/mini-charts/index.js +25 -0
- package/dist/cjs/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
- package/dist/cjs/Text/mini-charts/line/SingleLineChart.js +63 -0
- package/dist/cjs/Text/mini-charts/line/index.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/line/index.js +29 -0
- package/dist/cjs/Text/mini-charts/line/scaleLinear.d.ts +4 -0
- package/dist/cjs/Text/mini-charts/line/scaleLinear.js +35 -0
- package/dist/cjs/Text/mini-charts/line/useLineCompute.d.ts +6 -0
- package/dist/cjs/Text/mini-charts/line/useLineCompute.js +103 -0
- package/dist/cjs/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
- package/dist/cjs/Text/mini-charts/proportion/getArcPath.js +51 -0
- package/dist/cjs/Text/mini-charts/proportion/index.d.ts +3 -0
- package/dist/cjs/Text/mini-charts/proportion/index.js +72 -0
- package/dist/cjs/Text/types.d.ts +20 -0
- package/dist/cjs/Text/types.js +17 -0
- package/dist/cjs/Treemap/index.d.ts +11 -0
- package/dist/cjs/Treemap/index.js +73 -0
- package/dist/cjs/WordCloud/index.d.ts +4 -5
- package/dist/cjs/WordCloud/index.js +7 -15
- package/dist/cjs/constants/index.d.ts +1 -3
- package/dist/cjs/constants/index.js +4 -35
- package/dist/cjs/export.d.ts +28 -0
- package/dist/cjs/export.js +116 -0
- package/dist/cjs/index.d.ts +10 -11
- package/dist/cjs/index.js +9 -25
- package/dist/cjs/types/chart.d.ts +49 -14
- package/dist/cjs/types/chart.js +12 -0
- package/dist/cjs/types/config.d.ts +16 -0
- package/dist/cjs/types/index.d.ts +1 -1
- package/dist/cjs/types/index.js +0 -9
- package/dist/cjs/types/map.d.ts +242 -0
- package/dist/cjs/types/map.js +17 -0
- package/dist/cjs/utils/config.d.ts +5 -5
- package/dist/cjs/utils/config.js +41 -24
- package/dist/cjs/utils/graph.d.ts +18 -0
- package/dist/cjs/utils/graph.js +64 -0
- package/dist/cjs/utils/index.d.ts +1 -1
- package/dist/cjs/utils/index.js +3 -13
- package/dist/cjs/utils/map/context.d.ts +3 -0
- package/dist/cjs/utils/map/context.js +42 -0
- package/dist/cjs/utils/map/controls.d.ts +0 -0
- package/dist/cjs/utils/map/controls.js +0 -0
- package/dist/cjs/utils/map/index.d.ts +6 -0
- package/dist/cjs/utils/map/index.js +33 -0
- package/dist/cjs/utils/map/markers.d.ts +2 -0
- package/dist/cjs/utils/map/markers.js +88 -0
- package/dist/cjs/utils/map/polyline.d.ts +2 -0
- package/dist/cjs/utils/map/polyline.js +52 -0
- package/dist/cjs/utils/map/style.d.ts +45 -0
- package/dist/cjs/utils/map/style.js +112 -0
- package/dist/cjs/utils/map/util.d.ts +1 -0
- package/dist/cjs/utils/map/util.js +38 -0
- package/dist/cjs/utils/map/view.d.ts +3 -0
- package/dist/cjs/utils/map/view.js +93 -0
- package/dist/cjs/utils/plot.d.ts +4 -0
- package/dist/cjs/utils/plot.js +69 -0
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/version.js +25 -0
- package/dist/esm/Area/index.d.ts +8 -2
- package/dist/esm/Area/index.js +21 -27
- package/dist/esm/Bar/index.d.ts +11 -0
- package/dist/esm/Bar/index.js +35 -0
- package/dist/esm/ChartCodeRender/Loading.d.ts +3 -0
- package/dist/esm/ChartCodeRender/Loading.js +20 -0
- package/dist/esm/ChartCodeRender/VisChart.d.ts +11 -0
- package/dist/esm/ChartCodeRender/VisChart.js +65 -0
- package/dist/esm/ChartCodeRender/index.d.ts +3 -4
- package/dist/esm/ChartCodeRender/index.js +28 -84
- package/dist/esm/ChartCodeRender/type.d.ts +9 -11
- package/dist/esm/Column/index.d.ts +8 -2
- package/dist/esm/Column/index.js +22 -27
- package/dist/esm/ConfigProvider/context.d.ts +3 -0
- package/dist/esm/ConfigProvider/context.js +3 -0
- package/dist/esm/ConfigProvider/hooks/index.d.ts +1 -0
- package/dist/esm/ConfigProvider/hooks/index.js +1 -0
- package/dist/esm/ConfigProvider/hooks/useConfig.d.ts +13 -0
- package/dist/esm/ConfigProvider/hooks/useConfig.js +57 -0
- package/dist/esm/ConfigProvider/index.d.ts +2 -5
- package/dist/esm/ConfigProvider/index.js +9 -9
- package/dist/esm/DualAxes/index.d.ts +15 -0
- package/dist/esm/DualAxes/index.js +44 -0
- package/dist/esm/DualAxes/util.d.ts +9 -0
- package/dist/esm/DualAxes/util.js +61 -0
- package/dist/esm/FlowDiagram/index.d.ts +6 -0
- package/dist/esm/FlowDiagram/index.js +75 -0
- package/dist/esm/GPTVis/Lite.d.ts +10 -0
- package/dist/esm/GPTVis/Lite.js +18 -0
- package/dist/esm/GPTVis/index.d.ts +4 -8
- package/dist/esm/GPTVis/index.js +5 -5
- package/dist/esm/HeatMap/index.d.ts +7 -7
- package/dist/esm/HeatMap/index.js +19 -27
- package/dist/esm/Histogram/index.d.ts +10 -0
- package/dist/esm/Histogram/index.js +25 -0
- package/dist/esm/IndentedTree/index.d.ts +6 -0
- package/dist/esm/IndentedTree/index.js +47 -0
- package/dist/esm/Line/index.d.ts +8 -6
- package/dist/esm/Line/index.js +17 -23
- package/dist/esm/Map/data.json +305 -0
- package/dist/esm/Map/index.d.ts +5 -0
- package/dist/esm/Map/index.js +60 -0
- package/dist/esm/MindMap/index.d.ts +6 -0
- package/dist/esm/MindMap/index.js +48 -0
- package/dist/esm/NetworkGraph/index.d.ts +6 -0
- package/dist/esm/NetworkGraph/index.js +57 -0
- package/dist/esm/OrganizationChart/index.d.ts +6 -0
- package/dist/esm/OrganizationChart/index.js +64 -0
- package/dist/esm/PathMap/index.d.ts +3 -9
- package/dist/esm/PathMap/index.js +32 -129
- package/dist/esm/Pie/index.d.ts +7 -5
- package/dist/esm/Pie/index.js +24 -20
- package/dist/esm/PinMap/index.d.ts +3 -9
- package/dist/esm/PinMap/index.js +18 -104
- package/dist/esm/Radar/index.d.ts +11 -0
- package/dist/esm/Radar/index.js +54 -0
- package/dist/esm/Scatter/index.d.ts +11 -0
- package/dist/esm/Scatter/index.js +30 -0
- package/dist/esm/Text/VisText.d.ts +4 -0
- package/dist/esm/Text/VisText.js +38 -0
- package/dist/esm/Text/config.d.ts +18 -0
- package/dist/esm/Text/config.js +79 -0
- package/dist/esm/Text/constants.d.ts +9 -0
- package/dist/esm/Text/constants.js +9 -0
- package/dist/esm/Text/custom-icons/index.d.ts +3 -0
- package/dist/esm/Text/custom-icons/index.js +37 -0
- package/dist/esm/Text/index.d.ts +3 -0
- package/dist/esm/Text/index.js +2 -0
- package/dist/esm/Text/mini-charts/hooks/getElementFontSize.d.ts +1 -0
- package/dist/esm/Text/mini-charts/hooks/getElementFontSize.js +32 -0
- package/dist/esm/Text/mini-charts/hooks/index.d.ts +1 -0
- package/dist/esm/Text/mini-charts/hooks/index.js +1 -0
- package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.d.ts +5 -0
- package/dist/esm/Text/mini-charts/hooks/useSvgWrapper.js +31 -0
- package/dist/esm/Text/mini-charts/index.d.ts +2 -0
- package/dist/esm/Text/mini-charts/index.js +2 -0
- package/dist/esm/Text/mini-charts/line/SingleLineChart.d.ts +3 -0
- package/dist/esm/Text/mini-charts/line/SingleLineChart.js +57 -0
- package/dist/esm/Text/mini-charts/line/index.d.ts +1 -0
- package/dist/esm/Text/mini-charts/line/index.js +1 -0
- package/dist/esm/Text/mini-charts/line/scaleLinear.d.ts +4 -0
- package/dist/esm/Text/mini-charts/line/scaleLinear.js +14 -0
- package/dist/esm/Text/mini-charts/line/useLineCompute.d.ts +6 -0
- package/dist/esm/Text/mini-charts/line/useLineCompute.js +106 -0
- package/dist/esm/Text/mini-charts/proportion/getArcPath.d.ts +1 -0
- package/dist/esm/Text/mini-charts/proportion/getArcPath.js +19 -0
- package/dist/esm/Text/mini-charts/proportion/index.d.ts +3 -0
- package/dist/esm/Text/mini-charts/proportion/index.js +60 -0
- package/dist/esm/Text/types.d.ts +20 -0
- package/dist/esm/Text/types.js +1 -0
- package/dist/esm/Treemap/index.d.ts +11 -0
- package/dist/esm/Treemap/index.js +52 -0
- package/dist/esm/WordCloud/index.d.ts +4 -5
- package/dist/esm/WordCloud/index.js +8 -18
- package/dist/esm/constants/index.d.ts +1 -3
- package/dist/esm/constants/index.js +5 -14
- package/dist/esm/export.d.ts +28 -0
- package/dist/esm/export.js +33 -0
- package/dist/esm/index.d.ts +10 -11
- package/dist/esm/index.js +9 -9
- package/dist/esm/types/chart.d.ts +49 -14
- package/dist/esm/types/chart.js +12 -0
- package/dist/esm/types/config.d.ts +16 -0
- package/dist/esm/types/index.d.ts +1 -1
- package/dist/esm/types/index.js +1 -1
- package/dist/esm/types/map.d.ts +242 -0
- package/dist/esm/types/map.js +1 -0
- package/dist/esm/utils/config.d.ts +5 -5
- package/dist/esm/utils/config.js +40 -18
- package/dist/esm/utils/graph.d.ts +18 -0
- package/dist/esm/utils/graph.js +49 -0
- package/dist/esm/utils/index.d.ts +1 -1
- package/dist/esm/utils/index.js +1 -1
- package/dist/esm/utils/map/context.d.ts +3 -0
- package/dist/esm/utils/map/context.js +34 -0
- package/dist/esm/utils/map/controls.d.ts +0 -0
- package/dist/esm/utils/map/controls.js +0 -0
- package/dist/esm/utils/map/index.d.ts +6 -0
- package/dist/esm/utils/map/index.js +6 -0
- package/dist/esm/utils/map/markers.d.ts +2 -0
- package/dist/esm/utils/map/markers.js +64 -0
- package/dist/esm/utils/map/polyline.d.ts +2 -0
- package/dist/esm/utils/map/polyline.js +26 -0
- package/dist/esm/utils/map/style.d.ts +45 -0
- package/dist/esm/utils/map/style.js +76 -0
- package/dist/esm/utils/map/util.d.ts +1 -0
- package/dist/esm/utils/map/util.js +11 -0
- package/dist/esm/utils/map/view.d.ts +3 -0
- package/dist/esm/utils/map/view.js +81 -0
- package/dist/esm/utils/plot.d.ts +4 -0
- package/dist/esm/utils/plot.js +65 -0
- package/dist/esm/version.d.ts +2 -0
- package/dist/esm/version.js +1 -0
- package/dist/umd/895.async.js +1 -0
- package/dist/umd/index.min.js +1 -0
- package/package.json +97 -58
|
@@ -0,0 +1,25 @@
|
|
|
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/version.ts
|
|
20
|
+
var version_exports = {};
|
|
21
|
+
__export(version_exports, {
|
|
22
|
+
default: () => version_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(version_exports);
|
|
25
|
+
var version_default = "0.2.0";
|
package/dist/esm/Area/index.d.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { AreaConfig } from '@ant-design/plots';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
3
|
+
import type { BasePlotProps } from '../types';
|
|
4
|
+
type AreaDataItem = {
|
|
5
|
+
time: string | number;
|
|
6
|
+
value: number;
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type AreaProps = BasePlotProps<AreaDataItem> & Partial<AreaConfig>;
|
|
4
10
|
declare const Area: (props: AreaProps) => React.JSX.Element;
|
|
5
11
|
export default Area;
|
package/dist/esm/Area/index.js
CHANGED
|
@@ -1,40 +1,34 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
// 引入必要的包
|
|
4
1
|
import { Area as ADCArea } from '@ant-design/plots';
|
|
2
|
+
import { get } from 'lodash';
|
|
5
3
|
import React from 'react';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
var _props$data = props.data,
|
|
10
|
-
data = _props$data === void 0 ? [] : _props$data,
|
|
4
|
+
import { usePlotConfig } from "../ConfigProvider/hooks";
|
|
5
|
+
var defaultConfig = function defaultConfig(props) {
|
|
6
|
+
var data = props.data,
|
|
11
7
|
_props$xField = props.xField,
|
|
12
|
-
xField = _props$xField === void 0 ? '
|
|
8
|
+
xField = _props$xField === void 0 ? 'time' : _props$xField,
|
|
13
9
|
_props$yField = props.yField,
|
|
14
|
-
yField = _props$yField === void 0 ? '
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
colorField: stackField,
|
|
22
|
-
isStack: true
|
|
23
|
-
} : {};
|
|
24
|
-
var config = _objectSpread({
|
|
25
|
-
data: data,
|
|
10
|
+
yField = _props$yField === void 0 ? 'value' : _props$yField;
|
|
11
|
+
var hasGroupField = get(data, '[0].group') !== undefined;
|
|
12
|
+
var axisYTitle = get(props, 'axis.y.title');
|
|
13
|
+
var defalutStyle = hasGroupField ? {} : {
|
|
14
|
+
opacity: 0.6
|
|
15
|
+
};
|
|
16
|
+
return {
|
|
26
17
|
xField: xField,
|
|
27
18
|
yField: yField,
|
|
19
|
+
style: defalutStyle,
|
|
20
|
+
colorField: hasGroupField ? 'group' : undefined,
|
|
28
21
|
tooltip: function tooltip(d) {
|
|
22
|
+
var tooltipName = axisYTitle || d[xField];
|
|
29
23
|
return {
|
|
30
|
-
name:
|
|
24
|
+
name: tooltipName,
|
|
31
25
|
value: d[yField]
|
|
32
26
|
};
|
|
33
27
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
var Area = function Area(props) {
|
|
31
|
+
var config = usePlotConfig('Area', defaultConfig, props);
|
|
32
|
+
return /*#__PURE__*/React.createElement(ADCArea, config);
|
|
39
33
|
};
|
|
40
34
|
export default Area;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BarConfig } from '@ant-design/plots';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { BasePlotProps } from '../types';
|
|
4
|
+
type BarDataItem = {
|
|
5
|
+
category: string;
|
|
6
|
+
value: number;
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type BarProps = BasePlotProps<BarDataItem> & Partial<BarConfig>;
|
|
10
|
+
declare const Bar: (props: BarProps) => React.JSX.Element;
|
|
11
|
+
export default Bar;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Bar as ADCBar } 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 ? 'category' : _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
|
+
var axisYTitle = get(props, 'axis.y.title');
|
|
13
|
+
return {
|
|
14
|
+
xField: xField,
|
|
15
|
+
yField: yField,
|
|
16
|
+
colorField: hasGroupField ? 'group' : undefined,
|
|
17
|
+
tooltip: function tooltip(d) {
|
|
18
|
+
var tooltipName = axisYTitle || d[xField];
|
|
19
|
+
return {
|
|
20
|
+
name: tooltipName,
|
|
21
|
+
value: d[yField]
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
style: {
|
|
25
|
+
// 圆角样式
|
|
26
|
+
radiusTopLeft: 5,
|
|
27
|
+
radiusTopRight: 5
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var Bar = function Bar(props) {
|
|
32
|
+
var config = usePlotConfig('Bar', defaultConfig, props);
|
|
33
|
+
return /*#__PURE__*/React.createElement(ADCBar, config);
|
|
34
|
+
};
|
|
35
|
+
export default Bar;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LoadingOutlined } from '@ant-design/icons';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
var StyledLoading = styled.div.withConfig({
|
|
5
|
+
displayName: "StyledLoading",
|
|
6
|
+
componentId: "gpt-vis-c7ef__sc-4x7w8p-0"
|
|
7
|
+
})(["display:flex;align-items:center;justify-content:center;flex-direction:column;height:300px;background-image:linear-gradient(135deg,#e3f3ff 0%,#f1eeff 100%);color:rgba(0,0,0,88%);&-icon{margin-bottom:6px;}"]);
|
|
8
|
+
var Loading = function Loading() {
|
|
9
|
+
return /*#__PURE__*/React.createElement(StyledLoading, {
|
|
10
|
+
className: "gpt-vis-loading"
|
|
11
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
12
|
+
className: "gpt-vis-loading-icon"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(LoadingOutlined, {
|
|
14
|
+
style: {
|
|
15
|
+
fontSize: '24px',
|
|
16
|
+
color: 'rgb(56, 177, 246)'
|
|
17
|
+
}
|
|
18
|
+
})), /*#__PURE__*/React.createElement("p", null, "\u6570\u636E\u751F\u6210\u4E2D"));
|
|
19
|
+
};
|
|
20
|
+
export default Loading;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ChartComponents } from './type';
|
|
3
|
+
type RenderVisChartProps = {
|
|
4
|
+
content: string;
|
|
5
|
+
components: ChartComponents;
|
|
6
|
+
debug?: boolean;
|
|
7
|
+
loadingTimeout: number;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
};
|
|
10
|
+
export declare const RenderVisChart: React.FC<RenderVisChartProps>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
var _excluded = ["type"];
|
|
4
|
+
import React, { memo, useRef, useState } from 'react';
|
|
5
|
+
import styled, { createGlobalStyle } from 'styled-components';
|
|
6
|
+
import Loading from "./Loading";
|
|
7
|
+
var StyledGPTVis = styled.div.withConfig({
|
|
8
|
+
displayName: "StyledGPTVis",
|
|
9
|
+
componentId: "gpt-vis-c7ef__sc-1f5p953-0"
|
|
10
|
+
})(["min-width:300px;height:300px;max-width:100%;"]);
|
|
11
|
+
var GlobalStyles = createGlobalStyle(["pre:has(.gpt-vis){overflow:hidden;}"]);
|
|
12
|
+
export var RenderVisChart = /*#__PURE__*/memo(function (_ref) {
|
|
13
|
+
var style = _ref.style,
|
|
14
|
+
content = _ref.content,
|
|
15
|
+
components = _ref.components,
|
|
16
|
+
debug = _ref.debug,
|
|
17
|
+
loadingTimeout = _ref.loadingTimeout;
|
|
18
|
+
var timeoutRef = useRef();
|
|
19
|
+
var _useState = useState(true),
|
|
20
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
21
|
+
loading = _useState2[0],
|
|
22
|
+
setLoading = _useState2[1];
|
|
23
|
+
var chartJson;
|
|
24
|
+
try {
|
|
25
|
+
chartJson = JSON.parse(content);
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
27
|
+
} catch (e) {
|
|
28
|
+
if (timeoutRef.current) {
|
|
29
|
+
clearTimeout(timeoutRef.current);
|
|
30
|
+
if (debug) {
|
|
31
|
+
console.warn('GPT-Vis withChartCode parse content timeout');
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
timeoutRef.current = setTimeout(function () {
|
|
35
|
+
setLoading(false);
|
|
36
|
+
}, loadingTimeout);
|
|
37
|
+
if (loading) {
|
|
38
|
+
return /*#__PURE__*/React.createElement(StyledGPTVis, {
|
|
39
|
+
className: "gpt-vis",
|
|
40
|
+
style: style
|
|
41
|
+
}, /*#__PURE__*/React.createElement(Loading, null));
|
|
42
|
+
}
|
|
43
|
+
return /*#__PURE__*/React.createElement("p", null, "Chart generation timeout.");
|
|
44
|
+
}
|
|
45
|
+
var _chartJson = chartJson,
|
|
46
|
+
type = _chartJson.type,
|
|
47
|
+
chartProps = _objectWithoutProperties(_chartJson, _excluded);
|
|
48
|
+
var ChartComponent = components[type];
|
|
49
|
+
|
|
50
|
+
// debug mode print chartJson
|
|
51
|
+
if (debug) {
|
|
52
|
+
console.log('GPT-Vis withChartCode get chartJson parse from vis-chart code block', chartJson);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// If the chart type is not supported, display an error message
|
|
56
|
+
if (!ChartComponent) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("p", null, "Chart type \"".concat(type, "\" is not supported."));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Render the supported chart component with data
|
|
61
|
+
return /*#__PURE__*/React.createElement(StyledGPTVis, {
|
|
62
|
+
className: "gpt-vis",
|
|
63
|
+
style: style
|
|
64
|
+
}, /*#__PURE__*/React.createElement(GlobalStyles, null), /*#__PURE__*/React.createElement(ChartComponent, chartProps));
|
|
65
|
+
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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;
|
|
1
|
+
import type { CodeBlockComponent, WithChartCodeOptions } from './type';
|
|
2
|
+
export declare const withChartCode: (options: WithChartCodeOptions) => CodeBlockComponent;
|
|
4
3
|
/**
|
|
5
4
|
* Includes built-in chart components such as line charts, pie charts, etc.
|
|
6
5
|
* @param componentsArray
|
|
7
6
|
* @returns
|
|
8
7
|
*/
|
|
9
|
-
export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) =>
|
|
8
|
+
export declare const withDefaultChartCode: (options?: Partial<WithChartCodeOptions>) => CodeBlockComponent;
|
|
@@ -1,122 +1,66 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
1
|
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
6
4
|
var _excluded = ["children", "className", "node"];
|
|
7
|
-
import { LoadingOutlined } from '@ant-design/icons';
|
|
8
5
|
import { get } from 'lodash';
|
|
9
|
-
import React
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
className: "gpt-vis-loading"
|
|
23
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
24
|
-
className: "gpt-vis-loading-icon"
|
|
25
|
-
}, /*#__PURE__*/React.createElement(LoadingOutlined, {
|
|
26
|
-
style: {
|
|
27
|
-
fontSize: '24px',
|
|
28
|
-
color: 'rgb(56, 177, 246)'
|
|
29
|
-
}
|
|
30
|
-
})), /*#__PURE__*/React.createElement("p", null, "\u6570\u636E\u751F\u6210\u4E2D"));
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { DEFAULT_CHART_COMPONENTS } from "../export";
|
|
8
|
+
import { RenderVisChart } from "./VisChart";
|
|
9
|
+
var RenderDefaultCode = function RenderDefaultCode(props) {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11
|
+
var children = props.children,
|
|
12
|
+
_props$className = props.className,
|
|
13
|
+
className = _props$className === void 0 ? '' : _props$className,
|
|
14
|
+
node = props.node,
|
|
15
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
16
|
+
return /*#__PURE__*/React.createElement("code", _extends({}, rest, {
|
|
17
|
+
className: className
|
|
18
|
+
}), children);
|
|
31
19
|
};
|
|
32
20
|
var withCodeBlock = function withCodeBlock(options) {
|
|
33
21
|
// Render code block component
|
|
34
22
|
return function CodeBlock(props) {
|
|
35
23
|
var _className$match;
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
24
|
var children = props.children,
|
|
38
|
-
_props$
|
|
39
|
-
className = _props$
|
|
40
|
-
node = props.node,
|
|
41
|
-
rest = _objectWithoutProperties(props, _excluded);
|
|
25
|
+
_props$className2 = props.className,
|
|
26
|
+
className = _props$className2 === void 0 ? '' : _props$className2;
|
|
42
27
|
var content = String(children).trim();
|
|
43
28
|
var isVisChart = className.includes('language-vis-chart');
|
|
44
29
|
var components = options.components,
|
|
45
|
-
extraRenderers = options.extraRenderers,
|
|
46
30
|
languageRenderers = options.languageRenderers,
|
|
47
31
|
DefaultRenderer = options.defaultRenderer,
|
|
48
32
|
debug = options.debug,
|
|
49
33
|
_options$loadingTimeo = options.loadingTimeout,
|
|
50
|
-
loadingTimeout = _options$loadingTimeo === void 0 ? 5000 : _options$loadingTimeo
|
|
51
|
-
|
|
52
|
-
var _useState = useState(true),
|
|
53
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
54
|
-
loading = _useState2[0],
|
|
55
|
-
setLoading = _useState2[1];
|
|
34
|
+
loadingTimeout = _options$loadingTimeo === void 0 ? 5000 : _options$loadingTimeo,
|
|
35
|
+
style = options.style;
|
|
56
36
|
|
|
57
37
|
// If the code block is a VisChart, render the corresponding chart component
|
|
58
38
|
if (isVisChart) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
console.log('GPT-Vis withChartCode parse content timeout');
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
timeoutRef.current = setTimeout(function () {
|
|
70
|
-
setLoading(false);
|
|
71
|
-
}, loadingTimeout);
|
|
72
|
-
return loading ? /*#__PURE__*/React.createElement(Loading, null) : /*#__PURE__*/React.createElement("code", null, content.toString());
|
|
73
|
-
}
|
|
74
|
-
var _chartJson = chartJson,
|
|
75
|
-
type = _chartJson.type;
|
|
76
|
-
var ChartComponent = components[type];
|
|
77
|
-
|
|
78
|
-
// debug mode print chartJson
|
|
79
|
-
if (debug) {
|
|
80
|
-
console.log('GPT-Vis withChartCode get chartJson parse from vis-chart code block', chartJson);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// If the chart type is not supported, display an error message
|
|
84
|
-
if (!ChartComponent) {
|
|
85
|
-
return /*#__PURE__*/React.createElement("code", null, "Chart type \"".concat(type, "\" is not supported."));
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
// Render the supported chart component with data
|
|
89
|
-
|
|
90
|
-
return /*#__PURE__*/React.createElement(StyledGPTVis, {
|
|
91
|
-
className: "gpt-vis"
|
|
92
|
-
}, /*#__PURE__*/React.createElement(ChartComponent, chartJson));
|
|
39
|
+
return /*#__PURE__*/React.createElement(RenderVisChart, {
|
|
40
|
+
style: style,
|
|
41
|
+
content: content,
|
|
42
|
+
components: components,
|
|
43
|
+
debug: debug,
|
|
44
|
+
loadingTimeout: loadingTimeout
|
|
45
|
+
});
|
|
93
46
|
}
|
|
94
47
|
|
|
95
48
|
// If the code block math extraRenderer languageName, the corresponding extra languageRenderers component
|
|
96
49
|
var languageName = ((_className$match = className.match(/language-(.*)/)) === null || _className$match === void 0 ? void 0 : _className$match[1]) || '';
|
|
97
|
-
var extraLanguageRenderers =
|
|
50
|
+
var extraLanguageRenderers = languageRenderers;
|
|
98
51
|
var ExtraRendererComponent = extraLanguageRenderers && extraLanguageRenderers[languageName];
|
|
99
52
|
if (ExtraRendererComponent) {
|
|
100
53
|
return /*#__PURE__*/React.createElement(ExtraRendererComponent, props);
|
|
101
54
|
}
|
|
102
55
|
|
|
103
56
|
// If the code block is not a VisChart, render plain code
|
|
104
|
-
return DefaultRenderer ? /*#__PURE__*/React.createElement(DefaultRenderer, props) : /*#__PURE__*/React.createElement(
|
|
105
|
-
className: className
|
|
106
|
-
}), children);
|
|
57
|
+
return DefaultRenderer ? /*#__PURE__*/React.createElement(DefaultRenderer, props) : /*#__PURE__*/React.createElement(RenderDefaultCode, props);
|
|
107
58
|
};
|
|
108
59
|
};
|
|
109
60
|
|
|
110
61
|
// Create a higher-order component (HOC) with chart code
|
|
111
62
|
export var withChartCode = function withChartCode(options) {
|
|
112
|
-
|
|
113
|
-
// Flatten the components array into a single object
|
|
114
|
-
var components = ((_options$components = options.components) === null || _options$components === void 0 ? void 0 : _options$components.reduce(function (acc, obj) {
|
|
115
|
-
return _objectSpread(_objectSpread({}, acc), obj);
|
|
116
|
-
}, {})) || [];
|
|
117
|
-
return withCodeBlock(_objectSpread(_objectSpread({}, options), {}, {
|
|
118
|
-
components: components
|
|
119
|
-
}));
|
|
63
|
+
return withCodeBlock(options);
|
|
120
64
|
};
|
|
121
65
|
|
|
122
66
|
/**
|
|
@@ -126,6 +70,6 @@ export var withChartCode = function withChartCode(options) {
|
|
|
126
70
|
*/
|
|
127
71
|
export var withDefaultChartCode = function withDefaultChartCode(options) {
|
|
128
72
|
return withChartCode(_objectSpread(_objectSpread({}, options), {}, {
|
|
129
|
-
components:
|
|
73
|
+
components: _objectSpread(_objectSpread({}, DEFAULT_CHART_COMPONENTS), get(options, 'components', {}))
|
|
130
74
|
}));
|
|
131
75
|
};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { FC } from 'react';
|
|
2
|
-
import { Components, ExtraProps } from 'react-markdown';
|
|
3
|
-
import { BaseChartProps } from '../types';
|
|
1
|
+
import type { FC } from 'react';
|
|
2
|
+
import type { Components, ExtraProps } from 'react-markdown';
|
|
4
3
|
export type WithChartCodeOptions = {
|
|
5
4
|
/**
|
|
6
5
|
* 要额外加载的图表组件
|
|
7
6
|
*/
|
|
8
|
-
components: ChartComponents
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated
|
|
11
|
-
* 请使用 languageRenderers
|
|
12
|
-
*/
|
|
13
|
-
extraRenderers?: LanguageRenderers;
|
|
7
|
+
components: ChartComponents;
|
|
14
8
|
/**
|
|
15
9
|
* 自定义其它语言代码块渲染器
|
|
16
10
|
*/
|
|
@@ -27,19 +21,23 @@ export type WithChartCodeOptions = {
|
|
|
27
21
|
* 设置loading动画的超时时间,默认为 5s
|
|
28
22
|
*/
|
|
29
23
|
loadingTimeout?: number;
|
|
24
|
+
/**
|
|
25
|
+
* 图表样式,配置容器样式
|
|
26
|
+
*/
|
|
27
|
+
style?: React.CSSProperties;
|
|
30
28
|
};
|
|
31
29
|
/**
|
|
32
30
|
* 图表渲染数据接口,后续拓展,这里只是写个示例
|
|
33
31
|
*/
|
|
34
32
|
export interface ChartJson {
|
|
35
33
|
type: string;
|
|
36
|
-
data: any
|
|
34
|
+
data: any;
|
|
37
35
|
}
|
|
38
36
|
/**
|
|
39
37
|
* 图表组件字典
|
|
40
38
|
*/
|
|
41
39
|
export interface ChartComponents {
|
|
42
|
-
[key: string]: FC<
|
|
40
|
+
[key: string]: FC<any>;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* 代码块渲染器接口
|
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import type { ColumnConfig } from '@ant-design/plots';
|
|
1
2
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
export type
|
|
3
|
+
import type { BasePlotProps } from '../types';
|
|
4
|
+
export type ColumnDataItem = {
|
|
5
|
+
category: string | number;
|
|
6
|
+
value: number;
|
|
7
|
+
[key: string]: string | number;
|
|
8
|
+
};
|
|
9
|
+
export type ColumnProps = BasePlotProps<ColumnDataItem> & Partial<ColumnConfig>;
|
|
4
10
|
declare const Column: (props: ColumnProps) => React.JSX.Element;
|
|
5
11
|
export default Column;
|
package/dist/esm/Column/index.js
CHANGED
|
@@ -1,40 +1,35 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
1
|
import { Column as ADCColumn } from '@ant-design/plots';
|
|
2
|
+
import { get } from 'lodash';
|
|
4
3
|
import React from 'react';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
import { usePlotConfig } from "../ConfigProvider/hooks";
|
|
5
|
+
var defaultConfig = function defaultConfig(props) {
|
|
6
|
+
var data = props.data,
|
|
8
7
|
_props$xField = props.xField,
|
|
9
|
-
xField = _props$xField === void 0 ? '
|
|
8
|
+
xField = _props$xField === void 0 ? 'category' : _props$xField,
|
|
10
9
|
_props$yField = props.yField,
|
|
11
|
-
yField = _props$yField === void 0 ? '
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var stackConfig = stackField ? {
|
|
16
|
-
colorField: stackField,
|
|
17
|
-
stack: true
|
|
18
|
-
} : {};
|
|
19
|
-
var config = _objectSpread({
|
|
20
|
-
data: data,
|
|
10
|
+
yField = _props$yField === void 0 ? 'value' : _props$yField;
|
|
11
|
+
var hasGroupField = get(data, '[0].group') !== undefined;
|
|
12
|
+
var axisYTitle = get(props, 'axis.y.title');
|
|
13
|
+
return {
|
|
21
14
|
xField: xField,
|
|
22
15
|
yField: yField,
|
|
23
|
-
|
|
24
|
-
// 圆角样式
|
|
25
|
-
radiusTopLeft: 10,
|
|
26
|
-
radiusTopRight: 10
|
|
27
|
-
},
|
|
16
|
+
colorField: hasGroupField ? 'group' : undefined,
|
|
28
17
|
tooltip: function tooltip(d) {
|
|
18
|
+
var tooltipName = axisYTitle || d[xField];
|
|
29
19
|
return {
|
|
30
|
-
name:
|
|
20
|
+
name: tooltipName,
|
|
31
21
|
value: d[yField]
|
|
32
22
|
};
|
|
23
|
+
},
|
|
24
|
+
style: {
|
|
25
|
+
// 圆角样式
|
|
26
|
+
radiusTopLeft: 10,
|
|
27
|
+
radiusTopRight: 10
|
|
33
28
|
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
var Column = function Column(props) {
|
|
32
|
+
var config = usePlotConfig('Column', defaultConfig, props);
|
|
33
|
+
return /*#__PURE__*/React.createElement(ADCColumn, config);
|
|
39
34
|
};
|
|
40
35
|
export default Column;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useConfig';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./useConfig";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GraphOptions } from '@ant-design/graphs';
|
|
2
|
+
import type { CommonConfig } from '@ant-design/plots';
|
|
3
|
+
import type { MapProps } from '../../Map';
|
|
4
|
+
import type { Charts } from '../../types';
|
|
5
|
+
export declare function useComponentGlobalConfig(name: Charts): Record<string, any> | undefined;
|
|
6
|
+
export declare function usePlotConfig<T extends CommonConfig>(name: Charts, defaultConfig: Partial<T> | ((props: Partial<T>) => Partial<T>), props: Partial<T>): Partial<T>;
|
|
7
|
+
export declare function useMapConfig<T extends MapProps>(name: Charts, props: T): {
|
|
8
|
+
mapType: string | undefined;
|
|
9
|
+
token: string | undefined;
|
|
10
|
+
} & T;
|
|
11
|
+
export declare function useGraphConfig<T extends GraphOptions>(name: Charts, defaultConfig: T, props: T): {
|
|
12
|
+
[x: string]: any;
|
|
13
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { mergeGraphOptions } from "../../utils/config";
|
|
4
|
+
import { transform2ADCProps } from "../../utils/plot";
|
|
5
|
+
import { ConfigContext } from "../context";
|
|
6
|
+
function useConfig() {
|
|
7
|
+
var context = React.useContext(ConfigContext);
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
export function useComponentGlobalConfig(name) {
|
|
11
|
+
var globalConfig = useConfig();
|
|
12
|
+
var _globalConfig$compone = globalConfig.components,
|
|
13
|
+
components = _globalConfig$compone === void 0 ? {} : _globalConfig$compone;
|
|
14
|
+
var config = components === null || components === void 0 ? void 0 : components[name];
|
|
15
|
+
return config;
|
|
16
|
+
}
|
|
17
|
+
function usePlotGlobalConfig(name) {
|
|
18
|
+
var componentConfig = useComponentGlobalConfig(name);
|
|
19
|
+
var _useConfig = useConfig(),
|
|
20
|
+
plotConfig = _useConfig.plot;
|
|
21
|
+
var config = _objectSpread(_objectSpread({}, plotConfig), componentConfig);
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
export function usePlotConfig(name, defaultConfig, props) {
|
|
25
|
+
var transformedProps = transform2ADCProps(props);
|
|
26
|
+
var _defaultConfig = typeof defaultConfig === 'function' ? defaultConfig(transformedProps) : defaultConfig;
|
|
27
|
+
var globalConfig = usePlotGlobalConfig(name);
|
|
28
|
+
var config = _objectSpread(_objectSpread(_objectSpread({}, _defaultConfig), globalConfig), transformedProps);
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
function useMapGlobalConfig(name) {
|
|
32
|
+
var componentConfig = useComponentGlobalConfig(name);
|
|
33
|
+
var _useConfig2 = useConfig(),
|
|
34
|
+
mapConfig = _useConfig2.map;
|
|
35
|
+
var transformedProps = {
|
|
36
|
+
mapType: mapConfig === null || mapConfig === void 0 ? void 0 : mapConfig.style,
|
|
37
|
+
token: mapConfig === null || mapConfig === void 0 ? void 0 : mapConfig.token
|
|
38
|
+
};
|
|
39
|
+
var config = _objectSpread(_objectSpread({}, transformedProps), componentConfig);
|
|
40
|
+
return config;
|
|
41
|
+
}
|
|
42
|
+
export function useMapConfig(name, props) {
|
|
43
|
+
var globalConfig = useMapGlobalConfig(name);
|
|
44
|
+
var mapConfig = _objectSpread(_objectSpread({}, globalConfig), props);
|
|
45
|
+
return mapConfig;
|
|
46
|
+
}
|
|
47
|
+
function useGraphGlobalConfig(name) {
|
|
48
|
+
var _useConfig3 = useConfig(),
|
|
49
|
+
_useConfig3$graph = _useConfig3.graph,
|
|
50
|
+
graphConfig = _useConfig3$graph === void 0 ? {} : _useConfig3$graph;
|
|
51
|
+
var componentConfig = useComponentGlobalConfig(name);
|
|
52
|
+
return mergeGraphOptions(graphConfig, componentConfig || {});
|
|
53
|
+
}
|
|
54
|
+
export function useGraphConfig(name, defaultConfig, props) {
|
|
55
|
+
var globalConfig = useGraphGlobalConfig(name);
|
|
56
|
+
return mergeGraphOptions(defaultConfig, globalConfig, props);
|
|
57
|
+
}
|