@antv/gpt-vis 0.5.5 → 0.5.7
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/dist/cjs/Area/index.d.ts +2 -3
- package/dist/cjs/Area/index.js +48 -5
- package/dist/cjs/Bar/index.d.ts +5 -2
- package/dist/cjs/Bar/index.js +43 -7
- package/dist/cjs/Boxplot/index.d.ts +13 -0
- package/dist/cjs/Boxplot/index.js +88 -0
- package/dist/cjs/ChartCodeRender/VisChart.d.ts +7 -1
- package/dist/cjs/ChartCodeRender/VisChart.js +100 -12
- package/dist/cjs/ChartCodeRender/index.js +16 -2
- package/dist/cjs/ChartCodeRender/type.d.ts +104 -5
- package/dist/cjs/Column/index.d.ts +5 -3
- package/dist/cjs/Column/index.js +44 -7
- package/dist/cjs/ConfigProvider/hooks/useConfig.js +2 -1
- package/dist/cjs/DualAxes/index.d.ts +1 -1
- package/dist/cjs/DualAxes/index.js +20 -8
- package/dist/cjs/FishboneDiagram/index.d.ts +1 -0
- package/dist/cjs/FishboneDiagram/index.js +21 -7
- package/dist/cjs/Funnel/index.d.ts +12 -0
- package/dist/cjs/Funnel/index.js +173 -0
- package/dist/cjs/Histogram/index.d.ts +4 -3
- package/dist/cjs/Histogram/index.js +32 -3
- package/dist/cjs/IndentedTree/index.d.ts +1 -0
- package/dist/cjs/IndentedTree/index.js +32 -20
- package/dist/cjs/Line/index.d.ts +2 -3
- package/dist/cjs/Line/index.js +36 -3
- package/dist/cjs/Liquid/index.d.ts +11 -0
- package/dist/cjs/Liquid/index.js +85 -0
- package/dist/cjs/MindMap/index.d.ts +1 -0
- package/dist/cjs/MindMap/index.js +29 -21
- package/dist/cjs/Pie/index.d.ts +2 -2
- package/dist/cjs/Pie/index.js +22 -3
- package/dist/cjs/Radar/index.d.ts +5 -3
- package/dist/cjs/Radar/index.js +106 -37
- package/dist/cjs/Sankey/index.d.ts +12 -0
- package/dist/cjs/Sankey/index.js +106 -0
- package/dist/cjs/Scatter/index.d.ts +2 -3
- package/dist/cjs/Scatter/index.js +52 -6
- package/dist/cjs/Treemap/index.d.ts +2 -3
- package/dist/cjs/Treemap/index.js +23 -3
- package/dist/cjs/Venn/index.d.ts +32 -0
- package/dist/cjs/Venn/index.js +87 -0
- package/dist/cjs/Violin/index.d.ts +10 -0
- package/dist/cjs/Violin/index.js +185 -0
- package/dist/cjs/WordCloud/index.d.ts +2 -3
- package/dist/cjs/WordCloud/index.js +34 -7
- package/dist/cjs/export.d.ts +7 -1
- package/dist/cjs/export.js +38 -8
- package/dist/cjs/theme.d.ts +2 -0
- package/dist/cjs/theme.js +133 -0
- package/dist/cjs/types/chart.d.ts +17 -0
- package/dist/cjs/types/chart.js +6 -0
- package/dist/cjs/utils/palette.d.ts +2 -0
- package/dist/cjs/utils/palette.js +54 -0
- package/dist/cjs/utils/plot.d.ts +1 -0
- package/dist/cjs/utils/plot.js +15 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Area/index.d.ts +2 -3
- package/dist/esm/Area/index.js +80 -6
- package/dist/esm/Bar/index.d.ts +5 -2
- package/dist/esm/Bar/index.js +66 -9
- package/dist/esm/Boxplot/index.d.ts +13 -0
- package/dist/esm/Boxplot/index.js +83 -0
- package/dist/esm/ChartCodeRender/VisChart.d.ts +7 -1
- package/dist/esm/ChartCodeRender/VisChart.js +144 -34
- package/dist/esm/ChartCodeRender/index.js +15 -1
- package/dist/esm/ChartCodeRender/type.d.ts +104 -5
- package/dist/esm/Column/index.d.ts +5 -3
- package/dist/esm/Column/index.js +67 -9
- package/dist/esm/ConfigProvider/hooks/useConfig.js +9 -1
- package/dist/esm/DualAxes/index.d.ts +1 -1
- package/dist/esm/DualAxes/index.js +35 -12
- package/dist/esm/FishboneDiagram/index.d.ts +1 -0
- package/dist/esm/FishboneDiagram/index.js +23 -7
- package/dist/esm/Funnel/index.d.ts +12 -0
- package/dist/esm/Funnel/index.js +171 -0
- package/dist/esm/Histogram/index.d.ts +4 -3
- package/dist/esm/Histogram/index.js +55 -5
- package/dist/esm/IndentedTree/index.d.ts +1 -0
- package/dist/esm/IndentedTree/index.js +36 -29
- package/dist/esm/Line/index.d.ts +2 -3
- package/dist/esm/Line/index.js +63 -4
- package/dist/esm/Liquid/index.d.ts +11 -0
- package/dist/esm/Liquid/index.js +100 -0
- package/dist/esm/MindMap/index.d.ts +1 -0
- package/dist/esm/MindMap/index.js +37 -30
- package/dist/esm/Pie/index.d.ts +2 -2
- package/dist/esm/Pie/index.js +37 -4
- package/dist/esm/Radar/index.d.ts +5 -3
- package/dist/esm/Radar/index.js +138 -42
- package/dist/esm/Sankey/index.d.ts +12 -0
- package/dist/esm/Sankey/index.js +88 -0
- package/dist/esm/Scatter/index.d.ts +2 -3
- package/dist/esm/Scatter/index.js +76 -11
- package/dist/esm/Treemap/index.d.ts +2 -3
- package/dist/esm/Treemap/index.js +39 -4
- package/dist/esm/Venn/index.d.ts +32 -0
- package/dist/esm/Venn/index.js +69 -0
- package/dist/esm/Violin/index.d.ts +10 -0
- package/dist/esm/Violin/index.js +192 -0
- package/dist/esm/WordCloud/index.d.ts +2 -3
- package/dist/esm/WordCloud/index.js +51 -9
- package/dist/esm/export.d.ts +7 -1
- package/dist/esm/export.js +8 -2
- package/dist/esm/theme.d.ts +2 -0
- package/dist/esm/theme.js +103 -0
- package/dist/esm/types/chart.d.ts +17 -0
- package/dist/esm/types/chart.js +6 -0
- package/dist/esm/utils/palette.d.ts +2 -0
- package/dist/esm/utils/palette.js +2 -0
- package/dist/esm/utils/plot.d.ts +1 -0
- package/dist/esm/utils/plot.js +10 -0
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/umd/373.async.js +1 -0
- package/dist/umd/index.min.js +1 -1
- package/package.json +2 -1
- package/dist/umd/962.async.js +0 -1
package/dist/esm/Line/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { LineConfig } from '@ant-design/plots';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import type { BasePlotProps } from '../types';
|
|
2
|
+
import type { BasePlotProps, Style, Theme } from '../types';
|
|
4
3
|
export type LineDataItem = {
|
|
5
4
|
time: string | number;
|
|
6
5
|
value: number;
|
|
7
6
|
[key: string]: string | number;
|
|
8
7
|
};
|
|
9
|
-
export type LineProps = BasePlotProps<LineDataItem> &
|
|
8
|
+
export type LineProps = BasePlotProps<LineDataItem> & Theme & Style;
|
|
10
9
|
declare const Line: (props: LineProps) => React.JSX.Element;
|
|
11
10
|
export default Line;
|
package/dist/esm/Line/index.js
CHANGED
|
@@ -1,30 +1,89 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
import { Line as ADCLine } from '@ant-design/plots';
|
|
2
8
|
import { get } from 'lodash';
|
|
3
9
|
import React from 'react';
|
|
4
10
|
import { usePlotConfig } from "../ConfigProvider/hooks";
|
|
11
|
+
import { THEME_MAP } from "../theme";
|
|
5
12
|
var defaultConfig = function defaultConfig(props) {
|
|
6
13
|
var data = props.data,
|
|
7
14
|
_props$xField = props.xField,
|
|
8
15
|
xField = _props$xField === void 0 ? 'time' : _props$xField,
|
|
9
16
|
_props$yField = props.yField,
|
|
10
|
-
yField = _props$yField === void 0 ? 'value' : _props$yField
|
|
17
|
+
yField = _props$yField === void 0 ? 'value' : _props$yField,
|
|
18
|
+
_props$style = props.style,
|
|
19
|
+
style = _props$style === void 0 ? {} : _props$style;
|
|
20
|
+
var palette = style.palette,
|
|
21
|
+
lineWidth = style.lineWidth,
|
|
22
|
+
backgroundColor = style.backgroundColor;
|
|
11
23
|
var hasGroupField = get(data, '[0].group') !== undefined;
|
|
12
24
|
var axisYTitle = get(props, 'axis.y.title');
|
|
13
|
-
|
|
25
|
+
var hasPalette = !!(palette !== null && palette !== void 0 && palette[0]);
|
|
26
|
+
var encode = {};
|
|
27
|
+
var paletteConfig = {
|
|
28
|
+
color: undefined
|
|
29
|
+
};
|
|
30
|
+
if (hasGroupField) {
|
|
31
|
+
encode = {
|
|
32
|
+
x: xField,
|
|
33
|
+
y: yField,
|
|
34
|
+
color: 'group'
|
|
35
|
+
};
|
|
36
|
+
} else {
|
|
37
|
+
encode = {
|
|
38
|
+
x: xField,
|
|
39
|
+
y: yField,
|
|
40
|
+
color: function color() {
|
|
41
|
+
return 'all';
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (hasPalette) {
|
|
46
|
+
paletteConfig = {
|
|
47
|
+
color: {
|
|
48
|
+
range: palette
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return _objectSpread({
|
|
14
53
|
xField: xField,
|
|
15
54
|
yField: yField,
|
|
16
55
|
colorField: hasGroupField ? 'group' : undefined,
|
|
56
|
+
encode: encode,
|
|
57
|
+
legend: hasGroupField ? {} : false,
|
|
17
58
|
tooltip: function tooltip(d) {
|
|
18
59
|
var tooltipName = axisYTitle || d[xField];
|
|
19
60
|
return {
|
|
20
61
|
name: tooltipName,
|
|
21
62
|
value: d[yField]
|
|
22
63
|
};
|
|
64
|
+
},
|
|
65
|
+
scale: _objectSpread({
|
|
66
|
+
y: {
|
|
67
|
+
nice: true
|
|
68
|
+
}
|
|
69
|
+
}, paletteConfig),
|
|
70
|
+
style: {
|
|
71
|
+
lineWidth: lineWidth || 2
|
|
23
72
|
}
|
|
24
|
-
}
|
|
73
|
+
}, backgroundColor ? {
|
|
74
|
+
viewStyle: {
|
|
75
|
+
viewFill: backgroundColor
|
|
76
|
+
}
|
|
77
|
+
} : {
|
|
78
|
+
viewStyle: undefined
|
|
79
|
+
});
|
|
25
80
|
};
|
|
26
81
|
var Line = function Line(props) {
|
|
27
|
-
var
|
|
82
|
+
var _props$theme;
|
|
83
|
+
var themeConfig = THEME_MAP[(_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : 'default'];
|
|
84
|
+
var config = usePlotConfig('Line', defaultConfig, _objectSpread(_objectSpread({}, props), {}, {
|
|
85
|
+
theme: themeConfig
|
|
86
|
+
}));
|
|
28
87
|
return /*#__PURE__*/React.createElement(ADCLine, config);
|
|
29
88
|
};
|
|
30
89
|
export default Line;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Style, Theme } from '../types';
|
|
3
|
+
export type LiquidProps = Theme & Style & {
|
|
4
|
+
percent: number;
|
|
5
|
+
shape?: 'rect' | 'circle' | 'pin' | 'triangle';
|
|
6
|
+
title?: string;
|
|
7
|
+
width?: number;
|
|
8
|
+
height?: number;
|
|
9
|
+
};
|
|
10
|
+
declare const Liquid: (props: LiquidProps) => React.JSX.Element;
|
|
11
|
+
export default Liquid;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
12
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
+
import { Liquid as ADCLiquid } from '@ant-design/plots';
|
|
14
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
15
|
+
import { usePlotConfig } from "../ConfigProvider/hooks";
|
|
16
|
+
import { THEME_MAP } from "../theme";
|
|
17
|
+
var defaultConfig = function defaultConfig(props) {
|
|
18
|
+
var percent = props.percent,
|
|
19
|
+
_props$shape = props.shape,
|
|
20
|
+
shape = _props$shape === void 0 ? 'circle' : _props$shape,
|
|
21
|
+
_props$style = props.style,
|
|
22
|
+
style = _props$style === void 0 ? {} : _props$style,
|
|
23
|
+
_props$width = props.width,
|
|
24
|
+
width = _props$width === void 0 ? 600 : _props$width,
|
|
25
|
+
_props$height = props.height,
|
|
26
|
+
height = _props$height === void 0 ? 400 : _props$height;
|
|
27
|
+
var backgroundColor = style.backgroundColor,
|
|
28
|
+
palette = style.palette;
|
|
29
|
+
var inferFontSize = Math.min(width, height) / 10;
|
|
30
|
+
var fontSize = Math.min(Math.max(inferFontSize, 24), 64);
|
|
31
|
+
var hasPalette = !!(palette !== null && palette !== void 0 && palette[0]);
|
|
32
|
+
var paletteConfig = {
|
|
33
|
+
fill: undefined,
|
|
34
|
+
outlineStroke: undefined
|
|
35
|
+
};
|
|
36
|
+
if (hasPalette) {
|
|
37
|
+
paletteConfig = {
|
|
38
|
+
fill: palette[0],
|
|
39
|
+
outlineStroke: palette[0]
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return _objectSpread(_objectSpread({
|
|
43
|
+
percent: percent,
|
|
44
|
+
style: _objectSpread({
|
|
45
|
+
shape: shape,
|
|
46
|
+
contentFontSize: fontSize,
|
|
47
|
+
contentFill: '#000',
|
|
48
|
+
contentStroke: '#fff',
|
|
49
|
+
contentLineWidth: 2,
|
|
50
|
+
outlineBorder: 4,
|
|
51
|
+
outlineDistance: 4,
|
|
52
|
+
waveLength: 128
|
|
53
|
+
}, paletteConfig)
|
|
54
|
+
}, backgroundColor ? {
|
|
55
|
+
viewStyle: {
|
|
56
|
+
viewFill: backgroundColor
|
|
57
|
+
}
|
|
58
|
+
} : {}), {}, {
|
|
59
|
+
interaction: {
|
|
60
|
+
tooltip: false
|
|
61
|
+
},
|
|
62
|
+
animate: false
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var Liquid = function Liquid(props) {
|
|
66
|
+
var _props$theme;
|
|
67
|
+
var themeConfig = THEME_MAP[(_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : 'default'];
|
|
68
|
+
var containerRef = useRef(null);
|
|
69
|
+
var _useState = useState({
|
|
70
|
+
width: 0,
|
|
71
|
+
height: 0
|
|
72
|
+
}),
|
|
73
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
74
|
+
size = _useState2[0],
|
|
75
|
+
setSize = _useState2[1];
|
|
76
|
+
var config = usePlotConfig('Liquid', defaultConfig, _objectSpread(_objectSpread({}, props), {}, {
|
|
77
|
+
theme: themeConfig,
|
|
78
|
+
width: size.width,
|
|
79
|
+
height: size.height
|
|
80
|
+
}));
|
|
81
|
+
useEffect(function () {
|
|
82
|
+
if (containerRef.current) {
|
|
83
|
+
var _containerRef$current = containerRef.current,
|
|
84
|
+
offsetWidth = _containerRef$current.offsetWidth,
|
|
85
|
+
offsetHeight = _containerRef$current.offsetHeight;
|
|
86
|
+
setSize({
|
|
87
|
+
width: offsetWidth,
|
|
88
|
+
height: offsetHeight
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}, []);
|
|
92
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
93
|
+
ref: containerRef,
|
|
94
|
+
style: {
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: '100%'
|
|
97
|
+
}
|
|
98
|
+
}, /*#__PURE__*/React.createElement(ADCLiquid, config));
|
|
99
|
+
};
|
|
100
|
+
export default Liquid;
|
|
@@ -17,36 +17,43 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
17
17
|
import { MindMap as ADCMindMap } from '@ant-design/graphs';
|
|
18
18
|
import React, { useMemo } from 'react';
|
|
19
19
|
import { useGraphConfig } from "../ConfigProvider/hooks";
|
|
20
|
+
import { G6THEME_MAP } from "../theme";
|
|
20
21
|
import { visTreeData2GraphData } from "../utils/graph";
|
|
21
|
-
var
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
22
|
+
var getDefaultConfig = function getDefaultConfig(props) {
|
|
23
|
+
var _props$theme = props.theme,
|
|
24
|
+
theme = _props$theme === void 0 ? 'default' : _props$theme;
|
|
25
|
+
return {
|
|
26
|
+
type: 'boxed',
|
|
27
|
+
autoFit: 'view',
|
|
28
|
+
autoResize: true,
|
|
29
|
+
padding: 2,
|
|
30
|
+
zoomRange: [0.1, 5],
|
|
31
|
+
zoom: 1,
|
|
32
|
+
node: {
|
|
33
|
+
animation: {
|
|
34
|
+
translate: false,
|
|
35
|
+
update: false
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
edge: {
|
|
39
|
+
animation: {
|
|
40
|
+
translate: false,
|
|
41
|
+
update: false
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
transforms: function transforms(prev) {
|
|
45
|
+
return [].concat(_toConsumableArray(prev.filter(function (transform) {
|
|
46
|
+
return transform.type !== 'collapse-expand-react-node';
|
|
47
|
+
})), [_objectSpread(_objectSpread({}, prev.find(function (transform) {
|
|
48
|
+
return transform.type === 'collapse-expand-react-node';
|
|
49
|
+
})), {}, {
|
|
50
|
+
enable: true
|
|
51
|
+
}), _objectSpread(_objectSpread({}, prev.find(function (transform) {
|
|
52
|
+
return transform.key === 'assign-color-by-branch';
|
|
53
|
+
}) || {}), G6THEME_MAP[theme])]);
|
|
54
|
+
},
|
|
55
|
+
behaviors: ['drag-canvas']
|
|
56
|
+
};
|
|
50
57
|
};
|
|
51
58
|
var MindMap = function MindMap(props) {
|
|
52
59
|
var propsData = props.data,
|
|
@@ -54,7 +61,7 @@ var MindMap = function MindMap(props) {
|
|
|
54
61
|
var data = useMemo(function () {
|
|
55
62
|
return visTreeData2GraphData(propsData);
|
|
56
63
|
}, [propsData]);
|
|
57
|
-
var config = useGraphConfig('MindMap',
|
|
64
|
+
var config = useGraphConfig('MindMap', getDefaultConfig(props), restProps);
|
|
58
65
|
return /*#__PURE__*/React.createElement(ADCMindMap, _extends({
|
|
59
66
|
data: data
|
|
60
67
|
}, config));
|
package/dist/esm/Pie/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PieConfig } from '@ant-design/plots';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
import type { BasePlotProps } from '../types';
|
|
3
|
+
import type { BasePlotProps, Theme } from '../types';
|
|
4
4
|
/**
|
|
5
5
|
* PieDataItem is the type for each data item in the pie chart.
|
|
6
6
|
* It includes the name of the sector and its corresponding value.
|
|
@@ -16,6 +16,6 @@ type PieDataItem = {
|
|
|
16
16
|
* the props for the Pie
|
|
17
17
|
* @param data pie data
|
|
18
18
|
*/
|
|
19
|
-
export type PieProps = BasePlotProps<PieDataItem> & Partial<PieConfig
|
|
19
|
+
export type PieProps = BasePlotProps<PieDataItem> & Partial<PieConfig> & Theme;
|
|
20
20
|
declare const Pie: (props: PieProps) => React.JSX.Element;
|
|
21
21
|
export default Pie;
|
package/dist/esm/Pie/index.js
CHANGED
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
1
7
|
import { Pie as ADCPie } from '@ant-design/plots';
|
|
2
8
|
import { round, sumBy } from 'lodash';
|
|
3
9
|
import React from 'react';
|
|
4
10
|
import { usePlotConfig } from "../ConfigProvider/hooks";
|
|
11
|
+
import { THEME_MAP } from "../theme";
|
|
5
12
|
|
|
6
13
|
/**
|
|
7
14
|
* PieDataItem is the type for each data item in the pie chart.
|
|
@@ -21,9 +28,24 @@ var defaultConfig = function defaultConfig(props) {
|
|
|
21
28
|
_props$angleField = props.angleField,
|
|
22
29
|
angleField = _props$angleField === void 0 ? 'value' : _props$angleField,
|
|
23
30
|
_props$colorField = props.colorField,
|
|
24
|
-
colorField = _props$colorField === void 0 ? 'category' : _props$colorField
|
|
31
|
+
colorField = _props$colorField === void 0 ? 'category' : _props$colorField,
|
|
32
|
+
_props$style = props.style,
|
|
33
|
+
style = _props$style === void 0 ? {} : _props$style;
|
|
25
34
|
var sumValue = sumBy(data, angleField);
|
|
26
|
-
|
|
35
|
+
var backgroundColor = style.backgroundColor,
|
|
36
|
+
palette = style.palette;
|
|
37
|
+
var hasPalette = !!(palette !== null && palette !== void 0 && palette[0]);
|
|
38
|
+
var paletteConfig = {
|
|
39
|
+
color: undefined
|
|
40
|
+
};
|
|
41
|
+
if (hasPalette) {
|
|
42
|
+
paletteConfig = {
|
|
43
|
+
color: {
|
|
44
|
+
range: palette
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return _objectSpread({
|
|
27
49
|
angleField: angleField,
|
|
28
50
|
colorField: colorField,
|
|
29
51
|
tooltip: function tooltip(d) {
|
|
@@ -49,11 +71,22 @@ var defaultConfig = function defaultConfig(props) {
|
|
|
49
71
|
elementSelect: {
|
|
50
72
|
single: true
|
|
51
73
|
}
|
|
74
|
+
},
|
|
75
|
+
scale: _objectSpread({}, paletteConfig)
|
|
76
|
+
}, backgroundColor ? {
|
|
77
|
+
viewStyle: {
|
|
78
|
+
viewFill: backgroundColor
|
|
52
79
|
}
|
|
53
|
-
}
|
|
80
|
+
} : {
|
|
81
|
+
viewStyle: undefined
|
|
82
|
+
});
|
|
54
83
|
};
|
|
55
84
|
var Pie = function Pie(props) {
|
|
56
|
-
var
|
|
85
|
+
var _props$theme;
|
|
86
|
+
var themeConfig = THEME_MAP[(_props$theme = props.theme) !== null && _props$theme !== void 0 ? _props$theme : 'default'];
|
|
87
|
+
var config = usePlotConfig('Pie', defaultConfig, _objectSpread(_objectSpread({}, props), {}, {
|
|
88
|
+
theme: themeConfig
|
|
89
|
+
}));
|
|
57
90
|
return /*#__PURE__*/React.createElement(ADCPie, config);
|
|
58
91
|
};
|
|
59
92
|
export default Pie;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import type { RadarConfig } from '@ant-design/plots';
|
|
2
1
|
import React from 'react';
|
|
3
|
-
import type { BasePlotProps } from '../types';
|
|
2
|
+
import type { BasePlotProps, Style, Theme } from '../types';
|
|
4
3
|
export type RadarDataItem = {
|
|
5
4
|
name: string;
|
|
6
5
|
value: number;
|
|
7
6
|
[key: string]: string | number;
|
|
8
7
|
};
|
|
9
|
-
export type RadarProps = BasePlotProps<RadarDataItem> &
|
|
8
|
+
export type RadarProps = BasePlotProps<RadarDataItem> & Theme & Style & {
|
|
9
|
+
width?: number;
|
|
10
|
+
height?: number;
|
|
11
|
+
};
|
|
10
12
|
declare const Radar: (props: RadarProps) => React.JSX.Element;
|
|
11
13
|
export default Radar;
|
package/dist/esm/Radar/index.js
CHANGED
|
@@ -1,54 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import { Chart } from '@antv/g2';
|
|
14
|
+
import React, { useEffect, useRef } from 'react';
|
|
15
|
+
import { THEME_MAP } from "../theme";
|
|
16
|
+
import { groupBy } from "../utils/plot";
|
|
17
|
+
function transformRadartoParallel(data) {
|
|
18
|
+
if (!data || data.length === 0) {
|
|
19
|
+
return [];
|
|
20
|
+
}
|
|
21
|
+
var groups = groupBy(data, function (d) {
|
|
22
|
+
return d.group || '';
|
|
23
|
+
});
|
|
24
|
+
return Object.entries(groups).map(function (_ref) {
|
|
25
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
26
|
+
group = _ref2[0],
|
|
27
|
+
values = _ref2[1];
|
|
28
|
+
var paralleValues = (values || []).reduce(function (acc, _ref3) {
|
|
29
|
+
var name = _ref3.name,
|
|
30
|
+
value = _ref3.value;
|
|
31
|
+
acc[name] = value;
|
|
32
|
+
return acc;
|
|
33
|
+
}, {});
|
|
34
|
+
return _objectSpread(_objectSpread({}, paralleValues), {}, {
|
|
35
|
+
group: group
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
}
|
|
5
39
|
var defaultConfig = function defaultConfig(props) {
|
|
6
40
|
var data = props.data,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
_props$
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
41
|
+
title = props.title,
|
|
42
|
+
_props$theme = props.theme,
|
|
43
|
+
theme = _props$theme === void 0 ? 'default' : _props$theme,
|
|
44
|
+
_props$style = props.style,
|
|
45
|
+
style = _props$style === void 0 ? {} : _props$style;
|
|
46
|
+
var backgroundColor = style.backgroundColor,
|
|
47
|
+
_style$palette = style.palette,
|
|
48
|
+
palette = _style$palette === void 0 ? [] : _style$palette,
|
|
49
|
+
_style$lineWidth = style.lineWidth,
|
|
50
|
+
lineWidth = _style$lineWidth === void 0 ? 2 : _style$lineWidth;
|
|
51
|
+
var parallelData = transformRadartoParallel(data);
|
|
52
|
+
var position = Object.keys(parallelData[0] || {}).filter(function (key) {
|
|
53
|
+
return key !== 'group';
|
|
54
|
+
});
|
|
55
|
+
return _objectSpread(_objectSpread({
|
|
56
|
+
title: title,
|
|
57
|
+
autoFit: true,
|
|
58
|
+
theme: THEME_MAP[theme],
|
|
59
|
+
inset: 18,
|
|
60
|
+
type: 'line',
|
|
61
|
+
data: parallelData,
|
|
62
|
+
coordinate: {
|
|
63
|
+
type: 'radar'
|
|
64
|
+
},
|
|
65
|
+
encode: {
|
|
66
|
+
position: position,
|
|
67
|
+
color: 'group'
|
|
20
68
|
},
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
69
|
+
style: {
|
|
70
|
+
lineWidth: lineWidth,
|
|
71
|
+
lineCap: 'round',
|
|
72
|
+
lineJoin: 'round'
|
|
73
|
+
}
|
|
74
|
+
}, backgroundColor ? {
|
|
75
|
+
viewStyle: {
|
|
76
|
+
viewFill: backgroundColor
|
|
77
|
+
}
|
|
78
|
+
} : {}), {}, {
|
|
79
|
+
legend: {
|
|
80
|
+
color: parallelData.length > 1 ? {
|
|
81
|
+
itemMarker: 'point'
|
|
82
|
+
} : false
|
|
83
|
+
},
|
|
84
|
+
scale: _objectSpread(_objectSpread({}, Object.fromEntries(Array.from({
|
|
85
|
+
length: position.length
|
|
86
|
+
}, function (_, i) {
|
|
87
|
+
return ["position".concat(i === 0 ? '' : i), {
|
|
88
|
+
domainMin: 0,
|
|
27
89
|
nice: true
|
|
90
|
+
}];
|
|
91
|
+
}))), palette !== null && palette !== void 0 && palette[0] ? {
|
|
92
|
+
color: {
|
|
93
|
+
range: palette
|
|
28
94
|
}
|
|
29
|
-
},
|
|
30
|
-
axis: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
},
|
|
35
|
-
y: {
|
|
95
|
+
} : {}),
|
|
96
|
+
axis: Object.fromEntries(Array.from({
|
|
97
|
+
length: position.length
|
|
98
|
+
}, function (_, i) {
|
|
99
|
+
return ["position".concat(i === 0 ? '' : i), {
|
|
36
100
|
zIndex: 1,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
101
|
+
titleFontSize: 10,
|
|
102
|
+
titleSpacing: 8,
|
|
103
|
+
label: true,
|
|
104
|
+
labelFill: theme === 'dark' ? '#fff' : '#000',
|
|
105
|
+
labelOpacity: 0.45,
|
|
106
|
+
labelFontSize: 10,
|
|
107
|
+
line: true,
|
|
108
|
+
lineFill: '#000',
|
|
109
|
+
lineStrokeOpacity: 0.25,
|
|
110
|
+
tickFilter: function tickFilter(_, idx) {
|
|
111
|
+
return !(i !== 0 && idx === 0);
|
|
112
|
+
},
|
|
113
|
+
tickCount: 4,
|
|
114
|
+
gridStrokeOpacity: 0.45,
|
|
115
|
+
gridStroke: theme === 'dark' ? '#fff' : '#000',
|
|
116
|
+
gridLineWidth: 1,
|
|
117
|
+
gridLineDash: [4, 4]
|
|
118
|
+
}];
|
|
119
|
+
})),
|
|
120
|
+
interaction: {
|
|
121
|
+
tooltip: {
|
|
122
|
+
series: false
|
|
40
123
|
}
|
|
41
|
-
},
|
|
42
|
-
tooltip: function tooltip(d) {
|
|
43
|
-
return {
|
|
44
|
-
name: d[xField],
|
|
45
|
-
value: d[yField]
|
|
46
|
-
};
|
|
47
124
|
}
|
|
48
|
-
};
|
|
125
|
+
});
|
|
49
126
|
};
|
|
50
127
|
var Radar = function Radar(props) {
|
|
51
|
-
var
|
|
52
|
-
|
|
128
|
+
var containerRef = useRef(null);
|
|
129
|
+
var chartRef = useRef(null);
|
|
130
|
+
useEffect(function () {
|
|
131
|
+
if (!containerRef.current) return;
|
|
132
|
+
var chart = new Chart({
|
|
133
|
+
container: containerRef.current,
|
|
134
|
+
autoFit: true,
|
|
135
|
+
padding: 'auto'
|
|
136
|
+
});
|
|
137
|
+
var config = defaultConfig(props);
|
|
138
|
+
chart.options(config);
|
|
139
|
+
chart.render();
|
|
140
|
+
chartRef.current = chart;
|
|
141
|
+
return function () {
|
|
142
|
+
chart.destroy();
|
|
143
|
+
chartRef.current = null;
|
|
144
|
+
};
|
|
145
|
+
}, [props]);
|
|
146
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
147
|
+
ref: containerRef
|
|
148
|
+
});
|
|
53
149
|
};
|
|
54
150
|
export default Radar;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { BasePlotProps, Style, Theme } from '../types';
|
|
3
|
+
type SankeyDatum = {
|
|
4
|
+
source: string;
|
|
5
|
+
target: string;
|
|
6
|
+
value: number;
|
|
7
|
+
};
|
|
8
|
+
export type SankeyProps = BasePlotProps<SankeyDatum> & Theme & Style & {
|
|
9
|
+
nodeAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
10
|
+
};
|
|
11
|
+
declare const Sankey: (props: SankeyProps) => React.JSX.Element;
|
|
12
|
+
export default Sankey;
|