@quillsql/react 2.8.8 → 2.8.9
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/AddToDashboardModal.js +146 -181
- package/dist/BarList.js +36 -44
- package/dist/Chart.d.ts +0 -5
- package/dist/Chart.d.ts.map +1 -1
- package/dist/Chart.js +94 -276
- package/dist/ChartBuilder.d.ts +1 -0
- package/dist/ChartBuilder.d.ts.map +1 -1
- package/dist/ChartBuilder.js +96 -93
- package/dist/ChartEditor.d.ts +2 -1
- package/dist/ChartEditor.d.ts.map +1 -1
- package/dist/ChartEditor.js +14 -21
- package/dist/Context.js +52 -57
- package/dist/Dashboard.d.ts.map +1 -1
- package/dist/Dashboard.js +181 -213
- package/dist/DateRangePicker/Calendar.js +41 -46
- package/dist/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/DateRangePicker/DateRangePicker.js +33 -62
- package/dist/DateRangePicker/DateRangePickerButton.js +14 -17
- package/dist/DateRangePicker/dateRangePickerUtils.js +76 -90
- package/dist/DateRangePicker/index.js +1 -9
- package/dist/PieChart.js +35 -70
- package/dist/QuillProvider.js +4 -7
- package/dist/ReportBuilder.js +120 -129
- package/dist/SQLEditor.d.ts +5 -1
- package/dist/SQLEditor.d.ts.map +1 -1
- package/dist/SQLEditor.js +82 -89
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +64 -66
- package/dist/TableChart.js +17 -45
- package/dist/assets/ArrowDownHeadIcon.js +3 -6
- package/dist/assets/ArrowDownIcon.js +3 -6
- package/dist/assets/ArrowDownRightIcon.js +3 -6
- package/dist/assets/ArrowLeftHeadIcon.js +3 -6
- package/dist/assets/ArrowRightHeadIcon.js +3 -6
- package/dist/assets/ArrowRightIcon.js +3 -6
- package/dist/assets/ArrowUpHeadIcon.js +3 -6
- package/dist/assets/ArrowUpIcon.js +3 -6
- package/dist/assets/ArrowUpRightIcon.js +3 -6
- package/dist/assets/CalendarIcon.js +3 -6
- package/dist/assets/CalendarNormalIcon.js +3 -6
- package/dist/assets/DoubleArrowLeftHeadIcon.js +3 -6
- package/dist/assets/DoubleArrowRightHeadIcon.js +3 -6
- package/dist/assets/ExclamationFilledIcon.js +3 -6
- package/dist/assets/FilterIcon.js +3 -6
- package/dist/assets/LoadingSpinner.js +3 -6
- package/dist/assets/RefreshIcon.js +3 -6
- package/dist/assets/SearchIcon.js +3 -6
- package/dist/assets/UpLeftArrowsIcon.js +3 -6
- package/dist/assets/XCircleIcon.js +3 -6
- package/dist/assets/XIcon.js +3 -6
- package/dist/assets/index.js +21 -49
- package/dist/components/Banner/index.d.ts +3 -0
- package/dist/components/Banner/index.d.ts.map +1 -0
- package/dist/components/Banner/index.js +24 -0
- package/dist/components/BigModal/BigModal.js +13 -39
- package/dist/components/Dropdown/Dropdown.js +24 -53
- package/dist/components/Dropdown/DropdownItem.js +9 -35
- package/dist/components/Dropdown/index.js +2 -11
- package/dist/components/Modal/Modal.js +13 -39
- package/dist/components/Modal/index.js +1 -9
- package/dist/components/QuillCard.js +8 -13
- package/dist/components/ReportBuilder/ColumnSelector.d.ts +19 -0
- package/dist/components/ReportBuilder/ColumnSelector.d.ts.map +1 -0
- package/dist/components/ReportBuilder/ColumnSelector.js +87 -0
- package/dist/components/SqlTextEditor.d.ts.map +1 -1
- package/dist/components/SqlTextEditor.js +30 -13
- package/dist/components/UiComponents.d.ts.map +1 -1
- package/dist/components/UiComponents.js +40 -53
- package/dist/components/selectUtils.js +6 -17
- package/dist/contexts/BaseColorContext.js +3 -6
- package/dist/contexts/HoveredValueContext.js +3 -6
- package/dist/contexts/RootStylesContext.js +3 -6
- package/dist/contexts/SelectedValueContext.js +3 -6
- package/dist/contexts/index.js +4 -15
- package/dist/hooks/index.js +4 -15
- package/dist/hooks/useDashboard.js +10 -15
- package/dist/hooks/useInternalState.js +3 -6
- package/dist/hooks/useOnClickOutside.js +3 -6
- package/dist/hooks/useOnWindowResize.js +4 -7
- package/dist/hooks/useQuill.js +11 -16
- package/dist/hooks/useSelectOnKeyDown.js +4 -7
- package/dist/index.js +13 -33
- package/dist/internals/ReportBuilder/PivotList.js +14 -20
- package/dist/internals/ReportBuilder/PivotModal.d.ts +2 -2
- package/dist/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/internals/ReportBuilder/PivotModal.js +116 -119
- package/dist/internals/ReportBuilder/PivotModal.spec.js +70 -73
- package/dist/lib/font.js +2 -6
- package/dist/lib/index.js +3 -20
- package/dist/lib/inputTypes.js +1 -3
- package/dist/lib/utils.js +8 -19
- package/dist/test-data/tables.d.ts +2 -0
- package/dist/test-data/tables.d.ts.map +1 -0
- package/dist/test-data/tables.js +621 -0
- package/dist/utils/aggregate.js +28 -35
- package/dist/utils/axisFormatter.d.ts +20 -0
- package/dist/utils/axisFormatter.d.ts.map +1 -0
- package/dist/utils/axisFormatter.js +185 -0
- package/dist/utils/colorToHex.js +1 -5
- package/dist/utils/dataFetcher.js +2 -8
- package/dist/utils/downloadCSV.js +1 -6
- package/dist/utils/schema.d.ts +22 -0
- package/dist/utils/schema.d.ts.map +1 -0
- package/dist/utils/schema.js +134 -0
- package/dist/utils/textFormatting.d.ts +4 -0
- package/dist/utils/textFormatting.d.ts.map +1 -0
- package/dist/utils/textFormatting.js +38 -0
- package/dist/utils/valueFormatter.d.ts +17 -0
- package/dist/utils/valueFormatter.d.ts.map +1 -0
- package/dist/utils/valueFormatter.js +166 -0
- package/dist/utils/valueFormatterCSV.d.ts +17 -0
- package/dist/utils/valueFormatterCSV.d.ts.map +1 -0
- package/dist/utils/valueFormatterCSV.js +90 -0
- package/package.json +1 -2
package/dist/Chart.js
CHANGED
|
@@ -1,48 +1,20 @@
|
|
|
1
|
-
|
|
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]; } };
|
|
7
|
-
}
|
|
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;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.ChartTooltipRow = exports.ChartTooltipFrame = exports.valueFormatter = void 0;
|
|
30
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
31
2
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
32
3
|
// @ts-nocheck
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
4
|
+
import { useState, useEffect, useContext, useMemo } from 'react';
|
|
5
|
+
import { aggregate } from './utils/aggregate';
|
|
6
|
+
import { getPostgresBasicType } from './ReportBuilder';
|
|
7
|
+
import { Area, CartesianGrid, ComposedChart as ReChartsAreaChart, ResponsiveContainer, Tooltip, XAxis, YAxis, Bar, BarChart as ReChartsBarChart, } from 'recharts';
|
|
8
|
+
import { differenceInHours, format, } from 'date-fns';
|
|
9
|
+
import BarList from './BarList';
|
|
10
|
+
import PieChart, { findComplementaryAndAnalogousColors } from './PieChart';
|
|
11
|
+
import { ClientContext, DashboardContext, ThemeContext, DashboardFiltersContext, DateFilterContext, } from './Context';
|
|
12
|
+
import { SpecialTable } from './Table';
|
|
13
|
+
import { getData } from './utils/dataFetcher';
|
|
14
|
+
import { generatePivotTable, generatePivotTableYAxis, } from './internals/ReportBuilder/PivotModal';
|
|
15
|
+
import { COLOR_TO_HEX } from './utils/colorToHex';
|
|
16
|
+
import { valueFormatter } from './utils/valueFormatter';
|
|
17
|
+
import { axisFormatter } from './utils/axisFormatter';
|
|
46
18
|
const colorValues = [
|
|
47
19
|
'slate',
|
|
48
20
|
'silver',
|
|
@@ -82,8 +54,8 @@ function selectColor(element, colors, index) {
|
|
|
82
54
|
return color;
|
|
83
55
|
}
|
|
84
56
|
// If the element is a comparison, make the color grayscale.
|
|
85
|
-
if (Object.keys(
|
|
86
|
-
const colorHex =
|
|
57
|
+
if (Object.keys(COLOR_TO_HEX).includes(color)) {
|
|
58
|
+
const colorHex = COLOR_TO_HEX[color];
|
|
87
59
|
const rgbArray = hexToRGB(colorHex);
|
|
88
60
|
return toGrayscale(rgbArray);
|
|
89
61
|
}
|
|
@@ -159,157 +131,6 @@ function toGrayscale(rgba) {
|
|
|
159
131
|
// 'The Pragmatic Engineer': 1726,
|
|
160
132
|
// },
|
|
161
133
|
// ];
|
|
162
|
-
const valueFormatter = ({ value, field, fields }) => {
|
|
163
|
-
if (value === undefined ||
|
|
164
|
-
value === null ||
|
|
165
|
-
field === undefined ||
|
|
166
|
-
field === null) {
|
|
167
|
-
return '';
|
|
168
|
-
}
|
|
169
|
-
const fieldInfo = fields.find(f => f.field === field);
|
|
170
|
-
if (!fieldInfo) {
|
|
171
|
-
return '';
|
|
172
|
-
}
|
|
173
|
-
const formatType = fieldInfo.format;
|
|
174
|
-
const numValue = Number(value);
|
|
175
|
-
const absNumber = isNaN(numValue) ? 0 : Math.abs(numValue);
|
|
176
|
-
if (formatType === 'percent') {
|
|
177
|
-
if (absNumber < 1) {
|
|
178
|
-
return (absNumber * 100).toFixed(0) + '%';
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
return absNumber.toFixed(0) + '%';
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
if (formatType === 'dollar_amount') {
|
|
185
|
-
const formatter = new Intl.NumberFormat('en-US', {
|
|
186
|
-
style: 'currency',
|
|
187
|
-
currency: 'USD',
|
|
188
|
-
minimumFractionDigits: 0,
|
|
189
|
-
maximumFractionDigits: 0,
|
|
190
|
-
});
|
|
191
|
-
if (absNumber >= 1000000) {
|
|
192
|
-
return formatter.format(numValue / 1000000) + 'M';
|
|
193
|
-
}
|
|
194
|
-
else if (absNumber >= 1000) {
|
|
195
|
-
return formatter.format(numValue / 1000) + 'K';
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
return formatter.format(numValue);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (formatType === 'dollar_cents') {
|
|
202
|
-
const formatter = new Intl.NumberFormat('en-US', {
|
|
203
|
-
style: 'currency',
|
|
204
|
-
currency: 'USD',
|
|
205
|
-
minimumFractionDigits: 2,
|
|
206
|
-
maximumFractionDigits: 2,
|
|
207
|
-
});
|
|
208
|
-
if (absNumber >= 1000000) {
|
|
209
|
-
return formatter.format(numValue / 1000000) + 'M';
|
|
210
|
-
}
|
|
211
|
-
else if (absNumber >= 1000) {
|
|
212
|
-
return formatter.format(numValue / 1000) + 'K';
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
return formatter.format(numValue);
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
if (formatType === 'whole_number') {
|
|
219
|
-
if (absNumber >= 1000000) {
|
|
220
|
-
return (numValue / 1e6).toFixed(1) + 'M';
|
|
221
|
-
}
|
|
222
|
-
else if (absNumber >= 1000) {
|
|
223
|
-
return (numValue / 1000).toFixed(1) + 'K';
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
return Math.round(numValue).toString();
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
if (formatType === 'one_decimal_place') {
|
|
230
|
-
return numValue.toFixed(1);
|
|
231
|
-
}
|
|
232
|
-
if (formatType === 'two_decimal_places') {
|
|
233
|
-
return numValue.toFixed(2);
|
|
234
|
-
}
|
|
235
|
-
if (formatType === 'MMM_yyyy' ||
|
|
236
|
-
formatType === 'MMM_dd_yyyy' ||
|
|
237
|
-
formatType === 'MMM_dd_yyyy' ||
|
|
238
|
-
formatType === 'hh_ap_pm' ||
|
|
239
|
-
formatType === 'MMM_dd-MMM_dd' ||
|
|
240
|
-
formatType === 'MMM_dd_hh:mm_ap_pm' ||
|
|
241
|
-
formatType === 'yyyy' ||
|
|
242
|
-
formatType === 'wo, yyyy') {
|
|
243
|
-
const dateValue = new Date(value);
|
|
244
|
-
const utcDate = (0, date_fns_tz_1.utcToZonedTime)(dateValue, 'UTC');
|
|
245
|
-
if (!(0, date_fns_1.isValid)(utcDate)) {
|
|
246
|
-
return 'Invalid date';
|
|
247
|
-
}
|
|
248
|
-
if (formatType === 'yyyy') {
|
|
249
|
-
return (0, date_fns_1.format)(utcDate, 'yyyy');
|
|
250
|
-
}
|
|
251
|
-
if (formatType === 'MMM_yyyy') {
|
|
252
|
-
return (0, date_fns_1.format)(utcDate, 'MMM yyyy');
|
|
253
|
-
}
|
|
254
|
-
if (formatType === 'MMM_dd_yyyy') {
|
|
255
|
-
return (0, date_fns_1.format)(utcDate, 'dd MMM yyyy');
|
|
256
|
-
}
|
|
257
|
-
if (formatType === 'hh_ap_pm') {
|
|
258
|
-
return (0, date_fns_1.format)(utcDate, 'hh:mm aa');
|
|
259
|
-
}
|
|
260
|
-
if (formatType === 'MMM_dd-MMM_dd') {
|
|
261
|
-
const start = (0, date_fns_1.startOfWeek)(utcDate, { weekStartsOn: 1 }); // Monday
|
|
262
|
-
const end = (0, date_fns_1.endOfWeek)(utcDate, { weekStartsOn: 1 }); // Sunday
|
|
263
|
-
let formattedDate = '';
|
|
264
|
-
// Check if start and end are in the same month
|
|
265
|
-
if ((0, date_fns_1.format)(start, 'MMM') === (0, date_fns_1.format)(end, 'MMM')) {
|
|
266
|
-
formattedDate = `${(0, date_fns_1.format)(start, 'MMM dd')} - ${(0, date_fns_1.format)(end, 'dd')}`;
|
|
267
|
-
}
|
|
268
|
-
else {
|
|
269
|
-
formattedDate = `${(0, date_fns_1.format)(start, 'MMM dd')} - ${(0, date_fns_1.format)(end, 'MMM dd')}`;
|
|
270
|
-
}
|
|
271
|
-
return formattedDate;
|
|
272
|
-
}
|
|
273
|
-
if (formatType === 'MMM_dd_yyyy') {
|
|
274
|
-
const year = utcDate.getFullYear();
|
|
275
|
-
const monthNames = [
|
|
276
|
-
'Jan',
|
|
277
|
-
'Feb',
|
|
278
|
-
'Mar',
|
|
279
|
-
'Apr',
|
|
280
|
-
'May',
|
|
281
|
-
'Jun',
|
|
282
|
-
'Jul',
|
|
283
|
-
'Aug',
|
|
284
|
-
'Sep',
|
|
285
|
-
'Oct',
|
|
286
|
-
'Nov',
|
|
287
|
-
'Dec',
|
|
288
|
-
];
|
|
289
|
-
const month = monthNames[utcDate.getMonth()];
|
|
290
|
-
const day = utcDate.getDate();
|
|
291
|
-
return `${month} ${day}, ${year}`;
|
|
292
|
-
}
|
|
293
|
-
if (formatType === 'MMM_dd_hh:mm_ap_pm') {
|
|
294
|
-
const formatStr = utcDate.getMinutes() === 0 ? 'MMM do h a' : 'MMM do h:mm a';
|
|
295
|
-
let formattedTime = (0, date_fns_1.format)(utcDate, formatStr);
|
|
296
|
-
formattedTime =
|
|
297
|
-
formattedTime.slice(0, -2) + formattedTime.slice(-2).toLowerCase();
|
|
298
|
-
return formattedTime;
|
|
299
|
-
}
|
|
300
|
-
if (formatType === 'wo, yyyy') {
|
|
301
|
-
// Using the `getWeek` function to get the week number
|
|
302
|
-
const weekNumber = getWeek(utcDate);
|
|
303
|
-
const year = utcDate.getFullYear();
|
|
304
|
-
return `${weekNumber},${year}`;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
if (formatType === 'string') {
|
|
308
|
-
return value.toString();
|
|
309
|
-
}
|
|
310
|
-
return value.toString();
|
|
311
|
-
};
|
|
312
|
-
exports.valueFormatter = valueFormatter;
|
|
313
134
|
const yAxisFields = [
|
|
314
135
|
{ field: 'avg_days', label: 'average days' },
|
|
315
136
|
{ field: 'median_days', label: 'median days' },
|
|
@@ -318,7 +139,7 @@ const labelFormatter = (name) => {
|
|
|
318
139
|
// return yAxisFields.filter(elem => elem.field === name)[0].label;
|
|
319
140
|
return name;
|
|
320
141
|
};
|
|
321
|
-
const ChartTooltipFrame = ({ children, theme, }) => ((
|
|
142
|
+
export const ChartTooltipFrame = ({ children, theme, }) => (_jsx("div", { style: {
|
|
322
143
|
borderStyle: 'solid',
|
|
323
144
|
borderColor: theme?.borderColor || '#E5E7EB',
|
|
324
145
|
overflow: 'hidden',
|
|
@@ -327,8 +148,7 @@ const ChartTooltipFrame = ({ children, theme, }) => ((0, jsx_runtime_1.jsx)("div
|
|
|
327
148
|
borderRadius: '6px',
|
|
328
149
|
boxShadow: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
|
|
329
150
|
}, children: children }));
|
|
330
|
-
|
|
331
|
-
const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
151
|
+
export const ChartTooltipRow = ({ value, name, color, theme, }) => (_jsxs("div", { style: {
|
|
332
152
|
marginRight: '24px',
|
|
333
153
|
display: 'flex',
|
|
334
154
|
alignItems: 'center',
|
|
@@ -336,13 +156,13 @@ const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.j
|
|
|
336
156
|
width: '100%',
|
|
337
157
|
paddingTop: 2,
|
|
338
158
|
paddingBottom: 2,
|
|
339
|
-
}, children: [(
|
|
159
|
+
}, children: [_jsxs("div", {
|
|
340
160
|
// className="qq-flex qq-items-center qq-space-x-2"
|
|
341
161
|
style: {
|
|
342
162
|
// marginLeft: '0.5rem',
|
|
343
163
|
display: 'flex',
|
|
344
164
|
alignItems: 'center',
|
|
345
|
-
}, children: [(
|
|
165
|
+
}, children: [_jsx("span", { style: {
|
|
346
166
|
background: color,
|
|
347
167
|
borderWidth: 2,
|
|
348
168
|
borderStyle: 'solid',
|
|
@@ -353,7 +173,7 @@ const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.j
|
|
|
353
173
|
borderRadius: 100,
|
|
354
174
|
marginRight: 6,
|
|
355
175
|
boxSizing: 'border-box',
|
|
356
|
-
} }), (
|
|
176
|
+
} }), _jsx("p", {
|
|
357
177
|
// className={twMerge(
|
|
358
178
|
// 'font-medium tabular-nums text-right whitespace-nowrap',
|
|
359
179
|
// 'text-[#212121] !important'
|
|
@@ -365,7 +185,7 @@ const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.j
|
|
|
365
185
|
color: theme?.primaryTextColor,
|
|
366
186
|
fontSize: theme?.fontSizeSmall || '14px',
|
|
367
187
|
fontWeight: theme?.fontWeightMedium || '500',
|
|
368
|
-
}, children: value })] }), (
|
|
188
|
+
}, children: value })] }), _jsx("p", { style: {
|
|
369
189
|
marginTop: 0,
|
|
370
190
|
marginBottom: 0,
|
|
371
191
|
fontFamily: theme?.fontFamily,
|
|
@@ -377,11 +197,10 @@ const ChartTooltipRow = ({ value, name, color, theme, }) => ((0, jsx_runtime_1.j
|
|
|
377
197
|
fontSize: theme?.fontSizeSmall || '14px',
|
|
378
198
|
fontWeight: theme?.fontWeightNormal || '400',
|
|
379
199
|
}, children: name })] }));
|
|
380
|
-
exports.ChartTooltipRow = ChartTooltipRow;
|
|
381
200
|
const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter, dateFormatter, theme, }) => {
|
|
382
201
|
if (active && payload) {
|
|
383
202
|
if (label2) {
|
|
384
|
-
return ((
|
|
203
|
+
return (_jsx(ChartTooltipFrame, { theme: theme, children: payload.map(({ value, name }, idx) => (_jsxs(_Fragment, { children: [idx === 0 && (_jsx("div", { style: {
|
|
385
204
|
borderStyle: 'solid',
|
|
386
205
|
borderBottomColor: theme?.borderColor || '#E5E7EB',
|
|
387
206
|
background: theme?.backgroundColor || 'white',
|
|
@@ -395,7 +214,7 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
395
214
|
paddingRight: '16px',
|
|
396
215
|
paddingTop: '8px',
|
|
397
216
|
paddingBottom: '8px',
|
|
398
|
-
}, children: (
|
|
217
|
+
}, children: _jsx("p", { style: {
|
|
399
218
|
textAlign: 'left',
|
|
400
219
|
marginTop: 0,
|
|
401
220
|
marginBottom: 0,
|
|
@@ -405,7 +224,7 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
405
224
|
fontWeight: theme?.boldFontWeight || '500',
|
|
406
225
|
paddingTop: 2,
|
|
407
226
|
paddingBottom: 2,
|
|
408
|
-
}, children: labelFormatter(name) }) })), (
|
|
227
|
+
}, children: labelFormatter(name) }) })), _jsx("div", {
|
|
409
228
|
// className="qq-px-4 qq-space-y-1 qq-py-2 qq-px-4"
|
|
410
229
|
style: {
|
|
411
230
|
paddingRight: '16px',
|
|
@@ -413,18 +232,18 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
413
232
|
paddingTop: idx === 0 && '8px',
|
|
414
233
|
paddingBottom: '8px',
|
|
415
234
|
// marginTop: '0.25rem',
|
|
416
|
-
}, children: (
|
|
235
|
+
}, children: _jsx(ChartTooltipRow, { name: valueFormatter(value), value: !isNaN(new Date(idx === 0 ? label : label2)) &&
|
|
417
236
|
dateFormatter
|
|
418
237
|
? dateFormatter(idx === 0 ? label : label2)
|
|
419
238
|
: !isNaN(new Date(idx === 0 ? label : label2))
|
|
420
|
-
?
|
|
239
|
+
? format(new Date(idx === 0 ? label : label2), 'MMM yyyy')
|
|
421
240
|
: idx === 0
|
|
422
241
|
? label
|
|
423
242
|
: label2,
|
|
424
243
|
// color={categoryColors.get(name) ?? BaseColors.Blue}
|
|
425
244
|
color: colors[idx], theme: theme }, `id-${idx}`) })] }))) }));
|
|
426
245
|
}
|
|
427
|
-
return ((
|
|
246
|
+
return (_jsxs(ChartTooltipFrame, { theme: theme, children: [_jsx("div", { style: {
|
|
428
247
|
borderStyle: 'solid',
|
|
429
248
|
borderBottomColor: theme?.borderColor || '#E5E7EB',
|
|
430
249
|
background: theme?.backgroundColor || 'white',
|
|
@@ -438,7 +257,7 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
438
257
|
paddingRight: '16px',
|
|
439
258
|
paddingTop: '8px',
|
|
440
259
|
paddingBottom: '8px',
|
|
441
|
-
}, children: (
|
|
260
|
+
}, children: _jsx("p", { style: {
|
|
442
261
|
textAlign: 'left',
|
|
443
262
|
marginTop: 0,
|
|
444
263
|
marginBottom: 0,
|
|
@@ -451,8 +270,8 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
451
270
|
}, children: !isNaN(new Date(label)) && dateFormatter
|
|
452
271
|
? dateFormatter(label)
|
|
453
272
|
: !isNaN(new Date(label))
|
|
454
|
-
?
|
|
455
|
-
: label }) }), (
|
|
273
|
+
? format(new Date(label), 'MMM yyyy')
|
|
274
|
+
: label }) }), _jsx("div", {
|
|
456
275
|
// className="qq-px-4 qq-space-y-1 qq-py-2 qq-px-4"
|
|
457
276
|
style: {
|
|
458
277
|
paddingRight: '16px',
|
|
@@ -460,7 +279,7 @@ const ChartTooltip = ({ active, payload, label, label2, colors, valueFormatter,
|
|
|
460
279
|
paddingTop: '8px',
|
|
461
280
|
paddingBottom: '8px',
|
|
462
281
|
// marginTop: '0.25rem',
|
|
463
|
-
}, children: payload.map(({ value, name }, idx) => ((
|
|
282
|
+
}, children: payload.map(({ value, name }, idx) => (_jsx(ChartTooltipRow, { value: valueFormatter(value), name: labelFormatter(name),
|
|
464
283
|
// color={categoryColors.get(name) ?? BaseColors.Blue}
|
|
465
284
|
color: colors[idx], theme: theme }, `id-${idx}`))) })] }));
|
|
466
285
|
}
|
|
@@ -478,7 +297,7 @@ function isDate(str) {
|
|
|
478
297
|
return !isNaN(Date.parse(str));
|
|
479
298
|
}
|
|
480
299
|
function areDatesNearby(dateStr1, dateStr2) {
|
|
481
|
-
return Math.abs(
|
|
300
|
+
return Math.abs(differenceInHours(dateStr1, dateStr2)) < 24;
|
|
482
301
|
}
|
|
483
302
|
function isEquivalent(filters1, filters2) {
|
|
484
303
|
if (Object.keys(filters2).length !== Object.keys(filters1).length) {
|
|
@@ -522,9 +341,9 @@ function didFiltersChange(dashboardItem, filters) {
|
|
|
522
341
|
const Chart = ({ chartId, config, colors, containerStyle, query,
|
|
523
342
|
//chartFilters
|
|
524
343
|
SelectComponent, DatePickerComponent, }) => {
|
|
525
|
-
const { dateFilter, setDateFilter } =
|
|
526
|
-
const { dispatch, dashboard } =
|
|
527
|
-
const { dashboardFilters } =
|
|
344
|
+
const { dateFilter, setDateFilter } = useContext(DateFilterContext);
|
|
345
|
+
const { dispatch, dashboard } = useContext(DashboardContext);
|
|
346
|
+
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
528
347
|
// const [chartFilters, setChartFilters] = useState({
|
|
529
348
|
// chart_filter: {
|
|
530
349
|
// table: 'transactions',
|
|
@@ -542,16 +361,16 @@ SelectComponent, DatePickerComponent, }) => {
|
|
|
542
361
|
// ],
|
|
543
362
|
// },
|
|
544
363
|
// });
|
|
545
|
-
const [client, _] =
|
|
546
|
-
const [theme] =
|
|
547
|
-
const chartColors =
|
|
364
|
+
const [client, _] = useContext(ClientContext);
|
|
365
|
+
const [theme] = useContext(ThemeContext);
|
|
366
|
+
const chartColors = useMemo(() => {
|
|
548
367
|
return colors?.length
|
|
549
368
|
? colors
|
|
550
369
|
: theme && theme.chartColors.length
|
|
551
370
|
? theme.chartColors
|
|
552
371
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
553
372
|
}, [colors]);
|
|
554
|
-
return ((
|
|
373
|
+
return (_jsx(ChartUpdater, { config: config, dispatch: dispatch, dashboard: dashboard, chartId: chartId, containerStyle: containerStyle, colors: chartColors, client: client, theme: theme,
|
|
555
374
|
// isDateFilter={dateFilter}
|
|
556
375
|
dateFilter: dateFilter, dashboardFilters: dashboardFilters,
|
|
557
376
|
// chartFilters={chartFilters}
|
|
@@ -565,10 +384,10 @@ dashboardFilters,
|
|
|
565
384
|
// chartFilters,
|
|
566
385
|
// setChartFilters,
|
|
567
386
|
query, SelectComponent, DatePickerComponent, }) => {
|
|
568
|
-
const [loading, setLoading] =
|
|
569
|
-
const [isComparison, setIsComparison] =
|
|
570
|
-
const [bucketData, setBucketData] =
|
|
571
|
-
|
|
387
|
+
const [loading, setLoading] = useState(false);
|
|
388
|
+
const [isComparison, setIsComparison] = useState(false);
|
|
389
|
+
const [bucketData, setBucketData] = useState(null);
|
|
390
|
+
useEffect(() => {
|
|
572
391
|
let isSubscribed = true;
|
|
573
392
|
async function getChartOptions() {
|
|
574
393
|
if (dashboard[chartId] &&
|
|
@@ -598,7 +417,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
598
417
|
id: chartId,
|
|
599
418
|
filters: [...Object.values(dashboardFilters)],
|
|
600
419
|
};
|
|
601
|
-
const resp = await
|
|
420
|
+
const resp = await getData(client, 'itempost', 'omit', hostedBody, cloudBody);
|
|
602
421
|
if (resp) {
|
|
603
422
|
setLoading(false);
|
|
604
423
|
setIsComparison(!!resp.comparisonRows);
|
|
@@ -640,7 +459,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
640
459
|
isSubscribed = false;
|
|
641
460
|
};
|
|
642
461
|
}, [dashboardFilters, client, chartId]);
|
|
643
|
-
|
|
462
|
+
useEffect(() => {
|
|
644
463
|
if (!dashboardFilters ||
|
|
645
464
|
!chartId ||
|
|
646
465
|
!dashboard[chartId] ||
|
|
@@ -648,9 +467,9 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
648
467
|
!dashboard[chartId].buckets.length) {
|
|
649
468
|
return;
|
|
650
469
|
}
|
|
651
|
-
const dateFilter = Object.values(dashboardFilters).find(filter => filter.filterType == 'date_range');
|
|
470
|
+
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
652
471
|
if (dateFilter && dashboard[chartId].rows.length) {
|
|
653
|
-
const aggregatedObj =
|
|
472
|
+
const aggregatedObj = aggregate(dashboard[chartId], dashboard[chartId].buckets, dateFilter);
|
|
654
473
|
setBucketData({
|
|
655
474
|
name: dashboard[chartId].name,
|
|
656
475
|
xAxisFormat: aggregatedObj.xAxisFormat,
|
|
@@ -659,11 +478,11 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
659
478
|
rows: aggregatedObj.bucketedRows,
|
|
660
479
|
});
|
|
661
480
|
}
|
|
662
|
-
const stringFilters = dashboard[chartId].buckets.filter(bucket => {
|
|
663
|
-
return (
|
|
481
|
+
const stringFilters = dashboard[chartId].buckets.filter((bucket) => {
|
|
482
|
+
return (getPostgresBasicType(dashboard[chartId].fields.find((field) => field.name === bucket.field)) === 'string');
|
|
664
483
|
});
|
|
665
484
|
if (stringFilters.length && dashboard[chartId].rows.length) {
|
|
666
|
-
const aggregatedObj =
|
|
485
|
+
const aggregatedObj = aggregate(dashboard[chartId], dashboard[chartId].buckets, null);
|
|
667
486
|
setBucketData({
|
|
668
487
|
name: dashboard[chartId].name,
|
|
669
488
|
xAxisFormat: aggregatedObj.xAxisFormat,
|
|
@@ -697,17 +516,17 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
697
516
|
// return;
|
|
698
517
|
// }
|
|
699
518
|
// };
|
|
700
|
-
const dateFilter = Object.values(dashboardFilters).find(filter => filter.filterType == 'date_range');
|
|
701
|
-
const pivotTable =
|
|
519
|
+
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
520
|
+
const pivotTable = useMemo(() => {
|
|
702
521
|
const pivot = dashboard[chartId]?.pivot || config?.pivot;
|
|
703
522
|
const data = dashboard[chartId] ? dashboard[chartId] : config;
|
|
704
523
|
return pivot && data?.rows
|
|
705
|
-
?
|
|
524
|
+
? generatePivotTable(pivot, data.rows, dateFilter?.startDate
|
|
706
525
|
? [dateFilter?.startDate, dateFilter?.endDate, null]
|
|
707
526
|
: [null, null, null])
|
|
708
527
|
: null;
|
|
709
528
|
}, [dashboard, chartId, config, dateFilter]);
|
|
710
|
-
const pivotTableYAxis =
|
|
529
|
+
const pivotTableYAxis = useMemo(() => {
|
|
711
530
|
if (!pivotTable) {
|
|
712
531
|
return null;
|
|
713
532
|
}
|
|
@@ -716,11 +535,11 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
716
535
|
? config.yAxisFields
|
|
717
536
|
: dashboard[chartId]?.yAxisFields;
|
|
718
537
|
return yAxisFields
|
|
719
|
-
?
|
|
538
|
+
? generatePivotTableYAxis(pivot, pivotTable.columns, yAxisFields?.[0]?.format)
|
|
720
539
|
: null;
|
|
721
540
|
}, [pivotTable]);
|
|
722
541
|
if (!config && (!dashboard[chartId] || loading)) {
|
|
723
|
-
return ((
|
|
542
|
+
return (_jsx("div", {
|
|
724
543
|
// className="flex flex-col flex-1 h-[100%]"
|
|
725
544
|
style: {
|
|
726
545
|
...containerStyle,
|
|
@@ -731,13 +550,13 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
731
550
|
// display: 'flex',
|
|
732
551
|
// flexDirection: 'column',
|
|
733
552
|
// flex: 1,
|
|
734
|
-
}, children: (
|
|
553
|
+
}, children: _jsx("div", { style: {
|
|
735
554
|
height: containerStyle?.height,
|
|
736
555
|
width: '100%',
|
|
737
556
|
boxSizing: 'content-box',
|
|
738
557
|
borderRadius: 8,
|
|
739
558
|
overflow: 'hidden',
|
|
740
|
-
}, children: (
|
|
559
|
+
}, children: _jsxs("svg", { width: "100%", height: "100%", xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", children: [_jsx("rect", { width: "100%", height: "100%", fill: theme?.loadingStateBackgroundColor || '#F9F9FA' }), _jsx("defs", { fill: theme?.loadingStateBackgroundColor || '#F9F9FA', children: _jsxs("linearGradient", { id: "skeletonGradient", x1: "0%", y1: "0%", x2: "10%", y2: "0%", gradientUnits: "userSpaceOnUse", children: [_jsx("stop", { offset: "0%", stopColor: "rgba(255,255,255,0)" }), _jsx("stop", { offset: "50%", stopColor: "#FEFEFE" }), _jsx("stop", { offset: "100%", stopColor: "rgba(255,255,255,0)" }), _jsx("animate", { attributeName: "x1", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }), _jsx("animate", { attributeName: "x2", from: "-50%", to: "150%", dur: "2s", repeatCount: "indefinite" })] }) }), _jsx("rect", { width: "50%", height: "100%", fill: "url(#skeletonGradient)", children: _jsx("animate", { attributeName: "x", from: "-100%", to: "100%", dur: "2s", repeatCount: "indefinite" }) })] }) }) }));
|
|
741
560
|
}
|
|
742
561
|
if (config?.chartType === 'pie' || dashboard[chartId]?.chartType === 'pie') {
|
|
743
562
|
const rows = pivotTable
|
|
@@ -753,11 +572,11 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
753
572
|
const xAxisField = config
|
|
754
573
|
? config.xAxisField
|
|
755
574
|
: dashboard[chartId].xAxisField;
|
|
756
|
-
return ((
|
|
575
|
+
return (_jsx(_Fragment, { children: _jsx(PieChart
|
|
757
576
|
// @ts-ignore
|
|
758
577
|
, {
|
|
759
578
|
// @ts-ignore
|
|
760
|
-
containerStyle: containerStyle, data: rows.map(row => {
|
|
579
|
+
containerStyle: containerStyle, data: rows.map((row) => {
|
|
761
580
|
return {
|
|
762
581
|
...row,
|
|
763
582
|
count: parseInt(row[yAxisFields[0].field]) /
|
|
@@ -768,12 +587,12 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
768
587
|
if (config?.chartType === 'table' ||
|
|
769
588
|
dashboard[chartId]?.chartType === 'table') {
|
|
770
589
|
const data = dashboard[chartId] ? dashboard[chartId] : config;
|
|
771
|
-
return ((
|
|
590
|
+
return (_jsx(_Fragment, { children: _jsx(SpecialTable, { rows: pivotTable?.rows || data.rows, columns: pivotTable?.columns || data.columns || data.yAxisFields, height: '400px', containerStyle: {
|
|
772
591
|
...containerStyle,
|
|
773
592
|
}, theme: theme, isTableChart: true, name: data.name }) }));
|
|
774
593
|
}
|
|
775
594
|
if (config?.chartType === 'bar' || dashboard[chartId]?.chartType === 'bar') {
|
|
776
|
-
return ((
|
|
595
|
+
return (_jsx(_Fragment, { children: _jsx(BarList, { data: pivotTable
|
|
777
596
|
? pivotTable.rows
|
|
778
597
|
: config
|
|
779
598
|
? (config.bucketedRows &&
|
|
@@ -811,7 +630,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
811
630
|
}
|
|
812
631
|
if (config?.chartType === 'column' ||
|
|
813
632
|
dashboard[chartId]?.chartType === 'column') {
|
|
814
|
-
return ((
|
|
633
|
+
return (_jsx(_Fragment, { children: _jsx(BarChart, { colors: colors, theme: theme, yAxisFields: yAxisFields,
|
|
815
634
|
// @ts-ignore
|
|
816
635
|
data: pivotTable
|
|
817
636
|
? pivotTable.rows
|
|
@@ -839,7 +658,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
839
658
|
if (config?.chartType === 'metric' ||
|
|
840
659
|
dashboard[chartId]?.chartType === 'metric') {
|
|
841
660
|
const data = dashboard[chartId] ? dashboard[chartId] : config;
|
|
842
|
-
return ((
|
|
661
|
+
return (_jsx(_Fragment, { children: _jsx("div", { style: {
|
|
843
662
|
fontFamily: theme?.fontFamily,
|
|
844
663
|
fontSize: 32,
|
|
845
664
|
color: theme?.primaryTextColor,
|
|
@@ -859,7 +678,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
859
678
|
display: 'flex',
|
|
860
679
|
flexDirection: 'column',
|
|
861
680
|
}, children: data.rows.length > 0 &&
|
|
862
|
-
|
|
681
|
+
valueFormatter({
|
|
863
682
|
value: data.rows[0][data.xAxisField],
|
|
864
683
|
field: data.xAxisField,
|
|
865
684
|
fields: [
|
|
@@ -870,7 +689,7 @@ query, SelectComponent, DatePickerComponent, }) => {
|
|
|
870
689
|
],
|
|
871
690
|
}) }) }));
|
|
872
691
|
}
|
|
873
|
-
return ((
|
|
692
|
+
return (_jsx(_Fragment, { children: _jsx(LineChart, { colors: colors, yAxisFields: yAxisFields,
|
|
874
693
|
// @ts-ignore
|
|
875
694
|
data: pivotTable
|
|
876
695
|
? pivotTable.rows
|
|
@@ -927,10 +746,10 @@ function formatNumber(num, label) {
|
|
|
927
746
|
// return [adjustedMin, adjustedMax];
|
|
928
747
|
// }
|
|
929
748
|
function getDomain(data, fields) {
|
|
930
|
-
const fieldsArray = fields.map(elem => elem.field);
|
|
749
|
+
const fieldsArray = fields.map((elem) => elem.field);
|
|
931
750
|
const numericValues = [];
|
|
932
|
-
data.forEach(item => {
|
|
933
|
-
fieldsArray.forEach(field => {
|
|
751
|
+
data.forEach((item) => {
|
|
752
|
+
fieldsArray.forEach((field) => {
|
|
934
753
|
let value = item[field];
|
|
935
754
|
// Try to cast the value to a number
|
|
936
755
|
const numericValue = parseFloat(value);
|
|
@@ -953,12 +772,12 @@ const CustomizedTick = ({ x, y, payload, theme, }) => {
|
|
|
953
772
|
const maxLength = 10;
|
|
954
773
|
const value = payload.value;
|
|
955
774
|
const truncatedValue = value.length > maxLength ? value.substring(0, maxLength) + '...' : value;
|
|
956
|
-
return ((
|
|
775
|
+
return (_jsx("text", { xlinkTitle: value, fill: theme?.chartLabelColor, fontSize: 12, x: x, y: y + 15, width: 30, textAnchor: "middle", children: truncatedValue }));
|
|
957
776
|
};
|
|
958
777
|
function BarChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxisLabel, xAxisFormat, theme, comparison, }) {
|
|
959
|
-
const newColors =
|
|
778
|
+
const newColors = findComplementaryAndAnalogousColors(colors[0], colors[1]);
|
|
960
779
|
if (!data || data.length === 0) {
|
|
961
|
-
return ((
|
|
780
|
+
return (_jsx("div", { style: {
|
|
962
781
|
display: 'flex',
|
|
963
782
|
flex: '1 0 auto',
|
|
964
783
|
height: '100%',
|
|
@@ -969,12 +788,12 @@ function BarChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxis
|
|
|
969
788
|
color: theme.secondaryTextColor,
|
|
970
789
|
}, children: "No results found for specified time period." }));
|
|
971
790
|
}
|
|
972
|
-
return ((
|
|
791
|
+
return (_jsx("div", { style: {
|
|
973
792
|
...containerStyle,
|
|
974
793
|
boxSizing: 'content-box',
|
|
975
|
-
}, children: (
|
|
794
|
+
}, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsBarChart, { data: data,
|
|
976
795
|
// stackOffset={'none'}
|
|
977
|
-
layout: 'horizontal', children: [(
|
|
796
|
+
layout: 'horizontal', children: [_jsx(CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), _jsx(YAxis
|
|
978
797
|
// width={56}
|
|
979
798
|
, {
|
|
980
799
|
// width={56}
|
|
@@ -986,11 +805,11 @@ function BarChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxis
|
|
|
986
805
|
tick: { transform: 'translate(-3, 0)' }, style: {
|
|
987
806
|
fontSize: '12px',
|
|
988
807
|
fontFamily: theme.chartLabelFontFamily,
|
|
989
|
-
}, tickFormatter: tick => (
|
|
808
|
+
}, tickFormatter: (tick) => axisFormatter({
|
|
990
809
|
value: tick,
|
|
991
810
|
field: yAxisFields[0].field || 'what',
|
|
992
811
|
fields: yAxisFields,
|
|
993
|
-
}) }), (
|
|
812
|
+
}) }), _jsx(XAxis, { hide: false, dataKey: xAxisField,
|
|
994
813
|
// interval="preserveStartEnd"
|
|
995
814
|
tick: { transform: 'translate(0, 6)' },
|
|
996
815
|
//padding between labels and axis
|
|
@@ -999,27 +818,27 @@ function BarChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxis
|
|
|
999
818
|
// TODO: generalize
|
|
1000
819
|
fontFamily: theme.chartLabelFontFamily,
|
|
1001
820
|
marginTop: '20px',
|
|
1002
|
-
}, tickLine: false, axisLine: false, tickFormatter: tick => (
|
|
821
|
+
}, tickLine: false, axisLine: false, tickFormatter: (tick) => axisFormatter({
|
|
1003
822
|
value: tick,
|
|
1004
823
|
field: xAxisField,
|
|
1005
824
|
fields: [{ field: xAxisField, format: xAxisFormat }],
|
|
1006
|
-
}) }), (
|
|
825
|
+
}) }), _jsx(Tooltip, { wrapperStyle: { outline: 'none', zIndex: 2 }, isAnimationActive: false, cursor: { fill: '#d1d5db', opacity: '0.15' }, content: ({ active, payload, label }) => {
|
|
1007
826
|
let label2;
|
|
1008
827
|
if (comparison &&
|
|
1009
828
|
payload?.length > 1 &&
|
|
1010
829
|
payload[0].payload[xAxisField + '2']) {
|
|
1011
830
|
label2 = payload[0].payload[xAxisField + '2'];
|
|
1012
831
|
}
|
|
1013
|
-
return ((
|
|
832
|
+
return (_jsx(ChartTooltip, { theme: theme, active: active, payload: payload, label: label, label2: label2, dateFormatter: (value) => valueFormatter({
|
|
1014
833
|
value,
|
|
1015
834
|
field: xAxisField,
|
|
1016
835
|
fields: [{ field: xAxisField, format: xAxisFormat }],
|
|
1017
|
-
}), valueFormatter: value =>
|
|
836
|
+
}), valueFormatter: (value) => valueFormatter({
|
|
1018
837
|
value,
|
|
1019
838
|
field: payload[0].dataKey,
|
|
1020
839
|
fields: yAxisFields,
|
|
1021
840
|
}), colors: colors }));
|
|
1022
|
-
}, position: { y: 0 } }), yAxisFields.map((elem, index) => ((
|
|
841
|
+
}, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx(Bar, { name: elem.label, dataKey: elem.field, type: "linear",
|
|
1023
842
|
// stackId={stack || relative ? "a" : undefined}
|
|
1024
843
|
fill: selectColor(elem, colors, index),
|
|
1025
844
|
// barSize={20}
|
|
@@ -1038,7 +857,7 @@ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxi
|
|
|
1038
857
|
return null;
|
|
1039
858
|
}
|
|
1040
859
|
if (!data || data.length === 0) {
|
|
1041
|
-
return ((
|
|
860
|
+
return (_jsx("div", { style: {
|
|
1042
861
|
display: 'flex',
|
|
1043
862
|
flex: '1 0 auto',
|
|
1044
863
|
height: '100%',
|
|
@@ -1049,7 +868,7 @@ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxi
|
|
|
1049
868
|
color: theme.secondaryTextColor,
|
|
1050
869
|
}, children: "No results found for specified time period." }));
|
|
1051
870
|
}
|
|
1052
|
-
return ((
|
|
871
|
+
return (_jsx("div", { style: { ...containerStyle, boxSizing: 'content-box' }, children: _jsx(ResponsiveContainer, { width: "100%", height: '100%', children: _jsxs(ReChartsAreaChart, { data: data, children: [_jsx(CartesianGrid, { strokeDasharray: "3 3", horizontal: true, vertical: false }), _jsx(XAxis
|
|
1053
872
|
// hide={!showXAxis}
|
|
1054
873
|
, {
|
|
1055
874
|
// hide={!showXAxis}
|
|
@@ -1069,11 +888,11 @@ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxi
|
|
|
1069
888
|
// interval="preserveStartEnd"
|
|
1070
889
|
interval: "preserveStartEnd",
|
|
1071
890
|
// interval={0}
|
|
1072
|
-
tickLine: false, axisLine: false, padding: { left: 10, right: 10 }, minTickGap: 5, tickFormatter: tick => (
|
|
891
|
+
tickLine: false, axisLine: false, padding: { left: 10, right: 10 }, minTickGap: 5, tickFormatter: (tick) => axisFormatter({
|
|
1073
892
|
value: tick,
|
|
1074
893
|
field: xAxisField,
|
|
1075
894
|
fields: [{ field: xAxisField, format: xAxisFormat }],
|
|
1076
|
-
}) }), (
|
|
895
|
+
}) }), _jsx(YAxis
|
|
1077
896
|
// textAnchor="left"
|
|
1078
897
|
// tickMargin={11}
|
|
1079
898
|
, {
|
|
@@ -1090,25 +909,25 @@ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxi
|
|
|
1090
909
|
theme?.fontFamily ||
|
|
1091
910
|
'Inter; Helvetica',
|
|
1092
911
|
color: theme?.chartLabelColor || '#666666',
|
|
1093
|
-
}, tickFormatter: value => (
|
|
912
|
+
}, tickFormatter: (value) => axisFormatter({
|
|
1094
913
|
value,
|
|
1095
914
|
field: yAxisFields[0].field,
|
|
1096
915
|
fields: [
|
|
1097
916
|
...yAxisFields,
|
|
1098
917
|
{ field: xAxisField, format: xAxisFormat },
|
|
1099
918
|
],
|
|
1100
|
-
}) }), (
|
|
919
|
+
}) }), _jsx(Tooltip, { wrapperStyle: { outline: 'none' }, isAnimationActive: false, cursor: { stroke: '#d1d5db', strokeWidth: 1 }, content: ({ active, payload, label }) => {
|
|
1101
920
|
let label2;
|
|
1102
921
|
if (comparison &&
|
|
1103
922
|
payload?.length > 1 &&
|
|
1104
923
|
payload[0].payload[xAxisField + '2']) {
|
|
1105
924
|
label2 = payload[0].payload[xAxisField + '2'];
|
|
1106
925
|
}
|
|
1107
|
-
return ((
|
|
926
|
+
return (_jsx(ChartTooltip, { active: active, payload: payload, label: label, label2: label2, dateFormatter: (value) => valueFormatter({
|
|
1108
927
|
value,
|
|
1109
928
|
field: xAxisField,
|
|
1110
929
|
fields: [{ field: xAxisField, format: xAxisFormat }],
|
|
1111
|
-
}), valueFormatter: value =>
|
|
930
|
+
}), valueFormatter: (value) => valueFormatter({
|
|
1112
931
|
value,
|
|
1113
932
|
field: payload[0].dataKey,
|
|
1114
933
|
fields: [
|
|
@@ -1116,10 +935,9 @@ function LineChart({ colors, yAxisFields, data, containerStyle, xAxisField, xAxi
|
|
|
1116
935
|
{ field: xAxisField, format: xAxisFormat },
|
|
1117
936
|
],
|
|
1118
937
|
}), colors: colors, theme: theme }));
|
|
1119
|
-
}, position: { y: 0 } }), yAxisFields.map((elem, index) => ((
|
|
938
|
+
}, position: { y: 0 } }), yAxisFields.map((elem, index) => (_jsx("defs", { children: _jsxs("linearGradient", { id: `gradient${index}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [_jsx("stop", { offset: "5%", stopColor: selectColor(elem, colors, index), stopOpacity: 0.4 }), _jsx("stop", { offset: "95%", stopColor: 'rgba(0,0,0,0)', stopOpacity: 0 })] }) }, `defs${elem.field + index}`))), yAxisFields.map((elem, index) => (_jsx(Area, { name: elem.label, type: "linear", dataKey: elem.field, stroke: selectColor(elem, colors, index),
|
|
1120
939
|
// if hide area
|
|
1121
940
|
// fill="transparent"
|
|
1122
941
|
fill: `url(#gradient${index})`, strokeWidth: 2, dot: false, isAnimationActive: true }, elem.field)))] }) }) }));
|
|
1123
942
|
}
|
|
1124
|
-
|
|
1125
|
-
//# sourceMappingURL=Chart.js.map
|
|
943
|
+
export default Chart;
|