@hisptz/dhis2-analytics 1.0.10 → 1.0.11
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/build/cjs/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
- package/build/cjs/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/cjs/components/Map/Map.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/cjs/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/cjs/components/PivotTable/PivotTable.stories.js +277 -0
- package/build/cjs/components/PivotTable/components/AssignedCategoriesIcon/index.js +32 -0
- package/build/cjs/components/PivotTable/components/PivotTable.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableBody.js +41 -0
- package/build/cjs/components/PivotTable/components/PivotTableCell.js +40 -0
- package/build/cjs/components/PivotTable/components/PivotTableClippedAxis.js +26 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaderCell.js +71 -0
- package/build/cjs/components/PivotTable/components/PivotTableColumnHeaders.js +60 -0
- package/build/cjs/components/PivotTable/components/PivotTableContainer.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableDimensionLabelCell.js +77 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyCell.js +22 -0
- package/build/cjs/components/PivotTable/components/PivotTableEmptyRow.js +33 -0
- package/build/cjs/components/PivotTable/components/PivotTableEngineContext.js +25 -0
- package/build/cjs/components/PivotTable/components/PivotTableHead.js +35 -0
- package/build/cjs/components/PivotTable/components/PivotTableHeaderCell.js +37 -0
- package/build/cjs/components/PivotTable/components/PivotTableRow.js +65 -0
- package/build/cjs/components/PivotTable/components/PivotTableRowHeaderCell.js +49 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRow.js +52 -0
- package/build/cjs/components/PivotTable/components/PivotTableTitleRows.js +46 -0
- package/build/cjs/components/PivotTable/components/PivotTableValueCell.js +69 -0
- package/build/cjs/components/PivotTable/constants/dataTypes.js +129 -0
- package/build/cjs/components/PivotTable/constants/pivotTable.js +64 -0
- package/build/cjs/components/PivotTable/constants/predefinedDimensions.js +62 -0
- package/build/cjs/components/PivotTable/constants/valueTypes.js +55 -0
- package/build/cjs/components/PivotTable/data/column-data.json +210 -0
- package/build/cjs/components/PivotTable/hooks/useParentSize.js +41 -0
- package/build/cjs/components/PivotTable/hooks/useScrollPosition.js +38 -0
- package/build/cjs/components/PivotTable/hooks/useSortableColumns.js +34 -0
- package/build/cjs/components/PivotTable/hooks/useTableClipping.js +53 -0
- package/build/cjs/components/PivotTable/index.js +47 -0
- package/build/cjs/components/PivotTable/interfaces/index.js +1 -0
- package/build/cjs/components/PivotTable/services/adaptiveClippingController.js +197 -0
- package/build/cjs/components/PivotTable/services/engine.js +901 -0
- package/build/cjs/components/PivotTable/utils/getOuLevelAndGroupText.js +71 -0
- package/build/cjs/components/PivotTable/utils/index.js +322 -0
- package/build/cjs/components/PivotTable/utils/isColorBright.js +29 -0
- package/build/cjs/components/PivotTable/utils/layout/dimension.js +61 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetId.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionGetItems.js +12 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIs.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsEmpty.js +9 -0
- package/build/cjs/components/PivotTable/utils/layout/dimensionIsValid.js +25 -0
- package/build/cjs/components/PivotTable/utils/legend.js +40 -0
- package/build/cjs/components/PivotTable/utils/ouIdHelper/index.js +27 -0
- package/build/cjs/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/cjs/index.js +11 -0
- package/build/cjs/locales/en/translations.json +33 -0
- package/build/es/components/ChartAnalytics/ChartAnalytics.stories.js +1 -1
- package/build/es/components/CircularProgressDashboard/CircularProgressIndicator.stories.js +1 -1
- package/build/es/components/Map/Map.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/EarthEngineLayerConfiguration/EarthEngineLayerConfiguration.stories.js +1 -1
- package/build/es/components/Map/components/MapProvider/components/MapLayerProvider/hooks/index.js +8 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfigModal.stories.js +1 -1
- package/build/es/components/Map/components/ThematicLayerConfiguration/ThematicLayerConfiguration.stories.js +1 -1
- package/build/es/components/PivotTable/PivotTable.stories.js +268 -0
- package/build/es/components/PivotTable/components/AssignedCategoriesIcon/index.js +24 -0
- package/build/es/components/PivotTable/components/PivotTable.js +51 -0
- package/build/es/components/PivotTable/components/PivotTableBody.js +33 -0
- package/build/es/components/PivotTable/components/PivotTableCell.js +32 -0
- package/build/es/components/PivotTable/components/PivotTableClippedAxis.js +18 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaderCell.js +62 -0
- package/build/es/components/PivotTable/components/PivotTableColumnHeaders.js +52 -0
- package/build/es/components/PivotTable/components/PivotTableContainer.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableDimensionLabelCell.js +68 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyCell.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableEmptyRow.js +25 -0
- package/build/es/components/PivotTable/components/PivotTableEngineContext.js +14 -0
- package/build/es/components/PivotTable/components/PivotTableHead.js +27 -0
- package/build/es/components/PivotTable/components/PivotTableHeaderCell.js +29 -0
- package/build/es/components/PivotTable/components/PivotTableRow.js +57 -0
- package/build/es/components/PivotTable/components/PivotTableRowHeaderCell.js +41 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRow.js +42 -0
- package/build/es/components/PivotTable/components/PivotTableTitleRows.js +37 -0
- package/build/es/components/PivotTable/components/PivotTableValueCell.js +60 -0
- package/build/es/components/PivotTable/constants/dataTypes.js +98 -0
- package/build/es/components/PivotTable/constants/pivotTable.js +29 -0
- package/build/es/components/PivotTable/constants/predefinedDimensions.js +44 -0
- package/build/es/components/PivotTable/constants/valueTypes.js +27 -0
- package/build/es/components/PivotTable/data/column-data.json +210 -0
- package/build/es/components/PivotTable/hooks/useParentSize.js +33 -0
- package/build/es/components/PivotTable/hooks/useScrollPosition.js +30 -0
- package/build/es/components/PivotTable/hooks/useSortableColumns.js +27 -0
- package/build/es/components/PivotTable/hooks/useTableClipping.js +46 -0
- package/build/es/components/PivotTable/index.js +26 -0
- package/build/es/components/PivotTable/interfaces/index.js +1 -0
- package/build/es/components/PivotTable/services/adaptiveClippingController.js +191 -0
- package/build/es/components/PivotTable/services/engine.js +894 -0
- package/build/es/components/PivotTable/utils/getOuLevelAndGroupText.js +63 -0
- package/build/es/components/PivotTable/utils/index.js +309 -0
- package/build/es/components/PivotTable/utils/isColorBright.js +22 -0
- package/build/es/components/PivotTable/utils/layout/dimension.js +48 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetId.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionGetItems.js +5 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIs.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsEmpty.js +2 -0
- package/build/es/components/PivotTable/utils/layout/dimensionIsValid.js +18 -0
- package/build/es/components/PivotTable/utils/legend.js +27 -0
- package/build/es/components/PivotTable/utils/ouIdHelper/index.js +17 -0
- package/build/es/components/SingleValueContainer/SingleValueContainer.stories.js +1 -1
- package/build/es/index.js +1 -0
- package/build/es/locales/en/translations.json +33 -0
- package/build/types/components/PivotTable/components/AssignedCategoriesIcon/index.d.ts +3 -0
- package/build/types/components/PivotTable/components/PivotTable.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableBody.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableCell.d.ts +17 -0
- package/build/types/components/PivotTable/components/PivotTableClippedAxis.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaderCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableColumnHeaders.d.ts +11 -0
- package/build/types/components/PivotTable/components/PivotTableContainer.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableDimensionLabelCell.d.ts +13 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyCell.d.ts +7 -0
- package/build/types/components/PivotTable/components/PivotTableEmptyRow.d.ts +5 -0
- package/build/types/components/PivotTable/components/PivotTableEngineContext.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableHead.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableHeaderCell.d.ts +22 -0
- package/build/types/components/PivotTable/components/PivotTableRow.d.ts +19 -0
- package/build/types/components/PivotTable/components/PivotTableRowHeaderCell.d.ts +8 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRow.d.ts +21 -0
- package/build/types/components/PivotTable/components/PivotTableTitleRows.d.ts +12 -0
- package/build/types/components/PivotTable/components/PivotTableValueCell.d.ts +8 -0
- package/build/types/components/PivotTable/constants/dataTypes.d.ts +90 -0
- package/build/types/components/PivotTable/constants/pivotTable.d.ts +29 -0
- package/build/types/components/PivotTable/constants/predefinedDimensions.d.ts +80 -0
- package/build/types/components/PivotTable/constants/valueTypes.d.ts +22 -0
- package/build/types/components/PivotTable/hooks/useParentSize.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useScrollPosition.d.ts +5 -0
- package/build/types/components/PivotTable/hooks/useSortableColumns.d.ts +8 -0
- package/build/types/components/PivotTable/hooks/useTableClipping.d.ts +24 -0
- package/build/types/components/PivotTable/index.d.ts +26 -0
- package/build/types/components/PivotTable/interfaces/index.d.ts +72 -0
- package/build/types/components/PivotTable/services/adaptiveClippingController.d.ts +44 -0
- package/build/types/components/PivotTable/services/engine.d.ts +252 -0
- package/build/types/components/PivotTable/utils/getOuLevelAndGroupText.d.ts +1 -0
- package/build/types/components/PivotTable/utils/index.d.ts +38 -0
- package/build/types/components/PivotTable/utils/isColorBright.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimension.d.ts +35 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetId.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionGetItems.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIs.d.ts +1 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsEmpty.d.ts +3 -0
- package/build/types/components/PivotTable/utils/layout/dimensionIsValid.d.ts +5 -0
- package/build/types/components/PivotTable/utils/legend.d.ts +11 -0
- package/build/types/components/PivotTable/utils/ouIdHelper/index.d.ts +10 -0
- package/build/types/index.d.ts +1 -0
- package/package.json +6 -3
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTableClipping = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _utils = require("../utils");
|
|
9
|
+
var _pivotTable = require("../constants/pivotTable");
|
|
10
|
+
var _useScrollPosition = require("./useScrollPosition.js");
|
|
11
|
+
const useTableClipping = _ref => {
|
|
12
|
+
let {
|
|
13
|
+
containerRef,
|
|
14
|
+
width,
|
|
15
|
+
height,
|
|
16
|
+
engine
|
|
17
|
+
} = _ref;
|
|
18
|
+
const scrollPosition = (0, _useScrollPosition.useScrollPosition)(containerRef);
|
|
19
|
+
const lineHeight = engine.fontSize + engine.cellPadding * 2 + 2;
|
|
20
|
+
const rows = (0, _react.useMemo)(() => {
|
|
21
|
+
const headerSize = engine.adaptiveClippingController.rows.headerSize + (engine.options.title ? lineHeight : 0) + (engine.options.subtitle ? lineHeight : 0);
|
|
22
|
+
const viewportPosition = engine.options.fixColumnHeaders ? scrollPosition.y : Math.max(0, scrollPosition.y - headerSize);
|
|
23
|
+
const viewportWidth = height - (engine.options.fixColumnHeaders ? engine.adaptiveClippingController.rows.headerSize : Math.max(headerSize - scrollPosition.y, 0));
|
|
24
|
+
return (0, _utils.clipPartitionedAxis)({
|
|
25
|
+
partitionSize: _pivotTable.CLIPPED_AXIS_PARTITION_SIZE_PX,
|
|
26
|
+
partitions: engine.adaptiveClippingController.rows.partitions,
|
|
27
|
+
axisMap: engine.rowMap,
|
|
28
|
+
widthMap: engine.adaptiveClippingController.rows.sizes,
|
|
29
|
+
viewportWidth,
|
|
30
|
+
viewportPosition,
|
|
31
|
+
totalWidth: engine.adaptiveClippingController.rows.totalSize
|
|
32
|
+
});
|
|
33
|
+
}, [scrollPosition.y, height, lineHeight, engine.adaptiveClippingController.rows.headerSize, engine.adaptiveClippingController.rows.partitions, engine.adaptiveClippingController.rows.sizes, engine.adaptiveClippingController.rows.totalSize, engine.options.fixColumnHeaders, engine.rowMap, engine.options.title, engine.options.subtitle]);
|
|
34
|
+
const columns = (0, _react.useMemo)(() => {
|
|
35
|
+
const viewportPosition = Math.max(0, engine.options.fixRowHeaders ? scrollPosition.x : scrollPosition.x - engine.adaptiveClippingController.columns.headerSize);
|
|
36
|
+
const viewportWidth = width - (engine.options.fixRowHeaders ? engine.adaptiveClippingController.columns.headerSize : Math.max(engine.adaptiveClippingController.columns.headerSize - scrollPosition.x, 0));
|
|
37
|
+
return (0, _utils.clipPartitionedAxis)({
|
|
38
|
+
partitionSize: _pivotTable.CLIPPED_AXIS_PARTITION_SIZE_PX,
|
|
39
|
+
partitions: engine.adaptiveClippingController.columns.partitions,
|
|
40
|
+
axisMap: engine.columnMap,
|
|
41
|
+
widthMap: engine.adaptiveClippingController.columns.sizes,
|
|
42
|
+
viewportWidth,
|
|
43
|
+
viewportPosition,
|
|
44
|
+
totalWidth: engine.adaptiveClippingController.columns.totalSize
|
|
45
|
+
});
|
|
46
|
+
}, [scrollPosition.x, width, engine.adaptiveClippingController.columns.headerSize, engine.adaptiveClippingController.columns.partitions, engine.adaptiveClippingController.columns.sizes, engine.adaptiveClippingController.columns.totalSize, engine.options.fixRowHeaders, engine.columnMap]);
|
|
47
|
+
return {
|
|
48
|
+
rows,
|
|
49
|
+
columns,
|
|
50
|
+
scrollPosition
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.useTableClipping = useTableClipping;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
CustomPivotTable: true
|
|
8
|
+
};
|
|
9
|
+
exports.CustomPivotTable = CustomPivotTable;
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _PivotTable = require("./components/PivotTable");
|
|
12
|
+
var _interfaces = require("./interfaces");
|
|
13
|
+
Object.keys(_interfaces).forEach(function (key) {
|
|
14
|
+
if (key === "default" || key === "__esModule") return;
|
|
15
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
16
|
+
if (key in exports && exports[key] === _interfaces[key]) return;
|
|
17
|
+
Object.defineProperty(exports, key, {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () {
|
|
20
|
+
return _interfaces[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
+
function CustomPivotTable(_ref) {
|
|
26
|
+
var _config$options, _config$layout$column, _config$layout$rows$m, _config$layout$filter, _config$layout$filter2, _config$options2;
|
|
27
|
+
let {
|
|
28
|
+
analytics,
|
|
29
|
+
config
|
|
30
|
+
} = _ref;
|
|
31
|
+
return /*#__PURE__*/_react.default.createElement(_PivotTable.PivotTable, {
|
|
32
|
+
data: analytics,
|
|
33
|
+
legendSets: (_config$options = config.options) === null || _config$options === void 0 ? void 0 : _config$options.legendSets,
|
|
34
|
+
visualization: {
|
|
35
|
+
columns: (_config$layout$column = config.layout.columns.map(column => ({
|
|
36
|
+
dimension: column
|
|
37
|
+
}))) !== null && _config$layout$column !== void 0 ? _config$layout$column : [],
|
|
38
|
+
rows: (_config$layout$rows$m = config.layout.rows.map(column => ({
|
|
39
|
+
dimension: column
|
|
40
|
+
}))) !== null && _config$layout$rows$m !== void 0 ? _config$layout$rows$m : [],
|
|
41
|
+
filter: (_config$layout$filter = (_config$layout$filter2 = config.layout.filter) === null || _config$layout$filter2 === void 0 ? void 0 : _config$layout$filter2.map(column => ({
|
|
42
|
+
dimension: column
|
|
43
|
+
}))) !== null && _config$layout$filter !== void 0 ? _config$layout$filter : [],
|
|
44
|
+
...((_config$options2 = config.options) !== null && _config$options2 !== void 0 ? _config$options2 : {})
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AdaptiveClippingController = void 0;
|
|
7
|
+
var _utils = require("../utils");
|
|
8
|
+
var _pivotTable = require("../constants/pivotTable");
|
|
9
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
11
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
12
|
+
class AdaptiveClippingController {
|
|
13
|
+
constructor(engine) {
|
|
14
|
+
_defineProperty(this, "columns", {
|
|
15
|
+
orientation: "column",
|
|
16
|
+
sizes: [],
|
|
17
|
+
headerSize: 0,
|
|
18
|
+
partitions: [],
|
|
19
|
+
totalSize: 0
|
|
20
|
+
});
|
|
21
|
+
_defineProperty(this, "rows", {
|
|
22
|
+
orientation: "row",
|
|
23
|
+
sizes: [],
|
|
24
|
+
headerSize: 0,
|
|
25
|
+
partitions: [],
|
|
26
|
+
totalSize: 0
|
|
27
|
+
});
|
|
28
|
+
_defineProperty(this, "engine", void 0);
|
|
29
|
+
this.engine = engine;
|
|
30
|
+
this.reset();
|
|
31
|
+
}
|
|
32
|
+
addSize(_ref, _ref2) {
|
|
33
|
+
let {
|
|
34
|
+
row,
|
|
35
|
+
column
|
|
36
|
+
} = _ref;
|
|
37
|
+
let {
|
|
38
|
+
width,
|
|
39
|
+
height
|
|
40
|
+
} = _ref2;
|
|
41
|
+
if (column >= 0) {
|
|
42
|
+
const columnSize = this.columns.sizes[column] || {
|
|
43
|
+
pre: 0,
|
|
44
|
+
size: 0
|
|
45
|
+
};
|
|
46
|
+
columnSize.size = Math.max(columnSize.size, width);
|
|
47
|
+
this.columns.sizes[column] = columnSize;
|
|
48
|
+
} else {
|
|
49
|
+
const index = this.engine.rowDepth + column;
|
|
50
|
+
this.columns.headerSizes[index] = Math.max(this.columns.headerSizes[index] || 0, width);
|
|
51
|
+
}
|
|
52
|
+
if (row >= 0) {
|
|
53
|
+
const rowSize = this.rows.sizes[row] || {
|
|
54
|
+
pre: 0,
|
|
55
|
+
size: 0
|
|
56
|
+
};
|
|
57
|
+
rowSize.size = Math.max(rowSize.size, height);
|
|
58
|
+
this.rows.sizes[row] = rowSize;
|
|
59
|
+
} else {
|
|
60
|
+
const index = this.engine.columnDepth + row;
|
|
61
|
+
this.rows.headerSizes[index] = Math.max(this.rows.headerSizes[index] || 0, height);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
add(_ref3, renderedValue) {
|
|
65
|
+
let {
|
|
66
|
+
row,
|
|
67
|
+
column
|
|
68
|
+
} = _ref3;
|
|
69
|
+
this.addSize({
|
|
70
|
+
row,
|
|
71
|
+
column
|
|
72
|
+
}, this.measureText(renderedValue));
|
|
73
|
+
}
|
|
74
|
+
measureText(renderedValue) {
|
|
75
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
76
|
+
return (0, _utils.measureTextWithWrapping)(renderedValue, {
|
|
77
|
+
fontSize: this.engine.fontSize,
|
|
78
|
+
...options
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
getCellSize(contentSize) {
|
|
82
|
+
return Math.ceil(contentSize) + this.engine.cellPadding * 2 + /*border*/2;
|
|
83
|
+
}
|
|
84
|
+
finalizeAxis(axis) {
|
|
85
|
+
axis.headerSize = 0;
|
|
86
|
+
const isColumn = axis.orientation === 'column';
|
|
87
|
+
const map = isColumn ? this.engine.columnMap : this.engine.rowMap;
|
|
88
|
+
const getHeader = index => isColumn ? this.engine.getRawColumnHeader(index) : this.engine.getRawRowHeader(index);
|
|
89
|
+
map.forEach((index, mapIndex) => {
|
|
90
|
+
var _axis$sizes$index2;
|
|
91
|
+
const headerStack = getHeader(index);
|
|
92
|
+
headerStack === null || headerStack === void 0 ? void 0 : headerStack.forEach((header, level) => {
|
|
93
|
+
const label = this.engine.visualization.showHierarchy && header !== null && header !== void 0 && header.hierarchy ? header.hierarchy.join(' / ') : header === null || header === void 0 ? void 0 : header.name;
|
|
94
|
+
if (label) {
|
|
95
|
+
const isLeafHeader = level === headerStack.length - 1;
|
|
96
|
+
if (isColumn) {
|
|
97
|
+
var _axis$sizes$index;
|
|
98
|
+
const headerSize = this.measureText(label, {
|
|
99
|
+
maxWidth: isLeafHeader ? Math.max(_pivotTable.CLIPPED_CELL_MIN_SIZE, ((_axis$sizes$index = axis.sizes[index]) === null || _axis$sizes$index === void 0 ? void 0 : _axis$sizes$index.size) || 0) : 0
|
|
100
|
+
});
|
|
101
|
+
this.addSize({
|
|
102
|
+
row: -headerStack.length + level,
|
|
103
|
+
column: index
|
|
104
|
+
}, {
|
|
105
|
+
height: headerSize.height,
|
|
106
|
+
width: isLeafHeader ? headerSize.width + (this.engine.isSortable(mapIndex) ? this.engine.scrollIconBuffer : 0) : 0
|
|
107
|
+
});
|
|
108
|
+
} else {
|
|
109
|
+
const headerSize = this.measureText(label, {});
|
|
110
|
+
this.addSize({
|
|
111
|
+
row: index,
|
|
112
|
+
column: -headerStack.length + level
|
|
113
|
+
}, {
|
|
114
|
+
height: isLeafHeader ? headerSize.height : 0,
|
|
115
|
+
width: headerSize.width
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
axis.sizes[index] = {
|
|
121
|
+
pre: 0,
|
|
122
|
+
size: this.getCellSize((_axis$sizes$index2 = axis.sizes[index]) === null || _axis$sizes$index2 === void 0 ? void 0 : _axis$sizes$index2.size)
|
|
123
|
+
};
|
|
124
|
+
});
|
|
125
|
+
this.populateAxisPartitions(axis);
|
|
126
|
+
}
|
|
127
|
+
populateAxisPartitions(axis) {
|
|
128
|
+
axis.totalSize = 0;
|
|
129
|
+
axis.partitions = [];
|
|
130
|
+
let nextPartitionPx = 0;
|
|
131
|
+
const isColumn = axis.orientation === 'column';
|
|
132
|
+
const map = isColumn ? this.engine.columnMap : this.engine.rowMap;
|
|
133
|
+
map.forEach((index, mapIndex) => {
|
|
134
|
+
if (axis.totalSize >= nextPartitionPx) {
|
|
135
|
+
axis.partitions.push(mapIndex);
|
|
136
|
+
nextPartitionPx += _pivotTable.CLIPPED_AXIS_PARTITION_SIZE_PX;
|
|
137
|
+
}
|
|
138
|
+
axis.sizes[index].pre = axis.totalSize;
|
|
139
|
+
axis.totalSize += axis.sizes[index].size;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
resetRowPartitions() {
|
|
143
|
+
this.populateAxisPartitions(this.rows);
|
|
144
|
+
}
|
|
145
|
+
finalize() {
|
|
146
|
+
if (this.engine.visualization.showDimensionLabels) {
|
|
147
|
+
var _this$engine$dimensio, _this$engine$dimensio2, _this$engine$dimensio3, _this$engine$dimensio4, _this$engine$dimensio5, _this$engine$dimensio6;
|
|
148
|
+
const columnDimensionCount = (_this$engine$dimensio = (_this$engine$dimensio2 = this.engine.dimensionLookup) === null || _this$engine$dimensio2 === void 0 ? void 0 : _this$engine$dimensio2.columnHeaders.length) !== null && _this$engine$dimensio !== void 0 ? _this$engine$dimensio : 0;
|
|
149
|
+
const rowDimensionCount = (_this$engine$dimensio3 = (_this$engine$dimensio4 = this.engine.dimensionLookup) === null || _this$engine$dimensio4 === void 0 ? void 0 : _this$engine$dimensio4.rowHeaders.length) !== null && _this$engine$dimensio3 !== void 0 ? _this$engine$dimensio3 : 0;
|
|
150
|
+
(_this$engine$dimensio5 = this.engine.dimensionLookup) === null || _this$engine$dimensio5 === void 0 ? void 0 : (_this$engine$dimensio6 = _this$engine$dimensio5.columnHeaders) === null || _this$engine$dimensio6 === void 0 ? void 0 : _this$engine$dimensio6.forEach((_, columnLevel) => {
|
|
151
|
+
var _this$engine$dimensio7, _this$engine$dimensio8;
|
|
152
|
+
(_this$engine$dimensio7 = this.engine.dimensionLookup) === null || _this$engine$dimensio7 === void 0 ? void 0 : (_this$engine$dimensio8 = _this$engine$dimensio7.rowHeaders) === null || _this$engine$dimensio8 === void 0 ? void 0 : _this$engine$dimensio8.forEach((_, rowLevel) => {
|
|
153
|
+
const label = this.engine.getDimensionLabel(rowLevel, columnLevel);
|
|
154
|
+
if (label) {
|
|
155
|
+
this.add({
|
|
156
|
+
row: -rowDimensionCount + rowLevel,
|
|
157
|
+
column: -columnDimensionCount + columnLevel
|
|
158
|
+
}, label);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
this.finalizeAxis(this.columns);
|
|
164
|
+
this.finalizeAxis(this.rows);
|
|
165
|
+
this.columns.headerSize = 0;
|
|
166
|
+
this.columns.headerSizes = this.columns.headerSizes.map(size => {
|
|
167
|
+
const paddedSize = this.getCellSize(size);
|
|
168
|
+
this.columns.headerSize += paddedSize;
|
|
169
|
+
return paddedSize;
|
|
170
|
+
});
|
|
171
|
+
this.rows.headerSize = 0;
|
|
172
|
+
this.rows.headerSizes = this.rows.headerSizes.map(size => {
|
|
173
|
+
const paddedSize = this.getCellSize(size);
|
|
174
|
+
this.rows.headerSize += paddedSize;
|
|
175
|
+
return paddedSize;
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
reset() {
|
|
179
|
+
this.columns = {
|
|
180
|
+
orientation: 'column',
|
|
181
|
+
totalSize: 0,
|
|
182
|
+
headerSize: 0,
|
|
183
|
+
sizes: [],
|
|
184
|
+
partitions: [],
|
|
185
|
+
headerSizes: []
|
|
186
|
+
};
|
|
187
|
+
this.rows = {
|
|
188
|
+
orientation: 'row',
|
|
189
|
+
totalSize: 0,
|
|
190
|
+
headerSize: 0,
|
|
191
|
+
sizes: [],
|
|
192
|
+
partitions: [],
|
|
193
|
+
headerSizes: []
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
exports.AdaptiveClippingController = AdaptiveClippingController;
|