pixelize-design-library 2.2.144 → 2.2.146
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/Components/Apexcharts/ApexBarChart/ApexBarChart.js +72 -18
- package/dist/Components/Apexcharts/ApexLineChart/ApexLineChart.js +37 -26
- package/dist/Components/Apexcharts/ApexPieChart/ApexPieChart.js +168 -121
- package/dist/Components/Apexcharts/ApexPolarCharts/ApexPolarCharts.js +93 -44
- package/dist/Components/Common/ErrorComponent.d.ts +2 -2
- package/dist/Components/Common/ErrorComponent.js +12 -6
- package/dist/Components/Common/Label.d.ts +2 -2
- package/dist/Components/Common/Label.js +8 -2
- package/dist/Components/DatePicker/CalendarPanel.js +2 -2
- package/dist/Components/FilterSidebar/FilterSidebar.js +8 -6
- package/dist/Components/Input/Input/Input.d.ts +1 -1
- package/dist/Components/Input/Input/Input.js +29 -6
- package/dist/Components/Loading/Loading.js +4 -2
- package/dist/Components/PinInputs/PinInputs.d.ts +2 -2
- package/dist/Components/PinInputs/PinInputs.js +19 -4
- package/dist/Components/ProductCard/ProductPrice.js +2 -2
- package/dist/Components/ProductCard/ProductTags.js +7 -3
- package/dist/Components/ProfileCard/ProfileCard.js +8 -4
- package/dist/Components/ProfilePhotoViewer/ProfilePhotoViewer.js +4 -4
- package/dist/Components/SelectSearch/SelectSearch.js +14 -4
- package/dist/Components/SideBar/SideBar.d.ts +1 -1
- package/dist/Components/SideBar/SideBar.js +3 -1
- package/dist/Components/SideBar/SideBarProps.d.ts +11 -0
- package/dist/Components/SideBar/components/OtherApps.d.ts +4 -0
- package/dist/Components/SideBar/components/OtherApps.js +38 -0
- package/dist/Components/SideBar/components/OtherApps.test.d.ts +1 -0
- package/dist/Components/SideBar/components/OtherApps.test.js +112 -0
- package/dist/Components/Table/Components/TableHeader.js +3 -3
- package/dist/Components/Table/LeftFilterPane.js +5 -5
- package/dist/Components/Timeline/Timeline.js +15 -15
- package/dist/Components/Trail/TrailWorks.js +13 -206
- package/dist/Theme/chartColorsFromTheme.d.ts +18 -0
- package/dist/Theme/chartColorsFromTheme.js +39 -0
- package/dist/Theme/chartColorsFromTheme.test.d.ts +1 -0
- package/dist/Theme/chartColorsFromTheme.test.js +35 -0
- package/package.json +1 -1
|
@@ -1,23 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
2
46
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
47
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
48
|
};
|
|
5
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
50
|
exports.default = ApexBarChart;
|
|
7
|
-
var react_1 =
|
|
51
|
+
var react_1 = __importStar(require("react"));
|
|
8
52
|
var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
|
|
53
|
+
var react_2 = require("@chakra-ui/react");
|
|
54
|
+
var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
|
|
9
55
|
function ApexBarChart(_a) {
|
|
10
|
-
var data = _a.data, labels = _a.labels, title = _a.title, titlePosition = _a.titlePosition, _b = _a.height, height = _b === void 0 ? 400 : _b, _c = _a.width, width = _c === void 0 ? 500 : _c,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var options = {
|
|
56
|
+
var data = _a.data, labels = _a.labels, title = _a.title, titlePosition = _a.titlePosition, _b = _a.height, height = _b === void 0 ? 400 : _b, _c = _a.width, width = _c === void 0 ? 500 : _c, barColor = _a.barColor, xAxisStyle = _a.xAxisStyle, yAxisStyle = _a.yAxisStyle, titleStyle = _a.titleStyle;
|
|
57
|
+
var theme = (0, react_2.useTheme)();
|
|
58
|
+
var palette = theme.colors;
|
|
59
|
+
var resolvedBarColors = barColor !== null && barColor !== void 0 ? barColor : [(0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette)[0]];
|
|
60
|
+
var axisColor = (0, chartColorsFromTheme_1.chartAxisLabelColor)(palette);
|
|
61
|
+
var mergedXAxis = (0, react_1.useMemo)(function () { var _a; return (__assign(__assign({}, xAxisStyle), { color: (_a = xAxisStyle === null || xAxisStyle === void 0 ? void 0 : xAxisStyle.color) !== null && _a !== void 0 ? _a : axisColor })); }, [axisColor, xAxisStyle]);
|
|
62
|
+
var mergedYAxis = (0, react_1.useMemo)(function () { var _a; return (__assign(__assign({}, yAxisStyle), { color: (_a = yAxisStyle === null || yAxisStyle === void 0 ? void 0 : yAxisStyle.color) !== null && _a !== void 0 ? _a : axisColor })); }, [axisColor, yAxisStyle]);
|
|
63
|
+
var mergedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
|
|
64
|
+
var dataLabelColor = palette.primary[500];
|
|
65
|
+
var options = (0, react_1.useMemo)(function () { return ({
|
|
21
66
|
chart: {
|
|
22
67
|
type: "bar",
|
|
23
68
|
height: 350,
|
|
@@ -32,27 +77,36 @@ function ApexBarChart(_a) {
|
|
|
32
77
|
enabled: false,
|
|
33
78
|
style: {
|
|
34
79
|
fontSize: "12px",
|
|
35
|
-
colors: [
|
|
80
|
+
colors: [dataLabelColor],
|
|
36
81
|
},
|
|
37
82
|
},
|
|
38
83
|
xaxis: {
|
|
39
84
|
categories: labels,
|
|
40
85
|
labels: {
|
|
41
|
-
style:
|
|
86
|
+
style: mergedXAxis,
|
|
42
87
|
},
|
|
43
88
|
},
|
|
44
89
|
yaxis: {
|
|
45
90
|
labels: {
|
|
46
|
-
style:
|
|
91
|
+
style: mergedYAxis,
|
|
47
92
|
},
|
|
48
93
|
},
|
|
49
94
|
title: {
|
|
50
95
|
text: title,
|
|
51
96
|
align: titlePosition,
|
|
52
|
-
style:
|
|
97
|
+
style: mergedTitleStyle,
|
|
53
98
|
},
|
|
54
|
-
colors:
|
|
55
|
-
};
|
|
99
|
+
colors: resolvedBarColors,
|
|
100
|
+
}); }, [
|
|
101
|
+
labels,
|
|
102
|
+
mergedXAxis,
|
|
103
|
+
mergedYAxis,
|
|
104
|
+
title,
|
|
105
|
+
titlePosition,
|
|
106
|
+
mergedTitleStyle,
|
|
107
|
+
resolvedBarColors,
|
|
108
|
+
dataLabelColor,
|
|
109
|
+
]);
|
|
56
110
|
var series = [
|
|
57
111
|
{
|
|
58
112
|
name: "Data",
|
|
@@ -47,29 +47,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
47
47
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
48
|
var react_1 = __importStar(require("react"));
|
|
49
49
|
var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
|
|
50
|
+
var react_2 = require("@chakra-ui/react");
|
|
50
51
|
var ToolTip_1 = __importDefault(require("../../ToolTip/ToolTip"));
|
|
52
|
+
var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
|
|
51
53
|
var ApexLineChart = function (_a) {
|
|
52
|
-
var data = _a.data, labels = _a.labels, title = _a.title, height = _a.height, width = _a.width,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
} : _d, _e = _a.compact, compact = _e === void 0 ? false : _e, _f = _a.toolbarBreakpointPct, toolbarBreakpointPct = _f === void 0 ? 0.6 : _f, titleClampLines = _a.titleClampLines, _g = _a.showTitleEllipsis, showTitleEllipsis = _g === void 0 ? true : _g, _h = _a.showSeries, showSeries = _h === void 0 ? true : _h, seriesNames = _a.series, _j = _a.variant, variant = _j === void 0 ? "basic" : _j;
|
|
54
|
+
var data = _a.data, labels = _a.labels, title = _a.title, height = _a.height, width = _a.width, lineColors = _a.lineColors, _b = _a.titlePosition, titlePosition = _b === void 0 ? "center" : _b, titleStyle = _a.titleStyle, _c = _a.compact, compact = _c === void 0 ? false : _c, _d = _a.toolbarBreakpointPct, toolbarBreakpointPct = _d === void 0 ? 0.6 : _d, titleClampLines = _a.titleClampLines, _e = _a.showTitleEllipsis, showTitleEllipsis = _e === void 0 ? true : _e, _f = _a.showSeries, showSeries = _f === void 0 ? true : _f, seriesNames = _a.series, _g = _a.variant, variant = _g === void 0 ? "basic" : _g;
|
|
55
|
+
var theme = (0, react_2.useTheme)();
|
|
56
|
+
var palette = theme.colors;
|
|
57
|
+
var resolvedLineColors = lineColors !== null && lineColors !== void 0 ? lineColors : (0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette);
|
|
58
|
+
var resolvedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
|
|
58
59
|
var initialName = Array.isArray(seriesNames) && seriesNames.length ? seriesNames[0] : "Series 1";
|
|
59
|
-
var
|
|
60
|
+
var _h = (0, react_1.useState)([
|
|
60
61
|
{
|
|
61
62
|
name: initialName,
|
|
62
63
|
data: Array.isArray(data) ? data : [],
|
|
63
64
|
},
|
|
64
|
-
]), apexSeries =
|
|
65
|
+
]), apexSeries = _h[0], setApexSeries = _h[1];
|
|
65
66
|
(0, react_1.useEffect)(function () {
|
|
66
67
|
if (variant === "realtime") {
|
|
67
68
|
var interval_1 = setInterval(function () {
|
|
68
69
|
setApexSeries(function (prev) {
|
|
69
70
|
var newData = __spreadArray([], prev[0].data, true);
|
|
70
|
-
newData.push(Math.floor(Math.random() * 100) + 10);
|
|
71
|
+
newData.push(Math.floor(Math.random() * 100) + 10);
|
|
71
72
|
if (newData.length > 20)
|
|
72
|
-
newData.shift();
|
|
73
|
+
newData.shift();
|
|
73
74
|
return [{ name: prev[0].name, data: newData }];
|
|
74
75
|
});
|
|
75
76
|
}, 1000);
|
|
@@ -77,7 +78,7 @@ var ApexLineChart = function (_a) {
|
|
|
77
78
|
}
|
|
78
79
|
}, [variant]);
|
|
79
80
|
var wrapperRef = (0, react_1.useRef)(null);
|
|
80
|
-
var
|
|
81
|
+
var _j = (0, react_1.useState)(0), containerW = _j[0], setContainerW = _j[1];
|
|
81
82
|
(0, react_1.useEffect)(function () {
|
|
82
83
|
if (!wrapperRef.current)
|
|
83
84
|
return;
|
|
@@ -90,7 +91,7 @@ var ApexLineChart = function (_a) {
|
|
|
90
91
|
return function () { return ro.disconnect(); };
|
|
91
92
|
}, []);
|
|
92
93
|
var parsePercent = function (v) {
|
|
93
|
-
var n = parseFloat(v.replace(
|
|
94
|
+
var n = parseFloat(v.replace("%", ""));
|
|
94
95
|
return isNaN(n) ? 0 : n / 100;
|
|
95
96
|
};
|
|
96
97
|
var chartW = typeof width === "number"
|
|
@@ -98,17 +99,15 @@ var ApexLineChart = function (_a) {
|
|
|
98
99
|
: typeof width === "string" && width.trim().endsWith("%")
|
|
99
100
|
? containerW * parsePercent(width.trim())
|
|
100
101
|
: containerW;
|
|
101
|
-
var hNum = typeof height === "number"
|
|
102
|
-
? height
|
|
103
|
-
: 0;
|
|
102
|
+
var hNum = typeof height === "number" ? height : 0;
|
|
104
103
|
var isSmall = compact || (chartW > 0 && chartW < 280) || (hNum > 0 && hNum < 220);
|
|
105
|
-
var computedFontSize = (
|
|
104
|
+
var computedFontSize = (resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontSize) ||
|
|
106
105
|
(chartW
|
|
107
106
|
? "".concat(Math.max(12, Math.min(18, Math.floor(chartW / 18))), "px")
|
|
108
107
|
: "14px");
|
|
109
108
|
var clampLines = titleClampLines !== null && titleClampLines !== void 0 ? titleClampLines : (isSmall ? 2 : 1);
|
|
110
109
|
var titleRef = (0, react_1.useRef)(null);
|
|
111
|
-
var
|
|
110
|
+
var _k = (0, react_1.useState)(false), isTruncated = _k[0], setIsTruncated = _k[1];
|
|
112
111
|
(0, react_1.useEffect)(function () {
|
|
113
112
|
var el = titleRef.current;
|
|
114
113
|
if (!el)
|
|
@@ -126,7 +125,7 @@ var ApexLineChart = function (_a) {
|
|
|
126
125
|
? parsePercent(width.trim())
|
|
127
126
|
: 1;
|
|
128
127
|
var showToolbar = !isSmall && ratio >= toolbarBreakpointPct;
|
|
129
|
-
var options = {
|
|
128
|
+
var options = (0, react_1.useMemo)(function () { return ({
|
|
130
129
|
chart: {
|
|
131
130
|
type: "line",
|
|
132
131
|
animations: variant === "realtime"
|
|
@@ -140,31 +139,43 @@ var ApexLineChart = function (_a) {
|
|
|
140
139
|
toolbar: { show: showToolbar },
|
|
141
140
|
},
|
|
142
141
|
stroke: { curve: "smooth" },
|
|
143
|
-
colors:
|
|
142
|
+
colors: resolvedLineColors,
|
|
144
143
|
xaxis: labels
|
|
145
144
|
? { categories: labels }
|
|
146
145
|
: { type: variant === "realtime" ? "numeric" : "category" },
|
|
147
146
|
title: {
|
|
148
147
|
text: isSmall ? undefined : title,
|
|
149
148
|
align: titlePosition !== null && titlePosition !== void 0 ? titlePosition : "center",
|
|
150
|
-
style:
|
|
149
|
+
style: resolvedTitleStyle,
|
|
151
150
|
},
|
|
152
151
|
tooltip: {
|
|
153
|
-
enabled: !!showSeries,
|
|
152
|
+
enabled: !!showSeries,
|
|
154
153
|
marker: { show: !!showSeries },
|
|
155
154
|
},
|
|
156
155
|
markers: { size: showSeries ? 4 : 0, hover: { size: showSeries ? 4 : 0 } },
|
|
157
156
|
dataLabels: { enabled: false },
|
|
158
157
|
grid: { padding: { top: isSmall ? 6 : 16, right: 8, left: 8 } },
|
|
159
|
-
};
|
|
158
|
+
}); }, [
|
|
159
|
+
variant,
|
|
160
|
+
showToolbar,
|
|
161
|
+
resolvedLineColors,
|
|
162
|
+
labels,
|
|
163
|
+
isSmall,
|
|
164
|
+
title,
|
|
165
|
+
titlePosition,
|
|
166
|
+
resolvedTitleStyle,
|
|
167
|
+
showSeries,
|
|
168
|
+
]);
|
|
169
|
+
var tooltipBg = (0, chartColorsFromTheme_1.chartTooltipBackground)(palette);
|
|
170
|
+
var tooltipFg = (0, chartColorsFromTheme_1.chartTooltipForeground)(palette);
|
|
160
171
|
return (react_1.default.createElement("div", { ref: wrapperRef },
|
|
161
|
-
title && isSmall && (react_1.default.createElement(ToolTip_1.default, { label: title, placement: "top", hasArrow: true, fontSize: "0.75rem", bg:
|
|
172
|
+
title && isSmall && (react_1.default.createElement(ToolTip_1.default, { label: title, placement: "top", hasArrow: true, fontSize: "0.75rem", bg: tooltipBg, color: tooltipFg, isDisabled: !isTruncated },
|
|
162
173
|
react_1.default.createElement("div", { ref: titleRef, style: {
|
|
163
174
|
textAlign: "left",
|
|
164
|
-
color:
|
|
175
|
+
color: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.color,
|
|
165
176
|
fontSize: computedFontSize,
|
|
166
|
-
fontWeight:
|
|
167
|
-
fontFamily:
|
|
177
|
+
fontWeight: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontWeight,
|
|
178
|
+
fontFamily: resolvedTitleStyle === null || resolvedTitleStyle === void 0 ? void 0 : resolvedTitleStyle.fontFamily,
|
|
168
179
|
marginBottom: 4,
|
|
169
180
|
width: typeof width === "string"
|
|
170
181
|
? width
|
|
@@ -10,143 +10,190 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
13
46
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
47
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
48
|
};
|
|
16
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var react_1 =
|
|
50
|
+
var react_1 = __importStar(require("react"));
|
|
18
51
|
var react_apexcharts_1 = __importDefault(require("react-apexcharts"));
|
|
52
|
+
var react_2 = require("@chakra-ui/react");
|
|
53
|
+
var chartColorsFromTheme_1 = require("../../../Theme/chartColorsFromTheme");
|
|
54
|
+
var getValidLegendPosition = function (position) {
|
|
55
|
+
var validPositions = ["left", "right", "top", "bottom"];
|
|
56
|
+
if (validPositions.includes(position)) {
|
|
57
|
+
return position;
|
|
58
|
+
}
|
|
59
|
+
console.warn("Invalid legend position: ".concat(position, ". Defaulting to 'bottom'."));
|
|
60
|
+
return "bottom";
|
|
61
|
+
};
|
|
19
62
|
var ApexPieChart = function (_a) {
|
|
20
|
-
var _b
|
|
21
|
-
var data = _a.data, labels = _a.labels, title = _a.title,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
63
|
+
var _b;
|
|
64
|
+
var data = _a.data, labels = _a.labels, title = _a.title, _c = _a.height, height = _c === void 0 ? 400 : _c, _d = _a.width, width = _d === void 0 ? 500 : _d, donutColors = _a.donutColors, chartColor = _a.chartColor, _e = _a.titlePosition, titlePosition = _e === void 0 ? "center" : _e, titleStyle = _a.titleStyle, _f = _a.legendPosition, legendPosition = _f === void 0 ? "bottom" : _f, legendStyle = _a.legendStyle, _g = _a.variant, variant = _g === void 0 ? "pie" : _g;
|
|
65
|
+
var theme = (0, react_2.useTheme)();
|
|
66
|
+
var palette = theme.colors;
|
|
67
|
+
var mergedTitleStyle = (0, react_1.useMemo)(function () { return (0, chartColorsFromTheme_1.mergeChartTitleStyle)(palette, titleStyle); }, [palette, titleStyle]);
|
|
68
|
+
var mergedLegendStyle = (0, react_1.useMemo)(function () {
|
|
69
|
+
var defaults = {
|
|
70
|
+
colors: palette.text[900],
|
|
71
|
+
useSeriesColors: false,
|
|
72
|
+
horizontalGap: 10,
|
|
73
|
+
verticalGap: 5,
|
|
74
|
+
markerSize: 8,
|
|
75
|
+
markerOffsetX: -5,
|
|
76
|
+
markerOffsetY: 0,
|
|
77
|
+
};
|
|
78
|
+
return __assign(__assign({}, defaults), legendStyle);
|
|
79
|
+
}, [palette, legendStyle]);
|
|
80
|
+
var seriesColors = (0, react_1.useMemo)(function () { var _a; return (_a = chartColor !== null && chartColor !== void 0 ? chartColor : donutColors) !== null && _a !== void 0 ? _a : (0, chartColorsFromTheme_1.getDefaultSeriesColors)(palette); }, [chartColor, donutColors, palette]);
|
|
81
|
+
var validLegendPosition = getValidLegendPosition(legendPosition);
|
|
82
|
+
var options = (0, react_1.useMemo)(function () {
|
|
83
|
+
var extraOptions = {};
|
|
84
|
+
switch (variant) {
|
|
85
|
+
case "semi-donut":
|
|
86
|
+
extraOptions = {
|
|
87
|
+
plotOptions: {
|
|
88
|
+
pie: {
|
|
89
|
+
startAngle: -90,
|
|
90
|
+
endAngle: 90,
|
|
91
|
+
offsetY: 10,
|
|
92
|
+
},
|
|
45
93
|
},
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
94
|
+
};
|
|
95
|
+
break;
|
|
96
|
+
case "monochrome-pie":
|
|
97
|
+
extraOptions = {
|
|
98
|
+
theme: {
|
|
99
|
+
monochrome: {
|
|
100
|
+
enabled: true,
|
|
101
|
+
shadeTo: "light",
|
|
102
|
+
shadeIntensity: 0.65,
|
|
103
|
+
},
|
|
56
104
|
},
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
type: "gradient",
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
break;
|
|
67
|
-
case "donut-with-pattern":
|
|
68
|
-
extraOptions = {
|
|
69
|
-
fill: {
|
|
70
|
-
type: "pattern",
|
|
71
|
-
pattern: {
|
|
72
|
-
style: ["verticalLines", "squares", "horizontalLines", "circles"],
|
|
105
|
+
};
|
|
106
|
+
break;
|
|
107
|
+
case "gradient-donut":
|
|
108
|
+
extraOptions = {
|
|
109
|
+
fill: {
|
|
110
|
+
type: "gradient",
|
|
73
111
|
},
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
"https://i.imgur.com/UM3mrju.jpg",
|
|
84
|
-
"https://i.imgur.com/NpPOqQq.jpg",
|
|
85
|
-
],
|
|
112
|
+
};
|
|
113
|
+
break;
|
|
114
|
+
case "donut-with-pattern":
|
|
115
|
+
extraOptions = {
|
|
116
|
+
fill: {
|
|
117
|
+
type: "pattern",
|
|
118
|
+
pattern: {
|
|
119
|
+
style: ["verticalLines", "squares", "horizontalLines", "circles"],
|
|
120
|
+
},
|
|
86
121
|
},
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
122
|
+
};
|
|
123
|
+
break;
|
|
124
|
+
case "pie-with-image":
|
|
125
|
+
extraOptions = {
|
|
126
|
+
fill: {
|
|
127
|
+
type: "image",
|
|
128
|
+
image: {
|
|
129
|
+
src: [
|
|
130
|
+
"https://i.imgur.com/UM3mrju.jpg",
|
|
131
|
+
"https://i.imgur.com/NpPOqQq.jpg",
|
|
132
|
+
],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
break;
|
|
137
|
+
case "update-donut":
|
|
138
|
+
extraOptions = {
|
|
139
|
+
plotOptions: {
|
|
140
|
+
pie: {
|
|
141
|
+
donut: {
|
|
142
|
+
labels: {
|
|
98
143
|
show: true,
|
|
99
|
-
|
|
144
|
+
total: {
|
|
145
|
+
show: true,
|
|
146
|
+
label: "Total",
|
|
147
|
+
},
|
|
100
148
|
},
|
|
101
149
|
},
|
|
102
150
|
},
|
|
103
151
|
},
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
break;
|
|
114
|
-
}
|
|
115
|
-
// Validate and normalize legend position
|
|
116
|
-
var getValidLegendPosition = function (position) {
|
|
117
|
-
var validPositions = ["left", "right", "top", "bottom"];
|
|
118
|
-
if (validPositions.includes(position)) {
|
|
119
|
-
return position;
|
|
152
|
+
};
|
|
153
|
+
break;
|
|
154
|
+
case "pie":
|
|
155
|
+
extraOptions = {
|
|
156
|
+
chart: { type: "pie" },
|
|
157
|
+
};
|
|
158
|
+
break;
|
|
159
|
+
default:
|
|
160
|
+
break;
|
|
120
161
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
162
|
+
return __assign({ chart: {
|
|
163
|
+
type: variant.includes("pie") ? "pie" : "donut",
|
|
164
|
+
}, labels: labels, colors: seriesColors, legend: {
|
|
165
|
+
position: validLegendPosition,
|
|
166
|
+
labels: {
|
|
167
|
+
colors: mergedLegendStyle.colors,
|
|
168
|
+
useSeriesColors: mergedLegendStyle.useSeriesColors,
|
|
169
|
+
},
|
|
170
|
+
markers: {
|
|
171
|
+
size: mergedLegendStyle.markerSize,
|
|
172
|
+
offsetX: mergedLegendStyle.markerOffsetX,
|
|
173
|
+
offsetY: mergedLegendStyle.markerOffsetY,
|
|
174
|
+
strokeWidth: 0,
|
|
175
|
+
shape: "circle",
|
|
176
|
+
},
|
|
177
|
+
itemMargin: {
|
|
178
|
+
horizontal: mergedLegendStyle.horizontalGap,
|
|
179
|
+
vertical: mergedLegendStyle.verticalGap,
|
|
180
|
+
},
|
|
181
|
+
}, title: {
|
|
182
|
+
text: title,
|
|
183
|
+
align: titlePosition,
|
|
184
|
+
style: mergedTitleStyle,
|
|
185
|
+
}, dataLabels: { enabled: true } }, extraOptions);
|
|
186
|
+
}, [
|
|
187
|
+
variant,
|
|
188
|
+
labels,
|
|
189
|
+
seriesColors,
|
|
190
|
+
validLegendPosition,
|
|
191
|
+
mergedLegendStyle,
|
|
192
|
+
title,
|
|
193
|
+
titlePosition,
|
|
194
|
+
mergedTitleStyle,
|
|
195
|
+
]);
|
|
149
196
|
return (react_1.default.createElement("div", null,
|
|
150
|
-
react_1.default.createElement(react_apexcharts_1.default, { options: options, series: data, type: (
|
|
197
|
+
react_1.default.createElement(react_apexcharts_1.default, { options: options, series: data, type: (_b = options.chart) === null || _b === void 0 ? void 0 : _b.type, height: height, width: width })));
|
|
151
198
|
};
|
|
152
199
|
exports.default = ApexPieChart;
|