@quillsql/react 2.12.30 → 2.12.31

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