@quillsql/react 2.11.9 → 2.11.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BarList.d.ts +2 -1
- package/dist/cjs/BarList.d.ts.map +1 -1
- package/dist/cjs/BarList.js +9 -3
- package/dist/cjs/Chart.d.ts +11 -5
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +57 -20
- package/dist/cjs/ChartBuilder.d.ts +16 -1
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +423 -281
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +1 -0
- package/dist/cjs/Dashboard.d.ts +2 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +6 -20
- package/dist/cjs/PieChart.d.ts.map +1 -1
- package/dist/cjs/PieChart.js +2 -1
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/QuillProvider.js +15 -1
- package/dist/cjs/ReportBuilder.d.ts +4 -3
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +238 -108
- package/dist/cjs/SQLEditor.d.ts +2 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +61 -90
- package/dist/cjs/components/Chart/BarChart.d.ts +2 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +10 -3
- package/dist/cjs/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartTooltipFrame.js +1 -0
- package/dist/cjs/components/Chart/LineChart.d.ts +3 -4
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +35 -15
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +0 -3
- package/dist/cjs/components/Dashboard/DashboardSection.js +4 -4
- package/dist/cjs/components/Dashboard/DashboardSectionContainer.js +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +8 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +12 -3
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts +12 -1
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +105 -9
- package/dist/cjs/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +78 -3
- package/dist/cjs/components/QuillSelect.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelect.js +7 -1
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +3 -1
- package/dist/cjs/components/ReportBuilder/AddColumnPopover.js +3 -3
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts +3 -0
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -0
- package/dist/cjs/components/ReportBuilder/AddLimitPopover.js +43 -0
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +14 -7
- package/dist/cjs/components/ReportBuilder/ast.d.ts +4 -0
- package/dist/cjs/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ast.js +10 -1
- package/dist/cjs/components/ReportBuilder/bigDateMap.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/bigDateMap.js +2 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts +4 -1
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +45 -13
- package/dist/cjs/components/ReportBuilder/pivot.d.ts +3 -0
- package/dist/cjs/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +7 -5
- package/dist/cjs/components/ReportBuilder/util.d.ts +1 -0
- package/dist/cjs/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/util.js +55 -6
- package/dist/cjs/components/UiComponents.d.ts +3 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +4 -4
- package/dist/cjs/hooks/useQuill.js +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +91 -91
- package/dist/cjs/utils/axisFormatter.js +74 -30
- package/dist/cjs/utils/dataFetcher.d.ts.map +1 -1
- package/dist/cjs/utils/dataFetcher.js +10 -0
- package/dist/cjs/utils/getDomain.js +25 -4
- package/dist/cjs/utils/valueFormatter.d.ts +2 -1
- package/dist/cjs/utils/valueFormatter.d.ts.map +1 -1
- package/dist/esm/BarList.d.ts +2 -1
- package/dist/esm/BarList.d.ts.map +1 -1
- package/dist/esm/BarList.js +9 -3
- package/dist/esm/Chart.d.ts +11 -5
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +57 -20
- package/dist/esm/ChartBuilder.d.ts +16 -1
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +421 -280
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +1 -0
- package/dist/esm/Dashboard.d.ts +2 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +6 -20
- package/dist/esm/PieChart.d.ts.map +1 -1
- package/dist/esm/PieChart.js +2 -1
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/QuillProvider.js +16 -2
- package/dist/esm/ReportBuilder.d.ts +4 -3
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +242 -112
- package/dist/esm/SQLEditor.d.ts +2 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +62 -91
- package/dist/esm/components/Chart/BarChart.d.ts +2 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +10 -3
- package/dist/esm/components/Chart/ChartTooltipFrame.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartTooltipFrame.js +1 -0
- package/dist/esm/components/Chart/LineChart.d.ts +3 -4
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +35 -15
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +0 -3
- package/dist/esm/components/Dashboard/DashboardSection.js +4 -4
- package/dist/esm/components/Dashboard/DashboardSectionContainer.js +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts +8 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +13 -4
- package/dist/esm/components/Dashboard/MetricComponent.d.ts +12 -1
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +101 -8
- package/dist/esm/components/Dashboard/TableComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +74 -2
- package/dist/esm/components/QuillSelect.d.ts.map +1 -1
- package/dist/esm/components/QuillSelect.js +7 -1
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +3 -1
- package/dist/esm/components/ReportBuilder/AddColumnPopover.js +3 -3
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts +3 -0
- package/dist/esm/components/ReportBuilder/AddLimitPopover.d.ts.map +1 -0
- package/dist/esm/components/ReportBuilder/AddLimitPopover.js +38 -0
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +15 -8
- package/dist/esm/components/ReportBuilder/ast.d.ts +4 -0
- package/dist/esm/components/ReportBuilder/ast.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ast.js +8 -0
- package/dist/esm/components/ReportBuilder/bigDateMap.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/bigDateMap.js +2 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts +4 -1
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +45 -13
- package/dist/esm/components/ReportBuilder/pivot.d.ts +3 -0
- package/dist/esm/components/ReportBuilder/pivot.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +7 -5
- package/dist/esm/components/ReportBuilder/util.d.ts +1 -0
- package/dist/esm/components/ReportBuilder/util.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/util.js +53 -5
- package/dist/esm/components/UiComponents.d.ts +3 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +4 -4
- package/dist/esm/hooks/useQuill.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +2 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +91 -91
- package/dist/esm/utils/axisFormatter.js +74 -30
- package/dist/esm/utils/dataFetcher.d.ts.map +1 -1
- package/dist/esm/utils/dataFetcher.js +10 -0
- package/dist/esm/utils/getDomain.js +25 -4
- package/dist/esm/utils/valueFormatter.d.ts +2 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -3,13 +3,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useCallback, useContext, useMemo, useState, useEffect, useRef, } from 'react';
|
|
4
4
|
import { ClientContext } from '../../Context';
|
|
5
5
|
import { getDataFromCloud } from '../../utils/dataFetcher';
|
|
6
|
-
import { RefreshIcon } from '../../assets';
|
|
7
6
|
import { PivotList, PivotCard } from './PivotList';
|
|
8
7
|
import { differenceInDays, eachDayOfInterval, eachMonthOfInterval, eachWeekOfInterval, eachYearOfInterval, endOfDay, isWithinInterval, subMilliseconds, min, max, add, } from 'date-fns';
|
|
9
8
|
import { valueFormatter } from '../../utils/valueFormatter';
|
|
10
9
|
import { numberFormatOptions, dateFormatOptions } from '../../ChartBuilder';
|
|
11
10
|
import { snakeCaseToTitleCase } from '../../utils/textProcessing';
|
|
12
|
-
import { QuillCard } from '../../components/QuillCard';
|
|
13
11
|
const QuillHover = () => {
|
|
14
12
|
return (_jsx("style", { children: `
|
|
15
13
|
.quill-hover {
|
|
@@ -23,7 +21,7 @@ const QuillHover = () => {
|
|
|
23
21
|
}
|
|
24
22
|
` }));
|
|
25
23
|
};
|
|
26
|
-
export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotValueField, setPivotValueField, pivotAggregation, setPivotAggregation, popUpTitle, setPopUpTitle, selectedTable, SelectComponent, ButtonComponent, PopoverComponent, HeaderComponent, LabelComponent, TextComponent, selectedPivotIndex, setSelectedPivotIndex, removePivot, selectPivot, showUpdatePivot, setShowUpdatePivot, data, columns, theme, isOpen, setIsOpen, dateRange, createdPivots, setCreatedPivots, recommendedPivots, setRecommendedPivots, triggerButtonText = 'Pivot', showPivotEditButton = false, showEditOnPivotClick = true, selectPivotOnEdit = false, showTrigger = true, rightAlign = false, parentRef, recommendPivotCount = 6, }) => {
|
|
24
|
+
export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivotColumnField, pivotValueField, setPivotValueField, pivotAggregation, setPivotAggregation, popUpTitle, setPopUpTitle, selectedTable, SelectComponent, ButtonComponent, SecondaryButtonComponent, PopoverComponent, HeaderComponent, LabelComponent, TextComponent, selectedPivotIndex, setSelectedPivotIndex, removePivot, selectPivot, showUpdatePivot, setShowUpdatePivot, data, columns, theme, isOpen, setIsOpen, dateRange, createdPivots, setCreatedPivots, recommendedPivots, setRecommendedPivots, triggerButtonText = 'Pivot', showPivotEditButton = false, showEditOnPivotClick = true, selectPivotOnEdit = false, showTrigger = true, rightAlign = false, parentRef, recommendPivotCount = 6, }) => {
|
|
27
25
|
const [isLoading, setIsLoading] = useState(false);
|
|
28
26
|
const [pivotUpdateIndex, setPivotUpdateIndex] = useState(null);
|
|
29
27
|
const [selectedPivotType, setSelectedPivotType] = useState('recommended');
|
|
@@ -93,7 +91,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
93
91
|
const columnSelectOptions = useMemo(() => {
|
|
94
92
|
return [
|
|
95
93
|
...Object.keys(columnsToShow).map((key) => {
|
|
96
|
-
return { label: key, value: key };
|
|
94
|
+
return { label: snakeCaseToTitleCase(key), value: key };
|
|
97
95
|
}),
|
|
98
96
|
];
|
|
99
97
|
}, [columnsToShow]);
|
|
@@ -129,6 +127,9 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
129
127
|
onEditPivot(pivot, null);
|
|
130
128
|
};
|
|
131
129
|
const refreshPivots = useCallback(async () => {
|
|
130
|
+
if (!showTrigger) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
132
133
|
if (isLoading || Object.keys(columnsToShow).length === 0) {
|
|
133
134
|
return;
|
|
134
135
|
}
|
|
@@ -147,50 +148,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
147
148
|
try {
|
|
148
149
|
const resp = await getDataFromCloud(client, 'pivotai', cloudBody);
|
|
149
150
|
const recommendedPivots = resp?.data?.pivotTables.slice(0, recommendPivotCount) || [];
|
|
150
|
-
// for testing if needed
|
|
151
|
-
// const recommendedPivots = [
|
|
152
|
-
// {
|
|
153
|
-
// title: 'Total Amount by Merchant',
|
|
154
|
-
// rowField: 'merchant',
|
|
155
|
-
// valueField: 'amount',
|
|
156
|
-
// aggregationType: 'sum',
|
|
157
|
-
// },
|
|
158
|
-
// {
|
|
159
|
-
// title: 'Average Amount by User and Category',
|
|
160
|
-
// rowField: 'user_name',
|
|
161
|
-
// columnField: 'category',
|
|
162
|
-
// valueField: 'amount',
|
|
163
|
-
// aggregationType: 'average',
|
|
164
|
-
// },
|
|
165
|
-
// {
|
|
166
|
-
// title: 'Count of Transactions by User and Merchant',
|
|
167
|
-
// rowField: 'user_name',
|
|
168
|
-
// columnField: 'merchant',
|
|
169
|
-
// valueField: 'id',
|
|
170
|
-
// aggregationType: 'count',
|
|
171
|
-
// },
|
|
172
|
-
// {
|
|
173
|
-
// title: 'Total Amount by Merchant and Category',
|
|
174
|
-
// rowField: 'merchant',
|
|
175
|
-
// columnField: 'category',
|
|
176
|
-
// valueField: 'amount',
|
|
177
|
-
// aggregationType: 'sum',
|
|
178
|
-
// },
|
|
179
|
-
// {
|
|
180
|
-
// title: 'Average Amount by Category and Date',
|
|
181
|
-
// rowField: 'category',
|
|
182
|
-
// columnField: 'created_at',
|
|
183
|
-
// valueField: 'amount',
|
|
184
|
-
// aggregationType: 'average',
|
|
185
|
-
// },
|
|
186
|
-
// {
|
|
187
|
-
// title: 'Count of Transactions by Date and Category',
|
|
188
|
-
// rowField: 'created_at',
|
|
189
|
-
// columnField: 'category',
|
|
190
|
-
// valueField: 'id',
|
|
191
|
-
// aggregationType: 'count',
|
|
192
|
-
// },
|
|
193
|
-
// ];
|
|
194
151
|
setRecommendedPivots(recommendedPivots
|
|
195
152
|
.filter((pivot) => pivot.rowField != '')
|
|
196
153
|
.map((pivot) => {
|
|
@@ -207,7 +164,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
207
164
|
console.error('Failed parsing pivotai response', e);
|
|
208
165
|
}
|
|
209
166
|
setIsLoading(false);
|
|
210
|
-
}, [selectedTable, data, columnsToShow, isLoading]);
|
|
167
|
+
}, [selectedTable, data, columnsToShow, isLoading, showTrigger]);
|
|
211
168
|
useEffect(() => {
|
|
212
169
|
if (recommendedPivots.length === 0) {
|
|
213
170
|
refreshPivots();
|
|
@@ -268,6 +225,9 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
268
225
|
setShowUpdatePivot(false);
|
|
269
226
|
setPopUpTitle('Add Pivot');
|
|
270
227
|
}, style: rightAlign ? { right: 0 } : {}, parentRef: parentRef, showTrigger: showTrigger, label: triggerButtonText, isOpen: isOpen, setIsOpen: setIsOpen, onClick: () => {
|
|
228
|
+
if (columns.length === 0) {
|
|
229
|
+
setIsOpen(false);
|
|
230
|
+
}
|
|
271
231
|
// table is not loaded yet, so pivot button is not clickable
|
|
272
232
|
if (Object.keys(columnsToShow).length === 0) {
|
|
273
233
|
return;
|
|
@@ -280,12 +240,10 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
280
240
|
backgroundColor: 'rgb(255, 255, 255)',
|
|
281
241
|
display: 'flex',
|
|
282
242
|
flexDirection: 'column',
|
|
283
|
-
}, children: [_jsx(HeaderComponent, { children: popUpTitle }), _jsx("div", { style: { height: 12 } }), _jsx("div", { style: { width: divWidth }, children: samplePivotTable
|
|
243
|
+
}, children: [_jsx(HeaderComponent, { children: popUpTitle }), _jsx("div", { style: { height: 12 } }), _jsx("div", { style: { width: divWidth }, children: samplePivotTable && (_jsx("div", { style: {
|
|
284
244
|
marginBottom: 20,
|
|
285
245
|
minHeight: 160,
|
|
286
|
-
}, children: _jsx(PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight: 140, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }))
|
|
287
|
-
color: theme.secondaryTextColor,
|
|
288
|
-
}, children: "Select a row field and aggregation type to see a preview" }) }) })) }), _jsxs("div", { style: {
|
|
246
|
+
}, children: _jsx(PivotCard, { pivotTable: samplePivotTable, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, clickable: false, minHeight: 140, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) })) }), _jsxs("div", { style: {
|
|
289
247
|
display: 'flex',
|
|
290
248
|
flexDirection: 'column',
|
|
291
249
|
gap: 10,
|
|
@@ -299,7 +257,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
299
257
|
}, children: [_jsxs("div", { children: [_jsx(LabelComponent, { children: "Row Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotRowField, onChange: (e) => {
|
|
300
258
|
setPivotRowField(e === '' ? undefined : e);
|
|
301
259
|
}, options: [
|
|
302
|
-
{ label: 'Select', value: '' },
|
|
303
260
|
...columnSelectOptions.filter((option) => {
|
|
304
261
|
const format = columns.find((col) => col.field === option.value)?.format;
|
|
305
262
|
return (format === 'string' ||
|
|
@@ -308,7 +265,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
308
265
|
], theme: theme })] }), _jsxs("div", { children: [_jsx(LabelComponent, { children: "Column Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotColumnField, onChange: (e) => {
|
|
309
266
|
setPivotColumnField(e === '' ? undefined : e);
|
|
310
267
|
}, options: [
|
|
311
|
-
{ label: 'Select', value: '' },
|
|
312
268
|
...columnSelectOptions.filter((option) => {
|
|
313
269
|
return (columns.find((col) => col.field === option.value)
|
|
314
270
|
?.format === 'string');
|
|
@@ -320,18 +276,12 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
320
276
|
marginBottom: 20,
|
|
321
277
|
}, children: [_jsxs("div", { children: [_jsx(LabelComponent, { children: "Value Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotValueField, onChange: (e) => {
|
|
322
278
|
setPivotValueField(e === '' ? undefined : e);
|
|
323
|
-
}, options:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
{ label: 'Select', value: '' },
|
|
330
|
-
...columnSelectOptions.filter((option) => {
|
|
331
|
-
return (option.value === '' ||
|
|
332
|
-
numberFormatOptions.includes(columns.find((col) => col.field === option.value)?.format));
|
|
333
|
-
}),
|
|
334
|
-
], theme: theme })] }), _jsxs("div", { children: [_jsx(LabelComponent, { children: "Aggregation Type" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: (e) => {
|
|
279
|
+
}, options: [
|
|
280
|
+
...columnSelectOptions.filter((option) => {
|
|
281
|
+
return (option.value === '' ||
|
|
282
|
+
numberFormatOptions.includes(columns.find((col) => col.field === option.value)?.format));
|
|
283
|
+
}),
|
|
284
|
+
], theme: theme })] }), _jsxs("div", { children: [_jsx(LabelComponent, { children: "Aggregation Type" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: (e) => {
|
|
335
285
|
if (e !== 'count' &&
|
|
336
286
|
pivotValueField &&
|
|
337
287
|
!numberFormatOptions.includes(columns.find((col) => col.field === pivotValueField)?.format)) {
|
|
@@ -339,8 +289,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
339
289
|
}
|
|
340
290
|
setPivotAggregation(e === '' ? undefined : e);
|
|
341
291
|
}, options: [
|
|
342
|
-
|
|
343
|
-
...['sum', 'average', 'count'].map((option) => {
|
|
292
|
+
...['sum', 'average', 'count', 'max', 'min'].map((option) => {
|
|
344
293
|
return { label: option, value: option };
|
|
345
294
|
}),
|
|
346
295
|
] })] })] })] }), _jsx("div", { children: _jsx(ButtonComponent, { id: "custom-button", onClick: () => {
|
|
@@ -402,26 +351,24 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
402
351
|
columns: selectedPivotTable?.columns,
|
|
403
352
|
}, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, onClose: () => {
|
|
404
353
|
removePivot();
|
|
405
|
-
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
borderRadius: 5,
|
|
424
|
-
}, className: "quill-hover", children: [_jsx(QuillHover, {}), _jsx(RefreshIcon, { style: { marginRight: 5 } }), "Refresh"] }) }), isLoading ? (_jsxs("div", { style: {
|
|
354
|
+
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : (_jsxs("div", { style: { display: 'flex', flexDirection: 'column' }, children: [_jsxs("div", { style: {
|
|
355
|
+
display: 'flex',
|
|
356
|
+
flexDirection: 'row',
|
|
357
|
+
width: '100%',
|
|
358
|
+
alignItems: 'center',
|
|
359
|
+
justifyContent: 'space-between',
|
|
360
|
+
paddingBottom: 12,
|
|
361
|
+
}, children: [_jsx("div", { style: {
|
|
362
|
+
fontWeight: '600',
|
|
363
|
+
fontSize: 18,
|
|
364
|
+
}, children: "Recommended pivots" }), _jsx("div", { children: _jsx(SecondaryButtonComponent, { onClick: refreshPivots, label: _jsxs("div", { style: {
|
|
365
|
+
display: 'flex',
|
|
366
|
+
flexDirection: 'row',
|
|
367
|
+
whiteSpace: 'nowrap',
|
|
368
|
+
alignItems: 'center',
|
|
369
|
+
gap: 6,
|
|
370
|
+
fontSize: 14,
|
|
371
|
+
}, children: [_jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", style: { width: 16, height: 16 }, children: _jsx("path", { fillRule: "evenodd", d: "M9 4.5a.75.75 0 0 1 .721.544l.813 2.846a3.75 3.75 0 0 0 2.576 2.576l2.846.813a.75.75 0 0 1 0 1.442l-2.846.813a3.75 3.75 0 0 0-2.576 2.576l-.813 2.846a.75.75 0 0 1-1.442 0l-.813-2.846a3.75 3.75 0 0 0-2.576-2.576l-2.846-.813a.75.75 0 0 1 0-1.442l2.846-.813A3.75 3.75 0 0 0 7.466 7.89l.813-2.846A.75.75 0 0 1 9 4.5ZM18 1.5a.75.75 0 0 1 .728.568l.258 1.036c.236.94.97 1.674 1.91 1.91l1.036.258a.75.75 0 0 1 0 1.456l-1.036.258c-.94.236-1.674.97-1.91 1.91l-.258 1.036a.75.75 0 0 1-1.456 0l-.258-1.036a2.625 2.625 0 0 0-1.91-1.91l-1.036-.258a.75.75 0 0 1 0-1.456l1.036-.258a2.625 2.625 0 0 0 1.91-1.91l.258-1.036A.75.75 0 0 1 18 1.5ZM16.5 15a.75.75 0 0 1 .712.513l.394 1.183c.15.447.5.799.948.948l1.183.395a.75.75 0 0 1 0 1.422l-1.183.395c-.447.15-.799.5-.948.948l-.395 1.183a.75.75 0 0 1-1.422 0l-.395-1.183a1.5 1.5 0 0 0-.948-.948l-1.183-.395a.75.75 0 0 1 0-1.422l1.183-.395c.447-.15.799-.5.948-.948l.395-1.183A.75.75 0 0 1 16.5 15Z", clipRule: "evenodd" }) }), "Regenerate"] }) }) })] }), isLoading ? (_jsxs("div", { style: {
|
|
425
372
|
background: theme.backgroundColor,
|
|
426
373
|
width: 250,
|
|
427
374
|
minWidth: 250,
|
|
@@ -432,7 +379,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
432
379
|
display: 'flex',
|
|
433
380
|
margin: '0px auto',
|
|
434
381
|
justifyContent: 'center',
|
|
435
|
-
}, children: [_jsx("div", { style: { height: 100 } }), _jsxs("svg", { width: "24", height: "24", children: [_jsx("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 6)", stroke: theme?.primaryTextColor || '#364153', fill: "none", transform: "rotate(-90 12 12)", children: _jsx("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "-180 12 12", to: "180 12 12", dur: "0.8s", repeatCount: "indefinite" }) }), _jsx("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 1 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", stroke: '#ADB1B9', fill: "none", transform: "rotate(90 12 12)", children: _jsx("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.8s", repeatCount: "indefinite" }) })] })] })) : (
|
|
382
|
+
}, children: [_jsx("div", { style: { height: 100 } }), _jsxs("svg", { width: "24", height: "24", children: [_jsx("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 6)", stroke: theme?.primaryTextColor || '#364153', fill: "none", transform: "rotate(-90 12 12)", children: _jsx("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "-180 12 12", to: "180 12 12", dur: "0.8s", repeatCount: "indefinite" }) }), _jsx("circle", { cx: "12", cy: "12", r: "9.375", strokeWidth: "3.75", strokeDasharray: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 1 / 3)", strokeDashoffset: "calc(2 * 3.14 * 9.375 / 3) calc(2 * 3.14 * 9.375 * 2 / 3)", stroke: '#ADB1B9', fill: "none", transform: "rotate(90 12 12)", children: _jsx("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.8s", repeatCount: "indefinite" }) })] })] })) : (_jsx("div", { children: _jsx(PivotList, { recommendedPivotTables: recommendedPivotTables, createdPivotTables: createdPivotTables, theme: theme, onSelectRecommendedPivot: onSelectRecommendedPivot, onSelectCreatedPivot: onSelectCreatedPivot, selectedPivotIndex: selectedPivotIndex, selectedPivotType: selectedPivotType, ButtonComponent: ButtonComponent, HeaderComponent: HeaderComponent, onEditRecommendedPivot: onEditRecommendedPivot, onEditCreatedPivot: onEditPivot, showCreatePivot: true, showPivotEditButton: showPivotEditButton, LabelComponent: LabelComponent, TextComponent: TextComponent }) }))] })) })) }) })] }) }));
|
|
436
383
|
};
|
|
437
384
|
export function generatePivotTableYAxis(pivot, cols, format) {
|
|
438
385
|
// Use the column field for the field and label if there is one
|
|
@@ -575,7 +522,7 @@ const handleBigQueryValue = (value) => {
|
|
|
575
522
|
return value;
|
|
576
523
|
};
|
|
577
524
|
// Process out all the BigQuery dates.
|
|
578
|
-
const fixBigQueryData = (data) => {
|
|
525
|
+
const fixBigQueryData = (data = []) => {
|
|
579
526
|
const newData = [];
|
|
580
527
|
for (const row of data) {
|
|
581
528
|
const newRow = {};
|
|
@@ -587,6 +534,10 @@ const fixBigQueryData = (data) => {
|
|
|
587
534
|
return newData;
|
|
588
535
|
};
|
|
589
536
|
export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1, compRange = null) {
|
|
537
|
+
// If there is no rowField, aggregate on the valueField
|
|
538
|
+
if (!pivot.rowField) {
|
|
539
|
+
return valueFieldAggregation(data, pivot.valueField, pivot.aggregationType);
|
|
540
|
+
}
|
|
590
541
|
// Handle edge-case for BigQuery objects.
|
|
591
542
|
data = fixBigQueryData(data);
|
|
592
543
|
if (dateRange[0] === null && dateRange[1] === null) {
|
|
@@ -814,6 +765,18 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
814
765
|
: 0;
|
|
815
766
|
}
|
|
816
767
|
break;
|
|
768
|
+
case 'max':
|
|
769
|
+
value = filteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
770
|
+
if (isComparison) {
|
|
771
|
+
comparisonValue = comparisonFilteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
772
|
+
}
|
|
773
|
+
break;
|
|
774
|
+
case 'min':
|
|
775
|
+
value = filteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
776
|
+
if (isComparison) {
|
|
777
|
+
comparisonValue = comparisonFilteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
778
|
+
}
|
|
779
|
+
break;
|
|
817
780
|
// Implement other aggregation types as needed
|
|
818
781
|
default:
|
|
819
782
|
throw new Error('Unsupported aggregation type');
|
|
@@ -892,12 +855,49 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
892
855
|
if (pivot.sort) {
|
|
893
856
|
pivotRows.sort((a, b) => {
|
|
894
857
|
if (pivot.sortDirection === 'ASC') {
|
|
858
|
+
if (pivot.rowFieldType === 'date') {
|
|
859
|
+
return new Date(a[pivot.rowField]) - new Date(b[pivot.rowField]);
|
|
860
|
+
}
|
|
895
861
|
return a[pivot.rowField].localeCompare(b[pivot.rowField]);
|
|
896
862
|
}
|
|
897
863
|
else {
|
|
864
|
+
if (pivot.rowFieldType === 'date') {
|
|
865
|
+
return new Date(b[pivot.rowField]) - new Date(a[pivot.rowField]);
|
|
866
|
+
}
|
|
898
867
|
return b[pivot.rowField].localeCompare(a[pivot.rowField]);
|
|
899
868
|
}
|
|
900
869
|
});
|
|
901
870
|
}
|
|
902
871
|
return { rows: pivotRows, columns };
|
|
903
872
|
}
|
|
873
|
+
function valueFieldAggregation(data, valueField, aggregationType) {
|
|
874
|
+
let value;
|
|
875
|
+
switch (aggregationType) {
|
|
876
|
+
case 'sum':
|
|
877
|
+
value = data.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0);
|
|
878
|
+
break;
|
|
879
|
+
case 'count':
|
|
880
|
+
value = filteredData.length;
|
|
881
|
+
break;
|
|
882
|
+
case 'average':
|
|
883
|
+
value = filteredData.length
|
|
884
|
+
? filteredData.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0) / filteredData.length
|
|
885
|
+
: 0;
|
|
886
|
+
break;
|
|
887
|
+
case 'max':
|
|
888
|
+
value = data.reduce((max, item) => Math.max(max, parseFloat(item[valueField] ?? 0)), -Infinity);
|
|
889
|
+
break;
|
|
890
|
+
case 'min':
|
|
891
|
+
value = data.reduce((min, item) => Math.min(min, parseFloat(item[valueField] ?? 0)), Infinity);
|
|
892
|
+
break;
|
|
893
|
+
// Implement other aggregation types as needed
|
|
894
|
+
default:
|
|
895
|
+
throw new Error('Unsupported aggregation type');
|
|
896
|
+
}
|
|
897
|
+
const row = {};
|
|
898
|
+
row[valueField] = value;
|
|
899
|
+
return {
|
|
900
|
+
rows: [row],
|
|
901
|
+
columns: [{ label: snakeCaseToTitleCase(valueField), field: valueField }],
|
|
902
|
+
};
|
|
903
|
+
}
|
|
@@ -49,51 +49,83 @@ const formatString = (value) => {
|
|
|
49
49
|
}
|
|
50
50
|
return value.toString();
|
|
51
51
|
};
|
|
52
|
+
// Formats large numbers like 12345.67 -> $12K
|
|
53
|
+
const formatterBigDollars = new Intl.NumberFormat('en-US', {
|
|
54
|
+
style: 'currency',
|
|
55
|
+
currency: 'USD',
|
|
56
|
+
minimumSignificantDigits: 1,
|
|
57
|
+
maximumSignificantDigits: 2,
|
|
58
|
+
notation: 'compact',
|
|
59
|
+
compactDisplay: 'short',
|
|
60
|
+
});
|
|
61
|
+
// Formats to dollars like 1234.56 -> $1235
|
|
62
|
+
const formatterDollar = new Intl.NumberFormat('en-US', {
|
|
63
|
+
style: 'currency',
|
|
64
|
+
currency: 'USD',
|
|
65
|
+
maximumFractionDigits: 0,
|
|
66
|
+
});
|
|
67
|
+
// Formats to dollars like 1234.567 -> $1234.57
|
|
68
|
+
const formatterDollarsCents = new Intl.NumberFormat('en-US', {
|
|
69
|
+
style: 'currency',
|
|
70
|
+
currency: 'USD',
|
|
71
|
+
minimumFractionDigits: 2,
|
|
72
|
+
maximumFractionDigits: 2,
|
|
73
|
+
});
|
|
52
74
|
/**
|
|
53
|
-
* Formats the value as a (rounded) currency amount in dollars.
|
|
75
|
+
* Formats the value as a (rounded) currency amount in dollars. If value is
|
|
76
|
+
* zero, returns '$0' with no cents. If value is greater than or equal to 1000,
|
|
77
|
+
* it will not show cents and shorten the value with a suffix such as K
|
|
78
|
+
* (for thousands) or M (for millions).
|
|
54
79
|
*
|
|
55
|
-
*
|
|
80
|
+
* @example format(1,234,567) => "$1.2M"
|
|
81
|
+
* @example format(1234.567) => "$1.2K"
|
|
82
|
+
* @example format(5000) => "$5K"
|
|
83
|
+
* @example format(123.45) => "$123"
|
|
84
|
+
* @example format(0.00) => "$0"
|
|
56
85
|
*/
|
|
57
86
|
const formatDollarAmount = (value) => {
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
});
|
|
66
|
-
return formatter.format(Number(value ?? 0));
|
|
87
|
+
const num = Number(value ?? 0);
|
|
88
|
+
if (num >= 1000 || num === 0) {
|
|
89
|
+
return formatterBigDollars.format(num);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
return formatterDollar.format(num);
|
|
93
|
+
}
|
|
67
94
|
};
|
|
68
95
|
/**
|
|
69
|
-
* Formats the value as a (rounded) currency amount in dollars and cents.
|
|
96
|
+
* Formats the value as a (rounded) currency amount in dollars and cents. If
|
|
97
|
+
* value is zero, returns '$0' with no cents. If value is greater than or equal
|
|
98
|
+
* to 1000, it will not show cents and shorten the value with a suffix such
|
|
99
|
+
* as K (for thousands) or M (for millions).
|
|
70
100
|
*
|
|
101
|
+
* @example format(1,234,567) => "$1.2M"
|
|
71
102
|
* @example format(1234.567) => "$1.2K"
|
|
103
|
+
* @example format(5000) => "$5K"
|
|
104
|
+
* @example format(123.45) => "$123.45"
|
|
105
|
+
* @example format(0.00) => "$0"
|
|
72
106
|
*/
|
|
73
107
|
const formatDollarCents = (value) => {
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
return formatter.format(Number(value ?? 0));
|
|
108
|
+
const num = Number(value ?? 0);
|
|
109
|
+
if (num >= 1000 || num === 0) {
|
|
110
|
+
return formatterBigDollars.format(num);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
return formatterDollarsCents.format(num);
|
|
114
|
+
}
|
|
83
115
|
};
|
|
116
|
+
const formatterBigWholeNumber = new Intl.NumberFormat('en-US', {
|
|
117
|
+
minimumSignificantDigits: 1,
|
|
118
|
+
maximumSignificantDigits: 2,
|
|
119
|
+
notation: 'compact',
|
|
120
|
+
compactDisplay: 'short',
|
|
121
|
+
});
|
|
84
122
|
/**
|
|
85
123
|
* Formats the value as a (rounded) integer.
|
|
86
124
|
*
|
|
87
125
|
* @example format(1234.567) => "1.2K"
|
|
88
126
|
*/
|
|
89
127
|
const formatWholeNumber = (value) => {
|
|
90
|
-
|
|
91
|
-
minimumSignificantDigits: 2,
|
|
92
|
-
maximumSignificantDigits: 2,
|
|
93
|
-
notation: 'compact',
|
|
94
|
-
compactDisplay: 'short',
|
|
95
|
-
});
|
|
96
|
-
return formatter.format(Number(value));
|
|
128
|
+
return formatterBigWholeNumber.format(Number(value));
|
|
97
129
|
};
|
|
98
130
|
/**
|
|
99
131
|
* Formats the value as a number rounded to exactly one decimal place.
|
|
@@ -108,7 +140,13 @@ const formatOneDecimalPlace = (value) => {
|
|
|
108
140
|
notation: 'compact',
|
|
109
141
|
compactDisplay: 'short',
|
|
110
142
|
});
|
|
111
|
-
|
|
143
|
+
const num = Number(value ?? 0);
|
|
144
|
+
if (num >= 1000 || num === 0) {
|
|
145
|
+
return formatterBigWholeNumber.format(num);
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
return formatter.format(num);
|
|
149
|
+
}
|
|
112
150
|
};
|
|
113
151
|
/**
|
|
114
152
|
* Formats the value as a number rounded to exactly two decimal places.
|
|
@@ -123,7 +161,13 @@ const formatTwoDecimalPlaces = (value) => {
|
|
|
123
161
|
notation: 'compact',
|
|
124
162
|
compactDisplay: 'short',
|
|
125
163
|
});
|
|
126
|
-
|
|
164
|
+
const num = Number(value ?? 0);
|
|
165
|
+
if (num >= 1000 || num === 0) {
|
|
166
|
+
return formatterBigWholeNumber.format(num);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
return formatter.format(num);
|
|
170
|
+
}
|
|
127
171
|
};
|
|
128
172
|
/**
|
|
129
173
|
* Formats the value as a percentage.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataFetcher.d.ts","sourceRoot":"","sources":["../../../src/utils/dataFetcher.tsx"],"names":[],"mappings":"AAEA,wBAAsB,OAAO,CAC3B,MAAM,EAAE,GAAG,EACX,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,iBAAiB,EAAE,GAAG,EACtB,gBAAgB,EAAE,GAAG,EACrB,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"dataFetcher.d.ts","sourceRoot":"","sources":["../../../src/utils/dataFetcher.tsx"],"names":[],"mappings":"AAEA,wBAAsB,OAAO,CAC3B,MAAM,EAAE,GAAG,EACX,kBAAkB,EAAE,MAAM,EAC1B,MAAM,EAAE,kBAAkB,EAC1B,iBAAiB,EAAE,GAAG,EACtB,gBAAgB,EAAE,GAAG,EACrB,MAAM,SAAS,gBA8DhB;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,GAAG,EACX,kBAAkB,EAAE,MAAM,EAC1B,gBAAgB,EAAE,GAAG,EACrB,MAAM,SAAS,gBA+BhB"}
|
|
@@ -32,6 +32,16 @@ export async function getData(client, cloudQueryEndpoint, noCred, hostedRequestB
|
|
|
32
32
|
compareRows: responseJson?.queries?.queryResults[1]?.rows,
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
if (responseJson.data.columns &&
|
|
36
|
+
responseJson.data.fields &&
|
|
37
|
+
responseJson.data.columns.length != responseJson.data.fields) {
|
|
38
|
+
// Remove all columns that don't appear in fields, overtime this should never be the case
|
|
39
|
+
const columns = responseJson.data.columns.filter((columns) => responseJson.data.fields.find((field) => field.name === columns.field));
|
|
40
|
+
result = {
|
|
41
|
+
...result,
|
|
42
|
+
columns,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
35
45
|
return result;
|
|
36
46
|
}
|
|
37
47
|
else {
|
|
@@ -21,8 +21,29 @@ export default function getDomain(data, fields) {
|
|
|
21
21
|
});
|
|
22
22
|
});
|
|
23
23
|
const [minValue, maxValue] = numericValues.reduce(([min, max], value) => [Math.min(min, value), Math.max(max, value)], [Infinity, -Infinity]);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
24
|
+
if (minValue === 0 && maxValue === 0) {
|
|
25
|
+
return [0, 1];
|
|
26
|
+
}
|
|
27
|
+
return fuzzyRound(Math.min(minValue, 0), maxValue);
|
|
28
|
+
}
|
|
29
|
+
// Rounds the range to 4 equally-spaced increments of nice,round numbers.
|
|
30
|
+
function fuzzyRound(min, max) {
|
|
31
|
+
const range = parseFloat((max - min).toPrecision(1));
|
|
32
|
+
const increment = Math.ceil(range / 4);
|
|
33
|
+
let newMin = min;
|
|
34
|
+
// if (min % increment !== 0) {
|
|
35
|
+
// newMin = min - (min % increment);
|
|
36
|
+
// }
|
|
37
|
+
if (Number.isNaN(newMin)) {
|
|
38
|
+
newMin = 0;
|
|
39
|
+
}
|
|
40
|
+
let newMax = min + increment * 4;
|
|
41
|
+
if (max % increment !== 0) {
|
|
42
|
+
const adjMax = max + (increment - (max % increment));
|
|
43
|
+
newMax = parseFloat(adjMax.toPrecision(2));
|
|
44
|
+
}
|
|
45
|
+
if (Number.isNaN(newMax)) {
|
|
46
|
+
newMax = 0;
|
|
47
|
+
}
|
|
48
|
+
return [newMin ?? 0, newMax ?? 0];
|
|
28
49
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"valueFormatter.d.ts","sourceRoot":"","sources":["../../../src/utils/valueFormatter.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAE/C,KAAK,KAAK,GAAG;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACjC,MAAM,EAAE,KAAK,EAAE,CAAC;CACjB,CAAC;AAEF,eAAO,MAAM,iBAAiB,UAQ7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,6BAA8B,KAAK,KAAG,MAwChE,CAAC;AAEF,eAAO,MAAM,WAAW;WAIf,GAAG;YACF,MAAM;MACZ,MAoCH,CAAC;AAmJF,eAAO,MAAM,aAAa;;;;WAGhB,MAAM,KACb,MA2BF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quillsql/react",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.13",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/esm/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@monaco-editor/react": "^4.5.1",
|
|
25
25
|
"date-fns": "^2.29.3",
|
|
26
26
|
"date-fns-tz": "^2.0.0",
|
|
27
|
-
"recharts": "^2.5
|
|
27
|
+
"recharts": "^2.12.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@repo/eslint-config": "*",
|