@swimlane/ngx-charts
Version:
Declarative Charting Framework for Angular
138 lines • 5.87 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, Output, EventEmitter, ElementRef, ChangeDetectionStrategy, HostListener } from '@angular/core';
import { select } from 'd3-selection';
import { id } from '../utils/id';
var HeatMapCellComponent = /** @class */ (function () {
function HeatMapCellComponent(element) {
this.gradient = false;
this.animations = true;
this.select = new EventEmitter();
this.activate = new EventEmitter();
this.deactivate = new EventEmitter();
this.element = element.nativeElement;
}
HeatMapCellComponent.prototype.ngOnChanges = function (changes) {
this.transform = "translate(" + this.x + " , " + this.y + ")";
this.startOpacity = 0.3;
this.gradientId = 'grad' + id().toString();
this.gradientUrl = "url(#" + this.gradientId + ")";
this.gradientStops = this.getGradientStops();
if (this.animations) {
this.loadAnimation();
}
};
HeatMapCellComponent.prototype.getGradientStops = function () {
return [
{
offset: 0,
color: this.fill,
opacity: this.startOpacity
},
{
offset: 100,
color: this.fill,
opacity: 1
}
];
};
HeatMapCellComponent.prototype.loadAnimation = function () {
var node = select(this.element).select('.cell');
node.attr('opacity', 0);
this.animateToCurrentForm();
};
HeatMapCellComponent.prototype.animateToCurrentForm = function () {
var node = select(this.element).select('.cell');
node
.transition()
.duration(750)
.attr('opacity', 1);
};
HeatMapCellComponent.prototype.onClick = function () {
this.select.emit(this.data);
};
HeatMapCellComponent.prototype.onMouseEnter = function () {
this.activate.emit(this.data);
};
HeatMapCellComponent.prototype.onMouseLeave = function () {
this.deactivate.emit(this.data);
};
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "fill", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "x", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "y", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "width", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "height", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "data", void 0);
__decorate([
Input(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "label", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HeatMapCellComponent.prototype, "gradient", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], HeatMapCellComponent.prototype, "animations", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "select", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "activate", void 0);
__decorate([
Output(),
__metadata("design:type", Object)
], HeatMapCellComponent.prototype, "deactivate", void 0);
__decorate([
HostListener('mouseenter'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], HeatMapCellComponent.prototype, "onMouseEnter", null);
__decorate([
HostListener('mouseleave'),
__metadata("design:type", Function),
__metadata("design:paramtypes", []),
__metadata("design:returntype", void 0)
], HeatMapCellComponent.prototype, "onMouseLeave", null);
HeatMapCellComponent = __decorate([
Component({
selector: 'g[ngx-charts-heat-map-cell]',
template: "\n <svg:g [attr.transform]=\"transform\" class=\"cell\">\n <defs *ngIf=\"gradient\">\n <svg:g ngx-charts-svg-linear-gradient orientation=\"vertical\" [name]=\"gradientId\" [stops]=\"gradientStops\" />\n </defs>\n <svg:rect\n [attr.fill]=\"gradient ? gradientUrl : fill\"\n rx=\"3\"\n [attr.width]=\"width\"\n [attr.height]=\"height\"\n class=\"cell\"\n style=\"cursor: pointer\"\n (click)=\"onClick()\"\n />\n </svg:g>\n ",
changeDetection: ChangeDetectionStrategy.OnPush
}),
__metadata("design:paramtypes", [ElementRef])
], HeatMapCellComponent);
return HeatMapCellComponent;
}());
export { HeatMapCellComponent };
//# sourceMappingURL=heat-map-cell.component.js.map