ag-charts-community
Version:
Advanced Charting / Charts supporting Javascript / Typescript / React / Angular / Vue
96 lines • 4.12 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var bbox_1 = require("../scene/bbox");
var clipRect_1 = require("../scene/clipRect");
var chart_1 = require("./chart");
var HierarchyChart = /** @class */ (function (_super) {
__extends(HierarchyChart, _super);
function HierarchyChart(document) {
if (document === void 0) { document = window.document; }
var _this = _super.call(this, document) || this;
_this._data = {};
_this._seriesRoot = new clipRect_1.ClipRect();
// Prevent the scene from rendering chart components in an invalid state
// (before first layout is performed).
_this.scene.root.visible = false;
var root = _this.scene.root;
root.append(_this.seriesRoot);
root.append(_this.legend.group);
return _this;
}
Object.defineProperty(HierarchyChart.prototype, "seriesRoot", {
get: function () {
return this._seriesRoot;
},
enumerable: true,
configurable: true
});
HierarchyChart.prototype.performLayout = function () {
if (this.dataPending) {
return;
}
this.scene.root.visible = true;
var _a = this, width = _a.width, height = _a.height, legend = _a.legend;
var shrinkRect = new bbox_1.BBox(0, 0, width, height);
this.positionCaptions();
this.positionLegend();
if (legend.enabled && legend.data.length) {
var legendAutoPadding = this.legendAutoPadding;
var legendPadding = this.legend.spacing;
shrinkRect.x += legendAutoPadding.left;
shrinkRect.y += legendAutoPadding.top;
shrinkRect.width -= legendAutoPadding.left + legendAutoPadding.right;
shrinkRect.height -= legendAutoPadding.top + legendAutoPadding.bottom;
switch (this.legend.position) {
case 'right':
shrinkRect.width -= legendPadding;
break;
case 'bottom':
shrinkRect.height -= legendPadding;
break;
case 'left':
shrinkRect.x += legendPadding;
shrinkRect.width -= legendPadding;
break;
case 'top':
shrinkRect.y += legendPadding;
shrinkRect.height -= legendPadding;
break;
}
}
var _b = this, captionAutoPadding = _b.captionAutoPadding, padding = _b.padding;
shrinkRect.x += padding.left;
shrinkRect.width -= padding.left + padding.right;
shrinkRect.y += padding.top + captionAutoPadding;
shrinkRect.height -= padding.top + captionAutoPadding + padding.bottom;
this.seriesRect = shrinkRect;
this.series.forEach(function (series) {
series.group.translationX = Math.floor(shrinkRect.x);
series.group.translationY = Math.floor(shrinkRect.y);
series.update(); // this has to happen after the `updateAxes` call
});
var seriesRoot = this.seriesRoot;
seriesRoot.x = shrinkRect.x;
seriesRoot.y = shrinkRect.y;
seriesRoot.width = shrinkRect.width;
seriesRoot.height = shrinkRect.height;
};
HierarchyChart.className = 'HierarchyChart';
HierarchyChart.type = 'hierarchy';
return HierarchyChart;
}(chart_1.Chart));
exports.HierarchyChart = HierarchyChart;
//# sourceMappingURL=hierarchyChart.js.map