@swimlane/ngx-charts
Version:
Declarative Charting Framework for Angular2 and beyond!
74 lines • 3.22 kB
JavaScript
;
var core_1 = require('@angular/core');
var GridPanelSeriesComponent = (function () {
function GridPanelSeriesComponent() {
}
GridPanelSeriesComponent.prototype.ngOnChanges = function (changes) {
this.update();
};
GridPanelSeriesComponent.prototype.update = function () {
this.gridPanels = this.getGridPanels();
};
GridPanelSeriesComponent.prototype.getGridPanels = function () {
var _this = this;
return this.data.map(function (d, i) {
var offset;
var width;
var height;
var x;
var y;
var className = 'odd';
if (_this.orient === 'vertical') {
var position = _this.xScale(d.name);
var positionIndex = Number.parseInt((position / _this.xScale.step()).toString());
if (positionIndex % 2 === 1) {
className = 'even';
}
offset = _this.xScale.bandwidth() * _this.xScale.paddingInner();
width = _this.xScale.bandwidth() + offset;
height = _this.dims.height;
x = _this.xScale(d.name) - offset / 2;
y = 0;
}
else if (_this.orient === 'horizontal') {
var position = _this.yScale(d.name);
var positionIndex = Number.parseInt((position / _this.yScale.step()).toString());
if (positionIndex % 2 === 1) {
className = 'even';
}
offset = _this.yScale.bandwidth() * _this.yScale.paddingInner();
width = _this.dims.width;
height = _this.yScale.bandwidth() + offset;
x = 0;
y = _this.yScale(d.name) - offset / 2;
}
return {
name: d.name,
class: className,
height: height,
width: width,
x: x,
y: y
};
});
};
GridPanelSeriesComponent.decorators = [
{ type: core_1.Component, args: [{
selector: 'g[ngx-charts-grid-panel-series]',
template: "\n <svg:g ngx-charts-grid-panel *ngFor=\"let gridPanel of gridPanels\"\n [height]=\"gridPanel.height\"\n [width]=\"gridPanel.width\"\n [x]=\"gridPanel.x\"\n [y]=\"gridPanel.y\"\n [class.grid-panel]=\"true\"\n [class.odd]=\"gridPanel.class === 'odd'\"\n [class.even]=\"gridPanel.class === 'even'\">\n </svg:g>\n ",
changeDetection: core_1.ChangeDetectionStrategy.OnPush
},] },
];
/** @nocollapse */
GridPanelSeriesComponent.ctorParameters = function () { return []; };
GridPanelSeriesComponent.propDecorators = {
'data': [{ type: core_1.Input },],
'dims': [{ type: core_1.Input },],
'xScale': [{ type: core_1.Input },],
'yScale': [{ type: core_1.Input },],
'orient': [{ type: core_1.Input },],
};
return GridPanelSeriesComponent;
}());
exports.GridPanelSeriesComponent = GridPanelSeriesComponent;
//# sourceMappingURL=grid-panel-series.component.js.map