@quillsql/react 2.12.19 → 2.12.20
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/Chart.d.ts +2 -1
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +117 -105
- package/dist/cjs/ChartBuilder.d.ts +4 -2
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +26 -11
- package/dist/cjs/ChartEditor.d.ts +1 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +20 -12
- package/dist/cjs/Context.d.ts +0 -9
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +15 -43
- package/dist/cjs/Dashboard.d.ts +16 -3
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +64 -65
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +11 -4
- 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 +2 -2
- package/dist/cjs/components/Chart/ChartTooltip.d.ts +1 -0
- package/dist/cjs/components/Chart/ChartTooltip.d.ts.map +1 -1
- package/dist/cjs/components/Chart/ChartTooltip.js +3 -4
- package/dist/cjs/components/Chart/LineChart.d.ts +2 -1
- package/dist/cjs/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/LineChart.js +2 -2
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/ChartComponent.js +10 -4
- package/dist/cjs/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DashboardFilter.js +3 -18
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +6 -4
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +46 -32
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +27 -43
- package/dist/cjs/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/TableComponent.js +25 -52
- package/dist/cjs/hooks/useDashboard.d.ts.map +1 -1
- package/dist/cjs/hooks/useDashboard.js +3 -2
- package/dist/cjs/hooks/useQuill.d.ts +7 -0
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +43 -4
- package/dist/cjs/index.d.ts +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +2 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +8 -3
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +24 -12
- package/dist/cjs/utils/aggregate.d.ts.map +1 -1
- package/dist/cjs/utils/aggregate.js +0 -4
- package/dist/cjs/utils/dashboard.d.ts +2 -2
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +16 -11
- package/dist/cjs/utils/dates.d.ts.map +1 -1
- package/dist/cjs/utils/dates.js +7 -4
- package/dist/esm/Chart.d.ts +2 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +116 -105
- package/dist/esm/ChartBuilder.d.ts +4 -2
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +27 -12
- package/dist/esm/ChartEditor.d.ts +1 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +21 -13
- package/dist/esm/Context.d.ts +0 -9
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +14 -40
- package/dist/esm/Dashboard.d.ts +16 -3
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +66 -67
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +12 -5
- 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 +2 -2
- package/dist/esm/components/Chart/ChartTooltip.d.ts +1 -0
- package/dist/esm/components/Chart/ChartTooltip.d.ts.map +1 -1
- package/dist/esm/components/Chart/ChartTooltip.js +3 -4
- package/dist/esm/components/Chart/LineChart.d.ts +2 -1
- package/dist/esm/components/Chart/LineChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/LineChart.js +2 -2
- package/dist/esm/components/Dashboard/ChartComponent.d.ts +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/ChartComponent.js +7 -4
- package/dist/esm/components/Dashboard/DashboardFilter.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DashboardFilter.js +3 -18
- package/dist/esm/components/Dashboard/DataLoader.d.ts +6 -4
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +47 -33
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +28 -44
- package/dist/esm/components/Dashboard/TableComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/TableComponent.js +26 -53
- package/dist/esm/hooks/useDashboard.d.ts.map +1 -1
- package/dist/esm/hooks/useDashboard.js +3 -2
- package/dist/esm/hooks/useQuill.d.ts +7 -0
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +41 -3
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +8 -3
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +24 -12
- package/dist/esm/utils/aggregate.d.ts.map +1 -1
- package/dist/esm/utils/aggregate.js +0 -4
- package/dist/esm/utils/dashboard.d.ts +2 -2
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +16 -11
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +7 -4
- package/package.json +1 -1
|
@@ -1,40 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import { COMPARISON_OPTIONS } from '../../DateRangePicker/dateRangePickerUtils';
|
|
4
4
|
import { valueFormatter } from '../../utils/valueFormatter';
|
|
5
5
|
import ChartError from '../Chart/ChartError';
|
|
6
6
|
import ChartSkeleton from '../Chart/ChartSkeleton';
|
|
7
|
-
import { generatePivotTable } from '../../internals/ReportBuilder/PivotModal';
|
|
8
|
-
import { DashboardFiltersContext } from '../../Context';
|
|
9
7
|
import { useTheme } from '../../hooks';
|
|
8
|
+
import { usePivot } from '../../hooks/useQuill';
|
|
10
9
|
export default function QuillMetricComponent({ report, onClick, error, isLoading, }) {
|
|
11
10
|
const theme = useTheme();
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
? { start: dateFilter.startDate, end: dateFilter.endDate }
|
|
23
|
-
: undefined, Boolean(dateFilter?.comparisonRange?.startDate), -1, dateFilter?.comparisonRange?.startDate &&
|
|
24
|
-
dateFilter?.comparisonRange?.endDate
|
|
25
|
-
? {
|
|
26
|
-
start: dateFilter.comparisonRange.startDate,
|
|
27
|
-
end: dateFilter.comparisonRange.endDate,
|
|
28
|
-
}
|
|
29
|
-
: undefined)
|
|
30
|
-
: null;
|
|
31
|
-
}, [config?.pivot]);
|
|
32
|
-
const primaryMetricLabel = data?.filtersApplied?.date_range?.preset?.label;
|
|
33
|
-
const comparisonKey = data?.filtersApplied?.date_range?.comparisonRange?.value;
|
|
11
|
+
const dateFilter = report?.filtersApplied?.find((filter) => filter.filterType == 'date_range');
|
|
12
|
+
const [rows, setRows] = useState(report?.rows ?? []);
|
|
13
|
+
const pivotData = usePivot(report.id);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
if (pivotData.data) {
|
|
16
|
+
setRows(pivotData.data.rows);
|
|
17
|
+
}
|
|
18
|
+
}, [pivotData]);
|
|
19
|
+
const primaryMetricLabel = report?.filtersApplied?.date_range?.preset?.label;
|
|
20
|
+
const comparisonKey = report?.filtersApplied?.date_range?.comparisonRange?.value;
|
|
34
21
|
const comparisonLabel = COMPARISON_OPTIONS.find((opt) => opt.value === comparisonKey)?.text;
|
|
35
|
-
const rows = pivotTable?.rows ?? data.rows ?? [];
|
|
36
|
-
const isComparison = rows.length > 0 &&
|
|
37
|
-
Object.keys(rows[0]).includes(`comparison_${data.xAxisField}`);
|
|
38
22
|
return (_jsx("div", { onClick: () => onClick && onClick(report), style: {
|
|
39
23
|
cursor: 'pointer',
|
|
40
24
|
boxSizing: 'content-box',
|
|
@@ -72,7 +56,7 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
72
56
|
display: 'block',
|
|
73
57
|
maxWidth: '100%',
|
|
74
58
|
overflow: 'hidden',
|
|
75
|
-
}, children: report?.name }), onClick ? (_jsx("div", { style: {
|
|
59
|
+
}, children: report?.name }), onClick && report?.name ? (_jsx("div", { style: {
|
|
76
60
|
fontFamily: theme.fontFamily,
|
|
77
61
|
color: theme.primaryTextColor,
|
|
78
62
|
boxSizing: 'content-box',
|
|
@@ -85,7 +69,7 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
85
69
|
}, children: 'view report →' })) : null] }), isLoading ? (_jsx(ChartSkeleton, { containerStyle: {
|
|
86
70
|
maxHeight: '78px',
|
|
87
71
|
height: '100%',
|
|
88
|
-
} })) : error ? (_jsx(ChartError, {})) : rows?.length === 0 || rows[0][
|
|
72
|
+
} })) : error ? (_jsx(ChartError, {})) : rows?.length === 0 || rows[0][report.xAxisField] === null ? (_jsx("div", { style: {
|
|
89
73
|
display: 'flex',
|
|
90
74
|
flex: '1 0 auto',
|
|
91
75
|
height: '100%',
|
|
@@ -124,17 +108,17 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
124
108
|
marginRight: 'auto',
|
|
125
109
|
}, children: [_jsx("span", { children: rows.length > 0 &&
|
|
126
110
|
valueFormatter({
|
|
127
|
-
value: rows[0][
|
|
128
|
-
field:
|
|
111
|
+
value: rows[0][report.xAxisField] ?? 0,
|
|
112
|
+
field: report.xAxisField,
|
|
129
113
|
fields: [
|
|
130
114
|
{
|
|
131
|
-
field:
|
|
132
|
-
format:
|
|
133
|
-
label:
|
|
134
|
-
_id:
|
|
115
|
+
field: report.xAxisField,
|
|
116
|
+
format: report.xAxisFormat,
|
|
117
|
+
label: report.xAxisLabel,
|
|
118
|
+
_id: report.id || 'dummy',
|
|
135
119
|
},
|
|
136
120
|
],
|
|
137
|
-
}) }),
|
|
121
|
+
}) }), dateFilter?.comparison && (_jsx("span", { style: {
|
|
138
122
|
fontSize: 13,
|
|
139
123
|
fontWeight: '500',
|
|
140
124
|
fontFamily: theme?.fontFamily,
|
|
@@ -142,7 +126,7 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
142
126
|
marginLeft: 2,
|
|
143
127
|
}, children: primaryMetricLabel
|
|
144
128
|
? `in ${primaryMetricLabel.toLowerCase()}`
|
|
145
|
-
: 'this period' }))] }),
|
|
129
|
+
: 'this period' }))] }), dateFilter?.comparison && (_jsxs("div", { style: {
|
|
146
130
|
display: 'flex',
|
|
147
131
|
gap: 4,
|
|
148
132
|
alignItems: 'baseline',
|
|
@@ -155,14 +139,14 @@ export default function QuillMetricComponent({ report, onClick, error, isLoading
|
|
|
155
139
|
color: theme?.secondaryTextColor,
|
|
156
140
|
}, children: rows.length > 0 &&
|
|
157
141
|
valueFormatter({
|
|
158
|
-
value: rows[0][`comparison_${
|
|
159
|
-
field:
|
|
142
|
+
value: rows[0][`comparison_${report.xAxisField}`] ?? 0,
|
|
143
|
+
field: report.xAxisField,
|
|
160
144
|
fields: [
|
|
161
145
|
{
|
|
162
|
-
field:
|
|
163
|
-
format:
|
|
164
|
-
label:
|
|
165
|
-
_id:
|
|
146
|
+
field: report.xAxisField,
|
|
147
|
+
format: report.xAxisFormat,
|
|
148
|
+
label: report.xAxisLabel,
|
|
149
|
+
_id: report.id || 'dummy',
|
|
166
150
|
},
|
|
167
151
|
],
|
|
168
152
|
}) }), _jsx("span", { style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"TableComponent.d.ts","sourceRoot":"","sources":["../../../../src/components/Dashboard/TableComponent.tsx"],"names":[],"mappings":";AAQA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAKnD,MAAM,CAAC,OAAO,UAAU,mBAAmB,CAAC,EAC1C,MAAM,EACN,OAAO,EACP,SAAS,EACT,KAAK,EACL,YAAY,EACZ,YAAY,GACb,EAAE,gBAAgB,GAAG,GAAG,CAAC,OAAO,CAiJhC"}
|
|
@@ -1,62 +1,34 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useEffect, useState } from 'react';
|
|
3
3
|
import QuillTable from '../QuillTable';
|
|
4
|
-
import { generatePivotTable } from '../../internals/ReportBuilder/PivotModal';
|
|
5
|
-
import { DashboardFiltersContext } from '../../Context';
|
|
6
4
|
import { quillFormat } from '../../utils/valueFormatter';
|
|
7
5
|
import ChartSkeleton from '../Chart/ChartSkeleton';
|
|
8
6
|
import ChartError from '../Chart/ChartError';
|
|
9
7
|
import { useTheme } from '../../hooks';
|
|
10
8
|
import { useExport } from '../../hooks/useExport';
|
|
9
|
+
import { usePivot } from '../../hooks/useQuill';
|
|
11
10
|
export default function QuillTableComponent({ report, onClick, isLoading, error, onPageChange, onSortChange, }) {
|
|
12
11
|
const theme = useTheme();
|
|
13
|
-
const { dashboardFilters } = useContext(DashboardFiltersContext);
|
|
14
12
|
const [initialLoad, setInitialLoad] = useState(true);
|
|
15
13
|
const { downloadCSV } = useExport(report?.id);
|
|
14
|
+
const pivotData = usePivot(report.id);
|
|
15
|
+
const [rows, setRows] = useState(report?.rows ?? []);
|
|
16
|
+
const [columns, setColumns] = useState(report?.columns ?? report?.yAxisFields ?? []);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (report.pivot !== null && pivotData.data) {
|
|
19
|
+
setRows(pivotData.data.rows);
|
|
20
|
+
setColumns(pivotData.data.columns);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
setRows(report?.rows ?? []);
|
|
24
|
+
setColumns(report?.columns ?? report?.yAxisFields ?? []);
|
|
25
|
+
}
|
|
26
|
+
}, [pivotData, report]);
|
|
16
27
|
useEffect(() => {
|
|
17
28
|
if (!isLoading) {
|
|
18
29
|
setInitialLoad(false);
|
|
19
30
|
}
|
|
20
31
|
}, [isLoading]);
|
|
21
|
-
const config = report;
|
|
22
|
-
const data = report;
|
|
23
|
-
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
24
|
-
const pivotTable = useMemo(() => {
|
|
25
|
-
const pivot = config?.pivot;
|
|
26
|
-
const data = config;
|
|
27
|
-
return pivot && data?.rows
|
|
28
|
-
? generatePivotTable(pivot, JSON.parse(JSON.stringify(data.rows)), // deep copy
|
|
29
|
-
dateFilter
|
|
30
|
-
? { start: dateFilter.startDate, end: dateFilter.endDate }
|
|
31
|
-
: undefined, Boolean(dateFilter?.comparisonRange?.startDate), -1, dateFilter?.comparisonRange?.startDate &&
|
|
32
|
-
dateFilter?.comparisonRange?.endDate
|
|
33
|
-
? {
|
|
34
|
-
start: dateFilter.comparisonRange.startDate,
|
|
35
|
-
end: dateFilter.comparisonRange.endDate,
|
|
36
|
-
}
|
|
37
|
-
: undefined)
|
|
38
|
-
: null;
|
|
39
|
-
}, [config?.pivot]);
|
|
40
|
-
const columns = pivotTable?.columns ?? data.columns ?? data.yAxisFields;
|
|
41
|
-
const rows = pivotTable?.rows ?? data.rows ?? [];
|
|
42
|
-
// FOR PIVOTS - ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
43
|
-
const valueFieldType = config?.pivot?.valueFieldType || undefined;
|
|
44
|
-
// Walk through data.columns and pick off the labels from yAxisFields
|
|
45
|
-
columns.forEach((col, index) => {
|
|
46
|
-
// ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
47
|
-
if ((valueFieldType ||
|
|
48
|
-
['min', 'max'].includes(config?.pivot?.aggregationType || '')) &&
|
|
49
|
-
index !== 0) {
|
|
50
|
-
col.format = valueFieldType || 'two_decimal_places';
|
|
51
|
-
}
|
|
52
|
-
if (!data.yAxisFields)
|
|
53
|
-
return;
|
|
54
|
-
const matchingCol = data.yAxisFields.find((c) => c.field === col.field);
|
|
55
|
-
if (!col.label && matchingCol) {
|
|
56
|
-
col.label = matchingCol.label;
|
|
57
|
-
col.format = matchingCol.format;
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
32
|
const formattedRows = rows.map((row) => {
|
|
61
33
|
return columns.reduce((formattedRow, column) => {
|
|
62
34
|
// Apply the format function to each field in the row
|
|
@@ -69,14 +41,15 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
69
41
|
}, {});
|
|
70
42
|
});
|
|
71
43
|
let numberOfRows = undefined;
|
|
72
|
-
if (
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
44
|
+
if (report &&
|
|
45
|
+
report.compareRows &&
|
|
46
|
+
report.compareRows[0] &&
|
|
47
|
+
(report.compareRows[0].count || report.compareRows[0].COUNT)) {
|
|
48
|
+
if (report.compareRows[0].COUNT) {
|
|
49
|
+
numberOfRows = parseInt(report.compareRows[0].COUNT);
|
|
77
50
|
}
|
|
78
|
-
else if (
|
|
79
|
-
numberOfRows = parseInt(
|
|
51
|
+
else if (report.compareRows[0].count) {
|
|
52
|
+
numberOfRows = parseInt(report.compareRows[0].count);
|
|
80
53
|
}
|
|
81
54
|
}
|
|
82
55
|
return (_jsxs("div", { style: { cursor: 'pointer' }, onClick: () => onClick && onClick(report), children: [_jsxs("div", { style: {
|
|
@@ -98,7 +71,7 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
98
71
|
display: 'block',
|
|
99
72
|
maxWidth: '100%',
|
|
100
73
|
overflow: 'hidden',
|
|
101
|
-
}, children: report?.name }), onClick ? (_jsx("div", { style: {
|
|
74
|
+
}, children: report?.name }), onClick && report?.name ? (_jsx("div", { style: {
|
|
102
75
|
fontFamily: theme.fontFamily,
|
|
103
76
|
color: theme.primaryTextColor,
|
|
104
77
|
boxSizing: 'content-box',
|
|
@@ -114,7 +87,7 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
114
87
|
} })) : error ? (_jsx(ChartError, { containerStyle: {
|
|
115
88
|
width: '100%',
|
|
116
89
|
height: '400px',
|
|
117
|
-
} })) : (_jsx(QuillTable, { isLoading: isLoading, rows: formattedRows ?? [], numberOfRows: numberOfRows, columns: columns
|
|
90
|
+
} })) : (_jsx(QuillTable, { isLoading: isLoading, rows: formattedRows ?? [], numberOfRows: numberOfRows, columns: columns, rowsPerPage: 10, containerStyle: {
|
|
118
91
|
width: '100%',
|
|
119
92
|
height: '400px',
|
|
120
93
|
}, downloadCSV: () => {
|
|
@@ -123,5 +96,5 @@ export default function QuillTableComponent({ report, onClick, isLoading, error,
|
|
|
123
96
|
onPageChange && onPageChange(page);
|
|
124
97
|
}, onSortChange: (sort) => {
|
|
125
98
|
onSortChange && onSortChange(sort);
|
|
126
|
-
}, currentPage:
|
|
99
|
+
}, currentPage: report?.page, sort: report?.sort }))] }, report?.name));
|
|
127
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,kBAAmB,MAAM;;;;qCASF,MAAM;
|
|
1
|
+
{"version":3,"file":"useDashboard.d.ts","sourceRoot":"","sources":["../../../src/hooks/useDashboard.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,YAAY,kBAAmB,MAAM;;;;qCASF,MAAM;CAkDrD,CAAC"}
|
|
@@ -13,9 +13,9 @@ export const useDashboard = (dashboardName) => {
|
|
|
13
13
|
getDashboards(overrideDashboardName ?? dashboardName);
|
|
14
14
|
};
|
|
15
15
|
async function getDashboards(dashboardName) {
|
|
16
|
+
setIsLoading(true);
|
|
16
17
|
if (dashboardName === null || dashboardName === undefined)
|
|
17
18
|
return;
|
|
18
|
-
setIsLoading(true);
|
|
19
19
|
const { databaseType, publicKey, customerId } = client;
|
|
20
20
|
try {
|
|
21
21
|
const searchParams = new URLSearchParams({
|
|
@@ -34,14 +34,15 @@ export const useDashboard = (dashboardName) => {
|
|
|
34
34
|
};
|
|
35
35
|
const resp = await getData(client, `dashconfig?${searchParams}`, 'omit', hostedBody, null, 'GET');
|
|
36
36
|
setData(resp);
|
|
37
|
+
setIsLoading(false);
|
|
37
38
|
setError(null);
|
|
38
39
|
}
|
|
39
40
|
catch (error) {
|
|
40
41
|
setError(null);
|
|
42
|
+
setIsLoading(false);
|
|
41
43
|
setError(error);
|
|
42
44
|
console.error('Error fetching data:', error);
|
|
43
45
|
}
|
|
44
|
-
setIsLoading(false);
|
|
45
46
|
}
|
|
46
47
|
useEffect(() => {
|
|
47
48
|
getDashboards(dashboardName);
|
|
@@ -43,5 +43,12 @@ export declare const useQuill: (reportId?: string) => {
|
|
|
43
43
|
loading: boolean;
|
|
44
44
|
error: string | null;
|
|
45
45
|
};
|
|
46
|
+
export declare const usePivot: (reportId?: string) => {
|
|
47
|
+
data: {
|
|
48
|
+
rows: any[];
|
|
49
|
+
columns: Column[];
|
|
50
|
+
} | undefined;
|
|
51
|
+
error: string | undefined;
|
|
52
|
+
};
|
|
46
53
|
export {};
|
|
47
54
|
//# sourceMappingURL=useQuill.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useQuill.d.ts","sourceRoot":"","sources":["../../../src/hooks/useQuill.ts"],"names":[],"mappings":"AAWA,UAAU,MAAM;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GA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AC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B;AAED,eAAO,MAAM,QAAQ,cACR,MAAM;UAEX,WAAW,GAAG,IAAI;aACf,OAAO;WACT,MAAM,GAAG,IAAI;CAkGrB,CAAC;AAaF,eAAO,MAAM,QAAQ,cACR,MAAM;UAEX;QAAE,IAAI,EAAE,GAAG,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,SAAS;WAC7C,MAAM,GAAG,SAAS;CA4C1B,CAAC"}
|
|
@@ -24,6 +24,10 @@ export const useQuill = (reportId) => {
|
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
|
+
const specificDashboardFilter = dashboardFilters.filter((f) => f &&
|
|
28
|
+
reportId &&
|
|
29
|
+
dashboard[definedReportId] &&
|
|
30
|
+
dashboard[definedReportId].dashboardName === f.dashboardName);
|
|
27
31
|
setLoading(true);
|
|
28
32
|
const hostedBody = {
|
|
29
33
|
metadata: {
|
|
@@ -32,7 +36,7 @@ export const useQuill = (reportId) => {
|
|
|
32
36
|
clientId: client.publicKey,
|
|
33
37
|
task: 'item',
|
|
34
38
|
filters: [
|
|
35
|
-
...Object.values(
|
|
39
|
+
...Object.values(specificDashboardFilter).filter((elem) => elem
|
|
36
40
|
?.dashboardName === data?.dashboardName),
|
|
37
41
|
],
|
|
38
42
|
databaseType: client?.databaseType,
|
|
@@ -41,7 +45,7 @@ export const useQuill = (reportId) => {
|
|
|
41
45
|
};
|
|
42
46
|
const cloudBody = {
|
|
43
47
|
id: reportId,
|
|
44
|
-
filters: [...Object.values(
|
|
48
|
+
filters: [...Object.values(specificDashboardFilter)],
|
|
45
49
|
};
|
|
46
50
|
const resp = await getData(client, 'itempost', 'same-origin', hostedBody, cloudBody);
|
|
47
51
|
processFilterErrorList(resp);
|
|
@@ -57,7 +61,7 @@ export const useQuill = (reportId) => {
|
|
|
57
61
|
dispatch({
|
|
58
62
|
type: 'UPDATE_DASHBOARD_ITEM',
|
|
59
63
|
id: reportId,
|
|
60
|
-
data: { ...resp, filtersApplied:
|
|
64
|
+
data: { ...resp, filtersApplied: specificDashboardFilter },
|
|
61
65
|
});
|
|
62
66
|
}
|
|
63
67
|
}
|
|
@@ -94,3 +98,37 @@ function stringifyIfObject(e) {
|
|
|
94
98
|
}
|
|
95
99
|
return e; // returns the input as is for other types
|
|
96
100
|
}
|
|
101
|
+
export const usePivot = (reportId) => {
|
|
102
|
+
const { dashboard } = useContext(DashboardContext);
|
|
103
|
+
const [data, setData] = useState(undefined);
|
|
104
|
+
const [error, setError] = useState(undefined);
|
|
105
|
+
useEffect(() => {
|
|
106
|
+
if (!reportId ||
|
|
107
|
+
!dashboard ||
|
|
108
|
+
!dashboard[reportId] ||
|
|
109
|
+
!dashboard[reportId].pivotColumns ||
|
|
110
|
+
!dashboard[reportId].pivotRows) {
|
|
111
|
+
setError('No data found');
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
setData({
|
|
115
|
+
rows: dashboard[reportId].pivotRows,
|
|
116
|
+
columns: dashboard[reportId].pivotColumns
|
|
117
|
+
.map((col, index) => {
|
|
118
|
+
if (index === 0) {
|
|
119
|
+
return {
|
|
120
|
+
...col,
|
|
121
|
+
format: 'string',
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
...col,
|
|
126
|
+
format: dashboard[reportId].yAxisFields[0].format,
|
|
127
|
+
};
|
|
128
|
+
})
|
|
129
|
+
.filter((col) => dashboard[reportId].chartType !== 'table' ||
|
|
130
|
+
!col.field.startsWith('comparison_')),
|
|
131
|
+
});
|
|
132
|
+
}, [dashboard, reportId]);
|
|
133
|
+
return { data, error };
|
|
134
|
+
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export { default as ChartEditor } from './ChartEditor';
|
|
|
14
14
|
export type { ChartEditorProps } from './ChartEditor';
|
|
15
15
|
export { quillFormat as format } from './utils/valueFormatter';
|
|
16
16
|
export { useDashboard } from './hooks/useDashboard';
|
|
17
|
-
export { useQuill } from './hooks/useQuill';
|
|
17
|
+
export { useQuill, usePivot } from './hooks/useQuill';
|
|
18
18
|
export { useExport } from './hooks/useExport';
|
|
19
19
|
export { useMemoizedRows } from './hooks/useFormat';
|
|
20
20
|
export { downloadCSV } from './utils/csv';
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,WAAW,EACX,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACtE,O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M,yBAAyB,CAAC;AACnE,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,SAAS,GACV,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export { default as ReportBuilder } from './ReportBuilder';
|
|
|
8
8
|
export { default as ChartEditor } from './ChartEditor';
|
|
9
9
|
export { quillFormat as format } from './utils/valueFormatter';
|
|
10
10
|
export { useDashboard } from './hooks/useDashboard';
|
|
11
|
-
export { useQuill } from './hooks/useQuill';
|
|
11
|
+
export { useQuill, usePivot } from './hooks/useQuill';
|
|
12
12
|
export { useExport } from './hooks/useExport';
|
|
13
13
|
export { useMemoizedRows } from './hooks/useFormat';
|
|
14
14
|
export { downloadCSV } from './utils/csv';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotList.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotList.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PivotList.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotList.tsx"],"names":[],"mappings":"AAQA,KAAK,cAAc,GAAG;IACpB,UAAU,EAAE,GAAG,CAAC;IAChB,KAAK,EAAE,GAAG,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,eAAe,EAAE,GAAG,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MA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leCase } from '../../utils/textProcessing';
|
|
3
|
+
import { snakeAndCamelCaseToTitleCase, } from '../../utils/textProcessing';
|
|
4
4
|
import { QuillCard } from '../../components/QuillCard';
|
|
5
5
|
export const PivotCard = ({ pivotTable, theme, index, onSelectPivot, selectedPivotIndex, onEditPivot, ButtonComponent, showEdit = false, clickable = true, onClose, minHeight = 0, CardComponent = QuillCard, LabelComponent, TextComponent, HeaderComponent, }) => {
|
|
6
6
|
const maxRowsInPivotPeak = 5;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ButtonComponentProps } from '../../components/UiComponents';
|
|
3
3
|
import { ColumnInternal } from '../../models/Columns';
|
|
4
|
+
import { AxisFormat } from '../../Dashboard';
|
|
4
5
|
export interface Pivot {
|
|
5
6
|
rowField: string;
|
|
6
7
|
rowFieldType: string;
|
|
@@ -91,11 +92,15 @@ export declare const PivotModal: ({ pivotRowField, setPivotRowField, pivotColumn
|
|
|
91
92
|
export declare function generatePivotTableYAxis(pivot: Pivot, cols: {
|
|
92
93
|
label: string;
|
|
93
94
|
field: string;
|
|
94
|
-
}[],
|
|
95
|
+
}[], yAxisField: {
|
|
95
96
|
field: string;
|
|
96
97
|
label: string;
|
|
97
|
-
format:
|
|
98
|
-
}
|
|
98
|
+
format: AxisFormat;
|
|
99
|
+
}): {
|
|
100
|
+
field: string;
|
|
101
|
+
label: string;
|
|
102
|
+
format: AxisFormat;
|
|
103
|
+
}[];
|
|
99
104
|
export declare function generatePivotTitle(pivot: Pivot): string;
|
|
100
105
|
export declare function isDateField(fieldType: string): boolean;
|
|
101
106
|
export declare function generatePivotTable(pivot: Pivot, data: any, dateRange: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PivotModal.d.ts","sourceRoot":"","sources":["../../../../src/internals/ReportBuilder/PivotModal.tsx"],"names":[],"mappings":"AAAA,OAAc,EAOZ,SAAS,EACV,MAAM,OAAO,CAAC;AAuBf,OAAO,E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BAAkB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,CAiBvD;AA0MD,wBAAgB,WAAW,CAAC,SAAS,EAAE,MAAM,WAY5C;AAgCD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,GAAG,EACT,SAAS,EAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAS,EACjD,YAAY,EAAE,OAAO,EACrB,QAAQ,SAAK,EACb,SAAS,GAAE;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,GAAG,SAAqB,EAC7D,UAAU,CAAC,EAAE,MAAM;;;;;;EAqdpB"}
|
|
@@ -498,11 +498,25 @@ export const PivotModal = ({ pivotRowField, setPivotRowField, pivotColumnField,
|
|
|
498
498
|
gap: 8,
|
|
499
499
|
}, children: [_jsx(SecondaryButtonComponent, { label: "Regenerate", onClick: refreshPivots, icon: _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" }) }) }), _jsx(SecondaryButtonComponent, { label: "Create pivot +", onClick: () => onEditPivot({}, null) })] }), isLoading ? (_jsx(LoadingComponent, {})) : (_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, showPivotEditButton: showPivotEditButton, LabelComponent: LabelComponent, TextComponent: TextComponent, CardComponent: CardComponent }) }))] })) })) }) }) })] }) }));
|
|
500
500
|
};
|
|
501
|
-
export function generatePivotTableYAxis(pivot, cols,
|
|
502
|
-
|
|
503
|
-
|
|
501
|
+
export function generatePivotTableYAxis(pivot, cols, yAxisField) {
|
|
502
|
+
// For count aggregations, use 'count' for the label
|
|
503
|
+
if (pivot?.aggregationType === 'count') {
|
|
504
|
+
return [
|
|
505
|
+
{
|
|
506
|
+
field: pivot.valueField || 'count',
|
|
507
|
+
label: yAxisField.label,
|
|
508
|
+
format: yAxisField.format,
|
|
509
|
+
},
|
|
510
|
+
];
|
|
504
511
|
}
|
|
505
|
-
|
|
512
|
+
// otherwise use the default (ie. the field label)
|
|
513
|
+
return [
|
|
514
|
+
{
|
|
515
|
+
field: pivot.valueField,
|
|
516
|
+
label: yAxisField.label,
|
|
517
|
+
format: yAxisField.format,
|
|
518
|
+
},
|
|
519
|
+
];
|
|
506
520
|
}
|
|
507
521
|
export function generatePivotTitle(pivot) {
|
|
508
522
|
if (pivot.rowField && !pivot.valueField) {
|
|
@@ -1015,11 +1029,7 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
1015
1029
|
? 'Null'
|
|
1016
1030
|
: column === false
|
|
1017
1031
|
? 'False'
|
|
1018
|
-
:
|
|
1019
|
-
!pivot.columnField &&
|
|
1020
|
-
index === 1
|
|
1021
|
-
? 'Count'
|
|
1022
|
-
: snakeAndCamelCaseToTitleCase(columnName),
|
|
1032
|
+
: snakeAndCamelCaseToTitleCase(columnName).replace('Comparison', 'comparison'),
|
|
1023
1033
|
field: columnName,
|
|
1024
1034
|
};
|
|
1025
1035
|
}),
|
|
@@ -1036,9 +1046,9 @@ export function generatePivotTable(pivot, data, dateRange, isComparison, rowLimi
|
|
|
1036
1046
|
: pivot.aggregationType === 'count' &&
|
|
1037
1047
|
!pivot.columnField &&
|
|
1038
1048
|
index === 1
|
|
1039
|
-
?
|
|
1049
|
+
? `comparison Count`
|
|
1040
1050
|
: isDateField(pivot.columnFieldType || '')
|
|
1041
|
-
? COL_DATE_MAP[getDateString(column, dateRange, dateBucket)] ?? '
|
|
1051
|
+
? COL_DATE_MAP[getDateString(column, dateRange, dateBucket)] ?? 'comparison'
|
|
1042
1052
|
: `comparison ${snakeAndCamelCaseToTitleCase(columnName)}`,
|
|
1043
1053
|
field: `comparison_${columnName}`,
|
|
1044
1054
|
};
|
|
@@ -1121,6 +1131,8 @@ function valueFieldAggregation(data, valueField, aggregationType, isComparison)
|
|
|
1121
1131
|
}
|
|
1122
1132
|
return {
|
|
1123
1133
|
rows: [row],
|
|
1124
|
-
columns: [
|
|
1134
|
+
columns: [
|
|
1135
|
+
{ label: snakeAndCamelCaseToTitleCase(valueField), field: valueField },
|
|
1136
|
+
],
|
|
1125
1137
|
};
|
|
1126
1138
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../src/utils/aggregate.tsx"],"names":[],"mappings":"AA2DA,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,UAuCpD;AAED,wBAAgB,UAAU,CAAC,aAAa,KAAA,EAAE,YAAY,KAAA,EAAE,UAAU,KAAA,
|
|
1
|
+
{"version":3,"file":"aggregate.d.ts","sourceRoot":"","sources":["../../../src/utils/aggregate.tsx"],"names":[],"mappings":"AA2DA,wBAAgB,qBAAqB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,UAuCpD;AAED,wBAAgB,UAAU,CAAC,aAAa,KAAA,EAAE,YAAY,KAAA,EAAE,UAAU,KAAA,OA+IjE;AACD,wBAAgB,SAAS,CAAC,aAAa,KAAA,EAAE,YAAY,KAAA,EAAE,UAAU,KAAA,OAmRhE"}
|
|
@@ -113,10 +113,6 @@ export function aggregate2(dashboardItem, bucketFields, dateFilter) {
|
|
|
113
113
|
[stringField]: str,
|
|
114
114
|
[dashboardItem.yAxisFields[0].field]: aggregation[str][dashboardItem.yAxisFields[0].field].toFixed(2),
|
|
115
115
|
}));
|
|
116
|
-
// } else {
|
|
117
|
-
// console.log('should be in here');
|
|
118
|
-
// aggregatedArray = [];
|
|
119
|
-
// }
|
|
120
116
|
return {
|
|
121
117
|
...dashboardItem,
|
|
122
118
|
xAxisField: stringField,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { QuillReportInternal } from '../Dashboard';
|
|
2
2
|
/**
|
|
3
3
|
* Returns a cleaned version of the dashboard item we store in state. We clean
|
|
4
4
|
* the dashboard item so that we aren't exposing unnecessary details to the
|
|
@@ -8,5 +8,5 @@ import { QuillReport } from '../Dashboard';
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function cleanDashboardItem(item: {
|
|
10
10
|
[key: string]: any;
|
|
11
|
-
} | undefined, dashboardFilters: any):
|
|
11
|
+
} | undefined, dashboardFilters: any): QuillReportInternal;
|
|
12
12
|
//# sourceMappingURL=dashboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../../src/utils/dashboard.ts"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"dashboard.d.ts","sourceRoot":"","sources":["../../../src/utils/dashboard.ts"],"names":[],"mappings":"AACA,OAAO,EAA2B,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA6B5E;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG,SAAS,EACxC,gBAAgB,EAAE,GAAG,GACpB,mBAAmB,CA0CrB"}
|