@visactor/vtable
Version:
canvas table width high performance
694 lines (683 loc) • 131 kB
JavaScript
import { transpose } from "../tools/util";
import { HierarchyState } from "../ts-types";
import { IndicatorDimensionKeyPlaceholder } from "../tools/global";
import { diffCellAddress, diffCellAddressForGridTree, diffCellAddressForGridTreeOnColumn } from "../tools/diff-cell";
import { checkHasCartesianChart, checkHasChart, getChartAxes, getChartDataId, getChartSpec, getRawChartSpec, isCartesianChart, isHasCartesianChartInline, isNoChartDataRenderNothing, isShareChartSpec } from "./chart-helper/get-chart-spec";
import { DimensionTree, countLayoutTree, dealHeader, dealHeaderForGridTreeMode, dealHeaderForTreeMode, generateLayoutTree } from "./tree-helper";
import { cloneDeep, isArray, isValid } from "@visactor/vutils";
import { getQuadProps } from "../scenegraph/utils/padding";
import { Factory } from "../core/factory";
const defaultDimension = {
startInTotal: 0,
afterSpanLevel: 0
};
export class PivotHeaderLayoutMap {
constructor(table, dataset, columnDimensionTree, rowDimensionTree) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
this.colIndex = 0, this._showHeader = !0, this.columnHeaderObjs = [], this.rowHeaderObjs = [],
this._cornerHeaderCellFullPathIds = [], this._columnHeaderCellFullPathIds = [],
this._rowHeaderCellFullPathIds = [], this._rowHeaderCellFullPathIds_FULL = [], this._cornerHeaderCellIds = [],
this._columnHeaderCellIds = [], this._rowHeaderCellIds = [], this._rowHeaderCellIds_FULL = [],
this._columnWidths = [], this.columnPaths = [], this._headerObjects = [], this._headerObjectMap = {},
this._indicators = [], this.indicatorsAsCol = !0, this.hideIndicatorName = !1, this._showRowHeader = !0,
this._showColumnHeader = !0, this._indicatorShowType = "column", this.rowHierarchyTextStartAlignment = !1,
this.rowDimensionKeys = [], this.colDimensionKeys = [], this.indicatorKeys = [],
this.indicatorDimensionKey = IndicatorDimensionKeyPlaceholder, this._rowHeaderExtensionTree = {},
this._extensionRowDimensionKeys = [], this.fullRowDimensionKeys = [], this.leftRowSeriesNumberColumnCount = 0,
this.rightRowSeriesNumberColumnCount = 0, this._useGetBodyCache = !1, this._getBodyCache = new Map,
this._useHeaderPathCache = !1, this._colHeaderPathCache = new Map, this._rowHeaderPathCache = new Map,
this.sharedVar = table.layoutNodeId, this._table = table, "tree" === table.options.rowHierarchyType && (this.extensionRows = table.options.extensionRows),
this.dataset = dataset, this._largeCellRangeCache = [], this._CellHeaderPathMap = new Map,
this.rowTree = table.internalProps.rowTree, this.columnTree = table.internalProps.columnTree,
this.rowsDefine = null !== (_a = table.internalProps.rows) && void 0 !== _a ? _a : [],
this.columnsDefine = null !== (_b = table.internalProps.columns) && void 0 !== _b ? _b : [],
this.indicatorsDefine = null !== (_c = table.internalProps.indicators) && void 0 !== _c ? _c : [],
this.indicatorTitle = table.options.indicatorTitle, this.indicatorsAsCol = null === (_d = table.options.indicatorsAsCol) || void 0 === _d || _d,
this.hideIndicatorName = null !== (_e = table.options.hideIndicatorName) && void 0 !== _e && _e,
this.showRowHeader = null === (_f = table.options.showRowHeader) || void 0 === _f || _f,
this.showColumnHeader = null === (_g = table.options.showColumnHeader) || void 0 === _g || _g,
this.rowHeaderTitle = table.options.rowHeaderTitle, this.columnHeaderTitle = table.options.columnHeaderTitle,
this.rowHierarchyType = null !== (_h = table.options.rowHierarchyType) && void 0 !== _h ? _h : "grid",
this.columnHierarchyType = null !== (_j = table.options.columnHierarchyType) && void 0 !== _j ? _j : "grid",
this.rowExpandLevel = null !== (_k = table.options.rowExpandLevel) && void 0 !== _k ? _k : 1,
this.columnExpandLevel = null !== (_l = table.options.columnExpandLevel) && void 0 !== _l ? _l : 1,
this.rowHierarchyIndent = null !== (_m = table.options.rowHierarchyIndent) && void 0 !== _m ? _m : 20,
this.rowHierarchyTextStartAlignment = table.options.rowHierarchyTextStartAlignment,
this.cornerSetting = Object.assign({
titleOnDimension: "column",
forceShowHeader: !1
}, table.options.corner), (null === (_p = null === (_o = this._table.options) || void 0 === _o ? void 0 : _o.customConfig) || void 0 === _p ? void 0 : _p.enablePivotPathCache) && (this._useHeaderPathCache = !0,
this._colHeaderPathCache.clear(), this._rowHeaderPathCache.clear()), dataset && (this.rowTree = dataset.rowHeaderTree,
this.columnTree = dataset.colHeaderTree), null === (_q = this.indicatorsDefine) || void 0 === _q || _q.forEach((indicator => {
"string" == typeof indicator ? this.indicatorKeys.push(indicator) : this.indicatorKeys.push(indicator.indicatorKey);
})), this.columnDimensionTree = columnDimensionTree, this.rowDimensionTree = rowDimensionTree,
this.colDimensionKeys = this.columnDimensionTree.dimensionKeysIncludeVirtual.valueArr(),
this.rowDimensionKeys = this.rowDimensionTree.dimensionKeysIncludeVirtual.valueArr(),
this.fullRowDimensionKeys = this.fullRowDimensionKeys.concat(this.rowDimensionKeys),
this.resetRowHeaderLevelCount(), this._table.isPivotChart() && (this.hasTwoIndicatorAxes = this.indicatorsDefine.some((indicatorObject => {
var _a, _b;
if (indicatorObject.chartSpec && indicatorObject.chartSpec.series && indicatorObject.chartSpec.series.length > 1) {
const axes = null !== (_b = null !== (_a = indicatorObject.chartSpec.axes) && void 0 !== _a ? _a : this._table.pivotChartAxes) && void 0 !== _b ? _b : [];
if (!axes.length || axes.every((axis => axis.orient !== (this.indicatorsAsCol ? "top" : "right") || !1 !== axis.visible))) return !0;
}
return !1;
}))), this.resetColumnHeaderLevelCount(), this._generateColHeaderIds(), this.colIndex = 0,
this._generateRowHeaderIds(), this._rowHeaderCellFullPathIds_FULL = transpose(this._rowHeaderCellFullPathIds_FULL),
"tree" === table.options.rowHierarchyType && (null === (_r = this.extensionRows) || void 0 === _r ? void 0 : _r.length) >= 1 && (this.generateExtensionRowTree(),
this.extensionRows.forEach((extensionRow => {
const rowKeys = [];
extensionRow.rows.forEach((row => {
"string" == typeof row ? rowKeys.push(row) : rowKeys.push(row.dimensionKey);
})), this._extensionRowDimensionKeys.push(rowKeys), this.fullRowDimensionKeys = this.fullRowDimensionKeys.concat(rowKeys);
}))), this.sharedVar.seqId = Math.max(this.sharedVar.seqId, this._headerObjects.length);
let rowDimensionKeys, colDimensionKeys = this.columnDimensionTree.dimensionKeysIncludeVirtual.valueArr();
!this.dataset || this._table.isPivotChart() || 0 !== (null !== (_t = null === (_s = this.dataset.records) || void 0 === _s ? void 0 : _s.length) && void 0 !== _t ? _t : 0) || this.dataset.customColTree || (colDimensionKeys = this.columnsDefine.map((define => "string" == typeof define ? define : define.dimensionKey)),
this.indicatorsAsCol && colDimensionKeys.push(this.indicatorDimensionKey)), colDimensionKeys = this.columnHeaderTitle ? [ "" ].concat(colDimensionKeys) : colDimensionKeys;
let extensionRowDimensions = [];
if ("tree" === this.rowHierarchyType && (null === (_u = this.extensionRows) || void 0 === _u ? void 0 : _u.length) >= 1) {
const rowTreeFirstKey = [];
rowTreeFirstKey.push(this.rowDimensionKeys[0]), this._extensionRowDimensionKeys.forEach((extensionRowKeys => {
rowTreeFirstKey.push(extensionRowKeys[0]);
})), extensionRowDimensions = this.extensionRows.reduce(((dimensions, cur) => dimensions.concat(cur.rows)), []),
rowDimensionKeys = this.rowHeaderTitle ? [ "" ].concat(rowTreeFirstKey) : rowTreeFirstKey;
} else rowDimensionKeys = this.rowDimensionTree.dimensionKeysIncludeVirtual.valueArr(),
!this.dataset || this._table.isPivotChart() || 0 !== (null !== (_w = null === (_v = this.dataset.records) || void 0 === _v ? void 0 : _v.length) && void 0 !== _w ? _w : 0) || this.dataset.customRowTree || (rowDimensionKeys = this.rowsDefine.map((define => "string" == typeof define ? define : define.dimensionKey)),
this.indicatorsAsCol || rowDimensionKeys.push(this.indicatorDimensionKey)), rowDimensionKeys = this.rowHeaderTitle ? [ "" ].concat(rowDimensionKeys) : rowDimensionKeys;
this.cornerHeaderObjs = this._addCornerHeaders(colDimensionKeys, rowDimensionKeys, this.columnsDefine.concat(...this.rowsDefine, ...extensionRowDimensions)),
this.colIndex = 0, this._headerObjectMap = this._headerObjects.reduce(((o, e) => (o[e.id] = e,
o)), {}), this.indicatorsAsCol && !this.hideIndicatorName ? this._indicatorShowType = "column" : this.indicatorsAsCol || this.hideIndicatorName ? this._indicatorShowType = "none" : this._indicatorShowType = "row",
this.generateCellIdsConsiderHideHeader(), this.setPagination(table.options.pagination),
this._table.isPivotChart() && (this._chartItemSpanSize = 0, this._chartItemBandSize = 0,
this._indicators.find((indicatorObject => {
var _a, _b, _c, _d, _e, _f, _g, _h;
(null === (_a = null == indicatorObject ? void 0 : indicatorObject.style) || void 0 === _a ? void 0 : _a.padding) && (this._chartPadding = indicatorObject.style.padding),
(null === (_b = indicatorObject.chartSpec) || void 0 === _b ? void 0 : _b.barWidth) && "number" == typeof indicatorObject.chartSpec.barWidth && (this._chartItemSpanSize = null === (_c = indicatorObject.chartSpec) || void 0 === _c ? void 0 : _c.barWidth);
const bandAxisConfig = null === (_e = null === (_d = indicatorObject.chartSpec) || void 0 === _d ? void 0 : _d.axes) || void 0 === _e ? void 0 : _e.find((axis => "band" === axis.type));
return (null == bandAxisConfig ? void 0 : bandAxisConfig.bandSize) && (this._chartItemBandSize = null == bandAxisConfig ? void 0 : bandAxisConfig.bandSize,
this._chartPaddingInner = null !== (_f = isArray(bandAxisConfig.paddingInner) ? bandAxisConfig.paddingInner[0] : bandAxisConfig.paddingInner) && void 0 !== _f ? _f : 0,
this._chartPaddingOuter = null !== (_g = isArray(bandAxisConfig.paddingOuter) ? bandAxisConfig.paddingOuter[0] : bandAxisConfig.paddingOuter) && void 0 !== _g ? _g : 0),
this._chartItemSpanSize > 0 || (null === (_h = indicatorObject.chartSpec.series) || void 0 === _h || _h.find((seriesObject => (seriesObject.barWidth && "number" == typeof seriesObject.barWidth && (this._chartItemSpanSize = seriesObject.barWidth),
this._chartItemSpanSize > 0))), !1);
}))), this.handleRowSeriesNumber(table.internalProps.rowSeriesNumber), this.setColumnWidths();
}
handleRowSeriesNumber(rowSeriesNumber) {
var _a;
rowSeriesNumber && (Array.isArray(rowSeriesNumber) ? this.rowSeriesNumberColumn = rowSeriesNumber.map((seriesNumber => {
var _a;
return {
id: "",
title: seriesNumber.title,
define: seriesNumber,
cellType: null !== (_a = seriesNumber.cellType) && void 0 !== _a ? _a : "text",
headerType: seriesNumber.cellType && "radio" !== seriesNumber.cellType ? seriesNumber.cellType : "text",
width: seriesNumber.width,
style: seriesNumber.style,
format: seriesNumber.format,
field: seriesNumber.field,
icon: seriesNumber.icon
};
})) : this.rowSeriesNumberColumn = [ {
id: "",
title: rowSeriesNumber.title,
define: rowSeriesNumber,
cellType: null !== (_a = rowSeriesNumber.cellType) && void 0 !== _a ? _a : "text",
headerType: rowSeriesNumber.cellType && "radio" !== rowSeriesNumber.cellType ? rowSeriesNumber.cellType : "text",
style: rowSeriesNumber.style,
width: rowSeriesNumber.width,
format: rowSeriesNumber.format,
field: "",
icon: rowSeriesNumber.icon,
isChildNode: !1
} ], this.leftRowSeriesNumberColumn = this.rowSeriesNumberColumn.filter((rowSeriesNumberItem => !0)),
this.rightRowSeriesNumberColumn = this.rowSeriesNumberColumn.filter((rowSeriesNumberItem => !1)),
this.leftRowSeriesNumberColumnCount = this.leftRowSeriesNumberColumn.length, this.rightRowSeriesNumberColumnCount = this.rightRowSeriesNumberColumn.length);
}
_generateColHeaderIds() {
var _a, _b, _c, _d, _e, _f, _g, _h;
if ((null === (_a = this.columnDimensionTree.tree.children) || void 0 === _a ? void 0 : _a.length) >= 1) if ("grid-tree" === this.columnHierarchyType) {
const startCol = 0;
this._addHeadersForGridTreeMode(this._columnHeaderCellFullPathIds, startCol, this.columnDimensionTree.tree.children, [], this.columnDimensionTree.totalLevel, this._getColumnHeaderTreeExpandedMaxLevelCount(), !0, this.columnsDefine, this.columnHeaderObjs, !1);
} else {
let startRow = 0;
if (this.dataset && !this._table.isPivotChart() && 0 === (null !== (_c = null === (_b = this.dataset.records) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) && !this.dataset.customColTree && !this.dataset.customRowTree && this.indicatorsAsCol && this._getColumnHeaderTreeExpandedMaxLevelCount() < this.columnHeaderLevelCount) {
startRow = this.columnHeaderLevelCount - this._getColumnHeaderTreeExpandedMaxLevelCount();
for (let i = 0; i < startRow; i++) this._columnHeaderCellFullPathIds.unshift([]);
}
this._addHeaders(this._columnHeaderCellFullPathIds, startRow, this.columnDimensionTree.tree.children, [], this.columnHeaderObjs);
}
if (this.columnHeaderTitle) {
this.sharedVar.seqId = Math.max(this.sharedVar.seqId, this._headerObjects.length);
const id = ++this.sharedVar.seqId, firstRowIds = Array(this.colCount - this.rowHeaderLevelCount - this.rightFrozenColCount).fill(id);
this._columnHeaderCellFullPathIds.unshift(firstRowIds);
const cell = {
id: id,
title: "string" == typeof this.columnHeaderTitle.title ? this.columnHeaderTitle.title : this.columnsDefine.reduce(((title, value) => "string" == typeof value ? title : title + (title ? `/${value.title}` : `${value.title}`)), ""),
field: void 0,
headerType: null !== (_e = null === (_d = this.columnHeaderTitle) || void 0 === _d ? void 0 : _d.headerType) && void 0 !== _e ? _e : "text",
style: null === (_f = this.columnHeaderTitle) || void 0 === _f ? void 0 : _f.headerStyle,
define: {
id: id,
disableHeaderHover: !!(null === (_g = this.columnHeaderTitle) || void 0 === _g ? void 0 : _g.disableHeaderHover),
disableHeaderSelect: !!(null === (_h = this.columnHeaderTitle) || void 0 === _h ? void 0 : _h.disableHeaderSelect)
}
};
this.columnHeaderObjs.push(cell), this._headerObjects[id] = cell;
}
}
_generateRowHeaderIds() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
if ((null === (_a = this.rowDimensionTree.tree.children) || void 0 === _a ? void 0 : _a.length) >= 1) if ("tree" === this.rowHierarchyType) this._addHeadersForTreeMode(this._rowHeaderCellFullPathIds_FULL, 0, this.rowDimensionTree.tree.children, [], this.rowDimensionTree.totalLevel, !0, this.rowsDefine, this.rowHeaderObjs); else if ("grid-tree" === this.rowHierarchyType) {
const startRow = 0;
this._addHeadersForGridTreeMode(this._rowHeaderCellFullPathIds_FULL, startRow, this.rowDimensionTree.tree.children, [], this.rowDimensionTree.totalLevel, this._getRowHeaderTreeExpandedMaxLevelCount(), !0, this.rowsDefine, this.rowHeaderObjs, !0);
} else {
let startRow = 0;
if (this.dataset && !this._table.isPivotChart() && 0 === (null !== (_c = null === (_b = this.dataset.records) || void 0 === _b ? void 0 : _b.length) && void 0 !== _c ? _c : 0) && !this.dataset.customColTree && !this.dataset.customRowTree && !this.indicatorsAsCol && this._getRowHeaderTreeExpandedMaxLevelCount() < this.rowHeaderLevelCount) {
startRow = this.rowHeaderLevelCount - this._getRowHeaderTreeExpandedMaxLevelCount();
for (let i = 0; i < startRow; i++) this._rowHeaderCellFullPathIds_FULL.unshift([]);
}
this._addHeaders(this._rowHeaderCellFullPathIds_FULL, startRow, this.rowDimensionTree.tree.children, [], this.rowHeaderObjs);
}
if (this.rowHeaderTitle) {
this.sharedVar.seqId = Math.max(this.sharedVar.seqId, this._headerObjects.length);
const id = ++this.sharedVar.seqId, firstColIds = Array(null !== (_e = null === (_d = this._rowHeaderCellFullPathIds_FULL[0]) || void 0 === _d ? void 0 : _d.length) && void 0 !== _e ? _e : this.rowDimensionTree.tree.size).fill(id);
this._rowHeaderCellFullPathIds_FULL.unshift(firstColIds);
const cell = {
id: id,
title: "string" == typeof this.rowHeaderTitle.title ? this.rowHeaderTitle.title : this.rowsDefine.reduce(((title, value) => "string" == typeof value ? title : title + (title ? `/${value.title}` : `${value.title}`)), ""),
field: void 0,
headerType: null !== (_g = null === (_f = this.rowHeaderTitle) || void 0 === _f ? void 0 : _f.headerType) && void 0 !== _g ? _g : "text",
style: null === (_h = this.rowHeaderTitle) || void 0 === _h ? void 0 : _h.headerStyle,
define: {
id: id,
disableHeaderHover: !!(null === (_j = this.rowHeaderTitle) || void 0 === _j ? void 0 : _j.disableHeaderHover),
disableHeaderSelect: !!(null === (_k = this.rowHeaderTitle) || void 0 === _k ? void 0 : _k.disableHeaderSelect)
}
};
this.rowHeaderObjs.push(cell), this._headerObjects[id] = cell;
}
}
_getRowHeaderTreeExpandedMaxLevelCount() {
return "tree" === this.rowHierarchyType ? 1 : "grid-tree" === this.rowHierarchyType ? "row" === this.cornerSetting.titleOnDimension ? this.rowDimensionTree.totalLevel : this.indicatorsAsCol ? this.rowDimensionTree.expandedMaxLevel : this.rowDimensionTree.expandedMaxLevel + 1 : this.rowDimensionTree.totalLevel;
}
_getColumnHeaderTreeExpandedMaxLevelCount() {
return "grid-tree" === this.columnHierarchyType ? "column" === this.cornerSetting.titleOnDimension ? this.columnDimensionTree.totalLevel : !1 === this.indicatorsAsCol ? this.columnDimensionTree.expandedMaxLevel : this.columnDimensionTree.expandedMaxLevel + 1 : this.columnDimensionTree.totalLevel;
}
_addHeaders(_headerCellIds, row, header, roots, results) {
const _this = this;
_headerCellIds[row] || function(row) {
const newRow = _headerCellIds[row] = [];
if (0 === _this.colIndex) return newRow;
const prev = _headerCellIds[row - 1];
for (let col = 0; col < (null == prev ? void 0 : prev.length); col++) newRow[col] = prev[col];
}(row);
for (let i = 0; i < header.length; i++) {
const hd = header[i];
dealHeader(hd, _headerCellIds, results, roots, row, this);
}
}
_addHeadersForTreeMode(_headerCellIds, row, header, roots, totalLevel, show, dimensions, results) {
const _this = this;
_headerCellIds[row] || function(row) {
const newRow = _headerCellIds[row] = [];
if (0 === _this.colIndex) return newRow;
const prev = _headerCellIds[row - 1];
for (let col = 0; col < (null == prev ? void 0 : prev.length); col++) newRow[col] = prev[col];
}(row);
for (let i = 0; i < header.length; i++) {
const hd = header[i];
dealHeaderForTreeMode(hd, _headerCellIds, results, roots, row, totalLevel, show, dimensions, this);
}
}
_addHeadersForGridTreeMode(_headerCellIds, row, header, roots, totalLevel, expandedMaxLevel, show, dimensions, results, isRowTree) {
const _this = this;
_headerCellIds[row] || function(row) {
const newRow = _headerCellIds[row] = [];
if (0 === _this.colIndex) return newRow;
const prev = _headerCellIds[row - 1];
for (let col = 0; col < (null == prev ? void 0 : prev.length); col++) newRow[col] = prev[col];
}(row);
for (let i = 0; i < header.length; i++) {
const hd = header[i];
dealHeaderForGridTreeMode(hd, _headerCellIds, results, roots, row, totalLevel, expandedMaxLevel, show, dimensions, isRowTree, this.indicatorsAsCol, this);
}
}
_addCornerHeaders(colDimensionKeys, rowDimensionKeys, dimensions) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
this._cornerHeaderCellFullPathIds = [];
const results = [], colLevelCount = "grid-tree" === this.columnHierarchyType && this._getColumnHeaderTreeExpandedMaxLevelCount() || this.columnHeaderLevelCount, rowLevelCount = "grid-tree" === this.rowHierarchyType && this._getRowHeaderTreeExpandedMaxLevelCount() || this.rowHeaderLevelCount;
if (0 === colLevelCount || 0 === rowLevelCount) return results;
if ("all" === this.cornerSetting.titleOnDimension) if (this.indicatorsAsCol) {
if (colDimensionKeys) for (let i = 0; i < colLevelCount; i++) {
const dimensionKey = colDimensionKeys[i], id = ++this.sharedVar.seqId, dimensionInfo = dimensions.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey)), cell = {
id: id,
title: dimensionKey === this.indicatorDimensionKey ? this.indicatorTitle : dimensionInfo ? dimensionInfo.title : "axis" === dimensionKey ? "" : dimensionKey,
field: dimensionKey,
style: this.cornerSetting.headerStyle,
headerType: null !== (_a = this.cornerSetting.headerType) && void 0 !== _a ? _a : "text",
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
define: {
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
dimensionKey: dimensionKey,
id: id,
value: dimensionKey,
headerEditor: this.cornerSetting.headerEditor,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
},
dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.cornerDropDownMenu,
headerIcon: null == dimensionInfo ? void 0 : dimensionInfo.cornerHeaderIcon,
pivotInfo: {
value: null !== (_b = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _b ? _b : "",
dimensionKey: dimensionKey,
isPivotCorner: !0
},
description: null == dimensionInfo ? void 0 : dimensionInfo.cornerDescription
};
results[id] = cell, this._headerObjects[id] = cell, this._cornerHeaderCellFullPathIds[i] || (this._cornerHeaderCellFullPathIds[i] = []);
for (let r = 0; r < rowLevelCount; r++) this._cornerHeaderCellFullPathIds[i][r] = id;
}
if (rowDimensionKeys) for (let i = 0; i < rowLevelCount; i++) {
const dimensionKey = rowDimensionKeys[i], id = ++this.sharedVar.seqId, dimensionInfo = dimensions.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey)), cell = {
id: id,
title: dimensionKey === this.indicatorDimensionKey ? this.indicatorTitle : dimensionInfo ? dimensionInfo.title : "axis" === dimensionKey ? "" : dimensionKey,
field: dimensionKey,
style: this.cornerSetting.headerStyle,
headerType: null !== (_c = this.cornerSetting.headerType) && void 0 !== _c ? _c : "text",
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
define: {
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
dimensionKey: dimensionKey,
id: id,
value: dimensionKey,
headerEditor: this.cornerSetting.headerEditor,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
},
dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.cornerDropDownMenu,
headerIcon: null == dimensionInfo ? void 0 : dimensionInfo.cornerHeaderIcon,
pivotInfo: {
value: null !== (_d = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _d ? _d : "",
dimensionKey: dimensionKey,
isPivotCorner: !0
},
description: null == dimensionInfo ? void 0 : dimensionInfo.cornerDescription
};
results[id] = cell, this._headerObjects[id] = cell, this._cornerHeaderCellFullPathIds[this._cornerHeaderCellFullPathIds.length - 1] || (this._cornerHeaderCellFullPathIds[this._cornerHeaderCellFullPathIds.length - 1] = []),
this._cornerHeaderCellFullPathIds[this._cornerHeaderCellFullPathIds.length - 1][i] = id;
}
} else {
if (rowDimensionKeys) for (let i = 0; i < rowLevelCount; i++) {
const dimensionKey = rowDimensionKeys[i], id = ++this.sharedVar.seqId, dimensionInfo = dimensions.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey)), cell = {
id: id,
title: dimensionKey === this.indicatorDimensionKey ? this.indicatorTitle : dimensionInfo ? dimensionInfo.title : "axis" === dimensionKey ? "" : dimensionKey,
field: dimensionKey,
style: this.cornerSetting.headerStyle,
headerType: null !== (_e = this.cornerSetting.headerType) && void 0 !== _e ? _e : "text",
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
define: {
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
dimensionKey: dimensionKey,
id: id,
value: dimensionKey,
headerEditor: this.cornerSetting.headerEditor,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
},
dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.cornerDropDownMenu,
headerIcon: null == dimensionInfo ? void 0 : dimensionInfo.cornerHeaderIcon,
pivotInfo: {
value: null !== (_f = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _f ? _f : "",
dimensionKey: dimensionKey,
isPivotCorner: !0
},
description: null == dimensionInfo ? void 0 : dimensionInfo.cornerDescription
};
results[id] = cell, this._headerObjects[id] = cell;
for (let r = 0; r < colLevelCount; r++) this._cornerHeaderCellFullPathIds[r] || (this._cornerHeaderCellFullPathIds[r] = []),
this._cornerHeaderCellFullPathIds[r][i] = id;
}
if (colDimensionKeys) for (let c = 0; c < colLevelCount; c++) {
const dimensionKey = colDimensionKeys[c], id = ++this.sharedVar.seqId, dimensionInfo = dimensions.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey)), cell = {
id: id,
title: dimensionKey === this.indicatorDimensionKey ? this.indicatorTitle : dimensionInfo ? dimensionInfo.title : "axis" === dimensionKey ? "" : dimensionKey,
field: dimensionKey,
style: this.cornerSetting.headerStyle,
headerType: null !== (_g = this.cornerSetting.headerType) && void 0 !== _g ? _g : "text",
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
define: {
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
dimensionKey: dimensionKey,
id: id,
value: dimensionKey,
headerEditor: this.cornerSetting.headerEditor,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
},
dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.cornerDropDownMenu,
headerIcon: null == dimensionInfo ? void 0 : dimensionInfo.cornerHeaderIcon,
pivotInfo: {
value: null !== (_h = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _h ? _h : "",
dimensionKey: dimensionKey,
isPivotCorner: !0
},
description: null == dimensionInfo ? void 0 : dimensionInfo.cornerDescription
};
results[id] = cell, this._headerObjects[id] = cell, this._cornerHeaderCellFullPathIds[c][this._cornerHeaderCellFullPathIds[c].length - 1] = id;
}
} else if ("row" === this.cornerSetting.titleOnDimension || "column" === this.cornerSetting.titleOnDimension) {
const dimensionKeys = "row" === (null === (_j = this.cornerSetting) || void 0 === _j ? void 0 : _j.titleOnDimension) ? rowDimensionKeys : colDimensionKeys;
dimensionKeys && dimensionKeys.forEach(((dimensionKey, key) => {
var _a, _b;
const id = ++this.sharedVar.seqId, dimensionInfo = dimensions.find((dimension => "string" != typeof dimension && dimension.dimensionKey === dimensionKey)), cell = {
id: id,
title: dimensionKey === this.indicatorDimensionKey ? this.indicatorTitle : dimensionInfo ? dimensionInfo.title : "axis" === dimensionKey ? "" : dimensionKey,
field: dimensionKey,
style: this.cornerSetting.headerStyle,
headerType: null !== (_a = this.cornerSetting.headerType) && void 0 !== _a ? _a : "text",
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
define: {
showSort: null == dimensionInfo ? void 0 : dimensionInfo.showSortInCorner,
sort: null == dimensionInfo ? void 0 : dimensionInfo.sort,
dimensionKey: dimensionKey,
id: id,
value: dimensionKey,
headerCustomRender: this.cornerSetting.customRender,
headerCustomLayout: this.cornerSetting.customLayout,
headerEditor: this.cornerSetting.headerEditor,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
},
dropDownMenu: null == dimensionInfo ? void 0 : dimensionInfo.cornerDropDownMenu,
headerIcon: null == dimensionInfo ? void 0 : dimensionInfo.cornerHeaderIcon,
pivotInfo: {
value: null !== (_b = null == dimensionInfo ? void 0 : dimensionInfo.title) && void 0 !== _b ? _b : "",
dimensionKey: dimensionKey,
isPivotCorner: !0
},
description: null == dimensionInfo ? void 0 : dimensionInfo.cornerDescription
};
if (results[id] = cell, this._headerObjects[id] = cell, "column" === this.cornerSetting.titleOnDimension) {
this._cornerHeaderCellFullPathIds[key] || (this._cornerHeaderCellFullPathIds[key] = []);
for (let r = 0; r < this.rowHeaderLevelCount; r++) this._cornerHeaderCellFullPathIds[key][r] = id;
} else if ("row" === this.cornerSetting.titleOnDimension) for (let r = 0; r < this.columnHeaderLevelCount; r++) this._cornerHeaderCellFullPathIds[r] || (this._cornerHeaderCellFullPathIds[r] = []),
this._cornerHeaderCellFullPathIds[r][key] = id;
}));
} else {
const id = ++this.sharedVar.seqId, cell = {
id: id,
title: "",
field: "维度名称",
style: this.cornerSetting.headerStyle,
headerType: null !== (_k = this.cornerSetting.headerType) && void 0 !== _k ? _k : "text",
define: {
dimensionKey: "维度名称",
id: id,
headerCustomRender: this.cornerSetting.customRender,
headerCustomLayout: this.cornerSetting.customLayout,
disableHeaderHover: !!this.cornerSetting.disableHeaderHover,
disableHeaderSelect: !!this.cornerSetting.disableHeaderSelect
}
};
results[id] = cell, this._headerObjects[id] = cell;
for (let r = 0; r < this.columnHeaderLevelCount; r++) for (let j = 0; j < this.rowHeaderLevelCount; j++) this._cornerHeaderCellFullPathIds[r] || (this._cornerHeaderCellFullPathIds[r] = []),
this._cornerHeaderCellFullPathIds[r][j] = id;
}
return results;
}
generateExtensionRowTree() {
this.extensionRows.forEach(((extensionRow, indexP) => {
const old_rowHeaderCellIds = this._rowHeaderCellFullPathIds_FULL;
this._rowHeaderCellFullPathIds_FULL = [], old_rowHeaderCellIds.forEach(((row_ids, index) => {
const key = row_ids[row_ids.length - 1];
let tree, rowExtensionDimensionTree;
if (this.colIndex = 0, "function" == typeof extensionRow.rowTree) {
const fullCellIds = this.findFullCellIds(row_ids);
tree = extensionRow.rowTree(fullCellIds.map((id => ({
dimensionKey: this._headerObjects[id].field,
value: this._headerObjects[id].title
}))));
} else tree = cloneDeep(extensionRow.rowTree);
this._rowHeaderExtensionTree[key] ? (this._rowHeaderExtensionTree[key].reset(this._rowHeaderExtensionTree[key].tree.children),
rowExtensionDimensionTree = this._rowHeaderExtensionTree[key]) : (rowExtensionDimensionTree = new DimensionTree(null != tree ? tree : [], this.sharedVar, this.rowHierarchyType, void 0),
this._rowHeaderExtensionTree[key] = rowExtensionDimensionTree);
const extensionRowTreeHeaderIds = [];
this._addHeadersForTreeMode(extensionRowTreeHeaderIds, 0, rowExtensionDimensionTree.tree.children, [], rowExtensionDimensionTree.totalLevel, !0, extensionRow.rows, this.rowHeaderObjs);
for (let i = 0; i < extensionRowTreeHeaderIds[0].length; i++) this._rowHeaderCellFullPathIds_FULL.push(row_ids.concat(extensionRowTreeHeaderIds[0][i]));
}));
}));
}
setColumnWidths() {
var _a, _b, _c;
const returnWidths = new Array(this.colCount).fill(void 0);
if (this.leftRowSeriesNumberColumnCount && (returnWidths[0] = this.leftRowSeriesNumberColumn[0]),
this.showHeader && this.showRowHeader) if (this.rowHeaderTitle && (returnWidths[0 + this.leftRowSeriesNumberColumnCount] = {}),
"tree" === this.rowHierarchyType) {
const mainDimensionFirstRowKey = this.rowDimensionKeys[0];
if (mainDimensionFirstRowKey) {
const dimension = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === mainDimensionFirstRowKey));
dimension && (returnWidths[0 + (this.rowHeaderTitle ? 1 : 0) + this.leftRowSeriesNumberColumnCount] = {
width: dimension.width,
minWidth: dimension.minWidth,
maxWidth: dimension.maxWidth
});
}
null === (_b = this._extensionRowDimensionKeys) || void 0 === _b || _b.forEach(((extensionRowDimensionKeys, index) => {
var _a;
const curDimensionFirstRowKey = extensionRowDimensionKeys[0];
if (curDimensionFirstRowKey) {
const dimension = null === (_a = this.extensionRows[index].rows) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === curDimensionFirstRowKey));
dimension && (returnWidths[index + 1 + (this.rowHeaderTitle ? 1 : 0) + this.leftRowSeriesNumberColumnCount] = {
width: dimension.width,
minWidth: dimension.minWidth,
maxWidth: dimension.maxWidth
});
}
}));
} else {
(this.rowDimensionTree.totalLevel > 0 ? this.rowDimensionTree.dimensionKeysIncludeVirtual.valueArr() : this.rowsDefine.map((dimension => "string" == typeof dimension ? dimension : dimension.dimensionKey))).forEach(((objKey, index) => {
var _a;
const dimension = null === (_a = this.rowsDefine) || void 0 === _a ? void 0 : _a.find((dimension => "string" != typeof dimension && dimension.dimensionKey === objKey));
dimension && (returnWidths[index + (this.rowHeaderTitle ? 1 : 0) + this.leftRowSeriesNumberColumnCount] = {
width: dimension.width,
minWidth: dimension.minWidth,
maxWidth: dimension.maxWidth
});
}));
}
if (this.indicatorsAsCol) for (let i = this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount; i < this.colCount; i++) {
const cellDefine = this.getBody(i, this.columnHeaderLevelCount);
returnWidths[i] = {
width: null == cellDefine ? void 0 : cellDefine.width,
minWidth: null == cellDefine ? void 0 : cellDefine.minWidth,
maxWidth: null == cellDefine ? void 0 : cellDefine.maxWidth
};
} else {
let maxWidth, minWidth, isAuto, width = 0;
null === (_c = this._indicators) || void 0 === _c || _c.forEach(((obj, index) => {
var _a, _b;
"number" == typeof obj.width ? width = Math.max(obj.width, width) : "auto" === obj.width && (isAuto = !0),
"number" == typeof obj.minWidth && (minWidth = Math.max(obj.minWidth, null !== (_a = minWidth) && void 0 !== _a ? _a : 0)),
"number" == typeof obj.maxWidth && (maxWidth = Math.min(obj.maxWidth, null !== (_b = maxWidth) && void 0 !== _b ? _b : Number.MAX_VALUE));
})), width = width > 0 ? width : isAuto ? "auto" : void 0, returnWidths.fill({
width: width,
minWidth: minWidth,
maxWidth: maxWidth
}, this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount, this.colCount - this.rightFrozenColCount);
}
this._columnWidths = returnWidths;
}
get columnWidths() {
return this._columnWidths;
}
getColumnWidthDefined(col) {
return this._columnWidths[col];
}
get showHeader() {
return this._showHeader;
}
set showHeader(_showHeader) {
this._showHeader = _showHeader;
}
get showColumnHeader() {
return this._showColumnHeader;
}
set showColumnHeader(_showColumnHeader) {
this._showColumnHeader = _showColumnHeader;
}
get showRowHeader() {
return this._showRowHeader;
}
set showRowHeader(_showRowHeader) {
this._showRowHeader = _showRowHeader;
}
get columnHeaderTitle() {
return this._columnHeaderTitle;
}
set columnHeaderTitle(_columnHeaderTitle) {
this._columnHeaderTitle = _columnHeaderTitle;
}
get rowHeaderTitle() {
return this._rowHeaderTitle;
}
set rowHeaderTitle(_rowHeaderTitle) {
this._rowHeaderTitle = _rowHeaderTitle;
}
getHeaderFieldKey(col, row) {}
getCellLocation(col, row) {
return this.isCornerHeader(col, row) ? "cornerHeader" : this.isColumnHeader(col, row) ? "columnHeader" : this.isRowHeader(col, row) ? "rowHeader" : "body";
}
isHeader(col, row) {
return col >= this.leftRowSeriesNumberColumnCount && col < this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount || (row >= 0 && row < this.columnHeaderLevelCount || (col >= this.colCount - this.rightHeaderColCount || row >= this.rowCount - this.bottomHeaderRowCount));
}
isCornerHeader(col, row) {
return col >= 0 && col < this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount && row >= 0 && row < this.columnHeaderLevelCount;
}
isColumnHeader(col, row) {
return col >= this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount && row >= 0 && row < this.columnHeaderLevelCount;
}
isRowHeader(col, row) {
return col >= this.leftRowSeriesNumberColumnCount && col < this.rowHeaderLevelCount + this.leftRowSeriesNumberColumnCount && row >= this.columnHeaderLevelCount;
}
isFrozen(col, row) {
return this.isFrozenColumn(col) || this.isRightFrozenColumn(col) || this.isBottomFrozenRow(row) || this.isFrozenRow(row) || this.isSeriesNumberInBody(col, row) || this.isSeriesNumberInHeader(col, row);
}
isFrozenColumn(col, row) {
if (isValid(row)) {
if (col >= 0 && col < this.frozenColCount && row >= this.frozenRowCount && row < this.rowCount - this.bottomFrozenRowCount) return !0;
} else if (this.frozenColCount > 0 && col >= 0 && col < this.frozenColCount) return !0;
return !1;
}
isRightFrozenColumn(col, row) {
if (isValid(row)) {
if (col >= this.colCount - this.rightFrozenColCount && row >= this.frozenRowCount && row < this.rowCount - this.bottomFrozenRowCount) return !0;
} else if (this.rightFrozenColCount > 0 && col >= this.colCount - this.rightFrozenColCount) return !0;
return !1;
}
isFrozenRow(col, row) {
if (isValid(row)) {
if (row >= 0 && row < this.frozenRowCount && col >= this.frozenColCount && col < this.colCount - this.rightFrozenColCount) return !0;
} else if (row = col, this.frozenRowCount > 0 && row >= 0 && row < this.frozenRowCount) return !0;
return !1;
}
isBottomFrozenRow(col, row) {
if (isValid(row)) {
if (row >= this.rowCount - this.bottomFrozenRowCount && col >= this.frozenColCount && col < this.colCount - this.rightFrozenColCount) return !0;
} else if (row = col, this.bottomFrozenRowCount > 0 && row >= this.rowCount - this.bottomFrozenRowCount) return !0;
return !1;
}
isLeftTopCorner(col, row) {
return col >= 0 && col < this.frozenColCount && row >= 0 && row < this.frozenRowCount;
}
isLeftBottomCorner(col, row) {
return col >= 0 && col < this.frozenColCount && row >= this.rowCount - this.bottomFrozenRowCount;
}
isRightTopCorner(col, row) {
return col >= this.colCount - this.rightFrozenColCount && row >= 0 && row < this.frozenRowCount;
}
isRightBottomCorner(col, row) {
return col >= this.colCount - this.rightFrozenColCount && row >= this.rowCount - this.bottomFrozenRowCount;
}
getColumnHeaderRange() {
return {
start: {
col: this.rowHeaderLevelCount,
row: 0
},
end: {
col: this.colCount - 1,
row: this.columnHeaderLevelCount - 1
}
};
}
getRowHeaderRange() {
return {
start: {
col: 0,
row: this.columnHeaderLevelCount
},
end: {
col: this.rowHeaderLevelCount - 1,
row: this.rowCount - 1
}
};
}
getCornerHeaderRange() {
return {
start: {
col: 0,
row: 0
},
end: {
col: this.rowHeaderLevelCount - 1,
row: this.columnHeaderLevelCount - 1
}
};
}
getBodyRange() {
return {
start: {
col: this.rowHeaderLevelCount,
row: this.columnHeaderLevelCount
},
end: {
col: this.colCount - 1,
row: this.rowCount - 1
}
};
}
resetCellIds() {}
get frozenColCount() {
return this._table.internalProps.frozenColCount ? this.colCount > this._table.internalProps.frozenColCount ? this._table.internalProps.frozenColCount : this.colCount : 0;
}
get frozenRowCount() {
return this._table.internalProps.frozenRowCount ? this.rowCount >= this._table.internalProps.frozenRowCount ? this._table.internalProps.frozenRowCount : this.rowCount : 0;
}
get headerLevelCount() {
return this.columnHeaderLevelCount;
}
resetColumnHeaderLevelCount() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
if (this.showHeader && this.showColumnHeader) {
if (this._table.isPivotChart() && this.indicatorsAsCol && !(null === (_b = null === (_a = this.dataset) || void 0 === _a ? void 0 : _a.colKeys) || void 0 === _b ? void 0 : _b.length) && 0 === (null === (_d = null === (_c = this.columnDimensionTree) || void 0 === _c ? void 0 : _c.tree) || void 0 === _d ? void 0 : _d.level) && !this.hasTwoIndicatorAxes) return void (this.columnHeaderLevelCount = 0);
let count = this._getColumnHeaderTreeExpandedMaxLevelCount();
return this.indicatorsAsCol && this.hideIndicatorName && this.colDimensionKeys[this.colDimensionKeys.length - 1] === this.indicatorDimensionKey && count--,
0 === count && this.dataset && !(null === (_e = this.dataset.customColTree) || void 0 === _e ? void 0 : _e.length) ? "row" !== this.cornerSetting.titleOnDimension && "all" !== this.cornerSetting.titleOnDimension || !this.cornerSetting.forceShowHeader ? this._table.isPivotChart() || 0 !== (null !== (_g = null === (_f = this.dataset.records) || void 0 === _f ? void 0 : _f.length) && void 0 !== _g ? _g : 0) || "column" !== this.cornerSetting.titleOnDimension && "all" !== this.cornerSetting.titleOnDimension || (count = null !== (_h = this.columnsDefine.length) && void 0 !== _h ? _h : 0) : count = 1 : !this.dataset || this._table.isPivotChart() || 0 !== (null !== (_k = null === (_j = this.dataset.records) || void 0 === _j ? void 0 : _j.length) && void 0 !== _k ? _k : 0) || this.dataset.customColTree || "column" !== this.cornerSetting.titleOnDimension && "all" !== this.cornerSetting.titleOnDimension || (count = null !== (_l = this.columnsDefine.length) && void 0 !== _l ? _l : 0,
!this.hideIndicatorName && this.indicatorsAsCol && count++), this.columnHeaderTitle && (count += 1),
this._table.isPivotChart() && this.indicatorsAsCol && !this.hasTwoIndicatorAxes && checkHasCartesianChart(this.indicatorsDefine) && (count -= 1),
void (this.columnHeaderLevelCount = count);
}
this.columnHeaderLevelCount = this.indicatorsAsCol ? this.hideIndicatorName ? 0 : 1 : 0;
}
resetRowHeaderLevelCount() {
var _a, _b, _c, _d, _e, _f, _g, _h;
if (this.showHeader && this.showRowHeader) {
if ("tree" === this.rowHierarchyType) {