@quillsql/react 1.7.1 → 1.7.2
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/lib/AddToDashboardModal.js +369 -249
- package/lib/AddToDashboardModal.js.map +1 -1
- package/lib/BarList.js +109 -92
- package/lib/BarList.js.map +1 -1
- package/lib/Chart.js +414 -364
- package/lib/Chart.js.map +1 -1
- package/lib/Context.js +84 -92
- package/lib/Context.js.map +1 -1
- package/lib/Dashboard.js +209 -181
- package/lib/Dashboard.js.map +1 -1
- package/lib/DateRangePicker/Calendar.js +91 -87
- package/lib/DateRangePicker/Calendar.js.map +1 -1
- package/lib/DateRangePicker/DateRangePicker.js +68 -70
- package/lib/DateRangePicker/DateRangePicker.js.map +1 -1
- package/lib/DateRangePicker/DateRangePickerButton.js +57 -46
- package/lib/DateRangePicker/DateRangePickerButton.js.map +1 -1
- package/lib/DateRangePicker/dateRangePickerUtils.js +99 -105
- package/lib/DateRangePicker/dateRangePickerUtils.js.map +1 -1
- package/lib/DateRangePicker/index.js +1 -8
- package/lib/DateRangePicker/index.js.map +1 -1
- package/lib/PieChart.js +225 -221
- package/lib/PieChart.js.map +1 -1
- package/lib/QuillProvider.js +18 -8
- package/lib/QuillProvider.js.map +1 -1
- package/lib/ReportBuilder.js +526 -430
- package/lib/ReportBuilder.js.map +1 -1
- package/lib/SQLEditor.js +268 -183
- package/lib/SQLEditor.js.map +1 -1
- package/lib/Table.js +256 -213
- package/lib/Table.js.map +1 -1
- package/lib/TableChart.js +75 -76
- package/lib/TableChart.js.map +1 -1
- package/lib/assets/ArrowDownHeadIcon.js +28 -5
- package/lib/assets/ArrowDownHeadIcon.js.map +1 -1
- package/lib/assets/ArrowDownIcon.js +28 -5
- package/lib/assets/ArrowDownIcon.js.map +1 -1
- package/lib/assets/ArrowDownRightIcon.js +28 -5
- package/lib/assets/ArrowDownRightIcon.js.map +1 -1
- package/lib/assets/ArrowLeftHeadIcon.js +28 -5
- package/lib/assets/ArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightHeadIcon.js +28 -5
- package/lib/assets/ArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ArrowRightIcon.js +28 -5
- package/lib/assets/ArrowRightIcon.js.map +1 -1
- package/lib/assets/ArrowUpHeadIcon.js +28 -5
- package/lib/assets/ArrowUpHeadIcon.js.map +1 -1
- package/lib/assets/ArrowUpIcon.js +28 -5
- package/lib/assets/ArrowUpIcon.js.map +1 -1
- package/lib/assets/ArrowUpRightIcon.js +28 -5
- package/lib/assets/ArrowUpRightIcon.js.map +1 -1
- package/lib/assets/CalendarIcon.js +28 -5
- package/lib/assets/CalendarIcon.js.map +1 -1
- package/lib/assets/DoubleArrowLeftHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowLeftHeadIcon.js.map +1 -1
- package/lib/assets/DoubleArrowRightHeadIcon.js +28 -5
- package/lib/assets/DoubleArrowRightHeadIcon.js.map +1 -1
- package/lib/assets/ExclamationFilledIcon.js +28 -5
- package/lib/assets/ExclamationFilledIcon.js.map +1 -1
- package/lib/assets/LoadingSpinner.js +28 -5
- package/lib/assets/LoadingSpinner.js.map +1 -1
- package/lib/assets/SearchIcon.js +28 -5
- package/lib/assets/SearchIcon.js.map +1 -1
- package/lib/assets/XCircleIcon.js +28 -5
- package/lib/assets/XCircleIcon.js.map +1 -1
- package/lib/assets/index.js +16 -38
- package/lib/assets/index.js.map +1 -1
- package/lib/components/BigModal/BigModal.js +43 -45
- package/lib/components/BigModal/BigModal.js.map +1 -1
- package/lib/components/Dropdown/Dropdown.js +53 -57
- package/lib/components/Dropdown/Dropdown.js.map +1 -1
- package/lib/components/Dropdown/DropdownItem.js +40 -43
- package/lib/components/Dropdown/DropdownItem.js.map +1 -1
- package/lib/components/Dropdown/index.js +2 -10
- package/lib/components/Dropdown/index.js.map +1 -1
- package/lib/components/Modal/Modal.js +43 -45
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/Modal/index.js +1 -8
- package/lib/components/Modal/index.js.map +1 -1
- package/lib/components/selectUtils.js +15 -20
- package/lib/components/selectUtils.js.map +1 -1
- package/lib/contexts/BaseColorContext.js +3 -5
- package/lib/contexts/BaseColorContext.js.map +1 -1
- package/lib/contexts/HoveredValueContext.js +3 -5
- package/lib/contexts/HoveredValueContext.js.map +1 -1
- package/lib/contexts/RootStylesContext.js +3 -5
- package/lib/contexts/RootStylesContext.js.map +1 -1
- package/lib/contexts/SelectedValueContext.js +3 -5
- package/lib/contexts/SelectedValueContext.js.map +1 -1
- package/lib/contexts/index.js +4 -14
- package/lib/contexts/index.js.map +1 -1
- package/lib/hooks/index.js +4 -14
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/useInternalState.js +7 -9
- package/lib/hooks/useInternalState.js.map +1 -1
- package/lib/hooks/useOnClickOutside.js +6 -8
- package/lib/hooks/useOnClickOutside.js.map +1 -1
- package/lib/hooks/useOnWindowResize.js +7 -9
- package/lib/hooks/useOnWindowResize.js.map +1 -1
- package/lib/hooks/useQuill.js +111 -60
- package/lib/hooks/useQuill.js.map +1 -1
- package/lib/hooks/useSelectOnKeyDown.js +15 -17
- package/lib/hooks/useSelectOnKeyDown.js.map +1 -1
- package/lib/index.js +8 -22
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/PieChart.js
CHANGED
|
@@ -1,35 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
24
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
25
|
+
if (ar || !(i in from)) {
|
|
26
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
27
|
+
ar[i] = from[i];
|
|
28
|
+
}
|
|
7
29
|
}
|
|
8
|
-
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
30
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
31
|
};
|
|
25
|
-
|
|
26
|
-
exports.findComplementaryAndAnalogousColors = exports.DonutChartTooltip = exports.ChartTooltipRow = exports.ChartTooltipFrame = exports.parseLabelInput = exports.parseData = exports.sumNumericArray = exports.defaultValueFormatter = void 0;
|
|
27
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
32
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
28
33
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
29
34
|
/* eslint-disable react/display-name */
|
|
30
35
|
// @ts-nocheck
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
import React, { useRef, useState, useEffect } from 'react';
|
|
37
|
+
import { Pie, PieChart, ResponsiveContainer, Tooltip, Legend } from 'recharts';
|
|
33
38
|
// const data = [
|
|
34
39
|
// {
|
|
35
40
|
// name: 'Project Nile',
|
|
@@ -128,20 +133,20 @@ const recharts_1 = require("recharts");
|
|
|
128
133
|
// pct_of_the_total: 0.00522734435854761,
|
|
129
134
|
// },
|
|
130
135
|
// ];
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
(
|
|
134
|
-
|
|
136
|
+
var useOnWindowResize = function (handler, initialWindowSize) {
|
|
137
|
+
var _a = useState(initialWindowSize), windowSize = _a[0], setWindowSize = _a[1];
|
|
138
|
+
useEffect(function () {
|
|
139
|
+
var handleResize = function () {
|
|
135
140
|
setWindowSize(window.innerWidth);
|
|
136
141
|
handler();
|
|
137
142
|
};
|
|
138
143
|
handleResize();
|
|
139
144
|
window.addEventListener('resize', handleResize);
|
|
140
|
-
return ()
|
|
145
|
+
return function () { return window.removeEventListener('resize', handleResize); };
|
|
141
146
|
}, [handler, windowSize]);
|
|
142
147
|
};
|
|
143
|
-
|
|
144
|
-
|
|
148
|
+
var ChartLegend = function (categories, colors) {
|
|
149
|
+
var legendRef = useRef(null);
|
|
145
150
|
// useOnWindowResize(() => {
|
|
146
151
|
// const calculateHeight = (height: number | undefined) =>
|
|
147
152
|
// height
|
|
@@ -149,28 +154,28 @@ const ChartLegend = (categories, colors) => {
|
|
|
149
154
|
// : 60; // default height
|
|
150
155
|
// setLegendHeight(calculateHeight(legendRef.current?.clientHeight));
|
|
151
156
|
// });
|
|
152
|
-
return ((
|
|
157
|
+
return (_jsx("div", __assign({ ref: legendRef, className: "qq-flex qq-items-center qq-justify-end" }, { children: _jsx(Legend
|
|
153
158
|
// @ts-ignore
|
|
154
159
|
, {
|
|
155
160
|
// @ts-ignore
|
|
156
|
-
categories: categories, colors: colors }) }));
|
|
161
|
+
categories: categories, colors: colors }) })));
|
|
157
162
|
};
|
|
158
|
-
|
|
163
|
+
var iconVariantValues = [
|
|
159
164
|
'simple',
|
|
160
165
|
'light',
|
|
161
166
|
'shadow',
|
|
162
167
|
'solid',
|
|
163
168
|
'outlined',
|
|
164
169
|
];
|
|
165
|
-
|
|
170
|
+
var deltaTypeValues = [
|
|
166
171
|
'increase',
|
|
167
172
|
'moderateIncrease',
|
|
168
173
|
'decrease',
|
|
169
174
|
'moderateDecrease',
|
|
170
175
|
'unchanged',
|
|
171
176
|
];
|
|
172
|
-
|
|
173
|
-
|
|
177
|
+
var sizeValues = ['xs', 'sm', 'md', 'lg', 'xl'];
|
|
178
|
+
var colorValues = [
|
|
174
179
|
'slate',
|
|
175
180
|
'gray',
|
|
176
181
|
'zinc',
|
|
@@ -194,7 +199,7 @@ const colorValues = [
|
|
|
194
199
|
'pink',
|
|
195
200
|
'rose',
|
|
196
201
|
];
|
|
197
|
-
|
|
202
|
+
var justifyContentValues = [
|
|
198
203
|
'start',
|
|
199
204
|
'end',
|
|
200
205
|
'center',
|
|
@@ -202,17 +207,19 @@ const justifyContentValues = [
|
|
|
202
207
|
'around',
|
|
203
208
|
'evenly',
|
|
204
209
|
];
|
|
205
|
-
|
|
210
|
+
var alignItemsValues = [
|
|
206
211
|
'start',
|
|
207
212
|
'end',
|
|
208
213
|
'center',
|
|
209
214
|
'baseline',
|
|
210
215
|
'stretch',
|
|
211
216
|
];
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
export var defaultValueFormatter = function (value) {
|
|
218
|
+
return (value * 1).toFixed(1) + '%';
|
|
219
|
+
};
|
|
220
|
+
export var sumNumericArray = function (arr) {
|
|
221
|
+
return arr.reduce(function (prefixSum, num) { return prefixSum + num; }, 0);
|
|
222
|
+
};
|
|
216
223
|
// export const parseData = (data: any[], colors: any[]) =>
|
|
217
224
|
// data.map((dataPoint: any, idx: number) => {
|
|
218
225
|
// const baseColor = idx < colors.length ? colors[idx] : BaseColors.Gray;
|
|
@@ -224,108 +231,112 @@ exports.sumNumericArray = sumNumericArray;
|
|
|
224
231
|
// };
|
|
225
232
|
// });
|
|
226
233
|
// @ts-ignore
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
234
|
+
export var parseData = function (data, colors, categoryKey, valueKey) {
|
|
235
|
+
var _a;
|
|
236
|
+
var maxItems = 20;
|
|
237
|
+
var slicedData = data.slice(0, maxItems);
|
|
238
|
+
var totalValue = slicedData.reduce(function (acc, dataPoint) { return acc + Number(dataPoint[valueKey]); }, 0);
|
|
231
239
|
if (totalValue !== 100) {
|
|
232
|
-
slicedData.forEach(dataPoint
|
|
240
|
+
slicedData.forEach(function (dataPoint) {
|
|
233
241
|
dataPoint[valueKey] = (Number(dataPoint[valueKey]) * 100) / totalValue;
|
|
234
242
|
});
|
|
235
243
|
totalValue = 100;
|
|
236
244
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
...dataPoint,
|
|
241
|
-
color: baseColor,
|
|
242
|
-
fill: baseColor,
|
|
243
|
-
};
|
|
245
|
+
var parsedData = slicedData.map(function (dataPoint, idx) {
|
|
246
|
+
var baseColor = idx < colors.length ? colors[idx] : colors[colors.length - 1];
|
|
247
|
+
return __assign(__assign({}, dataPoint), { color: baseColor, fill: baseColor });
|
|
244
248
|
});
|
|
245
249
|
if (data.length > maxItems) {
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
parsedData.push({
|
|
251
|
-
[categoryKey]
|
|
252
|
-
[valueKey]
|
|
253
|
-
color
|
|
254
|
-
fill
|
|
255
|
-
|
|
250
|
+
var otherData = data.slice(maxItems);
|
|
251
|
+
var otherSum = otherData.reduce(function (acc, dataPoint) { return acc + Number(dataPoint[valueKey]); }, 0);
|
|
252
|
+
var otherColor = colors[colors.length - 1];
|
|
253
|
+
var normalizedOtherSum = (otherSum * 100) / totalValue;
|
|
254
|
+
parsedData.push((_a = {},
|
|
255
|
+
_a[categoryKey] = 'Other',
|
|
256
|
+
_a[valueKey] = normalizedOtherSum,
|
|
257
|
+
_a.color = otherColor,
|
|
258
|
+
_a.fill = otherColor,
|
|
259
|
+
_a));
|
|
256
260
|
}
|
|
257
261
|
return parsedData;
|
|
258
262
|
};
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
263
|
+
var calculateDefaultLabel = function (data, category) {
|
|
264
|
+
return sumNumericArray(data.map(function (dataPoint) { return dataPoint[category]; }));
|
|
265
|
+
};
|
|
266
|
+
export var parseLabelInput = function (labelInput, valueFormatter, data, category) {
|
|
267
|
+
return labelInput
|
|
268
|
+
? labelInput
|
|
269
|
+
: valueFormatter(calculateDefaultLabel(data, category));
|
|
270
|
+
};
|
|
271
|
+
export var ChartTooltipFrame = function (_a) {
|
|
272
|
+
var children = _a.children, theme = _a.theme;
|
|
273
|
+
return (_jsx("div", __assign({ style: {
|
|
274
|
+
borderStyle: 'solid',
|
|
275
|
+
borderColor: (theme === null || theme === void 0 ? void 0 : theme.borderColor) || '#E5E7EB',
|
|
276
|
+
borderWidth: 1,
|
|
277
|
+
background: (theme === null || theme === void 0 ? void 0 : theme.backgroundColor) || '#ffffff',
|
|
278
|
+
fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSize) || '14px',
|
|
279
|
+
borderRadius: '6px',
|
|
280
|
+
boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
281
|
+
} }, { children: children })));
|
|
282
|
+
};
|
|
283
|
+
export var ChartTooltipRow = function (_a) {
|
|
284
|
+
var value = _a.value, name = _a.name, color = _a.color, theme = _a.theme;
|
|
285
|
+
return (_jsxs("div", __assign({ style: {
|
|
286
|
+
display: 'flex',
|
|
287
|
+
alignItems: 'center',
|
|
288
|
+
justifyContent: 'space-between',
|
|
289
|
+
minWidth: 120,
|
|
290
|
+
// minHeight: 27,
|
|
291
|
+
// margin: '0 2rem',
|
|
292
|
+
} }, { children: [_jsxs("div", __assign({ style: {
|
|
293
|
+
display: 'flex',
|
|
294
|
+
alignItems: 'center',
|
|
295
|
+
justifyContent: 'space-between',
|
|
296
|
+
// margin: '0 0.5rem',
|
|
297
|
+
// minWidth: 120,
|
|
298
|
+
} }, { children: [_jsx("span", { style: {
|
|
299
|
+
background: color,
|
|
300
|
+
borderWidth: 2,
|
|
301
|
+
borderStyle: 'solid',
|
|
302
|
+
borderColor: 'white',
|
|
303
|
+
height: '8px',
|
|
304
|
+
width: '8px',
|
|
305
|
+
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
|
|
306
|
+
borderRadius: '9999px',
|
|
307
|
+
marginRight: 5,
|
|
308
|
+
} }), _jsx("p", __assign({
|
|
309
|
+
// className={twMerge(
|
|
310
|
+
// 'font-medium tabular-nums text-right whitespace-nowrap',
|
|
311
|
+
// 'text-[#212121] !important'
|
|
312
|
+
// )}
|
|
313
|
+
style: {
|
|
314
|
+
marginTop: 0,
|
|
315
|
+
marginBottom: 0,
|
|
316
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
317
|
+
color: theme === null || theme === void 0 ? void 0 : theme.primaryTextColor,
|
|
318
|
+
paddingTop: 2,
|
|
319
|
+
paddingBottom: 2,
|
|
320
|
+
fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
|
|
321
|
+
fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightMedium) || '500',
|
|
322
|
+
} }, { children: value }))] })), _jsx("p", __assign({ style: {
|
|
323
|
+
marginTop: 0,
|
|
324
|
+
marginBottom: 0,
|
|
325
|
+
fontFamily: theme === null || theme === void 0 ? void 0 : theme.fontFamily,
|
|
326
|
+
color: theme === null || theme === void 0 ? void 0 : theme.secondaryTextColor,
|
|
327
|
+
whiteSpace: 'nowrap',
|
|
328
|
+
overflow: 'hidden',
|
|
329
|
+
textOverflow: 'ellipsis',
|
|
330
|
+
textAlign: 'right',
|
|
331
|
+
fontSize: (theme === null || theme === void 0 ? void 0 : theme.fontSizeSmall) || '14px',
|
|
332
|
+
fontWeight: (theme === null || theme === void 0 ? void 0 : theme.fontWeightNormal) || '400',
|
|
333
|
+
} }, { children: name }))] })));
|
|
334
|
+
};
|
|
335
|
+
export var DonutChartTooltip = function (_a) {
|
|
336
|
+
var active = _a.active, payload = _a.payload, valueFormatter = _a.valueFormatter, theme = _a.theme;
|
|
326
337
|
if (active && payload[0]) {
|
|
327
|
-
|
|
328
|
-
return ((
|
|
338
|
+
var payloadRow = payload[0];
|
|
339
|
+
return (_jsx(ChartTooltipFrame, __assign({ theme: theme }, { children: _jsx("div", __assign({
|
|
329
340
|
// style={{ transform: 'translateX(-120px)' }}
|
|
330
341
|
// className={twMerge('qq-px-4', 'qq-py-2')}
|
|
331
342
|
style: {
|
|
@@ -333,42 +344,41 @@ const DonutChartTooltip = ({ active, payload, valueFormatter, theme, }) => {
|
|
|
333
344
|
paddingRight: '1rem',
|
|
334
345
|
paddingTop: '8px',
|
|
335
346
|
paddingBottom: '8px',
|
|
336
|
-
}, children: (
|
|
347
|
+
} }, { children: _jsx(ChartTooltipRow, { value: valueFormatter(payloadRow.value), name: payloadRow.name, color: payloadRow.payload.color, theme: theme }) })) })));
|
|
337
348
|
}
|
|
338
349
|
return null;
|
|
339
350
|
};
|
|
340
|
-
exports.DonutChartTooltip = DonutChartTooltip;
|
|
341
351
|
// @ts-ignore
|
|
342
|
-
function findComplementaryAndAnalogousColors(color1, color2) {
|
|
352
|
+
export function findComplementaryAndAnalogousColors(color1, color2) {
|
|
343
353
|
// Calculate the hue of the first color
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
354
|
+
var color1HSL = rgbToHsl(hexToRgb(color1));
|
|
355
|
+
var color2HSL = rgbToHsl(hexToRgb(color2));
|
|
356
|
+
var color1Hue = color1HSL.h;
|
|
347
357
|
// Calculate the complementary color of the first color
|
|
348
|
-
|
|
349
|
-
|
|
358
|
+
var complementaryHue = (color1Hue + 180) % 360;
|
|
359
|
+
var complementaryColor = hslToRgb({
|
|
350
360
|
h: complementaryHue,
|
|
351
361
|
s: color1HSL.s,
|
|
352
362
|
l: color1HSL.l,
|
|
353
363
|
});
|
|
354
364
|
// Find an analogous hue to the first color
|
|
355
|
-
|
|
356
|
-
|
|
365
|
+
var analogousHue1 = (color1Hue + 30) % 360;
|
|
366
|
+
var analogousHue2 = (color1Hue - 30 + 360) % 360;
|
|
357
367
|
// Convert the analogous hues back to RGB colors
|
|
358
|
-
|
|
368
|
+
var analogousColor1 = hslToRgb({
|
|
359
369
|
h: analogousHue1,
|
|
360
370
|
s: color1HSL.s,
|
|
361
371
|
l: color1HSL.l,
|
|
362
372
|
});
|
|
363
|
-
|
|
373
|
+
var analogousColor2 = hslToRgb({
|
|
364
374
|
h: analogousHue2,
|
|
365
375
|
s: color1HSL.s,
|
|
366
376
|
l: color1HSL.l,
|
|
367
377
|
});
|
|
368
378
|
// Calculate the average hue between the two colors
|
|
369
|
-
|
|
379
|
+
var avgHue = (color1HSL.h + color2HSL.h) / 2;
|
|
370
380
|
// Generate a new HSL object with the average hue and the same saturation and lightness as color1
|
|
371
|
-
|
|
381
|
+
var analogousHsl = { h: avgHue, s: color1HSL.s, l: color1HSL.l };
|
|
372
382
|
return [
|
|
373
383
|
color1,
|
|
374
384
|
color2,
|
|
@@ -378,31 +388,30 @@ function findComplementaryAndAnalogousColors(color1, color2) {
|
|
|
378
388
|
// rgbToHex(analogousColor2),
|
|
379
389
|
];
|
|
380
390
|
}
|
|
381
|
-
exports.findComplementaryAndAnalogousColors = findComplementaryAndAnalogousColors;
|
|
382
391
|
// @ts-ignore
|
|
383
392
|
function hexToRgb(hex) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return { r, g, b };
|
|
393
|
+
var r = parseInt(hex.substring(1, 3), 16);
|
|
394
|
+
var g = parseInt(hex.substring(3, 5), 16);
|
|
395
|
+
var b = parseInt(hex.substring(5, 7), 16);
|
|
396
|
+
return { r: r, g: g, b: b };
|
|
388
397
|
}
|
|
389
398
|
// @ts-ignore
|
|
390
399
|
function rgbToHex(rgb) {
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return
|
|
400
|
+
var rHex = rgb.r.toString(16).padStart(2, '0');
|
|
401
|
+
var gHex = rgb.g.toString(16).padStart(2, '0');
|
|
402
|
+
var bHex = rgb.b.toString(16).padStart(2, '0');
|
|
403
|
+
return "#".concat(rHex).concat(gHex).concat(bHex);
|
|
395
404
|
}
|
|
396
405
|
// @ts-ignore
|
|
397
406
|
function rgbToHsl(rgb) {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
407
|
+
var r = rgb.r / 255;
|
|
408
|
+
var g = rgb.g / 255;
|
|
409
|
+
var b = rgb.b / 255;
|
|
410
|
+
var max = Math.max(r, g, b);
|
|
411
|
+
var min = Math.min(r, g, b);
|
|
412
|
+
var h = 0, s = 0, l = (max + min) / 2;
|
|
404
413
|
if (max !== min) {
|
|
405
|
-
|
|
414
|
+
var d = max - min;
|
|
406
415
|
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
407
416
|
switch (max) {
|
|
408
417
|
case r:
|
|
@@ -421,16 +430,16 @@ function rgbToHsl(rgb) {
|
|
|
421
430
|
}
|
|
422
431
|
// @ts-ignore
|
|
423
432
|
function hslToRgb(hsl) {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
433
|
+
var h = hsl.h / 360;
|
|
434
|
+
var s = hsl.s / 100;
|
|
435
|
+
var l = hsl.l / 100;
|
|
436
|
+
var r, g, b;
|
|
428
437
|
if (s === 0) {
|
|
429
438
|
r = g = b = l;
|
|
430
439
|
}
|
|
431
440
|
else {
|
|
432
441
|
// @ts-ignore
|
|
433
|
-
|
|
442
|
+
var hue2rgb = function (p, q, t) {
|
|
434
443
|
if (t < 0)
|
|
435
444
|
t += 1;
|
|
436
445
|
if (t > 1)
|
|
@@ -443,8 +452,8 @@ function hslToRgb(hsl) {
|
|
|
443
452
|
return p + (q - p) * (2 / 3 - t) * 6;
|
|
444
453
|
return p;
|
|
445
454
|
};
|
|
446
|
-
|
|
447
|
-
|
|
455
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
456
|
+
var p = 2 * l - q;
|
|
448
457
|
r = hue2rgb(p, q, h + 1 / 3);
|
|
449
458
|
g = hue2rgb(p, q, h);
|
|
450
459
|
b = hue2rgb(p, q, h - 1 / 3);
|
|
@@ -457,21 +466,21 @@ function hslToRgb(hsl) {
|
|
|
457
466
|
}
|
|
458
467
|
// @ts-ignore
|
|
459
468
|
function generateColorGradientSteps(n, colors) {
|
|
460
|
-
|
|
469
|
+
var numColors = colors.length;
|
|
461
470
|
// If there are fewer than two colors, return the original array
|
|
462
471
|
if (numColors < 2) {
|
|
463
472
|
return colors;
|
|
464
473
|
}
|
|
465
474
|
// Initialize the output array with the first color
|
|
466
|
-
|
|
475
|
+
var output = [colors[0]];
|
|
467
476
|
// Calculate the number of gradient steps between each pair of colors
|
|
468
|
-
|
|
477
|
+
var stepsPerPair = Math.floor(n / (numColors - 1));
|
|
469
478
|
// Generate the gradient steps for each pair of colors
|
|
470
|
-
for (
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
output.push(
|
|
479
|
+
for (var i = 1; i < numColors; i++) {
|
|
480
|
+
var color1 = colors[i - 1];
|
|
481
|
+
var color2 = colors[i];
|
|
482
|
+
var gradientSteps = generateGradientSteps(color1, color2, stepsPerPair);
|
|
483
|
+
output.push.apply(output, gradientSteps);
|
|
475
484
|
}
|
|
476
485
|
// If there are remaining steps, add the last color as a stopgap measure
|
|
477
486
|
while (output.length < n) {
|
|
@@ -482,72 +491,67 @@ function generateColorGradientSteps(n, colors) {
|
|
|
482
491
|
//@ts-ignore
|
|
483
492
|
function generateGradientSteps(color1, color2, n) {
|
|
484
493
|
// Convert the colors to RGB objects
|
|
485
|
-
|
|
486
|
-
|
|
494
|
+
var rgb1 = hexToRgb(color1);
|
|
495
|
+
var rgb2 = hexToRgb(color2);
|
|
487
496
|
// Calculate the RGB color difference between the two colors
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
497
|
+
var diffR = rgb2.r - rgb1.r;
|
|
498
|
+
var diffG = rgb2.g - rgb1.g;
|
|
499
|
+
var diffB = rgb2.b - rgb1.b;
|
|
491
500
|
// Calculate the RGB gradient step size between the two colors
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
501
|
+
var stepR = diffR / (n + 1);
|
|
502
|
+
var stepG = diffG / (n + 1);
|
|
503
|
+
var stepB = diffB / (n + 1);
|
|
495
504
|
// Generate the RGB gradient steps
|
|
496
|
-
|
|
497
|
-
for (
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
gradientSteps.push(rgbToHex({ r, g, b }));
|
|
505
|
+
var gradientSteps = [];
|
|
506
|
+
for (var i = 1; i <= n; i++) {
|
|
507
|
+
var r = Math.round(rgb1.r + stepR * i);
|
|
508
|
+
var g = Math.round(rgb1.g + stepG * i);
|
|
509
|
+
var b = Math.round(rgb1.b + stepB * i);
|
|
510
|
+
gradientSteps.push(rgbToHex({ r: r, g: g, b: b }));
|
|
502
511
|
}
|
|
503
512
|
return gradientSteps;
|
|
504
513
|
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
return ((
|
|
511
|
-
...containerStyle,
|
|
512
|
-
width: '100%',
|
|
514
|
+
var PieChartWrapper = React.forwardRef(function (props, ref) {
|
|
515
|
+
var _a = props.category, category = _a === void 0 ? 'pct_of_the_total' : _a, _b = props.index, index = _b === void 0 ? 'status' : _b, data = props.data, _c = props.colors, colors = _c === void 0 ? [] : _c, _d = props.variant, variant = _d === void 0 ? 'donut' : _d, _e = props.valueFormatter, valueFormatter = _e === void 0 ? defaultValueFormatter : _e, label = props.label, _f = props.showLabel, showLabel = _f === void 0 ? true : _f, _g = props.showAnimation, showAnimation = _g === void 0 ? true : _g, _h = props.showTooltip, showTooltip = _h === void 0 ? true : _h, className = props.className, containerStyle = props.containerStyle, theme = props.theme, other = __rest(props, ["category", "index", "data", "colors", "variant", "valueFormatter", "label", "showLabel", "showAnimation", "showTooltip", "className", "containerStyle", "theme"]);
|
|
516
|
+
var isDonut = variant == 'donut';
|
|
517
|
+
var parsedLabelInput = parseLabelInput(label, valueFormatter, data, category);
|
|
518
|
+
var newColors = generateColorGradientSteps(data.length, findComplementaryAndAnalogousColors(colors[0], colors[1]));
|
|
519
|
+
return (_jsx("div", __assign({ ref: ref, style: __assign(__assign({}, containerStyle), { width: '100%',
|
|
513
520
|
// height: '100%',
|
|
514
|
-
display: 'flex',
|
|
515
|
-
flexDirection: 'row',
|
|
516
|
-
alignItems: 'center',
|
|
517
|
-
boxSizing: 'content-box',
|
|
518
|
-
}, ...other, children: (0, jsx_runtime_1.jsx)(recharts_1.ResponsiveContainer, { width: "100%", height: "100%", children: (0, jsx_runtime_1.jsxs)(recharts_1.PieChart, { children: [(0, jsx_runtime_1.jsx)(recharts_1.Pie
|
|
521
|
+
display: 'flex', flexDirection: 'row', alignItems: 'center', boxSizing: 'content-box' }) }, other, { children: _jsx(ResponsiveContainer, __assign({ width: "100%", height: "100%" }, { children: _jsxs(PieChart, { children: [_jsx(Pie
|
|
519
522
|
// style={{ transform: 'translateX(-120px)' }}
|
|
520
523
|
, {
|
|
521
524
|
// style={{ transform: 'translateX(-120px)' }}
|
|
522
|
-
data:
|
|
525
|
+
data: parseData(data, colors.length >= data.length
|
|
523
526
|
? colors
|
|
524
|
-
: generateColorGradientSteps(Math.min(21, data.length), [
|
|
525
|
-
...findComplementaryAndAnalogousColors(colors[0], colors[1]),
|
|
526
|
-
...colors.slice(2),
|
|
527
|
-
]), index, category), cx: "50%", cy: "50%", startAngle: 90, endAngle: -270, innerRadius: isDonut ? '70%' : '0%', outerRadius: "100%", paddingAngle: 0, dataKey: category, nameKey: index, isAnimationActive: true }), (0, jsx_runtime_1.jsx)(recharts_1.Tooltip, { wrapperStyle: {
|
|
527
|
+
: generateColorGradientSteps(Math.min(21, data.length), __spreadArray(__spreadArray([], findComplementaryAndAnalogousColors(colors[0], colors[1]), true), colors.slice(2), true)), index, category), cx: "50%", cy: "50%", startAngle: 90, endAngle: -270, innerRadius: isDonut ? '70%' : '0%', outerRadius: "100%", paddingAngle: 0, dataKey: category, nameKey: index, isAnimationActive: true }), _jsx(Tooltip, { wrapperStyle: {
|
|
528
528
|
outline: 'none',
|
|
529
|
-
}, content:
|
|
529
|
+
}, content: function (_a) {
|
|
530
|
+
var active = _a.active, payload = _a.payload;
|
|
531
|
+
return (_jsx(DonutChartTooltip, { active: active, payload: payload, valueFormatter: valueFormatter, theme: theme }));
|
|
532
|
+
} })] }) })) })));
|
|
530
533
|
});
|
|
531
|
-
function Legend2(
|
|
532
|
-
|
|
534
|
+
function Legend2(_a) {
|
|
535
|
+
var payload = _a.payload, colors = _a.colors;
|
|
536
|
+
return (_jsx("div", { children: payload.map(function (item, idx) {
|
|
533
537
|
if (idx > 9) {
|
|
534
538
|
return null;
|
|
535
539
|
}
|
|
536
|
-
return ((
|
|
540
|
+
return (_jsxs("div", { children: [_jsx("div", { style: {
|
|
537
541
|
height: 8,
|
|
538
542
|
width: 8,
|
|
539
543
|
borderRadius: 8,
|
|
540
544
|
background: colors[idx],
|
|
541
545
|
marginRight: 8,
|
|
542
546
|
marginTop: 2,
|
|
543
|
-
} }), (
|
|
547
|
+
} }), _jsx("div", __assign({ style: {
|
|
544
548
|
whiteSpace: 'nowrap',
|
|
545
549
|
overflow: 'hidden',
|
|
546
550
|
textOverflow: 'ellipsis',
|
|
547
551
|
display: 'block',
|
|
548
552
|
maxWidth: 120,
|
|
549
|
-
}, children: item.value })] }, item.value));
|
|
553
|
+
} }, { children: item.value }))] }, item.value));
|
|
550
554
|
}) }));
|
|
551
555
|
}
|
|
552
|
-
|
|
556
|
+
export default PieChartWrapper;
|
|
553
557
|
//# sourceMappingURL=PieChart.js.map
|