@quillsql/react 2.11.8 → 2.11.12
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 +5 -19
- 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 +76 -45
- package/dist/cjs/SQLEditor.d.ts +2 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +60 -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/LineChart.d.ts +3 -4
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +32 -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/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +3 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/AddSortPopover.js +5 -4
- 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/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 +3 -2
- 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 +48 -1
- 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.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +65 -62
- 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.d.ts.map +1 -1
- package/dist/cjs/utils/getDomain.js +22 -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 +5 -19
- 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 +80 -49
- package/dist/esm/SQLEditor.d.ts +2 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +61 -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/LineChart.d.ts +3 -4
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +32 -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/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +3 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/AddSortPopover.js +6 -5
- 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/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 +3 -2
- 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 +46 -0
- 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.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +65 -62
- 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.d.ts.map +1 -1
- package/dist/esm/utils/getDomain.js +22 -4
- package/dist/esm/utils/valueFormatter.d.ts +2 -1
- package/dist/esm/utils/valueFormatter.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -614,3 +614,49 @@ export const getDateFilterInfo = (node) => {
|
|
|
614
614
|
intervalPaths,
|
|
615
615
|
};
|
|
616
616
|
};
|
|
617
|
+
// NEED TO UPDATE FOR MORE POTENTIAL CASES
|
|
618
|
+
function getNodeTable(node) {
|
|
619
|
+
if (node.table) {
|
|
620
|
+
return node.table;
|
|
621
|
+
}
|
|
622
|
+
if (node.args && node.args.value[0].table) {
|
|
623
|
+
return node.args.value[0].table;
|
|
624
|
+
}
|
|
625
|
+
return null;
|
|
626
|
+
}
|
|
627
|
+
// Recursively remove filters that don't apply to the given table
|
|
628
|
+
function removeNonSelectedTableFilters(node, table) {
|
|
629
|
+
if (node.left.type !== 'binary_expr') {
|
|
630
|
+
const referencedTable = getNodeTable(node.left);
|
|
631
|
+
if (referencedTable && referencedTable !== table) {
|
|
632
|
+
return null;
|
|
633
|
+
}
|
|
634
|
+
else {
|
|
635
|
+
return node;
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
node.left = removeNonSelectedTableFilters(node.left, table);
|
|
639
|
+
node.right = removeNonSelectedTableFilters(node.right, table);
|
|
640
|
+
if (node.left && node.right) {
|
|
641
|
+
return node;
|
|
642
|
+
}
|
|
643
|
+
else if (node.left) {
|
|
644
|
+
return node.left;
|
|
645
|
+
}
|
|
646
|
+
else if (node.right) {
|
|
647
|
+
return node.right;
|
|
648
|
+
}
|
|
649
|
+
else {
|
|
650
|
+
return null;
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
export function removeNonSelectedTableReferences(ast, table) {
|
|
654
|
+
ast.columns = ast.columns.filter((col) => {
|
|
655
|
+
return col.table === table || col.expr.table === table || !col.expr.table;
|
|
656
|
+
});
|
|
657
|
+
if (!ast.where)
|
|
658
|
+
return ast;
|
|
659
|
+
ast.where = removeNonSelectedTableFilters(ast.where, table);
|
|
660
|
+
console.log(ast);
|
|
661
|
+
return ast;
|
|
662
|
+
}
|
|
@@ -14,6 +14,7 @@ export interface SelectComponentProps {
|
|
|
14
14
|
export interface ButtonComponentProps {
|
|
15
15
|
onClick: () => void;
|
|
16
16
|
label: string;
|
|
17
|
+
isLoading?: boolean | undefined;
|
|
17
18
|
primary?: boolean;
|
|
18
19
|
width?: string;
|
|
19
20
|
}
|
|
@@ -67,10 +68,11 @@ export declare const MemoizedTextInput: ({ value, onChange, placeholder, id }: {
|
|
|
67
68
|
placeholder: any;
|
|
68
69
|
id: any;
|
|
69
70
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
70
|
-
export declare const MemoizedButton: ({ label, onClick, primary }: {
|
|
71
|
+
export declare const MemoizedButton: ({ label, onClick, primary, isLoading, }: {
|
|
71
72
|
label: any;
|
|
72
73
|
onClick: any;
|
|
73
74
|
primary?: boolean | undefined;
|
|
75
|
+
isLoading?: boolean | undefined;
|
|
74
76
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
75
77
|
export declare const MemoizedSecondaryButton: ({ label, onClick }: {
|
|
76
78
|
label: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiComponents.d.ts","sourceRoot":"","sources":["../../../src/components/UiComponents.tsx"],"names":[],"mappings":"AACA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAK7D,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IAC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AAE,OAAO,KAAK,IAAI,CAAC;CACtC;AAED,wBAAgB,eAAe,CAAC,EAC9B,OAAO,EACP,SAAS,EACT,QAAQ,EACR,KAAU,EACV,OAAO,EACP,WAAkB,EAClB,MAAM,EACN,KAAK,EACL,SAAS,GACV,EAAE,oBAAoB,2CA2DtB;AAED,wBAAgB,aAAa,CAAC,EAC5B,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,QAAQ,EACR,KAAK,EACL,KAAU,GACX;;;;;;;;CAAA,kDA4FA;AAED,eAAO,MAAM,oBAAoB;;;6CA0BhC,CAAC;AAEF,eAAO,MAAM,cAAc,+CAwD1B,CAAC"}
|
|
@@ -27,7 +27,7 @@ export const MemoizedTextInput = ({ value, onChange, placeholder, id }) => {
|
|
|
27
27
|
.quill-text-input {
|
|
28
28
|
background-color: white;
|
|
29
29
|
height: 40px;
|
|
30
|
-
width:
|
|
30
|
+
width: 100%;
|
|
31
31
|
color: #384151;
|
|
32
32
|
border: 1px solid #e7e7e7;
|
|
33
33
|
border-radius: 6px;
|
|
@@ -37,10 +37,10 @@ export const MemoizedTextInput = ({ value, onChange, placeholder, id }) => {
|
|
|
37
37
|
padding-right: 12px;
|
|
38
38
|
padding-top: 0px;
|
|
39
39
|
padding-bottom: 0px;
|
|
40
|
-
box-sizing:
|
|
40
|
+
box-sizing: border-box;
|
|
41
41
|
}` }), _jsx("input", { id: id, className: "quill-text-input", type: "text", value: value, onChange: (event) => onChange(event.target.value), placeholder: placeholder, style: { fontFamily: theme?.fontFamily } })] }));
|
|
42
42
|
};
|
|
43
|
-
export const MemoizedButton = ({ label, onClick, primary = true }) => {
|
|
43
|
+
export const MemoizedButton = ({ label, onClick, primary = true, isLoading = false, }) => {
|
|
44
44
|
const [theme] = useContext(ThemeContext);
|
|
45
45
|
return (_jsxs("button", { className: "quill-button", onClick: onClick, style: { fontFamily: theme?.fontFamily }, children: [_jsx("style", { children: `
|
|
46
46
|
.quill-button {
|
|
@@ -60,7 +60,7 @@ export const MemoizedButton = ({ label, onClick, primary = true }) => {
|
|
|
60
60
|
.quill-button:hover {
|
|
61
61
|
background-color: rgba(56, 65, 81, 0.9);
|
|
62
62
|
border-radius: 6px;
|
|
63
|
-
}` }), label] }));
|
|
63
|
+
}` }), isLoading ? (_jsx("div", { style: { padding: '0px 16px' }, children: _jsx(LoadingSpinner, {}) })) : (label)] }));
|
|
64
64
|
};
|
|
65
65
|
export const MemoizedSecondaryButton = ({ label, onClick }) => {
|
|
66
66
|
const [theme] = useContext(ThemeContext);
|
|
@@ -40,7 +40,7 @@ export const useQuill = (chartId) => {
|
|
|
40
40
|
};
|
|
41
41
|
const resp = await getData(client, 'itempost', 'same-origin', hostedBody, cloudBody);
|
|
42
42
|
if (resp) {
|
|
43
|
-
if (resp.name === 'error') {
|
|
43
|
+
if (resp.name === 'error' || resp.errorMessage) {
|
|
44
44
|
setError(JSON.stringify(resp));
|
|
45
45
|
}
|
|
46
46
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotModal.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotModal.tsx"],"names":[],"mappings":"AA+BA,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAkBD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PivotModal.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotModal.tsx"],"names":[],"mappings":"AA+BA,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAkBD,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6CAotBtB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,KAAK,KAAA,EAAE,IAAI,KAAA,EAAE,MAAM,KAAA,OAyB1D;AAkHD,wBAAgB,WAAW,CAAC,SAAS,KAAA,WAYpC;AAgCD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,EACT,SAAS,EAAE,GAAG,EACd,YAAY,EAAE,OAAO,EACrB,QAAQ,SAAK,EACb,SAAS,GAAE,GAAU;;;;;;EA6atB"}
|
|
@@ -129,6 +129,9 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
129
129
|
onEditPivot(pivot, null);
|
|
130
130
|
};
|
|
131
131
|
const refreshPivots = useCallback(async () => {
|
|
132
|
+
if (!showTrigger) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
132
135
|
if (isLoading || Object.keys(columnsToShow).length === 0) {
|
|
133
136
|
return;
|
|
134
137
|
}
|
|
@@ -147,50 +150,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
147
150
|
try {
|
|
148
151
|
const resp = await getDataFromCloud(client, 'pivotai', cloudBody);
|
|
149
152
|
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
153
|
setRecommendedPivots(recommendedPivots
|
|
195
154
|
.filter((pivot) => pivot.rowField != '')
|
|
196
155
|
.map((pivot) => {
|
|
@@ -207,7 +166,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
207
166
|
console.error('Failed parsing pivotai response', e);
|
|
208
167
|
}
|
|
209
168
|
setIsLoading(false);
|
|
210
|
-
}, [selectedTable, data, columnsToShow, isLoading]);
|
|
169
|
+
}, [selectedTable, data, columnsToShow, isLoading, showTrigger]);
|
|
211
170
|
useEffect(() => {
|
|
212
171
|
if (recommendedPivots.length === 0) {
|
|
213
172
|
refreshPivots();
|
|
@@ -299,7 +258,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
299
258
|
}, children: [_jsxs("div", { children: [_jsx(LabelComponent, { children: "Row Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotRowField, onChange: (e) => {
|
|
300
259
|
setPivotRowField(e === '' ? undefined : e);
|
|
301
260
|
}, options: [
|
|
302
|
-
{ label: 'Select', value: '' },
|
|
303
261
|
...columnSelectOptions.filter((option) => {
|
|
304
262
|
const format = columns.find((col) => col.field === option.value)?.format;
|
|
305
263
|
return (format === 'string' ||
|
|
@@ -308,7 +266,6 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
308
266
|
], theme: theme })] }), _jsxs("div", { children: [_jsx(LabelComponent, { children: "Column Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotColumnField, onChange: (e) => {
|
|
309
267
|
setPivotColumnField(e === '' ? undefined : e);
|
|
310
268
|
}, options: [
|
|
311
|
-
{ label: 'Select', value: '' },
|
|
312
269
|
...columnSelectOptions.filter((option) => {
|
|
313
270
|
return (columns.find((col) => col.field === option.value)
|
|
314
271
|
?.format === 'string');
|
|
@@ -320,18 +277,12 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
320
277
|
marginBottom: 20,
|
|
321
278
|
}, children: [_jsxs("div", { children: [_jsx(LabelComponent, { children: "Value Field" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotValueField, onChange: (e) => {
|
|
322
279
|
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) => {
|
|
280
|
+
}, options: [
|
|
281
|
+
...columnSelectOptions.filter((option) => {
|
|
282
|
+
return (option.value === '' ||
|
|
283
|
+
numberFormatOptions.includes(columns.find((col) => col.field === option.value)?.format));
|
|
284
|
+
}),
|
|
285
|
+
], theme: theme })] }), _jsxs("div", { children: [_jsx(LabelComponent, { children: "Aggregation Type" }), _jsx(SelectComponent, { id: "pivot-row-field", value: pivotAggregation, theme: theme, onChange: (e) => {
|
|
335
286
|
if (e !== 'count' &&
|
|
336
287
|
pivotValueField &&
|
|
337
288
|
!numberFormatOptions.includes(columns.find((col) => col.field === pivotValueField)?.format)) {
|
|
@@ -339,8 +290,7 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
339
290
|
}
|
|
340
291
|
setPivotAggregation(e === '' ? undefined : e);
|
|
341
292
|
}, options: [
|
|
342
|
-
|
|
343
|
-
...['sum', 'average', 'count'].map((option) => {
|
|
293
|
+
...['sum', 'average', 'count', 'max', 'min'].map((option) => {
|
|
344
294
|
return { label: option, value: option };
|
|
345
295
|
}),
|
|
346
296
|
] })] })] })] }), _jsx("div", { children: _jsx(ButtonComponent, { id: "custom-button", onClick: () => {
|
|
@@ -575,7 +525,7 @@ const handleBigQueryValue = (value) => {
|
|
|
575
525
|
return value;
|
|
576
526
|
};
|
|
577
527
|
// Process out all the BigQuery dates.
|
|
578
|
-
const fixBigQueryData = (data) => {
|
|
528
|
+
const fixBigQueryData = (data = []) => {
|
|
579
529
|
const newData = [];
|
|
580
530
|
for (const row of data) {
|
|
581
531
|
const newRow = {};
|
|
@@ -587,6 +537,10 @@ const fixBigQueryData = (data) => {
|
|
|
587
537
|
return newData;
|
|
588
538
|
};
|
|
589
539
|
export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimit = -1, compRange = null) {
|
|
540
|
+
// If there is no rowField, aggregate on the valueField
|
|
541
|
+
if (!pivot.rowField) {
|
|
542
|
+
return valueFieldAggregation(data, pivot.valueField, pivot.aggregationType);
|
|
543
|
+
}
|
|
590
544
|
// Handle edge-case for BigQuery objects.
|
|
591
545
|
data = fixBigQueryData(data);
|
|
592
546
|
if (dateRange[0] === null && dateRange[1] === null) {
|
|
@@ -814,6 +768,18 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
814
768
|
: 0;
|
|
815
769
|
}
|
|
816
770
|
break;
|
|
771
|
+
case 'max':
|
|
772
|
+
value = filteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
773
|
+
if (isComparison) {
|
|
774
|
+
comparisonValue = comparisonFilteredData.reduce((max, item) => Math.max(max, parseFloat(item[key] ?? 0)), -Infinity);
|
|
775
|
+
}
|
|
776
|
+
break;
|
|
777
|
+
case 'min':
|
|
778
|
+
value = filteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
779
|
+
if (isComparison) {
|
|
780
|
+
comparisonValue = comparisonFilteredData.reduce((min, item) => Math.min(min, parseFloat(item[key] ?? 0)), Infinity);
|
|
781
|
+
}
|
|
782
|
+
break;
|
|
817
783
|
// Implement other aggregation types as needed
|
|
818
784
|
default:
|
|
819
785
|
throw new Error('Unsupported aggregation type');
|
|
@@ -892,12 +858,49 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
892
858
|
if (pivot.sort) {
|
|
893
859
|
pivotRows.sort((a, b) => {
|
|
894
860
|
if (pivot.sortDirection === 'ASC') {
|
|
861
|
+
if (pivot.rowFieldType === 'date') {
|
|
862
|
+
return new Date(a[pivot.rowField]) - new Date(b[pivot.rowField]);
|
|
863
|
+
}
|
|
895
864
|
return a[pivot.rowField].localeCompare(b[pivot.rowField]);
|
|
896
865
|
}
|
|
897
866
|
else {
|
|
867
|
+
if (pivot.rowFieldType === 'date') {
|
|
868
|
+
return new Date(b[pivot.rowField]) - new Date(a[pivot.rowField]);
|
|
869
|
+
}
|
|
898
870
|
return b[pivot.rowField].localeCompare(a[pivot.rowField]);
|
|
899
871
|
}
|
|
900
872
|
});
|
|
901
873
|
}
|
|
902
874
|
return { rows: pivotRows, columns };
|
|
903
875
|
}
|
|
876
|
+
function valueFieldAggregation(data, valueField, aggregationType) {
|
|
877
|
+
let value;
|
|
878
|
+
switch (aggregationType) {
|
|
879
|
+
case 'sum':
|
|
880
|
+
value = data.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0);
|
|
881
|
+
break;
|
|
882
|
+
case 'count':
|
|
883
|
+
value = filteredData.length;
|
|
884
|
+
break;
|
|
885
|
+
case 'average':
|
|
886
|
+
value = filteredData.length
|
|
887
|
+
? filteredData.reduce((sum, item) => sum + parseFloat(item[valueField] ?? 0), 0) / filteredData.length
|
|
888
|
+
: 0;
|
|
889
|
+
break;
|
|
890
|
+
case 'max':
|
|
891
|
+
value = data.reduce((max, item) => Math.max(max, parseFloat(item[valueField] ?? 0)), -Infinity);
|
|
892
|
+
break;
|
|
893
|
+
case 'min':
|
|
894
|
+
value = data.reduce((min, item) => Math.min(min, parseFloat(item[valueField] ?? 0)), Infinity);
|
|
895
|
+
break;
|
|
896
|
+
// Implement other aggregation types as needed
|
|
897
|
+
default:
|
|
898
|
+
throw new Error('Unsupported aggregation type');
|
|
899
|
+
}
|
|
900
|
+
const row = {};
|
|
901
|
+
row[valueField] = value;
|
|
902
|
+
return {
|
|
903
|
+
rows: [row],
|
|
904
|
+
columns: [{ label: snakeCaseToTitleCase(valueField), field: valueField }],
|
|
905
|
+
};
|
|
906
|
+
}
|
|
@@ -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 {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDomain.d.ts","sourceRoot":"","sources":["../../../src/utils/getDomain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"getDomain.d.ts","sourceRoot":"","sources":["../../../src/utils/getDomain.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,EAAE,CA0BtE"}
|
|
@@ -21,8 +21,26 @@ 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
|
-
|
|
24
|
+
return fuzzyRound(Math.min(minValue, 0), maxValue);
|
|
25
|
+
}
|
|
26
|
+
// Rounds the range to 4 equally-spaced increments of nice,round numbers.
|
|
27
|
+
function fuzzyRound(min, max) {
|
|
28
|
+
const range = parseFloat((max - min).toPrecision(1));
|
|
29
|
+
const increment = Math.ceil(range / 4);
|
|
30
|
+
let newMin = min;
|
|
31
|
+
// if (min % increment !== 0) {
|
|
32
|
+
// newMin = min - (min % increment);
|
|
33
|
+
// }
|
|
34
|
+
if (Number.isNaN(newMin)) {
|
|
35
|
+
newMin = 0;
|
|
36
|
+
}
|
|
37
|
+
let newMax = min + increment * 4;
|
|
38
|
+
if (max % increment !== 0) {
|
|
39
|
+
const adjMax = max + (increment - (max % increment));
|
|
40
|
+
newMax = parseFloat(adjMax.toPrecision(2));
|
|
41
|
+
}
|
|
42
|
+
if (Number.isNaN(newMax)) {
|
|
43
|
+
newMax = 0;
|
|
44
|
+
}
|
|
45
|
+
return [newMin ?? 0, newMax ?? 0];
|
|
28
46
|
}
|
|
@@ -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"}
|