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