@swimlane/ngx-charts
Version:
Declarative Charting Framework for Angular
93 lines • 4.26 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
var GridPanelSeriesComponent = /** @class */ (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) {
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(), 10);
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(), 10);
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
};
});
};
__decorate([
Input(),
__metadata("design:type", Object)
], GridPanelSeriesComponent.prototype, "data", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], GridPanelSeriesComponent.prototype, "dims", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], GridPanelSeriesComponent.prototype, "xScale", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], GridPanelSeriesComponent.prototype, "yScale", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], GridPanelSeriesComponent.prototype, "orient", void 0);
GridPanelSeriesComponent = __decorate([
Component({
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: ChangeDetectionStrategy.OnPush
})
], GridPanelSeriesComponent);
return GridPanelSeriesComponent;
}());
export { GridPanelSeriesComponent };
//# sourceMappingURL=grid-panel-series.component.js.map