@quillsql/react 2.12.30 → 2.12.32
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 +6 -37
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +86 -327
- package/dist/cjs/ChartBuilder.d.ts +12 -49
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +68 -36
- package/dist/cjs/ChartEditor.d.ts +1 -1
- package/dist/cjs/ChartEditor.d.ts.map +1 -1
- package/dist/cjs/ChartEditor.js +11 -7
- package/dist/cjs/Context.d.ts +4 -1
- package/dist/cjs/Context.d.ts.map +1 -1
- package/dist/cjs/Context.js +10 -4
- package/dist/cjs/Dashboard.d.ts +61 -114
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +261 -30
- package/dist/cjs/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/cjs/DateRangePicker/DateRangePicker.js +0 -26
- package/dist/cjs/ReportBuilder.d.ts +1 -1
- package/dist/cjs/ReportBuilder.d.ts.map +1 -1
- package/dist/cjs/ReportBuilder.js +62 -97
- package/dist/cjs/SQLEditor.d.ts +2 -2
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +10 -5
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +41 -43
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/cjs/components/Chart/BarChart.js +12 -1
- 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 +25 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts +7 -7
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +64 -28
- package/dist/cjs/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/MetricComponent.js +11 -45
- 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 +1 -30
- package/dist/cjs/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillMultiSelectWithCombo.js +16 -1
- package/dist/cjs/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/cjs/components/QuillSelectWithCombo.js +4 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts +10 -2
- package/dist/cjs/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/FilterModal.js +94 -70
- package/dist/cjs/components/ReportBuilder/convert.d.ts +7 -2
- package/dist/cjs/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/convert.js +53 -1
- package/dist/cjs/components/ReportBuilder/ui.d.ts +6 -6
- package/dist/cjs/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/cjs/components/ReportBuilder/ui.js +6 -22
- package/dist/cjs/components/UiComponents.d.ts +26 -1
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +97 -4
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/hooks/useQuill.js +19 -3
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -0
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/models/Columns.d.ts +2 -1
- package/dist/cjs/models/Columns.d.ts.map +1 -1
- package/dist/cjs/models/Filter.d.ts +15 -4
- package/dist/cjs/models/Filter.d.ts.map +1 -1
- package/dist/cjs/models/Filter.js +9 -1
- package/dist/cjs/models/Report.d.ts +10 -23
- package/dist/cjs/models/Report.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/astFilterProcessing.js +37 -2
- package/dist/cjs/utils/columnProcessing.d.ts +2 -0
- package/dist/cjs/utils/columnProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/columnProcessing.js +54 -1
- package/dist/cjs/utils/dashboard.d.ts +1 -1
- package/dist/cjs/utils/dashboard.d.ts.map +1 -1
- package/dist/cjs/utils/dashboard.js +3 -56
- package/dist/cjs/utils/dataProcessing.d.ts +4 -2
- package/dist/cjs/utils/dataProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/dataProcessing.js +18 -1
- package/dist/cjs/utils/dates.d.ts +2 -1
- package/dist/cjs/utils/dates.d.ts.map +1 -1
- package/dist/cjs/utils/dates.js +23 -1
- package/dist/cjs/utils/filterProcessing.d.ts +7 -1
- package/dist/cjs/utils/filterProcessing.d.ts.map +1 -1
- package/dist/cjs/utils/filterProcessing.js +100 -13
- package/dist/cjs/utils/pivotConstructor.d.ts +2 -1
- package/dist/cjs/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/cjs/utils/pivotConstructor.js +7 -1
- package/dist/cjs/utils/report.d.ts +4 -1
- package/dist/cjs/utils/report.d.ts.map +1 -1
- package/dist/cjs/utils/report.js +94 -7
- package/dist/cjs/utils/tableProcessing.d.ts +1 -1
- package/dist/esm/Chart.d.ts +6 -37
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +87 -329
- package/dist/esm/ChartBuilder.d.ts +12 -49
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +68 -33
- package/dist/esm/ChartEditor.d.ts +1 -1
- package/dist/esm/ChartEditor.d.ts.map +1 -1
- package/dist/esm/ChartEditor.js +11 -7
- package/dist/esm/Context.d.ts +4 -1
- package/dist/esm/Context.d.ts.map +1 -1
- package/dist/esm/Context.js +9 -3
- package/dist/esm/Dashboard.d.ts +61 -114
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +263 -32
- package/dist/esm/DateRangePicker/DateRangePicker.d.ts.map +1 -1
- package/dist/esm/DateRangePicker/DateRangePicker.js +0 -26
- package/dist/esm/ReportBuilder.d.ts +1 -1
- package/dist/esm/ReportBuilder.d.ts.map +1 -1
- package/dist/esm/ReportBuilder.js +64 -99
- package/dist/esm/SQLEditor.d.ts +2 -2
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +11 -6
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +42 -44
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- package/dist/esm/components/Chart/BarChart.js +13 -2
- 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 +26 -2
- package/dist/esm/components/Dashboard/DataLoader.d.ts +7 -7
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +65 -29
- package/dist/esm/components/Dashboard/MetricComponent.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/MetricComponent.js +11 -45
- 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 +1 -30
- package/dist/esm/components/QuillMultiSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillMultiSelectWithCombo.js +16 -1
- package/dist/esm/components/QuillSelectWithCombo.d.ts.map +1 -1
- package/dist/esm/components/QuillSelectWithCombo.js +5 -2
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts +10 -2
- package/dist/esm/components/ReportBuilder/FilterModal.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/FilterModal.js +94 -70
- package/dist/esm/components/ReportBuilder/convert.d.ts +7 -2
- package/dist/esm/components/ReportBuilder/convert.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/convert.js +51 -0
- package/dist/esm/components/ReportBuilder/ui.d.ts +6 -6
- package/dist/esm/components/ReportBuilder/ui.d.ts.map +1 -1
- package/dist/esm/components/ReportBuilder/ui.js +6 -22
- package/dist/esm/components/UiComponents.d.ts +26 -1
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +95 -3
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/hooks/useQuill.js +19 -3
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -0
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/models/Columns.d.ts +2 -1
- package/dist/esm/models/Columns.d.ts.map +1 -1
- package/dist/esm/models/Filter.d.ts +15 -4
- package/dist/esm/models/Filter.d.ts.map +1 -1
- package/dist/esm/models/Filter.js +8 -0
- package/dist/esm/models/Report.d.ts +10 -23
- package/dist/esm/models/Report.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/astFilterProcessing.js +38 -3
- package/dist/esm/utils/columnProcessing.d.ts +2 -0
- package/dist/esm/utils/columnProcessing.d.ts.map +1 -1
- package/dist/esm/utils/columnProcessing.js +52 -0
- package/dist/esm/utils/dashboard.d.ts +1 -1
- package/dist/esm/utils/dashboard.d.ts.map +1 -1
- package/dist/esm/utils/dashboard.js +3 -56
- package/dist/esm/utils/dataProcessing.d.ts +4 -2
- package/dist/esm/utils/dataProcessing.d.ts.map +1 -1
- package/dist/esm/utils/dataProcessing.js +16 -0
- package/dist/esm/utils/dates.d.ts +2 -1
- package/dist/esm/utils/dates.d.ts.map +1 -1
- package/dist/esm/utils/dates.js +21 -0
- package/dist/esm/utils/filterProcessing.d.ts +7 -1
- package/dist/esm/utils/filterProcessing.d.ts.map +1 -1
- package/dist/esm/utils/filterProcessing.js +97 -12
- package/dist/esm/utils/pivotConstructor.d.ts +2 -1
- package/dist/esm/utils/pivotConstructor.d.ts.map +1 -1
- package/dist/esm/utils/pivotConstructor.js +7 -1
- package/dist/esm/utils/report.d.ts +4 -1
- package/dist/esm/utils/report.d.ts.map +1 -1
- package/dist/esm/utils/report.js +92 -6
- package/dist/esm/utils/tableProcessing.d.ts +1 -1
- package/package.json +1 -1
- package/dist/esm/components/ReportBuilder/convert.uspec.d.ts +0 -2
- package/dist/esm/components/ReportBuilder/convert.uspec.d.ts.map +0 -1
- package/dist/esm/components/ReportBuilder/convert.uspec.js +0 -1152
- package/dist/esm/utils/astFilterProcessing.uspec.d.ts +0 -2
- package/dist/esm/utils/astFilterProcessing.uspec.d.ts.map +0 -1
- package/dist/esm/utils/astFilterProcessing.uspec.js +0 -2729
- package/dist/esm/utils/dataProcessing.uspec.d.ts +0 -2
- package/dist/esm/utils/dataProcessing.uspec.d.ts.map +0 -1
- package/dist/esm/utils/dataProcessing.uspec.js +0 -204
- package/dist/esm/utils/queryConstructor.uspec.d.ts +0 -2
- package/dist/esm/utils/queryConstructor.uspec.d.ts.map +0 -1
- package/dist/esm/utils/queryConstructor.uspec.js +0 -223
- package/dist/esm/utils/report.ispec.d.ts +0 -2
- package/dist/esm/utils/report.ispec.d.ts.map +0 -1
- package/dist/esm/utils/report.ispec.js +0 -46
- package/dist/esm/utils/tableProcessing.ispec.d.ts +0 -2
- package/dist/esm/utils/tableProcessing.ispec.d.ts.map +0 -1
- package/dist/esm/utils/tableProcessing.ispec.js +0 -61
package/dist/cjs/Chart.js
CHANGED
|
@@ -12,13 +12,10 @@ const BarList_1 = __importDefault(require("./components/Chart/BarList"));
|
|
|
12
12
|
const PieChart_1 = __importDefault(require("./components/Chart/PieChart"));
|
|
13
13
|
const Context_1 = require("./Context");
|
|
14
14
|
const QuillTable_1 = __importDefault(require("./components/QuillTable"));
|
|
15
|
-
const valueFormatter_1 = require("./utils/valueFormatter");
|
|
16
15
|
const LineChart_1 = __importDefault(require("./components/Chart/LineChart"));
|
|
17
16
|
const BarChart_1 = __importDefault(require("./components/Chart/BarChart"));
|
|
18
17
|
const ChartSkeleton_1 = require("./components/Chart/ChartSkeleton");
|
|
19
18
|
const ChartError_1 = __importDefault(require("./components/Chart/ChartError"));
|
|
20
|
-
const dateRangePickerUtils_1 = require("./DateRangePicker/dateRangePickerUtils");
|
|
21
|
-
const valueFormatter_2 = require("./utils/valueFormatter");
|
|
22
19
|
const useTheme_1 = __importDefault(require("./hooks/useTheme"));
|
|
23
20
|
const filterProcessing_1 = require("./utils/filterProcessing");
|
|
24
21
|
const UiComponents_1 = require("./components/UiComponents");
|
|
@@ -29,6 +26,7 @@ const QuillDateRangePicker_1 = require("./DateRangePicker/QuillDateRangePicker")
|
|
|
29
26
|
const report_1 = require("./utils/report");
|
|
30
27
|
const paginationProcessing_1 = require("./utils/paginationProcessing");
|
|
31
28
|
const tableProcessing_1 = require("./utils/tableProcessing");
|
|
29
|
+
const MetricComponent_1 = __importDefault(require("./components/Dashboard/MetricComponent"));
|
|
32
30
|
const MAX_ROWS_FOR_GENERIC_TABLE = 500;
|
|
33
31
|
// @ts-ignore
|
|
34
32
|
function sumByKey(arr, key) {
|
|
@@ -52,6 +50,15 @@ function isEquivalent(filters1, filters2) {
|
|
|
52
50
|
return false;
|
|
53
51
|
}
|
|
54
52
|
const filter2 = filters2[i];
|
|
53
|
+
if (filter1.isUserFilter !== filter2.isUserFilter) {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
else if (filter1.isUserFilter) {
|
|
57
|
+
if (filter1.operator !== filter2.operator ||
|
|
58
|
+
filter1.value !== filter2.value) {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
55
62
|
const filterType = filter2.filterType;
|
|
56
63
|
if (filterType === 'string') {
|
|
57
64
|
if (filter1.stringFilterType === 'multiselect') {
|
|
@@ -123,49 +130,8 @@ function didFiltersChange(dashboardItem, filters) {
|
|
|
123
130
|
return !isEquivalent(dashboardItem.filtersApplied, filters);
|
|
124
131
|
}
|
|
125
132
|
exports.didFiltersChange = didFiltersChange;
|
|
126
|
-
function
|
|
127
|
-
|
|
128
|
-
return {};
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* ### Quill Chart
|
|
132
|
-
*
|
|
133
|
-
* A simple component that displays the given data in one of many chart types.
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```js
|
|
137
|
-
* // Usage with chart id (will auto-fetch data)
|
|
138
|
-
* <Chart reportId="12345" />
|
|
139
|
-
* ```
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```js
|
|
143
|
-
* // Usage with a report (will not auto-fetch data)
|
|
144
|
-
* <Chart config={report} />
|
|
145
|
-
* ```
|
|
146
|
-
*
|
|
147
|
-
* ### Chart API
|
|
148
|
-
* @see https://docs.quillsql.com/components/chart
|
|
149
|
-
*/
|
|
150
|
-
const Chart = (props) => {
|
|
151
|
-
// Cast the props to the internal version so we can use the inherited types.
|
|
152
|
-
const data = props;
|
|
153
|
-
if ('config' in data) {
|
|
154
|
-
const isLoading = Boolean(!data.config);
|
|
155
|
-
return ((0, jsx_runtime_1.jsx)(exports.ChartDisplay, { ...data, loading: isLoading, onClickChartElement: props.onClickChartElement }));
|
|
156
|
-
}
|
|
157
|
-
const theme = (0, useTheme_1.default)();
|
|
158
|
-
const chartColors = (0, react_1.useMemo)(() => {
|
|
159
|
-
return data.colors?.length
|
|
160
|
-
? data.colors
|
|
161
|
-
: theme && theme.chartColors.length
|
|
162
|
-
? theme.chartColors
|
|
163
|
-
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
164
|
-
}, [data.colors]);
|
|
165
|
-
return ((0, jsx_runtime_1.jsx)(ChartUpdater, { reportId: data.reportId, className: data.className, containerStyle: data.containerStyle, colors: chartColors, isAnimationActive: data.isAnimationActive, hideXAxis: data.hideXAxis, hideYAxis: data.hideYAxis, hideCartesianGrid: data.hideCartesianGrid, hideHorizontalCartesianGrid: data.hideHorizontalCartesianGrid, hideVerticalCartesianGrid: data.hideVerticalCartesianGrid, hideSubsequentXAxisTicks: data.hideSubsequentXAxisTicks, hideDateRangeFilter: data.hideDateRangeFilter, cartesianGridLineStyle: data.cartesianGridLineStyle, cartesianGridLineColor: data.cartesianGridLineColor, comparisonLineStyle: data.comparisonLineStyle, mapColorsToFields: data.mapColorsToFields ?? fallbackMapColorsToFields, LoadingComponent: data.LoadingComponent, filters: data.filters, onClickChartElement: props.onClickChartElement, SelectComponent: data.SelectComponent, MultiSelectComponent: data.MultiSelectComponent, DateRangePickerComponent: data.DateRangePickerComponent, FilterContainerComponent: data.FilterContainerComponent, hideFilters: data.hideFilters }));
|
|
166
|
-
};
|
|
167
|
-
const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, hideDateRangeFilter = false, hideFilters = false, mapColorsToFields, LoadingComponent = ChartSkeleton_1.QuillLoadingSkeleton, SelectComponent = QuillSelect_1.QuillSelectComponent, MultiSelectComponent = QuillMultiSelect_1.QuillMultiSelectComponent, DateRangePickerComponent = QuillDateRangePicker_1.QuillDateRangePicker, FilterContainerComponent = UiComponents_1.QuillFilterContainerComponent, filters, onClickChartElement, }) => {
|
|
168
|
-
const { dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
133
|
+
function Chart({ colors, reportId, className, containerStyle, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, hideDateRangeFilter = false, hideFilters = false, mapColorsToFields, LoadingComponent = ChartSkeleton_1.QuillLoadingSkeleton, SelectComponent = QuillSelect_1.QuillSelectComponent, MultiSelectComponent = QuillMultiSelect_1.QuillMultiSelectComponent, DateRangePickerComponent = QuillDateRangePicker_1.QuillDateRangePicker, FilterContainerComponent = UiComponents_1.QuillFilterContainerComponent, filters, onClickChartElement, dateBucket, }) {
|
|
134
|
+
const [dashboard] = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
169
135
|
const { reportFiltersDispatch, reportFilters } = (0, react_1.useContext)(Context_1.ReportFiltersContext);
|
|
170
136
|
const [initialLoad, setInitialLoad] = (0, react_1.useState)(true);
|
|
171
137
|
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
@@ -178,10 +144,10 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
178
144
|
page: 0,
|
|
179
145
|
});
|
|
180
146
|
const [report, setReport] = (0, react_1.useState)(undefined);
|
|
181
|
-
const [dateFilter, setDateFilter] = (0, react_1.useState)(undefined);
|
|
182
147
|
const [chartFilters, setChartFilters] = (0, react_1.useState)([]);
|
|
183
148
|
const [previousPage, setPreviousPage] = (0, react_1.useState)(0);
|
|
184
149
|
const [filterUpdateIndex, setFilterUpdateIndex] = (0, react_1.useState)(-1);
|
|
150
|
+
const [previousDateBucket, setPreviousDateBucket] = (0, react_1.useState)(undefined);
|
|
185
151
|
const theme = (0, useTheme_1.default)();
|
|
186
152
|
const onPageChange = (page) => {
|
|
187
153
|
if (additionalProcessing.page &&
|
|
@@ -233,45 +199,44 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
233
199
|
}
|
|
234
200
|
};
|
|
235
201
|
const fetchReportHelper = async (useReportTask = true, reportFilterInfo, processing) => {
|
|
202
|
+
const tempReport = dashboard[reportId];
|
|
236
203
|
const allowDateRange = !hideDateRangeFilter;
|
|
237
204
|
const minimalFilters = Object.values(reportFilterInfo.filters).length
|
|
238
205
|
? Object.values(reportFilterInfo.filters)
|
|
239
206
|
.filter((f) => allowDateRange || f.filterType !== 'date_range')
|
|
240
207
|
.map((filter) => {
|
|
241
208
|
const newFilter = { ...filter };
|
|
242
|
-
if (newFilter.filterType === 'date_range') {
|
|
243
|
-
delete newFilter['field'];
|
|
244
|
-
delete newFilter['options'];
|
|
245
|
-
delete newFilter['selectedValue'];
|
|
246
|
-
}
|
|
247
209
|
return newFilter;
|
|
248
210
|
})
|
|
249
211
|
: [];
|
|
250
|
-
if (!didFiltersChange(
|
|
212
|
+
if (!didFiltersChange(tempReport, minimalFilters) &&
|
|
251
213
|
!loading &&
|
|
252
|
-
|
|
253
|
-
!
|
|
214
|
+
tempReport &&
|
|
215
|
+
!tempReport.triggerReload &&
|
|
216
|
+
!processing &&
|
|
217
|
+
dateBucket === previousDateBucket) {
|
|
254
218
|
setLoading(false);
|
|
255
|
-
setReport(
|
|
219
|
+
setReport(tempReport);
|
|
256
220
|
return;
|
|
257
221
|
}
|
|
258
222
|
setLoading(true);
|
|
259
|
-
const { report, error } = await (0, report_1.fetchReport)(reportId, client, useReportTask, minimalFilters, processing,
|
|
223
|
+
const { report, error } = await (0, report_1.fetchReport)(reportId, client, useReportTask, minimalFilters, processing, dateBucket, customFields);
|
|
260
224
|
if (error) {
|
|
261
225
|
setError(error);
|
|
262
226
|
setLoading(false);
|
|
263
227
|
return;
|
|
264
228
|
}
|
|
229
|
+
setPreviousDateBucket(dateBucket);
|
|
265
230
|
setReport(report);
|
|
266
231
|
if (mapColorsToFields && report) {
|
|
267
232
|
setColorMap(mapColorsToFields(report, theme));
|
|
268
233
|
}
|
|
269
|
-
let filterArray =
|
|
234
|
+
let filterArray = minimalFilters;
|
|
270
235
|
// THIS SHOULD ONLY BE UNDEFINED ON INITIAL LOAD
|
|
271
236
|
if (!filterArray) {
|
|
272
237
|
filterArray = report.filtersApplied
|
|
273
238
|
? report.filtersApplied.map((filter) => {
|
|
274
|
-
return (0, filterProcessing_1.processFilterFromBackend)(filter
|
|
239
|
+
return (0, filterProcessing_1.processFilterFromBackend)(filter);
|
|
275
240
|
})
|
|
276
241
|
: [];
|
|
277
242
|
reportFiltersDispatch({
|
|
@@ -283,17 +248,11 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
283
248
|
},
|
|
284
249
|
});
|
|
285
250
|
}
|
|
286
|
-
const dateFilter = filterArray &&
|
|
287
|
-
filterArray.find((filter) => {
|
|
288
|
-
return filter.filterType === 'date_range';
|
|
289
|
-
});
|
|
290
251
|
setFilterUpdateIndex(reportFilterInfo.updateIndex);
|
|
291
|
-
setDateFilter(dateFilter);
|
|
292
252
|
setChartFilters(filterArray || []);
|
|
293
253
|
if (mapColorsToFields) {
|
|
294
254
|
setColorMap(mapColorsToFields(report, theme));
|
|
295
255
|
}
|
|
296
|
-
setFilterUpdateIndex(reportFilterInfo.updateIndex);
|
|
297
256
|
setAdditionProcessing(processing);
|
|
298
257
|
setError(error);
|
|
299
258
|
setLoading(false);
|
|
@@ -315,69 +274,55 @@ const ChartUpdater = ({ colors, reportId, className, containerStyle, isAnimation
|
|
|
315
274
|
return;
|
|
316
275
|
}
|
|
317
276
|
fetchReportHelper(true, reportFilters[reportId] || { filters: [] }, additionalProcessing);
|
|
318
|
-
}, [client, reportId, reportFilters[reportId]?.updateIndex]);
|
|
277
|
+
}, [client, reportId, reportFilters[reportId]?.updateIndex, dateBucket]);
|
|
319
278
|
(0, react_1.useEffect)(() => {
|
|
320
|
-
|
|
279
|
+
const tempReport = dashboard[reportId];
|
|
280
|
+
if (!tempReport) {
|
|
321
281
|
return;
|
|
322
282
|
}
|
|
323
283
|
setInitialLoad(false);
|
|
324
284
|
setLoading(false);
|
|
325
|
-
setReport(dashboard[reportId]);
|
|
326
|
-
let dateFilter = undefined;
|
|
327
285
|
let filtersApplied = [];
|
|
328
|
-
if (
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
dateFilter = dashboard[reportId].filtersApplied.find((filter) => {
|
|
332
|
-
return filter.filterType === 'date_range';
|
|
286
|
+
if (tempReport.filtersApplied && tempReport.filtersApplied.length > 0) {
|
|
287
|
+
filtersApplied = tempReport.filtersApplied.map((filter) => {
|
|
288
|
+
return filter;
|
|
333
289
|
});
|
|
334
290
|
}
|
|
291
|
+
setReport(tempReport);
|
|
335
292
|
setChartFilters(filtersApplied);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
setError(dashboard[reportId].error);
|
|
293
|
+
if (tempReport.error) {
|
|
294
|
+
setError(tempReport.error);
|
|
339
295
|
}
|
|
340
|
-
}, []);
|
|
296
|
+
}, [dashboard[reportId]]);
|
|
341
297
|
if (error) {
|
|
342
298
|
return ((0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: className, children: (0, jsx_runtime_1.jsx)(ChartError_1.default, { errorMessage: error }) }));
|
|
343
299
|
}
|
|
344
|
-
return ((0, jsx_runtime_1.jsxs)("div", { children: [!hideFilters && ((0, jsx_runtime_1.jsx)(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
300
|
+
return ((0, jsx_runtime_1.jsxs)("div", { children: [!hideFilters && ((0, jsx_runtime_1.jsx)(FilterContainerComponent, { children: chartFilters.map((filter, index) => ((0, jsx_runtime_1.jsx)(DashboardFilter_1.DashboardFilter, { filter: filter, onChangeFilter: (filter, value = null, comparison = null) => {
|
|
301
|
+
const updatedFilters = chartFilters.map((f) => {
|
|
302
|
+
if (f.field === filter.field ||
|
|
303
|
+
(f.filterType === 'date_range' &&
|
|
304
|
+
filter.filterType === 'date_range')) {
|
|
305
|
+
return (0, filterProcessing_1.updateFilter)(f, value, comparison);
|
|
306
|
+
}
|
|
307
|
+
return f;
|
|
308
|
+
});
|
|
309
|
+
setChartFilters(updatedFilters);
|
|
310
|
+
fetchReportHelper(true, {
|
|
311
|
+
filters: updatedFilters,
|
|
312
|
+
updateIndex: filterUpdateIndex + 1,
|
|
313
|
+
}, additionalProcessing);
|
|
314
|
+
reportFiltersDispatch({
|
|
315
|
+
type: 'UPDATE_REPORT_FILTER',
|
|
316
|
+
id: reportId,
|
|
317
|
+
data: {
|
|
360
318
|
filters: updatedFilters,
|
|
361
319
|
updateIndex: filterUpdateIndex + 1,
|
|
362
|
-
},
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
updateIndex: filterUpdateIndex + 1,
|
|
369
|
-
},
|
|
370
|
-
});
|
|
371
|
-
}, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent }, index))) }) })), (0, jsx_runtime_1.jsx)(exports.ChartDisplay, { config: report, reportId: reportId, colors: colors, className: className, containerStyle: containerStyle, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, hideHorizontalCartesianGrid: hideHorizontalCartesianGrid, hideVerticalCartesianGrid: hideVerticalCartesianGrid, hideSubsequentXAxisTicks: hideSubsequentXAxisTicks, cartesianGridLineStyle: cartesianGridLineStyle, cartesianGridLineColor: cartesianGridLineColor, hideDateRangeFilter: hideDateRangeFilter, comparisonLineStyle: comparisonLineStyle, isAnimationActive: isAnimationActive, loading: loading || initialLoad, paginating: paginating, colorMap: colorMap, LoadingComponent: LoadingComponent, onPageChange: onPageChange, onSortChange: onSortChange, onClickChartElement: onClickChartElement, initialDateFilter: dateFilter })] }));
|
|
372
|
-
};
|
|
373
|
-
const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hideXAxis, hideYAxis, hideCartesianGrid, hideDateRangeFilter = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, isAnimationActive, loading = false, paginating = false, ErrorComponent = ChartError_1.default, colorMap, LoadingComponent = ChartSkeleton_1.QuillLoadingSkeleton, onPageChange, onSortChange, onClickChartElement, dateBucket, overrideTheme, initialDateFilter, }) => {
|
|
374
|
-
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
375
|
-
const specificDashboardFilter = (0, react_1.useMemo)(() => {
|
|
376
|
-
if (!dashboardFilters) {
|
|
377
|
-
return [];
|
|
378
|
-
}
|
|
379
|
-
return dashboardFilters.filter((f) => f && config && config.dashboardName === f.dashboardName);
|
|
380
|
-
}, [dashboardFilters]);
|
|
320
|
+
},
|
|
321
|
+
});
|
|
322
|
+
}, theme: theme, SelectComponent: SelectComponent, MultiSelectComponent: MultiSelectComponent, DateRangePickerComponent: DateRangePickerComponent }, index))) })), (0, jsx_runtime_1.jsx)(exports.ChartDisplay, { config: report ? (0, report_1.convertInternalReportToReport)(report) : undefined, reportId: reportId, colors: colors, className: className, containerStyle: containerStyle, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, hideHorizontalCartesianGrid: hideHorizontalCartesianGrid, hideVerticalCartesianGrid: hideVerticalCartesianGrid, hideSubsequentXAxisTicks: hideSubsequentXAxisTicks, cartesianGridLineStyle: cartesianGridLineStyle, cartesianGridLineColor: cartesianGridLineColor, hideDateRangeFilter: hideDateRangeFilter, comparisonLineStyle: comparisonLineStyle, isAnimationActive: isAnimationActive, loading: loading || initialLoad, paginating: paginating, colorMap: colorMap, LoadingComponent: LoadingComponent, onPageChange: onPageChange, onSortChange: onSortChange, onClickChartElement: onClickChartElement })] }));
|
|
323
|
+
}
|
|
324
|
+
exports.default = Chart;
|
|
325
|
+
const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hideXAxis, hideYAxis, hideCartesianGrid, hideDateRangeFilter = false, hideHorizontalCartesianGrid = false, hideVerticalCartesianGrid = true, hideSubsequentXAxisTicks = false, cartesianGridLineStyle = 'solid', cartesianGridLineColor, comparisonLineStyle, isAnimationActive, loading = false, paginating = false, ErrorComponent = ChartError_1.default, colorMap, LoadingComponent = ChartSkeleton_1.QuillLoadingSkeleton, onPageChange, onSortChange, onClickChartElement, overrideTheme, }) => {
|
|
381
326
|
const { downloadCSV } = (0, useExport_1.useExport)(reportId);
|
|
382
327
|
const theme = overrideTheme ?? (0, useTheme_1.default)();
|
|
383
328
|
const chartColors = (0, react_1.useMemo)(() => {
|
|
@@ -387,127 +332,42 @@ const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hid
|
|
|
387
332
|
? theme.chartColors
|
|
388
333
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
389
334
|
}, [colors]);
|
|
390
|
-
const rows = config?.pivotRows ?? config?.rows ?? [];
|
|
391
335
|
const getDateFilter = () => {
|
|
392
|
-
if (!hideDateRangeFilter) {
|
|
393
|
-
return (0, filterProcessing_1.findAndProcessDateFilter)(
|
|
336
|
+
if (!hideDateRangeFilter && config && config.filtersApplied) {
|
|
337
|
+
return (0, filterProcessing_1.findAndProcessDateFilter)(config.filtersApplied.map((f) => f));
|
|
394
338
|
}
|
|
395
339
|
return undefined;
|
|
396
340
|
};
|
|
397
|
-
const [dateFilter, setDateFilter] = (0, react_1.useState)(
|
|
398
|
-
const getYAxisFields = (curDateFilter) => {
|
|
399
|
-
if (config &&
|
|
400
|
-
config.pivot &&
|
|
401
|
-
config.pivotColumns &&
|
|
402
|
-
config.pivot.columnField) {
|
|
403
|
-
return (config?.pivotColumns
|
|
404
|
-
.slice(1)
|
|
405
|
-
.map((column) => {
|
|
406
|
-
return { ...column, format: config?.yAxisFields[0].format };
|
|
407
|
-
}) ?? []);
|
|
408
|
-
}
|
|
409
|
-
else if (config && config.pivot && config.pivotColumns) {
|
|
410
|
-
return (config?.pivotColumns
|
|
411
|
-
.slice(1)
|
|
412
|
-
.map((column) => {
|
|
413
|
-
return {
|
|
414
|
-
...column,
|
|
415
|
-
label: config?.yAxisFields[0].label,
|
|
416
|
-
format: config?.yAxisFields[0].format,
|
|
417
|
-
};
|
|
418
|
-
}) ?? []);
|
|
419
|
-
}
|
|
420
|
-
else {
|
|
421
|
-
if (curDateFilter?.comparison &&
|
|
422
|
-
curDateFilter.comparisonRange.value !== 'NO_COMPARISON') {
|
|
423
|
-
const comparisonYAxisFields = config?.yAxisFields?.map((field) => {
|
|
424
|
-
return {
|
|
425
|
-
...field,
|
|
426
|
-
field: `comparison_${field.field}`,
|
|
427
|
-
label: `comparison ${field.label ?? field.field}`,
|
|
428
|
-
};
|
|
429
|
-
});
|
|
430
|
-
if (config?.pivotColumns) {
|
|
431
|
-
return config.pivotColumns;
|
|
432
|
-
}
|
|
433
|
-
else if (comparisonYAxisFields || config.yAxisFields) {
|
|
434
|
-
const yAxisFields = config.yAxisFields ?? [];
|
|
435
|
-
const compYAxisFields = comparisonYAxisFields ?? [];
|
|
436
|
-
return [...yAxisFields, ...compYAxisFields];
|
|
437
|
-
}
|
|
438
|
-
return [];
|
|
439
|
-
}
|
|
440
|
-
return config?.pivotColumns ?? config?.yAxisFields ?? [];
|
|
441
|
-
}
|
|
442
|
-
};
|
|
443
|
-
const [yAxisFields, setYAxisFields] = (0, react_1.useState)(getYAxisFields(dateFilter ?? getDateFilter()));
|
|
341
|
+
const [dateFilter, setDateFilter] = (0, react_1.useState)(getDateFilter());
|
|
444
342
|
(0, react_1.useEffect)(() => {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}, [config, specificDashboardFilter, initialDateFilter]);
|
|
343
|
+
setDateFilter(getDateFilter());
|
|
344
|
+
}, [config]);
|
|
448
345
|
if (config &&
|
|
449
346
|
!config.pivot &&
|
|
450
|
-
config
|
|
451
|
-
config
|
|
452
|
-
(config.rowCount > MAX_ROWS_FOR_GENERIC_TABLE ||
|
|
453
|
-
(rows && rows.length > MAX_ROWS_FOR_GENERIC_TABLE))) {
|
|
347
|
+
config.chartType !== 'metric' &&
|
|
348
|
+
config.chartType !== 'table' &&
|
|
349
|
+
((config.rowCount && config.rowCount > MAX_ROWS_FOR_GENERIC_TABLE) ||
|
|
350
|
+
(config?.rows && config?.rows.length > MAX_ROWS_FOR_GENERIC_TABLE))) {
|
|
454
351
|
return ((0, jsx_runtime_1.jsx)("div", { style: containerStyle, className: className, children: (0, jsx_runtime_1.jsx)(ErrorComponent, { errorMessage: `Charts can only display ${MAX_ROWS_FOR_GENERIC_TABLE} rows. Please add a pivot or modify the query.` }) }));
|
|
455
352
|
}
|
|
456
|
-
else if (
|
|
353
|
+
else if (loading) {
|
|
457
354
|
return ((0, jsx_runtime_1.jsx)("div", { className: className, style: containerStyle, children: (0, jsx_runtime_1.jsx)(LoadingComponent, {}) }));
|
|
458
355
|
}
|
|
459
356
|
const chartTypes = [config?.chartType];
|
|
460
357
|
if (chartTypes.includes('pie')) {
|
|
461
|
-
|
|
462
|
-
return ((0, jsx_runtime_1.jsx)(PieChart_1.default, { className: className, containerStyle: containerStyle, data: rows.map((row) => {
|
|
358
|
+
return ((0, jsx_runtime_1.jsx)(PieChart_1.default, { className: className, containerStyle: containerStyle, data: config?.rows.map((row) => {
|
|
463
359
|
return {
|
|
464
360
|
...row,
|
|
465
|
-
count:
|
|
466
|
-
|
|
361
|
+
count:
|
|
362
|
+
// @ts-ignore
|
|
363
|
+
parseInt(row[config?.yAxisFields[0]?.field]) /
|
|
364
|
+
// @ts-ignore
|
|
365
|
+
sumByKey(rows, config?.yAxisFields[0].field),
|
|
467
366
|
};
|
|
468
|
-
}), category: yAxisFields[0]
|
|
367
|
+
}) || [], category: config?.yAxisFields[0]?.field, index: config?.xAxisField, colors: chartColors, theme: theme, colorMap: colorMap, onClickChartElement: onClickChartElement }));
|
|
469
368
|
}
|
|
470
369
|
if (chartTypes.includes('table')) {
|
|
471
|
-
|
|
472
|
-
// FOR PIVOTS - ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
473
|
-
const valueFieldType = config?.pivot?.valueFieldType || undefined;
|
|
474
|
-
// Walk through data.columns and pick off the labels from yAxisFields
|
|
475
|
-
columns.forEach((col, index) => {
|
|
476
|
-
// ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
477
|
-
if ((valueFieldType ||
|
|
478
|
-
['min', 'max'].includes(config?.pivot?.aggregationType)) &&
|
|
479
|
-
index !== 0) {
|
|
480
|
-
col.format = valueFieldType || 'two_decimal_places';
|
|
481
|
-
}
|
|
482
|
-
if (!yAxisFields)
|
|
483
|
-
return;
|
|
484
|
-
const matchingCol = yAxisFields.find((c) => c.field === col.field);
|
|
485
|
-
if (!col.label && matchingCol) {
|
|
486
|
-
col.label = matchingCol.label;
|
|
487
|
-
col.format = matchingCol.format;
|
|
488
|
-
}
|
|
489
|
-
});
|
|
490
|
-
const formattedRows = rows.map((row) => {
|
|
491
|
-
return columns.reduce((formattedRow, column) => {
|
|
492
|
-
// Apply the format function to each field in the row
|
|
493
|
-
const formattedValue = (0, valueFormatter_2.quillFormat)({
|
|
494
|
-
value: row[column.field],
|
|
495
|
-
format: column.format,
|
|
496
|
-
});
|
|
497
|
-
formattedRow[column.field] = formattedValue;
|
|
498
|
-
return formattedRow;
|
|
499
|
-
}, {});
|
|
500
|
-
});
|
|
501
|
-
let numberOfRows = undefined;
|
|
502
|
-
if (config.compareRows && config.compareRows[0]) {
|
|
503
|
-
if (config.compareRows[0].COUNT) {
|
|
504
|
-
numberOfRows = parseInt(config.compareRows[0].COUNT);
|
|
505
|
-
}
|
|
506
|
-
else if (config.compareRows[0].count) {
|
|
507
|
-
numberOfRows = parseInt(config.compareRows[0].count);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { rows: formattedRows ?? [], rowCount: numberOfRows, columns: columns ?? yAxisFields, currentPage: config.page, sort: config.sort, rowsPerPage: config?.rowsPerPage || 10, containerStyle: {
|
|
370
|
+
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { rows: config?.rows ?? [], rowCount: config?.rowCount, columns: config?.columns ?? config?.yAxisFields ?? [], currentPage: config?.pagination?.page || 1, sort: config?.sort, rowsPerPage: config?.pagination?.rowsPerPage || 10, containerStyle: {
|
|
511
371
|
width: containerStyle?.width || '100%',
|
|
512
372
|
height: containerStyle?.height || '400px',
|
|
513
373
|
...containerStyle,
|
|
@@ -520,43 +380,18 @@ const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hid
|
|
|
520
380
|
}, isLoading: paginating }));
|
|
521
381
|
}
|
|
522
382
|
if (chartTypes.includes('bar')) {
|
|
523
|
-
return ((0, jsx_runtime_1.jsx)(BarList_1.default, { data: rows, theme: theme, yAxisFields: yAxisFields, colors: chartColors, xAxisField: config
|
|
383
|
+
return ((0, jsx_runtime_1.jsx)(BarList_1.default, { data: config?.rows || [], theme: theme, yAxisFields: config?.yAxisFields || [], colors: chartColors, xAxisField: config?.xAxisField || '', xAxisFormat: config?.xAxisFormat || 'string', containerStyle: containerStyle, className: className, colorMap: colorMap, onClickChartElement: onClickChartElement }));
|
|
524
384
|
}
|
|
525
385
|
if (chartTypes.includes('column')) {
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (dateFilter && (!barChartData || barChartData.length === 0)) {
|
|
529
|
-
const xAxis = config.xAxisField;
|
|
530
|
-
const yAxis = yAxisFields[0]?.field;
|
|
531
|
-
barChartData = [{ [xAxis]: '', [yAxis]: '0' }];
|
|
532
|
-
}
|
|
533
|
-
let xAxisFormat = config.xAxisFormat;
|
|
534
|
-
if (dateBucket) {
|
|
535
|
-
switch (dateBucket) {
|
|
536
|
-
case 'day':
|
|
537
|
-
xAxisFormat = 'MMM_dd';
|
|
538
|
-
break;
|
|
539
|
-
case 'week':
|
|
540
|
-
xAxisFormat = 'string';
|
|
541
|
-
break;
|
|
542
|
-
case 'month':
|
|
543
|
-
xAxisFormat = 'MMM_yyyy';
|
|
544
|
-
break;
|
|
545
|
-
default:
|
|
546
|
-
xAxisFormat = 'MMM_yyyy';
|
|
547
|
-
break;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
return ((0, jsx_runtime_1.jsx)(BarChart_1.default, { colors: chartColors, theme: theme, isStacked: config.pivot && yAxisFields.length > (dateFilter?.comparison ? 2 : 1), yAxisFields: yAxisFields, data: barChartData, xAxisField: config.xAxisField, xAxisLabel: config.xAxisLabel, xAxisFormat: xAxisFormat, containerStyle: containerStyle, className: className, comparison: dateFilter?.comparison &&
|
|
386
|
+
return ((0, jsx_runtime_1.jsx)(BarChart_1.default, { colors: chartColors, theme: theme, isStacked: !!config?.pivot &&
|
|
387
|
+
config?.yAxisFields?.length > (dateFilter?.comparison ? 2 : 1), yAxisFields: config?.yAxisFields || [], data: config?.rows || [], xAxisField: config?.xAxisField || '', xAxisLabel: config?.xAxisLabel || '', xAxisFormat: config?.xAxisFormat || 'string', containerStyle: containerStyle, className: className, comparison: dateFilter?.comparison &&
|
|
551
388
|
dateFilter.comparisonRange.value !== 'NO_COMPARISON', isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, colorMap: colorMap, onClickChartElement: onClickChartElement, dateFilter: dateFilter }));
|
|
552
389
|
}
|
|
553
390
|
if (chartTypes.includes('metric')) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
const comparisonLabel = dateRangePickerUtils_1.COMPARISON_OPTIONS.find((opt) => opt.value === comparisonKey)?.text;
|
|
559
|
-
if (rows?.length === 0 || rows[0][config.xAxisField] === null) {
|
|
391
|
+
if (!config?.rows ||
|
|
392
|
+
config?.rows?.length === 0 ||
|
|
393
|
+
// @ts-ignore
|
|
394
|
+
config?.rows[0][config?.xAxisField] === null) {
|
|
560
395
|
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
561
396
|
display: 'flex',
|
|
562
397
|
flex: '1 0 auto',
|
|
@@ -571,7 +406,7 @@ const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hid
|
|
|
571
406
|
...containerStyle,
|
|
572
407
|
}, className: className, children: "No results" }));
|
|
573
408
|
}
|
|
574
|
-
return ((0, jsx_runtime_1.
|
|
409
|
+
return ((0, jsx_runtime_1.jsx)("div", { style: {
|
|
575
410
|
fontFamily: theme?.fontFamily,
|
|
576
411
|
fontSize: 32,
|
|
577
412
|
color: theme?.primaryTextColor,
|
|
@@ -588,84 +423,9 @@ const ChartDisplay = ({ reportId, config, colors, className, containerStyle, hid
|
|
|
588
423
|
width: '100%',
|
|
589
424
|
flexDirection: 'row',
|
|
590
425
|
...containerStyle,
|
|
591
|
-
}, className: className, children:
|
|
592
|
-
display: 'flex',
|
|
593
|
-
gap: 4,
|
|
594
|
-
alignItems: 'baseline',
|
|
595
|
-
marginRight: 'auto',
|
|
596
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { children: rows?.length > 0 &&
|
|
597
|
-
(0, valueFormatter_1.valueFormatter)({
|
|
598
|
-
value: rows[0][config.xAxisField] ?? 0,
|
|
599
|
-
field: config.xAxisField,
|
|
600
|
-
fields: [
|
|
601
|
-
{
|
|
602
|
-
field: config.xAxisField,
|
|
603
|
-
format: config.xAxisFormat,
|
|
604
|
-
label: config.xAxisLabel,
|
|
605
|
-
_id: config._id || 'dummy',
|
|
606
|
-
},
|
|
607
|
-
],
|
|
608
|
-
}) }), isComparison && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
609
|
-
fontSize: 13,
|
|
610
|
-
fontWeight: '500',
|
|
611
|
-
fontFamily: theme?.fontFamily,
|
|
612
|
-
color: theme?.primaryTextColor,
|
|
613
|
-
marginLeft: 2,
|
|
614
|
-
}, children: primaryMetricLabel
|
|
615
|
-
? `in ${primaryMetricLabel.toLowerCase()}`
|
|
616
|
-
: 'this period' }))] }), isComparison && ((0, jsx_runtime_1.jsxs)("div", { style: {
|
|
617
|
-
display: 'flex',
|
|
618
|
-
gap: 4,
|
|
619
|
-
alignItems: 'baseline',
|
|
620
|
-
paddingTop: 4,
|
|
621
|
-
color: theme?.secondaryTextColor,
|
|
622
|
-
}, children: [(0, jsx_runtime_1.jsx)("span", { style: {
|
|
623
|
-
fontSize: 28,
|
|
624
|
-
fontWeight: '500',
|
|
625
|
-
fontFamily: theme?.fontFamily,
|
|
626
|
-
color: theme?.secondaryTextColor,
|
|
627
|
-
}, children: rows?.length > 0 &&
|
|
628
|
-
(0, valueFormatter_1.valueFormatter)({
|
|
629
|
-
value: rows[0][`comparison_${config.xAxisField}`] ?? 0,
|
|
630
|
-
field: config.xAxisField,
|
|
631
|
-
fields: [
|
|
632
|
-
{
|
|
633
|
-
field: config.xAxisField,
|
|
634
|
-
format: config.xAxisFormat,
|
|
635
|
-
label: config.xAxisLabel,
|
|
636
|
-
_id: config._id || 'dummy',
|
|
637
|
-
},
|
|
638
|
-
],
|
|
639
|
-
}) }), (0, jsx_runtime_1.jsx)("span", { style: {
|
|
640
|
-
fontSize: 13,
|
|
641
|
-
fontWeight: '500',
|
|
642
|
-
fontFamily: theme?.fontFamily,
|
|
643
|
-
color: theme?.secondaryTextColor,
|
|
644
|
-
marginLeft: 2,
|
|
645
|
-
}, children: comparisonLabel
|
|
646
|
-
? 'in ' + comparisonLabel.toLowerCase()
|
|
647
|
-
: 'previous period' })] }))] }));
|
|
426
|
+
}, className: className, children: (0, jsx_runtime_1.jsx)(MetricComponent_1.default, { report: config ?? report_1.EMPTY_REPORT }) }));
|
|
648
427
|
}
|
|
649
|
-
|
|
650
|
-
// when there are no rows on the config.
|
|
651
|
-
let lineChartData = rows;
|
|
652
|
-
const xAxisFieldFormat = config.columns.find((col) => col.field === config.xAxisField)?.format;
|
|
653
|
-
if (dateFilter &&
|
|
654
|
-
valueFormatter_1.DATE_FORMAT_TYPES.includes(xAxisFieldFormat) &&
|
|
655
|
-
(!lineChartData || lineChartData.length === 0)) {
|
|
656
|
-
const xAxis = config.xAxisField;
|
|
657
|
-
const yAxis = yAxisFields[0]?.field;
|
|
658
|
-
const format = config.pivot
|
|
659
|
-
? 'MMM_yyyy'
|
|
660
|
-
: config.columns.find((c) => c.field === xAxis).format;
|
|
661
|
-
const startDate = (0, valueFormatter_2.quillFormat)({ value: dateFilter?.startDate, format });
|
|
662
|
-
const endDate = (0, valueFormatter_2.quillFormat)({ value: dateFilter?.endDate, format });
|
|
663
|
-
lineChartData = [
|
|
664
|
-
{ [xAxis]: startDate, [yAxis]: '0' },
|
|
665
|
-
{ [xAxis]: endDate, [yAxis]: '0' },
|
|
666
|
-
];
|
|
667
|
-
}
|
|
668
|
-
return ((0, jsx_runtime_1.jsx)(LineChart_1.default, { colors: chartColors, colorMap: colorMap, yAxisFields: yAxisFields.sort(sortComparisonFirst), data: lineChartData, xAxisField: config.xAxisField, xAxisLabel: config.xAxisLabel, xAxisFormat: config.xAxisFormat, containerStyle: containerStyle, className: className, theme: theme, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, hideHorizontalCartesianGrid: hideHorizontalCartesianGrid, hideVerticalCartesianGrid: hideVerticalCartesianGrid, hideSubsequentXAxisTicks: hideSubsequentXAxisTicks, cartesianGridLineStyle: cartesianGridLineStyle ?? 'solid', comparisonLineStyle: comparisonLineStyle ?? 'solid', cartesianGridLineColor: cartesianGridLineColor, onClickChartElement: onClickChartElement, dateFilter: dateFilter }));
|
|
428
|
+
return ((0, jsx_runtime_1.jsx)(LineChart_1.default, { colors: chartColors, colorMap: colorMap, yAxisFields: config?.yAxisFields.sort(sortComparisonFirst) || [], data: config?.rows || [], xAxisField: config?.xAxisField || '', xAxisLabel: config?.xAxisLabel || '', xAxisFormat: config?.xAxisFormat || 'string', containerStyle: containerStyle, className: className, theme: theme, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, hideHorizontalCartesianGrid: hideHorizontalCartesianGrid, hideVerticalCartesianGrid: hideVerticalCartesianGrid, hideSubsequentXAxisTicks: hideSubsequentXAxisTicks, cartesianGridLineStyle: cartesianGridLineStyle ?? 'solid', comparisonLineStyle: comparisonLineStyle ?? 'solid', cartesianGridLineColor: cartesianGridLineColor, onClickChartElement: onClickChartElement, dateFilter: dateFilter }));
|
|
669
429
|
};
|
|
670
430
|
exports.ChartDisplay = ChartDisplay;
|
|
671
431
|
// Sort to put comparison first (ie. underneath) primary.
|
|
@@ -679,4 +439,3 @@ const sortComparisonFirst = (a, b) => {
|
|
|
679
439
|
return 1;
|
|
680
440
|
return 0;
|
|
681
441
|
};
|
|
682
|
-
exports.default = Chart;
|