autoql-fe-utils 1.0.57 → 1.0.58
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/index.global.js +55 -33
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +55 -33
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +55 -33
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.global.js
CHANGED
|
@@ -14629,6 +14629,7 @@
|
|
|
14629
14629
|
if (displayType === "suggestion" || displayType === "help" || displayType === "html") {
|
|
14630
14630
|
return [displayType];
|
|
14631
14631
|
}
|
|
14632
|
+
console.log("response:", response);
|
|
14632
14633
|
const rows = (_e = (_d = (_c = response == null ? void 0 : response.data) == null ? void 0 : _c.data) == null ? void 0 : _d.rows) != null ? _e : [];
|
|
14633
14634
|
const allColumns = columns || ((_g = (_f = response == null ? void 0 : response.data) == null ? void 0 : _f.data) == null ? void 0 : _g.columns);
|
|
14634
14635
|
const visibleColumns = getVisibleColumns(allColumns);
|
|
@@ -14652,6 +14653,7 @@
|
|
|
14652
14653
|
if (pivotDataLengthProvided) {
|
|
14653
14654
|
pivotDataHasLength = !!pivotDataLength;
|
|
14654
14655
|
}
|
|
14656
|
+
console.log("supports pivot table?", supportsRegularPivotTable(visibleColumns, rows, numRows));
|
|
14655
14657
|
if (supportsRegularPivotTable(visibleColumns, rows, numRows)) {
|
|
14656
14658
|
supportedDisplayTypes.push("pivot_table");
|
|
14657
14659
|
if (
|
|
@@ -18768,6 +18770,8 @@
|
|
|
18768
18770
|
console.error("Unable to generate pivot data - rows, columns, or table config was not provided");
|
|
18769
18771
|
return {};
|
|
18770
18772
|
}
|
|
18773
|
+
let pivotTableRowsLimited = false;
|
|
18774
|
+
let pivotTableColumnsLimited = false;
|
|
18771
18775
|
try {
|
|
18772
18776
|
let tableData = rows == null ? void 0 : rows.filter((row) => row[0] !== null);
|
|
18773
18777
|
if (!(tableData == null ? void 0 : tableData.length)) {
|
|
@@ -18775,30 +18779,43 @@
|
|
|
18775
18779
|
return {};
|
|
18776
18780
|
}
|
|
18777
18781
|
const { legendColumnIndex, stringColumnIndex, numberColumnIndex } = tableConfig;
|
|
18782
|
+
const maxColumns = 20;
|
|
18783
|
+
const maxRows = 100;
|
|
18778
18784
|
if (isNaN(legendColumnIndex) || isNaN(stringColumnIndex) || isNaN(numberColumnIndex)) {
|
|
18779
18785
|
console.error(
|
|
18780
18786
|
"Unable to generate pivot data - table config provided was invalid. You must provide a valid legend, string, ad number column index."
|
|
18781
18787
|
);
|
|
18782
18788
|
return {};
|
|
18783
18789
|
}
|
|
18784
|
-
let
|
|
18790
|
+
let uniqueRowHeaders = sortDataByDate(tableData, columns, "desc", "isTable").map((d) => d[stringColumnIndex]).filter(onlyUnique);
|
|
18791
|
+
let uniqueColumnHeaders = sortDataByDate(tableData, columns, "desc", "isTable").map((d) => d[legendColumnIndex]).filter(onlyUnique);
|
|
18792
|
+
let newStringColumnIndex = stringColumnIndex;
|
|
18793
|
+
let newLegendColumnIndex = legendColumnIndex;
|
|
18794
|
+
if (isFirstGeneration && Object.keys(uniqueColumnHeaders).length > Object.keys(uniqueRowHeaders).length && (!isColumnDateType(columns[stringColumnIndex]) || Object.keys(uniqueColumnHeaders).length > MAX_LEGEND_LABELS)) {
|
|
18795
|
+
newStringColumnIndex = legendColumnIndex;
|
|
18796
|
+
newLegendColumnIndex = stringColumnIndex;
|
|
18797
|
+
const tempValues = [...uniqueRowHeaders];
|
|
18798
|
+
uniqueRowHeaders = [...uniqueColumnHeaders];
|
|
18799
|
+
uniqueColumnHeaders = tempValues;
|
|
18800
|
+
}
|
|
18801
|
+
if ((uniqueRowHeaders == null ? void 0 : uniqueRowHeaders.length) > maxRows) {
|
|
18802
|
+
uniqueRowHeaders = uniqueRowHeaders.slice(0, maxRows);
|
|
18803
|
+
pivotTableRowsLimited = true;
|
|
18804
|
+
}
|
|
18805
|
+
const uniqueRowHeadersObj = uniqueRowHeaders.reduce((map4, title, i) => {
|
|
18785
18806
|
map4[title] = i;
|
|
18786
18807
|
return map4;
|
|
18787
18808
|
}, {});
|
|
18788
|
-
|
|
18809
|
+
if ((uniqueColumnHeaders == null ? void 0 : uniqueColumnHeaders.length) > maxColumns) {
|
|
18810
|
+
uniqueColumnHeaders = uniqueColumnHeaders.slice(0, maxColumns);
|
|
18811
|
+
pivotTableColumnsLimited = true;
|
|
18812
|
+
}
|
|
18813
|
+
const uniqueColumnHeadersObj = uniqueColumnHeaders.reduce((map4, title, i) => {
|
|
18789
18814
|
map4[title] = i;
|
|
18790
18815
|
return map4;
|
|
18791
18816
|
}, {});
|
|
18792
|
-
|
|
18793
|
-
|
|
18794
|
-
if (isFirstGeneration && Object.keys(uniqueValues1).length > Object.keys(uniqueValues0).length && (!isColumnDateType(columns[stringColumnIndex]) || Object.keys(uniqueValues1).length > MAX_LEGEND_LABELS)) {
|
|
18795
|
-
newStringColumnIndex = legendColumnIndex;
|
|
18796
|
-
newLegendColumnIndex = stringColumnIndex;
|
|
18797
|
-
const tempValues = (0, import_lodash5.default)(uniqueValues0);
|
|
18798
|
-
uniqueValues0 = (0, import_lodash5.default)(uniqueValues1);
|
|
18799
|
-
uniqueValues1 = (0, import_lodash5.default)(tempValues);
|
|
18800
|
-
}
|
|
18801
|
-
const firstColumn = {
|
|
18817
|
+
const pivotTableColumns = [];
|
|
18818
|
+
pivotTableColumns.push({
|
|
18802
18819
|
...columns[newStringColumnIndex],
|
|
18803
18820
|
index: 0,
|
|
18804
18821
|
frozen: true,
|
|
@@ -18808,10 +18825,9 @@
|
|
|
18808
18825
|
cssClass: "pivot-category",
|
|
18809
18826
|
pivot: true,
|
|
18810
18827
|
headerFilter: false
|
|
18811
|
-
};
|
|
18812
|
-
const pivotTableColumns = [firstColumn];
|
|
18828
|
+
});
|
|
18813
18829
|
const fullDataFormatting = getDataFormatting(dataFormatting);
|
|
18814
|
-
|
|
18830
|
+
uniqueColumnHeaders.forEach((columnName, i) => {
|
|
18815
18831
|
const formattedColumnName = formatElement({
|
|
18816
18832
|
element: columnName,
|
|
18817
18833
|
column: columns[newLegendColumnIndex],
|
|
@@ -18833,30 +18849,38 @@
|
|
|
18833
18849
|
});
|
|
18834
18850
|
});
|
|
18835
18851
|
const pivotTableData = makeEmptyArray(
|
|
18836
|
-
|
|
18852
|
+
uniqueColumnHeaders.length + 1,
|
|
18837
18853
|
// Add one for the frozen first column
|
|
18838
|
-
|
|
18854
|
+
uniqueRowHeaders.length
|
|
18839
18855
|
);
|
|
18840
18856
|
tableData.forEach((row) => {
|
|
18841
|
-
var _a;
|
|
18842
|
-
const
|
|
18843
|
-
const
|
|
18844
|
-
pivotTableData[
|
|
18845
|
-
|
|
18857
|
+
var _a, _b;
|
|
18858
|
+
const pivotRowIndex = uniqueRowHeadersObj[row[newStringColumnIndex]];
|
|
18859
|
+
const pivotRowHeaderValue = row[newStringColumnIndex];
|
|
18860
|
+
if (!pivotRowHeaderValue || !pivotTableData[pivotRowIndex]) {
|
|
18861
|
+
return;
|
|
18862
|
+
}
|
|
18863
|
+
pivotTableData[pivotRowIndex][0] = pivotRowHeaderValue;
|
|
18846
18864
|
const pivotValue = Number(row[numberColumnIndex]);
|
|
18847
|
-
|
|
18848
|
-
|
|
18849
|
-
|
|
18850
|
-
|
|
18851
|
-
|
|
18865
|
+
const pivotColumnIndex = uniqueColumnHeadersObj[row[newLegendColumnIndex]] + 1;
|
|
18866
|
+
pivotTableData[pivotRowIndex][pivotColumnIndex] = pivotValue;
|
|
18867
|
+
if (pivotTableColumns[pivotColumnIndex]) {
|
|
18868
|
+
pivotTableColumns[pivotColumnIndex].origValues[pivotRowHeaderValue] = {
|
|
18869
|
+
name: (_a = columns[newStringColumnIndex]) == null ? void 0 : _a.name,
|
|
18870
|
+
drill_down: (_b = columns[newStringColumnIndex]) == null ? void 0 : _b.drill_down,
|
|
18871
|
+
value: pivotRowHeaderValue
|
|
18872
|
+
};
|
|
18873
|
+
}
|
|
18852
18874
|
});
|
|
18853
18875
|
const dataReturn = {
|
|
18854
18876
|
pivotTableColumns,
|
|
18855
18877
|
pivotTableData,
|
|
18856
18878
|
stringColumnIndex: newStringColumnIndex,
|
|
18857
18879
|
legendColumnIndex: newLegendColumnIndex,
|
|
18858
|
-
pivotColumnHeaders:
|
|
18859
|
-
pivotRowHeaders:
|
|
18880
|
+
pivotColumnHeaders: uniqueColumnHeaders,
|
|
18881
|
+
pivotRowHeaders: uniqueRowHeaders,
|
|
18882
|
+
pivotTableRowsLimited,
|
|
18883
|
+
pivotTableColumnsLimited
|
|
18860
18884
|
};
|
|
18861
18885
|
return dataReturn;
|
|
18862
18886
|
} catch (error) {
|
|
@@ -23388,10 +23412,8 @@
|
|
|
23388
23412
|
};
|
|
23389
23413
|
var applyStylesForHiddenSeries = ({ legendElement, legendLabels }) => {
|
|
23390
23414
|
try {
|
|
23391
|
-
select_default2(legendElement).selectAll(".cell").each(function() {
|
|
23392
|
-
|
|
23393
|
-
const cellData = JSON.parse((_b = (_a = select_default2(this)) == null ? void 0 : _a.data) == null ? void 0 : _b.call(_a));
|
|
23394
|
-
const legendLabel = legendLabels == null ? void 0 : legendLabels.find((l) => l.label === (cellData == null ? void 0 : cellData.label));
|
|
23415
|
+
select_default2(legendElement).selectAll(".cell").each(function(label) {
|
|
23416
|
+
const legendLabel = legendLabels.find((l) => l.label === label);
|
|
23395
23417
|
if (legendLabel) {
|
|
23396
23418
|
select_default2(this).select(".swatch").attr("stroke", legendLabel.color).attr("stroke-location", "outside");
|
|
23397
23419
|
if (legendLabel.hidden) {
|