@swimlane/ngx-charts
Version:
Declarative Charting Framework for Angular
116 lines • 5.82 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 __());
};
})();
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, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core';
import { BaseChartComponent } from '../common/base-chart.component';
import { calculateViewDimensions } from '../common/view-dimensions.helper';
import { ColorHelper } from '../common/color.helper';
import { gridLayout, gridSize } from '../common/grid-layout.helper';
var NumberCardComponent = /** @class */ (function (_super) {
__extends(NumberCardComponent, _super);
function NumberCardComponent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.emptyColor = 'rgba(0, 0, 0, 0)';
_this.innerPadding = 15;
_this.margin = [10, 10, 10, 10];
return _this;
}
Object.defineProperty(NumberCardComponent.prototype, "clickable", {
get: function () {
return !!this.select.observers.length;
},
enumerable: true,
configurable: true
});
NumberCardComponent.prototype.update = function () {
_super.prototype.update.call(this);
this.dims = calculateViewDimensions({
width: this.width,
height: this.height,
margins: this.margin
});
this.formatDates();
this.domain = this.getDomain();
this.setColors();
this.transform = "translate(" + this.dims.xOffset + " , " + this.margin[0] + ")";
var size = gridSize(this.dims, this.results.length, 150);
var N = size[0] * size[1];
var data = this.results.slice();
while (data.length < N) {
data.push({ value: null });
}
this.data = gridLayout(this.dims, data, 150, this.designatedTotal);
};
NumberCardComponent.prototype.getDomain = function () {
return this.results.map(function (d) { return d.label; });
};
NumberCardComponent.prototype.onClick = function (data) {
this.select.emit(data);
};
NumberCardComponent.prototype.setColors = function () {
this.colors = new ColorHelper(this.scheme, 'ordinal', this.domain, this.customColors);
};
__decorate([
Input(),
__metadata("design:type", String)
], NumberCardComponent.prototype, "cardColor", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NumberCardComponent.prototype, "bandColor", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NumberCardComponent.prototype, "emptyColor", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NumberCardComponent.prototype, "innerPadding", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NumberCardComponent.prototype, "textColor", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NumberCardComponent.prototype, "valueFormatting", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], NumberCardComponent.prototype, "labelFormatting", void 0);
__decorate([
Input(),
__metadata("design:type", Number)
], NumberCardComponent.prototype, "designatedTotal", void 0);
NumberCardComponent = __decorate([
Component({
selector: 'ngx-charts-number-card',
template: "\n <ngx-charts-chart [view]=\"[width, height]\" [showLegend]=\"false\" [animations]=\"animations\">\n <svg:g [attr.transform]=\"transform\" class=\"number-card chart\" [class.clickable]=\"clickable\">\n <svg:g\n ngx-charts-card-series\n [colors]=\"colors\"\n [cardColor]=\"cardColor\"\n [bandColor]=\"bandColor\"\n [textColor]=\"textColor\"\n [emptyColor]=\"emptyColor\"\n [data]=\"data\"\n [dims]=\"dims\"\n [innerPadding]=\"innerPadding\"\n [valueFormatting]=\"valueFormatting\"\n [labelFormatting]=\"labelFormatting\"\n [animations]=\"animations\"\n (select)=\"onClick($event)\"\n />\n </svg:g>\n </ngx-charts-chart>\n ",
styleUrls: ['../common/base-chart.component.css', './card.component.css'],
encapsulation: ViewEncapsulation.None,
changeDetection: ChangeDetectionStrategy.OnPush
})
], NumberCardComponent);
return NumberCardComponent;
}(BaseChartComponent));
export { NumberCardComponent };
//# sourceMappingURL=number-card.component.js.map