nts-ng2-components
Version:
Paquete de componentes para Angular2 desarrollado por NITSNETS.
37 lines (28 loc) • 1.09 kB
text/typescript
import { Component, OnChanges, Input } from '@angular/core';
export class NtsChartTooltipComponent implements OnChanges {
tooltip;
tooltipStyle: any = {};
tooltipTitles = [];
tooltipSeries = [];
ngOnChanges(changes) {
if (!this.tooltip || this.tooltip.opacity === 0) { this.tooltipStyle.opacity = '0'; return; }
if (!this.tooltip.body) { return; }
this.tooltipStyle.opacity = '1';
this.tooltipStyle.left = this.tooltip.x + 'px';
this.tooltipStyle.top = this.tooltip.y + 'px';
this.tooltipTitles = this.tooltip.title || [];
this.tooltipSeries = [];
let lines = this.tooltip.body.map(b => b.lines);
lines.forEach((line, i) => {
let serie = this.tooltip.labelColors[i];
serie.label = line;
this.tooltipSeries.push(serie);
});
}
constructor() { }
}