@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
|
@@ -6,13 +6,11 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const Context_1 = require("../../Context");
|
|
8
8
|
const dataFetcher_1 = require("../../utils/dataFetcher");
|
|
9
|
-
const assets_1 = require("../../assets");
|
|
10
9
|
const PivotList_1 = require("./PivotList");
|
|
11
10
|
const date_fns_1 = require("date-fns");
|
|
12
11
|
const valueFormatter_1 = require("../../utils/valueFormatter");
|
|
13
12
|
const ChartBuilder_1 = require("../../ChartBuilder");
|
|
14
13
|
const textProcessing_1 = require("../../utils/textProcessing");
|
|
15
|
-
const QuillCard_1 = require("../../components/QuillCard");
|
|
16
14
|
const QuillHover = () => {
|
|
17
15
|
return ((0, jsx_runtime_1.jsx)("style", { children: `
|
|
18
16
|
.quill-hover {
|
|
@@ -26,7 +24,7 @@ const QuillHover = () => {
|
|
|
26
24
|
}
|
|
27
25
|
` }));
|
|
28
26
|
};
|
|
29
|
-
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, }) => {
|
|
27
|
+
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, }) => {
|
|
30
28
|
const [isLoading, setIsLoading] = (0, react_1.useState)(false);
|
|
31
29
|
const [pivotUpdateIndex, setPivotUpdateIndex] = (0, react_1.useState)(null);
|
|
32
30
|
const [selectedPivotType, setSelectedPivotType] = (0, react_1.useState)('recommended');
|
|
@@ -96,7 +94,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
96
94
|
const columnSelectOptions = (0, react_1.useMemo)(() => {
|
|
97
95
|
return [
|
|
98
96
|
...Object.keys(columnsToShow).map((key) => {
|
|
99
|
-
return { label: key, value: key };
|
|
97
|
+
return { label: (0, textProcessing_1.snakeCaseToTitleCase)(key), value: key };
|
|
100
98
|
}),
|
|
101
99
|
];
|
|
102
100
|
}, [columnsToShow]);
|
|
@@ -132,6 +130,9 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
132
130
|
onEditPivot(pivot, null);
|
|
133
131
|
};
|
|
134
132
|
const refreshPivots = (0, react_1.useCallback)(async () => {
|
|
133
|
+
if (!showTrigger) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
135
136
|
if (isLoading || Object.keys(columnsToShow).length === 0) {
|
|
136
137
|
return;
|
|
137
138
|
}
|
|
@@ -150,50 +151,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
150
151
|
try {
|
|
151
152
|
const resp = await (0, dataFetcher_1.getDataFromCloud)(client, 'pivotai', cloudBody);
|
|
152
153
|
const recommendedPivots = resp?.data?.pivotTables.slice(0, recommendPivotCount) || [];
|
|
153
|
-
// for testing if needed
|
|
154
|
-
// const recommendedPivots = [
|
|
155
|
-
// {
|
|
156
|
-
// title: 'Total Amount by Merchant',
|
|
157
|
-
// rowField: 'merchant',
|
|
158
|
-
// valueField: 'amount',
|
|
159
|
-
// aggregationType: 'sum',
|
|
160
|
-
// },
|
|
161
|
-
// {
|
|
162
|
-
// title: 'Average Amount by User and Category',
|
|
163
|
-
// rowField: 'user_name',
|
|
164
|
-
// columnField: 'category',
|
|
165
|
-
// valueField: 'amount',
|
|
166
|
-
// aggregationType: 'average',
|
|
167
|
-
// },
|
|
168
|
-
// {
|
|
169
|
-
// title: 'Count of Transactions by User and Merchant',
|
|
170
|
-
// rowField: 'user_name',
|
|
171
|
-
// columnField: 'merchant',
|
|
172
|
-
// valueField: 'id',
|
|
173
|
-
// aggregationType: 'count',
|
|
174
|
-
// },
|
|
175
|
-
// {
|
|
176
|
-
// title: 'Total Amount by Merchant and Category',
|
|
177
|
-
// rowField: 'merchant',
|
|
178
|
-
// columnField: 'category',
|
|
179
|
-
// valueField: 'amount',
|
|
180
|
-
// aggregationType: 'sum',
|
|
181
|
-
// },
|
|
182
|
-
// {
|
|
183
|
-
// title: 'Average Amount by Category and Date',
|
|
184
|
-
// rowField: 'category',
|
|
185
|
-
// columnField: 'created_at',
|
|
186
|
-
// valueField: 'amount',
|
|
187
|
-
// aggregationType: 'average',
|
|
188
|
-
// },
|
|
189
|
-
// {
|
|
190
|
-
// title: 'Count of Transactions by Date and Category',
|
|
191
|
-
// rowField: 'created_at',
|
|
192
|
-
// columnField: 'category',
|
|
193
|
-
// valueField: 'id',
|
|
194
|
-
// aggregationType: 'count',
|
|
195
|
-
// },
|
|
196
|
-
// ];
|
|
197
154
|
setRecommendedPivots(recommendedPivots
|
|
198
155
|
.filter((pivot) => pivot.rowField != '')
|
|
199
156
|
.map((pivot) => {
|
|
@@ -210,7 +167,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
210
167
|
console.error('Failed parsing pivotai response', e);
|
|
211
168
|
}
|
|
212
169
|
setIsLoading(false);
|
|
213
|
-
}, [selectedTable, data, columnsToShow, isLoading]);
|
|
170
|
+
}, [selectedTable, data, columnsToShow, isLoading, showTrigger]);
|
|
214
171
|
(0, react_1.useEffect)(() => {
|
|
215
172
|
if (recommendedPivots.length === 0) {
|
|
216
173
|
refreshPivots();
|
|
@@ -271,6 +228,9 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
271
228
|
setShowUpdatePivot(false);
|
|
272
229
|
setPopUpTitle('Add Pivot');
|
|
273
230
|
}, style: rightAlign ? { right: 0 } : {}, parentRef: parentRef, showTrigger: showTrigger, label: triggerButtonText, isOpen: isOpen, setIsOpen: setIsOpen, onClick: () => {
|
|
231
|
+
if (columns.length === 0) {
|
|
232
|
+
setIsOpen(false);
|
|
233
|
+
}
|
|
274
234
|
// table is not loaded yet, so pivot button is not clickable
|
|
275
235
|
if (Object.keys(columnsToShow).length === 0) {
|
|
276
236
|
return;
|
|
@@ -283,12 +243,10 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
283
243
|
backgroundColor: 'rgb(255, 255, 255)',
|
|
284
244
|
display: 'flex',
|
|
285
245
|
flexDirection: 'column',
|
|
286
|
-
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { children: popUpTitle }), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)("div", { style: { width: divWidth }, children: samplePivotTable
|
|
246
|
+
}, children: [(0, jsx_runtime_1.jsx)(HeaderComponent, { children: popUpTitle }), (0, jsx_runtime_1.jsx)("div", { style: { height: 12 } }), (0, jsx_runtime_1.jsx)("div", { style: { width: divWidth }, children: samplePivotTable && ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
287
247
|
marginBottom: 20,
|
|
288
248
|
minHeight: 160,
|
|
289
|
-
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.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 }) }))
|
|
290
|
-
color: theme.secondaryTextColor,
|
|
291
|
-
}, children: "Select a row field and aggregation type to see a preview" }) }) })) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
249
|
+
}, children: (0, jsx_runtime_1.jsx)(PivotList_1.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 }) })) }), (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
292
250
|
display: 'flex',
|
|
293
251
|
flexDirection: 'column',
|
|
294
252
|
gap: 10,
|
|
@@ -302,7 +260,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
302
260
|
}, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Row Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", value: pivotRowField, onChange: (e) => {
|
|
303
261
|
setPivotRowField(e === '' ? undefined : e);
|
|
304
262
|
}, options: [
|
|
305
|
-
{ label: 'Select', value: '' },
|
|
306
263
|
...columnSelectOptions.filter((option) => {
|
|
307
264
|
const format = columns.find((col) => col.field === option.value)?.format;
|
|
308
265
|
return (format === 'string' ||
|
|
@@ -311,7 +268,6 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
311
268
|
], theme: theme })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Column Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", value: pivotColumnField, onChange: (e) => {
|
|
312
269
|
setPivotColumnField(e === '' ? undefined : e);
|
|
313
270
|
}, options: [
|
|
314
|
-
{ label: 'Select', value: '' },
|
|
315
271
|
...columnSelectOptions.filter((option) => {
|
|
316
272
|
return (columns.find((col) => col.field === option.value)
|
|
317
273
|
?.format === 'string');
|
|
@@ -323,18 +279,12 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
323
279
|
marginBottom: 20,
|
|
324
280
|
}, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Value Field" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", value: pivotValueField, onChange: (e) => {
|
|
325
281
|
setPivotValueField(e === '' ? undefined : e);
|
|
326
|
-
}, options:
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
{ label: 'Select', value: '' },
|
|
333
|
-
...columnSelectOptions.filter((option) => {
|
|
334
|
-
return (option.value === '' ||
|
|
335
|
-
ChartBuilder_1.numberFormatOptions.includes(columns.find((col) => col.field === option.value)?.format));
|
|
336
|
-
}),
|
|
337
|
-
], theme: theme })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Aggregation Type" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: (e) => {
|
|
282
|
+
}, options: [
|
|
283
|
+
...columnSelectOptions.filter((option) => {
|
|
284
|
+
return (option.value === '' ||
|
|
285
|
+
ChartBuilder_1.numberFormatOptions.includes(columns.find((col) => col.field === option.value)?.format));
|
|
286
|
+
}),
|
|
287
|
+
], theme: theme })] }), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)(LabelComponent, { children: "Aggregation Type" }), (0, jsx_runtime_1.jsx)(SelectComponent, { id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: (e) => {
|
|
338
288
|
if (e !== 'count' &&
|
|
339
289
|
pivotValueField &&
|
|
340
290
|
!ChartBuilder_1.numberFormatOptions.includes(columns.find((col) => col.field === pivotValueField)?.format)) {
|
|
@@ -342,8 +292,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
342
292
|
}
|
|
343
293
|
setPivotAggregation(e === '' ? undefined : e);
|
|
344
294
|
}, options: [
|
|
345
|
-
|
|
346
|
-
...['sum', 'average', 'count'].map((option) => {
|
|
295
|
+
...['sum', 'average', 'count', 'max', 'min'].map((option) => {
|
|
347
296
|
return { label: option, value: option };
|
|
348
297
|
}),
|
|
349
298
|
] })] })] })] }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(ButtonComponent, { id: "custom-button", onClick: () => {
|
|
@@ -405,26 +354,24 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
405
354
|
columns: selectedPivotTable?.columns,
|
|
406
355
|
}, theme: theme, index: 0, onSelectPivot: () => { }, selectedPivotIndex: -1, onEditPivot: () => { }, ButtonComponent: ButtonComponent, showEdit: false, onClose: () => {
|
|
407
356
|
removePivot();
|
|
408
|
-
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
borderRadius: 5,
|
|
427
|
-
}, className: "quill-hover", children: [(0, jsx_runtime_1.jsx)(QuillHover, {}), (0, jsx_runtime_1.jsx)(assets_1.RefreshIcon, { style: { marginRight: 5 } }), "Refresh"] }) }), isLoading ? ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
357
|
+
}, clickable: true, minHeight: 180, LabelComponent: LabelComponent, TextComponent: TextComponent, HeaderComponent: HeaderComponent }) }) })) : ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: {
|
|
358
|
+
display: 'flex',
|
|
359
|
+
flexDirection: 'row',
|
|
360
|
+
width: '100%',
|
|
361
|
+
alignItems: 'center',
|
|
362
|
+
justifyContent: 'space-between',
|
|
363
|
+
paddingBottom: 12,
|
|
364
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: {
|
|
365
|
+
fontWeight: '600',
|
|
366
|
+
fontSize: 18,
|
|
367
|
+
}, children: "Recommended pivots" }), (0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(SecondaryButtonComponent, { onClick: refreshPivots, label: (0, jsx_runtime_1.jsxs)("div", { style: {
|
|
368
|
+
display: 'flex',
|
|
369
|
+
flexDirection: 'row',
|
|
370
|
+
whiteSpace: 'nowrap',
|
|
371
|
+
alignItems: 'center',
|
|
372
|
+
gap: 6,
|
|
373
|
+
fontSize: 14,
|
|
374
|
+
}, children: [(0, jsx_runtime_1.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", style: { width: 16, height: 16 }, children: (0, jsx_runtime_1.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 ? ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
428
375
|
background: theme.backgroundColor,
|
|
429
376
|
width: 250,
|
|
430
377
|
minWidth: 250,
|
|
@@ -435,7 +382,7 @@ const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField, setPivo
|
|
|
435
382
|
display: 'flex',
|
|
436
383
|
margin: '0px auto',
|
|
437
384
|
justifyContent: 'center',
|
|
438
|
-
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 100 } }), (0, jsx_runtime_1.jsxs)("svg", { width: "24", height: "24", children: [(0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "-180 12 12", to: "180 12 12", dur: "0.8s", repeatCount: "indefinite" }) }), (0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.8s", repeatCount: "indefinite" }) })] })] })) : ((0, jsx_runtime_1.
|
|
385
|
+
}, children: [(0, jsx_runtime_1.jsx)("div", { style: { height: 100 } }), (0, jsx_runtime_1.jsxs)("svg", { width: "24", height: "24", children: [(0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "-180 12 12", to: "180 12 12", dur: "0.8s", repeatCount: "indefinite" }) }), (0, jsx_runtime_1.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: (0, jsx_runtime_1.jsx)("animateTransform", { attributeName: "transform", attributeType: "XML", type: "rotate", from: "0 12 12", to: "360 12 12", dur: "0.8s", repeatCount: "indefinite" }) })] })] })) : ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(PivotList_1.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 }) }))] })) })) }) })] }) }));
|
|
439
386
|
};
|
|
440
387
|
exports.PivotModal = PivotModal;
|
|
441
388
|
function generatePivotTableYAxis(pivot, cols, format) {
|
|
@@ -581,7 +528,7 @@ const handleBigQueryValue = (value) => {
|
|
|
581
528
|
return value;
|
|
582
529
|
};
|
|
583
530
|
// Process out all the BigQuery dates.
|
|
584
|
-
const fixBigQueryData = (data) => {
|
|
531
|
+
const fixBigQueryData = (data = []) => {
|
|
585
532
|
const newData = [];
|
|
586
533
|
for (const row of data) {
|
|
587
534
|
const newRow = {};
|
|
@@ -593,6 +540,10 @@ const fixBigQueryData = (data) => {
|
|
|
593
540
|
return newData;
|
|
594
541
|
};
|
|
595
542
|
function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1, compRange = null) {
|
|
543
|
+
// If there is no rowField, aggregate on the valueField
|
|
544
|
+
if (!pivot.rowField) {
|
|
545
|
+
return valueFieldAggregation(data, pivot.valueField, pivot.aggregationType);
|
|
546
|
+
}
|
|
596
547
|
// Handle edge-case for BigQuery objects.
|
|
597
548
|
data = fixBigQueryData(data);
|
|
598
549
|
if (dateRange[0] === null && dateRange[1] === null) {
|
|
@@ -820,6 +771,18 @@ function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1,
|
|
|
820
771
|
: 0;
|
|
821
772
|
}
|
|
822
773
|
break;
|
|
774
|
+
case 'max':
|
|
775
|
+
value = filteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
776
|
+
if (isComparison) {
|
|
777
|
+
comparisonValue = comparisonFilteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
778
|
+
}
|
|
779
|
+
break;
|
|
780
|
+
case 'min':
|
|
781
|
+
value = filteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
782
|
+
if (isComparison) {
|
|
783
|
+
comparisonValue = comparisonFilteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
784
|
+
}
|
|
785
|
+
break;
|
|
823
786
|
// Implement other aggregation types as needed
|
|
824
787
|
default:
|
|
825
788
|
throw new Error('Unsupported aggregation type');
|
|
@@ -898,9 +861,15 @@ function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1,
|
|
|
898
861
|
if (pivot.sort) {
|
|
899
862
|
pivotRows.sort((a, b) => {
|
|
900
863
|
if (pivot.sortDirection === 'ASC') {
|
|
864
|
+
if (pivot.rowFieldType === 'date') {
|
|
865
|
+
return new Date(a[pivot.rowField]) - new Date(b[pivot.rowField]);
|
|
866
|
+
}
|
|
901
867
|
return a[pivot.rowField].localeCompare(b[pivot.rowField]);
|
|
902
868
|
}
|
|
903
869
|
else {
|
|
870
|
+
if (pivot.rowFieldType === 'date') {
|
|
871
|
+
return new Date(b[pivot.rowField]) - new Date(a[pivot.rowField]);
|
|
872
|
+
}
|
|
904
873
|
return b[pivot.rowField].localeCompare(a[pivot.rowField]);
|
|
905
874
|
}
|
|
906
875
|
});
|
|
@@ -908,3 +877,34 @@ function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1,
|
|
|
908
877
|
return { rows: pivotRows, columns };
|
|
909
878
|
}
|
|
910
879
|
exports.generatePivotTable = generatePivotTable;
|
|
880
|
+
function valueFieldAggregation(data, valueField, aggregationType) {
|
|
881
|
+
let value;
|
|
882
|
+
switch (aggregationType) {
|
|
883
|
+
case 'sum':
|
|
884
|
+
value = data.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0);
|
|
885
|
+
break;
|
|
886
|
+
case 'count':
|
|
887
|
+
value = filteredData.length;
|
|
888
|
+
break;
|
|
889
|
+
case 'average':
|
|
890
|
+
value = filteredData.length
|
|
891
|
+
? filteredData.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0) / filteredData.length
|
|
892
|
+
: 0;
|
|
893
|
+
break;
|
|
894
|
+
case 'max':
|
|
895
|
+
value = data.reduce((max, item) => Math.max(max, parseFloat(item[valueField] ?? 0)), -Infinity);
|
|
896
|
+
break;
|
|
897
|
+
case 'min':
|
|
898
|
+
value = data.reduce((min, item) => Math.min(min, parseFloat(item[valueField] ?? 0)), Infinity);
|
|
899
|
+
break;
|
|
900
|
+
// Implement other aggregation types as needed
|
|
901
|
+
default:
|
|
902
|
+
throw new Error('Unsupported aggregation type');
|
|
903
|
+
}
|
|
904
|
+
const row = {};
|
|
905
|
+
row[valueField] = value;
|
|
906
|
+
return {
|
|
907
|
+
rows: [row],
|
|
908
|
+
columns: [{ label: (0, textProcessing_1.snakeCaseToTitleCase)(valueField), field: valueField }],
|
|
909
|
+
};
|
|
910
|
+
}
|
|
@@ -53,51 +53,83 @@ const formatString = (value) => {
|
|
|
53
53
|
}
|
|
54
54
|
return value.toString();
|
|
55
55
|
};
|
|
56
|
+
// Formats large numbers like 12345.67 -> $12K
|
|
57
|
+
const formatterBigDollars = new Intl.NumberFormat('en-US', {
|
|
58
|
+
style: 'currency',
|
|
59
|
+
currency: 'USD',
|
|
60
|
+
minimumSignificantDigits: 1,
|
|
61
|
+
maximumSignificantDigits: 2,
|
|
62
|
+
notation: 'compact',
|
|
63
|
+
compactDisplay: 'short',
|
|
64
|
+
});
|
|
65
|
+
// Formats to dollars like 1234.56 -> $1235
|
|
66
|
+
const formatterDollar = new Intl.NumberFormat('en-US', {
|
|
67
|
+
style: 'currency',
|
|
68
|
+
currency: 'USD',
|
|
69
|
+
maximumFractionDigits: 0,
|
|
70
|
+
});
|
|
71
|
+
// Formats to dollars like 1234.567 -> $1234.57
|
|
72
|
+
const formatterDollarsCents = new Intl.NumberFormat('en-US', {
|
|
73
|
+
style: 'currency',
|
|
74
|
+
currency: 'USD',
|
|
75
|
+
minimumFractionDigits: 2,
|
|
76
|
+
maximumFractionDigits: 2,
|
|
77
|
+
});
|
|
56
78
|
/**
|
|
57
|
-
* Formats the value as a (rounded) currency amount in dollars.
|
|
79
|
+
* Formats the value as a (rounded) currency amount in dollars. If value is
|
|
80
|
+
* zero, returns '$0' with no cents. If value is greater than or equal to 1000,
|
|
81
|
+
* it will not show cents and shorten the value with a suffix such as K
|
|
82
|
+
* (for thousands) or M (for millions).
|
|
58
83
|
*
|
|
59
|
-
*
|
|
84
|
+
* @example format(1,234,567) => "$1.2M"
|
|
85
|
+
* @example format(1234.567) => "$1.2K"
|
|
86
|
+
* @example format(5000) => "$5K"
|
|
87
|
+
* @example format(123.45) => "$123"
|
|
88
|
+
* @example format(0.00) => "$0"
|
|
60
89
|
*/
|
|
61
90
|
const formatDollarAmount = (value) => {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
70
|
-
return formatter.format(Number(value ?? 0));
|
|
91
|
+
const num = Number(value ?? 0);
|
|
92
|
+
if (num >= 1000 || num === 0) {
|
|
93
|
+
return formatterBigDollars.format(num);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return formatterDollar.format(num);
|
|
97
|
+
}
|
|
71
98
|
};
|
|
72
99
|
/**
|
|
73
|
-
* Formats the value as a (rounded) currency amount in dollars and cents.
|
|
100
|
+
* Formats the value as a (rounded) currency amount in dollars and cents. If
|
|
101
|
+
* value is zero, returns '$0' with no cents. If value is greater than or equal
|
|
102
|
+
* to 1000, it will not show cents and shorten the value with a suffix such
|
|
103
|
+
* as K (for thousands) or M (for millions).
|
|
74
104
|
*
|
|
105
|
+
* @example format(1,234,567) => "$1.2M"
|
|
75
106
|
* @example format(1234.567) => "$1.2K"
|
|
107
|
+
* @example format(5000) => "$5K"
|
|
108
|
+
* @example format(123.45) => "$123.45"
|
|
109
|
+
* @example format(0.00) => "$0"
|
|
76
110
|
*/
|
|
77
111
|
const formatDollarCents = (value) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
return formatter.format(Number(value ?? 0));
|
|
112
|
+
const num = Number(value ?? 0);
|
|
113
|
+
if (num >= 1000 || num === 0) {
|
|
114
|
+
return formatterBigDollars.format(num);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
return formatterDollarsCents.format(num);
|
|
118
|
+
}
|
|
87
119
|
};
|
|
120
|
+
const formatterBigWholeNumber = new Intl.NumberFormat('en-US', {
|
|
121
|
+
minimumSignificantDigits: 1,
|
|
122
|
+
maximumSignificantDigits: 2,
|
|
123
|
+
notation: 'compact',
|
|
124
|
+
compactDisplay: 'short',
|
|
125
|
+
});
|
|
88
126
|
/**
|
|
89
127
|
* Formats the value as a (rounded) integer.
|
|
90
128
|
*
|
|
91
129
|
* @example format(1234.567) => "1.2K"
|
|
92
130
|
*/
|
|
93
131
|
const formatWholeNumber = (value) => {
|
|
94
|
-
|
|
95
|
-
minimumSignificantDigits: 2,
|
|
96
|
-
maximumSignificantDigits: 2,
|
|
97
|
-
notation: 'compact',
|
|
98
|
-
compactDisplay: 'short',
|
|
99
|
-
});
|
|
100
|
-
return formatter.format(Number(value));
|
|
132
|
+
return formatterBigWholeNumber.format(Number(value));
|
|
101
133
|
};
|
|
102
134
|
/**
|
|
103
135
|
* Formats the value as a number rounded to exactly one decimal place.
|
|
@@ -112,7 +144,13 @@ const formatOneDecimalPlace = (value) => {
|
|
|
112
144
|
notation: 'compact',
|
|
113
145
|
compactDisplay: 'short',
|
|
114
146
|
});
|
|
115
|
-
|
|
147
|
+
const num = Number(value ?? 0);
|
|
148
|
+
if (num >= 1000 || num === 0) {
|
|
149
|
+
return formatterBigWholeNumber.format(num);
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
return formatter.format(num);
|
|
153
|
+
}
|
|
116
154
|
};
|
|
117
155
|
/**
|
|
118
156
|
* Formats the value as a number rounded to exactly two decimal places.
|
|
@@ -127,7 +165,13 @@ const formatTwoDecimalPlaces = (value) => {
|
|
|
127
165
|
notation: 'compact',
|
|
128
166
|
compactDisplay: 'short',
|
|
129
167
|
});
|
|
130
|
-
|
|
168
|
+
const num = Number(value ?? 0);
|
|
169
|
+
if (num >= 1000 || num === 0) {
|
|
170
|
+
return formatterBigWholeNumber.format(num);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
return formatter.format(num);
|
|
174
|
+
}
|
|
131
175
|
};
|
|
132
176
|
/**
|
|
133
177
|
* 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"}
|
|
@@ -35,6 +35,16 @@ async function getData(client, cloudQueryEndpoint, noCred, hostedRequestBody, cl
|
|
|
35
35
|
compareRows: responseJson?.queries?.queryResults[1]?.rows,
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
+
if (responseJson.data.columns &&
|
|
39
|
+
responseJson.data.fields &&
|
|
40
|
+
responseJson.data.columns.length != responseJson.data.fields) {
|
|
41
|
+
// Remove all columns that don't appear in fields, overtime this should never be the case
|
|
42
|
+
const columns = responseJson.data.columns.filter((columns) => responseJson.data.fields.find((field) => field.name === columns.field));
|
|
43
|
+
result = {
|
|
44
|
+
...result,
|
|
45
|
+
columns,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
38
48
|
return result;
|
|
39
49
|
}
|
|
40
50
|
else {
|
|
@@ -23,9 +23,30 @@ function getDomain(data, fields) {
|
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
25
|
const [minValue, maxValue] = numericValues.reduce(([min, max], value) => [Math.min(min, value), Math.max(max, value)], [Infinity, -Infinity]);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return
|
|
26
|
+
if (minValue === 0 && maxValue === 0) {
|
|
27
|
+
return [0, 1];
|
|
28
|
+
}
|
|
29
|
+
return fuzzyRound(Math.min(minValue, 0), maxValue);
|
|
30
30
|
}
|
|
31
31
|
exports.default = getDomain;
|
|
32
|
+
// Rounds the range to 4 equally-spaced increments of nice,round numbers.
|
|
33
|
+
function fuzzyRound(min, max) {
|
|
34
|
+
const range = parseFloat((max - min).toPrecision(1));
|
|
35
|
+
const increment = Math.ceil(range / 4);
|
|
36
|
+
let newMin = min;
|
|
37
|
+
// if (min % increment !== 0) {
|
|
38
|
+
// newMin = min - (min % increment);
|
|
39
|
+
// }
|
|
40
|
+
if (Number.isNaN(newMin)) {
|
|
41
|
+
newMin = 0;
|
|
42
|
+
}
|
|
43
|
+
let newMax = min + increment * 4;
|
|
44
|
+
if (max % increment !== 0) {
|
|
45
|
+
const adjMax = max + (increment - (max % increment));
|
|
46
|
+
newMax = parseFloat(adjMax.toPrecision(2));
|
|
47
|
+
}
|
|
48
|
+
if (Number.isNaN(newMax)) {
|
|
49
|
+
newMax = 0;
|
|
50
|
+
}
|
|
51
|
+
return [newMin ?? 0, newMax ?? 0];
|
|
52
|
+
}
|
|
@@ -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/dist/esm/BarList.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { type ColorMapType } from './Chart';
|
|
2
3
|
interface YAxisField {
|
|
3
4
|
label: string;
|
|
4
5
|
field: string;
|
|
@@ -14,7 +15,7 @@ export interface BarListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
14
15
|
containerStyle: any;
|
|
15
16
|
xAxisFormat: string;
|
|
16
17
|
colors?: string[];
|
|
17
|
-
colorMap?:
|
|
18
|
+
colorMap?: ColorMapType;
|
|
18
19
|
theme: any;
|
|
19
20
|
}
|
|
20
21
|
export declare function hexToRgbaWith10PercentAlpha(hex: any): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarList.d.ts","sourceRoot":"","sources":["../../src/BarList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"BarList.d.ts","sourceRoot":"","sources":["../../src/BarList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAcxC,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,SAAS,CAAC;AAuB5C,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACxE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,GAAG,CAAC;CACZ;AAYD,wBAAgB,2BAA2B,CAAC,GAAG,KAAA,UAW9C;AAED,QAAA,MAAM,OAAO,qFAwdX,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
package/dist/esm/BarList.js
CHANGED
|
@@ -123,7 +123,9 @@ const BarList = React.forwardRef((props, ref) => {
|
|
|
123
123
|
marginBottom: '8px',
|
|
124
124
|
width: `${widths[idx]}%`,
|
|
125
125
|
transition: showAnimation ? 'all 2s' : '',
|
|
126
|
-
backgroundColor: (colorMap &&
|
|
126
|
+
backgroundColor: (colorMap &&
|
|
127
|
+
colorMap[xAxisField] &&
|
|
128
|
+
colorMap[xAxisField]['primary']) ??
|
|
127
129
|
hexToRgbaWith10PercentAlpha(colors[0]),
|
|
128
130
|
boxSizing: 'content-box',
|
|
129
131
|
}, children: _jsx("div", { style: {
|
|
@@ -150,7 +152,9 @@ const BarList = React.forwardRef((props, ref) => {
|
|
|
150
152
|
marginBottom: '8px',
|
|
151
153
|
width: `${widths2[idx]}%`,
|
|
152
154
|
transition: showAnimation ? 'all 2s' : '',
|
|
153
|
-
backgroundColor: (colorMap &&
|
|
155
|
+
backgroundColor: (colorMap &&
|
|
156
|
+
colorMap[xAxisField] &&
|
|
157
|
+
colorMap[xAxisField]['primary']) ??
|
|
154
158
|
hexToRgbaWith10PercentAlpha(colors[1]),
|
|
155
159
|
boxSizing: 'content-box',
|
|
156
160
|
}, children: _jsx("div", { style: {
|
|
@@ -228,7 +232,9 @@ const BarList = React.forwardRef((props, ref) => {
|
|
|
228
232
|
width: `${widths[idx]}%`,
|
|
229
233
|
transition: showAnimation ? 'all 2s' : '',
|
|
230
234
|
boxSizing: 'content-box',
|
|
231
|
-
backgroundColor: (colorMap &&
|
|
235
|
+
backgroundColor: (colorMap &&
|
|
236
|
+
colorMap[xAxisField] &&
|
|
237
|
+
colorMap[xAxisField]['primary']) ??
|
|
232
238
|
hexToRgbaWith10PercentAlpha(colors[0]),
|
|
233
239
|
display: 'flex',
|
|
234
240
|
alignItems: 'center',
|