@quillsql/react 2.10.37 → 2.10.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/BarList.d.ts +1 -1
- package/dist/cjs/BarList.d.ts.map +1 -1
- package/dist/cjs/Chart.d.ts +2 -1
- package/dist/cjs/Chart.d.ts.map +1 -1
- package/dist/cjs/Chart.js +70 -73
- package/dist/cjs/ChartBuilder.d.ts +8 -4
- package/dist/cjs/ChartBuilder.d.ts.map +1 -1
- package/dist/cjs/ChartBuilder.js +206 -126
- package/dist/cjs/ChartEditor.js +1 -1
- package/dist/cjs/Dashboard.d.ts.map +1 -1
- package/dist/cjs/Dashboard.js +9 -1
- package/dist/cjs/PieChart.d.ts +1 -0
- package/dist/cjs/PieChart.d.ts.map +1 -1
- package/dist/cjs/PieChart.js +2 -2
- package/dist/cjs/QuillProvider.d.ts +2 -0
- package/dist/cjs/QuillProvider.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.d.ts.map +1 -1
- package/dist/cjs/SQLEditor.js +9 -0
- package/dist/cjs/Table.d.ts.map +1 -1
- package/dist/cjs/Table.js +0 -4
- package/dist/cjs/components/Chart/BarChart.d.ts +1 -1
- package/dist/cjs/components/Chart/BarChart.d.ts.map +1 -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/Dashboard/DataLoader.d.ts +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/cjs/components/Dashboard/DataLoader.js +2 -7
- 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 +5 -21
- package/dist/cjs/components/QuillTable.d.ts.map +1 -1
- package/dist/cjs/components/QuillTable.js +5 -2
- package/dist/cjs/components/UiComponents.d.ts +6 -18
- package/dist/cjs/components/UiComponents.d.ts.map +1 -1
- package/dist/cjs/components/UiComponents.js +21 -3
- package/dist/cjs/hooks/useQuill.d.ts +1 -1
- package/dist/cjs/hooks/useQuill.d.ts.map +1 -1
- package/dist/cjs/index.d.ts +3 -2
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotList.js +9 -3
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/cjs/internals/ReportBuilder/PivotModal.js +31 -28
- package/dist/cjs/models/Pivots.d.ts +2 -0
- package/dist/cjs/models/Pivots.d.ts.map +1 -0
- package/dist/cjs/models/Pivots.js +2 -0
- package/dist/cjs/models/Tables.d.ts +16 -0
- package/dist/cjs/models/Tables.d.ts.map +1 -0
- package/dist/cjs/models/Tables.js +2 -0
- package/dist/cjs/utils/aggregate.d.ts.map +1 -1
- package/dist/cjs/utils/aggregate.js +26 -23
- package/dist/cjs/utils/textProcessing.d.ts +5 -0
- package/dist/cjs/utils/textProcessing.d.ts.map +1 -0
- package/dist/cjs/utils/textProcessing.js +37 -0
- package/dist/cjs/utils/types.d.ts +4 -0
- package/dist/cjs/utils/types.d.ts.map +1 -0
- package/dist/cjs/utils/types.js +52 -0
- package/dist/esm/BarList.d.ts +1 -1
- package/dist/esm/BarList.d.ts.map +1 -1
- package/dist/esm/Chart.d.ts +2 -1
- package/dist/esm/Chart.d.ts.map +1 -1
- package/dist/esm/Chart.js +70 -73
- package/dist/esm/ChartBuilder.d.ts +8 -4
- package/dist/esm/ChartBuilder.d.ts.map +1 -1
- package/dist/esm/ChartBuilder.js +206 -125
- package/dist/esm/ChartEditor.js +1 -1
- package/dist/esm/Dashboard.d.ts.map +1 -1
- package/dist/esm/Dashboard.js +9 -1
- package/dist/esm/PieChart.d.ts +1 -0
- package/dist/esm/PieChart.d.ts.map +1 -1
- package/dist/esm/PieChart.js +2 -2
- package/dist/esm/QuillProvider.d.ts +2 -0
- package/dist/esm/QuillProvider.d.ts.map +1 -1
- package/dist/esm/SQLEditor.d.ts.map +1 -1
- package/dist/esm/SQLEditor.js +9 -0
- package/dist/esm/Table.d.ts.map +1 -1
- package/dist/esm/Table.js +1 -5
- package/dist/esm/components/Chart/BarChart.d.ts +1 -1
- package/dist/esm/components/Chart/BarChart.d.ts.map +1 -1
- 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/Dashboard/DataLoader.d.ts +1 -1
- package/dist/esm/components/Dashboard/DataLoader.d.ts.map +1 -1
- package/dist/esm/components/Dashboard/DataLoader.js +4 -9
- 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 +5 -18
- package/dist/esm/components/QuillTable.d.ts.map +1 -1
- package/dist/esm/components/QuillTable.js +2 -2
- package/dist/esm/components/UiComponents.d.ts +6 -18
- package/dist/esm/components/UiComponents.d.ts.map +1 -1
- package/dist/esm/components/UiComponents.js +19 -2
- package/dist/esm/hooks/useQuill.d.ts +1 -1
- package/dist/esm/hooks/useQuill.d.ts.map +1 -1
- package/dist/esm/index.d.ts +3 -2
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotList.js +9 -3
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.d.ts.map +1 -1
- package/dist/esm/internals/ReportBuilder/PivotModal.js +28 -25
- package/dist/esm/models/Pivots.d.ts +2 -0
- package/dist/esm/models/Pivots.d.ts.map +1 -0
- package/dist/esm/models/Pivots.js +1 -0
- package/dist/esm/models/Tables.d.ts +16 -0
- package/dist/esm/models/Tables.d.ts.map +1 -0
- package/dist/esm/models/Tables.js +1 -0
- package/dist/esm/utils/aggregate.d.ts.map +1 -1
- package/dist/esm/utils/aggregate.js +26 -23
- package/dist/esm/utils/textProcessing.d.ts +5 -0
- package/dist/esm/utils/textProcessing.d.ts.map +1 -0
- package/dist/esm/utils/textProcessing.js +30 -0
- package/dist/esm/utils/types.d.ts +4 -0
- package/dist/esm/utils/types.d.ts.map +1 -0
- package/dist/esm/utils/types.js +48 -0
- package/package.json +1 -1
package/dist/cjs/BarList.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export interface BarListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
13
13
|
yAxisFields: YAxisField[];
|
|
14
14
|
containerStyle: any;
|
|
15
15
|
xAxisFormat: string;
|
|
16
|
-
colors
|
|
16
|
+
colors?: string[];
|
|
17
17
|
theme: any;
|
|
18
18
|
}
|
|
19
19
|
export declare function hexToRgbaWith10PercentAlpha(hex: any): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarList.d.ts","sourceRoot":"","sources":["../../src/BarList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAqExC,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACxE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"BarList.d.ts","sourceRoot":"","sources":["../../src/BarList.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAqExC,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAa,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACxE,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,cAAc,CAAC,EAAE,GAAG,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,GAAG,CAAC;CACZ;AAYD,wBAAgB,2BAA2B,CAAC,GAAG,KAAA,UAW9C;AAED,QAAA,MAAM,OAAO,qFA6dX,CAAC;AAEH,eAAe,OAAO,CAAC"}
|
package/dist/cjs/Chart.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ interface BaseChartProps {
|
|
|
9
9
|
hideXAxis?: boolean;
|
|
10
10
|
hideYAxis?: boolean;
|
|
11
11
|
hideCartesianGrid?: boolean;
|
|
12
|
+
dateRangeFilterDisabled?: boolean;
|
|
12
13
|
}
|
|
13
14
|
interface WithChartId extends BaseChartProps {
|
|
14
15
|
chartId: string;
|
|
@@ -37,6 +38,6 @@ interface WithConfig extends BaseChartProps {
|
|
|
37
38
|
}
|
|
38
39
|
type ChartProps = WithChartId | WithConfig;
|
|
39
40
|
export declare function didFiltersChange(dashboardItem: any, filters: any): boolean;
|
|
40
|
-
declare const Chart: (
|
|
41
|
+
declare const Chart: (data: ChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
41
42
|
export default Chart;
|
|
42
43
|
//# sourceMappingURL=Chart.d.ts.map
|
package/dist/cjs/Chart.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/Chart.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/Chart.tsx"],"names":[],"mappings":";AA6BA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED,UAAU,WAAY,SAAQ,cAAc;IAC1C,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,mBAAmB,GACnB,oBAAoB,GACpB,eAAe,GACf,cAAc,GACd,UAAU,GACV,aAAa,GACb,eAAe,GACf,oBAAoB,GACpB,UAAU,GACV,SAAS,GACT,QAAQ,CAAC;AAEb,UAAU,UAAU;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,GAAG,EAAE,CAAC;IACf,KAAK,EAAE,GAAG,CAAC;CACZ;AAED,UAAU,UAAW,SAAQ,cAAc;IACzC,MAAM,EAAE,aAAa,GAAG,GAAG,CAAC;CAC7B;AAED,KAAK,UAAU,GAAG,WAAW,GAAG,UAAU,CAAC;AA+D3C,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,WAQhE;AAKD,QAAA,MAAM,KAAK,SAAU,UAAU,4CAiC9B,CAAC;AAmeF,eAAe,KAAK,CAAC"}
|
package/dist/cjs/Chart.js
CHANGED
|
@@ -5,7 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.didFiltersChange = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
// @ts-nocheck
|
|
9
8
|
const react_1 = require("react");
|
|
10
9
|
const date_fns_1 = require("date-fns");
|
|
11
10
|
const BarList_1 = __importDefault(require("./BarList"));
|
|
@@ -31,8 +30,8 @@ function sumByKey(arr, key) {
|
|
|
31
30
|
return isNaN(val) ? acc : acc + val;
|
|
32
31
|
}, 0);
|
|
33
32
|
}
|
|
34
|
-
function areDatesNearby(
|
|
35
|
-
return Math.abs((0, date_fns_1.differenceInHours)(
|
|
33
|
+
function areDatesNearby(date1, date2) {
|
|
34
|
+
return Math.abs((0, date_fns_1.differenceInHours)(date1, date2)) < 24;
|
|
36
35
|
}
|
|
37
36
|
function isEquivalent(filters1, filters2) {
|
|
38
37
|
if (Object.keys(filters2).length !== Object.keys(filters1).length) {
|
|
@@ -41,6 +40,9 @@ function isEquivalent(filters1, filters2) {
|
|
|
41
40
|
const filterKeys = Object.keys(filters2);
|
|
42
41
|
for (let i = 0; i < filterKeys.length; i++) {
|
|
43
42
|
const currentKeyWereLookingAt = filterKeys[i];
|
|
43
|
+
if (!currentKeyWereLookingAt) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
44
46
|
const filter1 = filters1[currentKeyWereLookingAt];
|
|
45
47
|
if (!filter1) {
|
|
46
48
|
return false;
|
|
@@ -77,25 +79,27 @@ function didFiltersChange(dashboardItem, filters) {
|
|
|
77
79
|
return !isEquivalent(dashboardItem.filtersApplied, filters);
|
|
78
80
|
}
|
|
79
81
|
exports.didFiltersChange = didFiltersChange;
|
|
80
|
-
const Chart = (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
82
|
+
const Chart = (data) => {
|
|
83
|
+
if ('config' in data) {
|
|
84
|
+
return ((0, jsx_runtime_1.jsx)(ChartDisplay, { ...data, loading: false, isComparison: !!data.config.compareRows?.length }));
|
|
85
|
+
}
|
|
85
86
|
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
86
87
|
const chartColors = (0, react_1.useMemo)(() => {
|
|
87
|
-
return colors?.length
|
|
88
|
-
? colors
|
|
88
|
+
return data.colors?.length
|
|
89
|
+
? data.colors
|
|
89
90
|
: theme && theme.chartColors.length
|
|
90
91
|
? theme.chartColors
|
|
91
92
|
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
92
|
-
}, [colors]);
|
|
93
|
-
return ((0, jsx_runtime_1.jsx)(ChartUpdater, {
|
|
93
|
+
}, [data.colors]);
|
|
94
|
+
return ((0, jsx_runtime_1.jsx)(ChartUpdater, { chartId: data.chartId, containerStyle: data.containerStyle, colors: chartColors, theme: theme, isAnimationActive: data.isAnimationActive, hideXAxis: data.hideXAxis, hideYAxis: data.hideYAxis, hideCartesianGrid: data.hideCartesianGrid, dateRangeFilterDisabled: data.dateRangeFilterDisabled }));
|
|
94
95
|
};
|
|
95
|
-
const ChartUpdater = ({ colors, chartId,
|
|
96
|
+
const ChartUpdater = ({ colors, chartId, containerStyle, theme, isAnimationActive, hideXAxis, hideYAxis, hideCartesianGrid, dateRangeFilterDisabled, }) => {
|
|
97
|
+
const { dispatch, dashboard } = (0, react_1.useContext)(Context_1.DashboardContext);
|
|
98
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
96
99
|
const [initialLoad, setInitialLoad] = (0, react_1.useState)(true);
|
|
97
100
|
const [loading, setLoading] = (0, react_1.useState)(false);
|
|
98
101
|
const [isComparison, setIsComparison] = (0, react_1.useState)(false);
|
|
102
|
+
const [client, _] = (0, react_1.useContext)(Context_1.ClientContext);
|
|
99
103
|
(0, react_1.useEffect)(() => {
|
|
100
104
|
async function getChartOptions() {
|
|
101
105
|
if (!didFiltersChange(dashboard[chartId], dashboardFilters)) {
|
|
@@ -155,22 +159,30 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
155
159
|
setLoading(false);
|
|
156
160
|
}
|
|
157
161
|
}
|
|
158
|
-
if (config) {
|
|
159
|
-
setLoading(false);
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
162
|
setInitialLoad(false);
|
|
163
163
|
getChartOptions();
|
|
164
164
|
}, [dashboardFilters, client, chartId]);
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
return ((0, jsx_runtime_1.jsx)(ChartDisplay, { config: dashboard[chartId], colors: colors, containerStyle: containerStyle, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid, isAnimationActive: isAnimationActive, isComparison: isComparison, loading: loading || initialLoad }));
|
|
166
|
+
};
|
|
167
|
+
const ChartDisplay = ({ config, colors, containerStyle, hideXAxis, hideYAxis, hideCartesianGrid, isAnimationActive, loading = false, isComparison = false, }) => {
|
|
168
|
+
const { dashboardFilters } = (0, react_1.useContext)(Context_1.DashboardFiltersContext);
|
|
169
|
+
const [theme] = (0, react_1.useContext)(Context_1.ThemeContext);
|
|
170
|
+
const chartColors = (0, react_1.useMemo)(() => {
|
|
171
|
+
return colors?.length
|
|
172
|
+
? colors
|
|
173
|
+
: theme && theme.chartColors.length
|
|
174
|
+
? theme.chartColors
|
|
175
|
+
: ['#4E80EE', '#E14F62', '#55B5A6', '#E9A23B', '#6466E9', '#55B685'];
|
|
176
|
+
}, [colors]);
|
|
177
|
+
const dateFilter = Object.values(dashboardFilters).find((filter) => filter.filterType == 'date_range');
|
|
178
|
+
const isPivot = config?.pivot;
|
|
167
179
|
const pivotTable = (0, react_1.useMemo)(() => {
|
|
168
|
-
const pivot =
|
|
169
|
-
const data =
|
|
180
|
+
const pivot = config?.pivot;
|
|
181
|
+
const data = config;
|
|
170
182
|
return pivot && data?.rows
|
|
171
183
|
? (0, PivotModal_1.generatePivotTable)(pivot, JSON.parse(JSON.stringify(data.rows)), // deep copy
|
|
172
|
-
dateFilter
|
|
173
|
-
? [dateFilter
|
|
184
|
+
dateFilter
|
|
185
|
+
? [dateFilter.startDate || null, dateFilter.endDate || null, null]
|
|
174
186
|
: [null, null, null], Boolean(dateFilter?.comparisonRange?.startDate), -1, dateFilter?.comparisonRange?.startDate
|
|
175
187
|
? [
|
|
176
188
|
dateFilter?.comparisonRange.startDate,
|
|
@@ -179,21 +191,19 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
179
191
|
]
|
|
180
192
|
: [null, null, null])
|
|
181
193
|
: null;
|
|
182
|
-
}, [
|
|
194
|
+
}, [config, dateFilter]);
|
|
183
195
|
const pivotTableYAxis = (0, react_1.useMemo)(() => {
|
|
184
196
|
if (!pivotTable) {
|
|
185
197
|
return null;
|
|
186
198
|
}
|
|
187
|
-
const pivot =
|
|
188
|
-
const yAxisFields = config
|
|
189
|
-
? config.yAxisFields
|
|
190
|
-
: dashboard[chartId]?.yAxisFields;
|
|
199
|
+
const pivot = config?.pivot;
|
|
200
|
+
const yAxisFields = config.yAxisFields;
|
|
191
201
|
return yAxisFields
|
|
192
202
|
? (0, PivotModal_1.generatePivotTableYAxis)(pivot, pivotTable.columns, yAxisFields?.[0]?.format)
|
|
193
203
|
: null;
|
|
194
204
|
}, [pivotTable]);
|
|
195
|
-
if (!config
|
|
196
|
-
if (loading
|
|
205
|
+
if (!config || loading) {
|
|
206
|
+
if (loading) {
|
|
197
207
|
return (0, jsx_runtime_1.jsx)(ChartSkeleton_1.default, { containerStyle: containerStyle });
|
|
198
208
|
}
|
|
199
209
|
else {
|
|
@@ -201,34 +211,31 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
201
211
|
}
|
|
202
212
|
}
|
|
203
213
|
// TODO: Figure out if we can use ?? to coalesce these into the variable.
|
|
204
|
-
const chartTypes = [config?.chartType
|
|
214
|
+
const chartTypes = [config?.chartType];
|
|
205
215
|
if (chartTypes.includes('pie')) {
|
|
206
|
-
const rows = pivotTable
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
? config.rows
|
|
210
|
-
: dashboard[chartId].rows;
|
|
211
|
-
const yAxisFields = pivotTableYAxis
|
|
212
|
-
? pivotTableYAxis
|
|
213
|
-
: config
|
|
214
|
-
? config.yAxisFields
|
|
215
|
-
: dashboard[chartId].yAxisFields;
|
|
216
|
-
const xAxisField = config
|
|
217
|
-
? config.xAxisField
|
|
218
|
-
: dashboard[chartId].xAxisField;
|
|
216
|
+
const rows = pivotTable ? pivotTable.rows : config.rows;
|
|
217
|
+
const yAxisFields = pivotTableYAxis ? pivotTableYAxis : config.yAxisFields;
|
|
218
|
+
const xAxisField = config.xAxisField;
|
|
219
219
|
return ((0, jsx_runtime_1.jsx)(PieChart_1.default, { containerStyle: containerStyle, data: rows.map((row) => {
|
|
220
220
|
return {
|
|
221
221
|
...row,
|
|
222
222
|
count: parseInt(row[yAxisFields[0].field]) /
|
|
223
223
|
sumByKey(rows, yAxisFields[0].field),
|
|
224
224
|
};
|
|
225
|
-
}), category: yAxisFields[0].field, index: xAxisField, colors:
|
|
225
|
+
}), category: yAxisFields[0].field, index: xAxisField, colors: chartColors, theme: theme }));
|
|
226
226
|
}
|
|
227
227
|
if (chartTypes.includes('table')) {
|
|
228
|
-
const data =
|
|
228
|
+
const data = config;
|
|
229
229
|
const columns = pivotTable?.columns ?? data.columns ?? data.yAxisFields;
|
|
230
|
+
const rows = pivotTable?.rows ?? data.rows ?? [];
|
|
231
|
+
// FOR PIVOTS - ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
232
|
+
const valueFieldType = config?.pivot?.valueFieldType || undefined;
|
|
230
233
|
// Walk through data.columns and pick off the labels from yAxisFields
|
|
231
|
-
columns.forEach((col) => {
|
|
234
|
+
columns.forEach((col, index) => {
|
|
235
|
+
// ADD THE RIGHT FIELD TYPE FOR THE VALUE COLUMNS
|
|
236
|
+
if (valueFieldType && index !== 0) {
|
|
237
|
+
col.format = valueFieldType;
|
|
238
|
+
}
|
|
232
239
|
if (!data.yAxisFields)
|
|
233
240
|
return;
|
|
234
241
|
const matchingCol = data.yAxisFields.find((c) => c.field === col.field);
|
|
@@ -237,7 +244,7 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
237
244
|
col.format = matchingCol.format;
|
|
238
245
|
}
|
|
239
246
|
});
|
|
240
|
-
const
|
|
247
|
+
const formattedRows = rows.map((row) => {
|
|
241
248
|
return columns.reduce((formattedRow, column) => {
|
|
242
249
|
// Apply the format function to each field in the row
|
|
243
250
|
const formattedValue = (0, valueFormatter_2.quillFormat)({
|
|
@@ -248,57 +255,43 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
248
255
|
return formattedRow;
|
|
249
256
|
}, {});
|
|
250
257
|
});
|
|
251
|
-
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { rows:
|
|
258
|
+
return ((0, jsx_runtime_1.jsx)(QuillTable_1.default, { rows: formattedRows ?? [], columns: columns ?? data.yAxisFields, containerStyle: {
|
|
252
259
|
height: '400px',
|
|
253
260
|
width: containerStyle?.width || '100%',
|
|
254
261
|
}, showDownloadCSVButton: true, downloadCSV: () => {
|
|
255
262
|
(0, csv_1.downloadCSV)({
|
|
256
263
|
rows: pivotTable?.rows ?? data.rows ?? [],
|
|
257
|
-
fields:
|
|
264
|
+
fields: columns ?? data.yAxisFields,
|
|
258
265
|
name: data.name || '',
|
|
259
266
|
});
|
|
260
267
|
} }));
|
|
261
268
|
}
|
|
262
269
|
if (chartTypes.includes('bar')) {
|
|
263
|
-
return ((0, jsx_runtime_1.jsx)(BarList_1.default, { data: pivotTable
|
|
264
|
-
? pivotTable.rows
|
|
265
|
-
: config
|
|
266
|
-
? config.rows
|
|
267
|
-
: dashboard[chartId].rows, theme: theme, yAxisFields: pivotTableYAxis
|
|
268
|
-
? pivotTableYAxis
|
|
269
|
-
: config
|
|
270
|
-
? config.yAxisFields
|
|
271
|
-
: dashboard[chartId].yAxisFields, colors: colors, xAxisField: config ? config.xAxisField : dashboard[chartId].xAxisField, xAxisFormat: config ? config.xAxisFormat : dashboard[chartId].xAxisFormat, containerStyle: containerStyle }));
|
|
270
|
+
return ((0, jsx_runtime_1.jsx)(BarList_1.default, { data: pivotTable ? pivotTable.rows : config.rows, theme: theme, yAxisFields: pivotTableYAxis ? pivotTableYAxis : config.yAxisFields, colors: chartColors, xAxisField: config.xAxisField, xAxisFormat: config.xAxisFormat, containerStyle: containerStyle }));
|
|
272
271
|
}
|
|
273
272
|
const yAxisFields = pivotTableYAxis
|
|
274
273
|
? pivotTableYAxis
|
|
275
|
-
: config
|
|
276
|
-
? config.yAxisFields
|
|
277
|
-
: dashboard[chartId].yAxisFields;
|
|
274
|
+
: config.yAxisFields;
|
|
278
275
|
if (isComparison && yAxisFields.length == 1) {
|
|
279
276
|
const sampleField = yAxisFields[0];
|
|
280
277
|
yAxisFields[yAxisFields.length] = {
|
|
281
278
|
...sampleField,
|
|
282
|
-
field: `comparison_${sampleField
|
|
283
|
-
label: `comparison ${sampleField
|
|
279
|
+
field: `comparison_${sampleField?.field}`,
|
|
280
|
+
label: `comparison ${sampleField?.label}`,
|
|
284
281
|
};
|
|
285
282
|
}
|
|
286
|
-
const data = (pivotTable
|
|
287
|
-
? pivotTable.rows
|
|
288
|
-
: config
|
|
289
|
-
? config.rows
|
|
290
|
-
: dashboard[chartId].rows)
|
|
283
|
+
const data = (pivotTable ? pivotTable.rows : config.rows)
|
|
291
284
|
// filter out any rows with a comparison key but no corresponding primary
|
|
292
285
|
?.filter((row) => Object.keys(row).every((key) => !key.startsWith('comparison_') ||
|
|
293
286
|
(key.startsWith('comparison_') &&
|
|
294
287
|
Boolean(row[key.replace('comparison_', '')]))));
|
|
295
288
|
if (chartTypes.includes('column')) {
|
|
296
|
-
return ((0, jsx_runtime_1.jsx)(BarChart_1.default, { colors:
|
|
289
|
+
return ((0, jsx_runtime_1.jsx)(BarChart_1.default, { colors: chartColors, theme: theme, isStacked: isPivot && yAxisFields.length > (dateFilter?.comparison ? 2 : 1), yAxisFields: yAxisFields,
|
|
297
290
|
// @ts-ignore
|
|
298
|
-
data: data, xAxisField: config
|
|
291
|
+
data: data, xAxisField: config.xAxisField, xAxisLabel: config.xAxisLabel, xAxisFormat: config.xAxisFormat, containerStyle: containerStyle, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }));
|
|
299
292
|
}
|
|
300
293
|
if (chartTypes.includes('metric')) {
|
|
301
|
-
const data =
|
|
294
|
+
const data = config; // THIS SHOULD ACCOUNT FOR PIVOT TABLES IN THE FUTURE
|
|
302
295
|
const isComparison = data.rows.length > 0 &&
|
|
303
296
|
Object.keys(data.rows[0]).includes(`comparison_${data.xAxisField}`);
|
|
304
297
|
const primaryMetricLabel = data?.filtersApplied?.date_range?.preset?.label;
|
|
@@ -333,6 +326,8 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
333
326
|
{
|
|
334
327
|
field: data.xAxisField,
|
|
335
328
|
format: data.xAxisFormat,
|
|
329
|
+
label: data.xAxisLabel,
|
|
330
|
+
_id: data._id || 'dummy',
|
|
336
331
|
},
|
|
337
332
|
],
|
|
338
333
|
}) }), isComparison && ((0, jsx_runtime_1.jsx)("span", { style: {
|
|
@@ -362,6 +357,8 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
362
357
|
{
|
|
363
358
|
field: data.xAxisField,
|
|
364
359
|
format: data.xAxisFormat,
|
|
360
|
+
label: data.xAxisLabel,
|
|
361
|
+
_id: data._id || 'dummy',
|
|
365
362
|
},
|
|
366
363
|
],
|
|
367
364
|
}) }), (0, jsx_runtime_1.jsx)("span", { style: {
|
|
@@ -374,6 +371,6 @@ const ChartUpdater = ({ colors, chartId, config, containerStyle, dashboard, disp
|
|
|
374
371
|
? 'in ' + comparisonLabel.toLowerCase()
|
|
375
372
|
: 'previous period' })] }))] }));
|
|
376
373
|
}
|
|
377
|
-
return ((0, jsx_runtime_1.jsx)(LineChart_1.default, { colors:
|
|
374
|
+
return ((0, jsx_runtime_1.jsx)(LineChart_1.default, { colors: chartColors, yAxisFields: yAxisFields, data: data, xAxisField: config.xAxisField, xAxisLabel: config.xAxisLabel, xAxisFormat: config.xAxisFormat, containerStyle: containerStyle, theme: theme, comparison: dateFilter?.comparison, isAnimationActive: isAnimationActive, hideXAxis: hideXAxis, hideYAxis: hideYAxis, hideCartesianGrid: hideCartesianGrid }));
|
|
378
375
|
};
|
|
379
376
|
exports.default = Chart;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Pivot } from './internals/ReportBuilder/PivotModal';
|
|
3
3
|
import { SelectComponentProps, TextInputComponentProps, ButtonComponentProps, ModalComponentProps, HeaderProps, LabelProps, TextProps, DeleteButtonProps, PopoverComponentProps } from './components/UiComponents';
|
|
4
|
-
|
|
4
|
+
import { Column } from './models/Tables';
|
|
5
|
+
import { Field } from './hooks/useQuill';
|
|
5
6
|
export declare const numberFormatOptions: string[];
|
|
7
|
+
export declare const dateFormatOptions: string[];
|
|
6
8
|
interface ChartBuilderProps {
|
|
7
9
|
isOpen: boolean;
|
|
8
10
|
setIsOpen: (isOpen: boolean) => void;
|
|
@@ -16,8 +18,10 @@ interface ChartBuilderProps {
|
|
|
16
18
|
DeleteButton?: (props: DeleteButtonProps) => JSX.Element;
|
|
17
19
|
Modal?: (props: ModalComponentProps) => JSX.Element;
|
|
18
20
|
Popover?: (props: PopoverComponentProps) => JSX.Element;
|
|
19
|
-
rows:
|
|
20
|
-
|
|
21
|
+
rows: {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}[];
|
|
24
|
+
columns: Column[];
|
|
21
25
|
query?: string;
|
|
22
26
|
isEditMode?: boolean;
|
|
23
27
|
formHeaderStyle?: React.CSSProperties;
|
|
@@ -28,7 +32,7 @@ interface ChartBuilderProps {
|
|
|
28
32
|
showDashboardDropdown?: boolean;
|
|
29
33
|
onAddToDashboardComplete?: () => void;
|
|
30
34
|
onDelete?: () => void;
|
|
31
|
-
fields?:
|
|
35
|
+
fields?: Field[];
|
|
32
36
|
pivot?: Pivot;
|
|
33
37
|
dateRange?: (string | Date)[];
|
|
34
38
|
dashboardItem?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartBuilder.d.ts","sourceRoot":"","sources":["../../src/ChartBuilder.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ChartBuilder.d.ts","sourceRoot":"","sources":["../../src/ChartBuilder.tsx"],"names":[],"mappings":"AAAA,OAAO,KAON,MAAM,OAAO,CAAC;AAWf,OAAO,EACL,KAAK,EAIN,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,oBAAoB,EACp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