unicorn-components
Version:
<a target="_blank" href="https://getunicorn.io"><img src="https://bitbucket-assetroot.s3.amazonaws.com/c/photos/2017/Jul/07/2615006260-5-nitsnetsstudios-ondemand-UNI_avatar.png" align="left"></a>
38 lines (29 loc) • 1.14 kB
text/typescript
import { Component, Input, OnChanges, HostBinding } from '@angular/core';
export class UniChartTooltipComponent implements OnChanges {
componentClass = true;
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 = [];
const lines = this.tooltip.body.map(b => b.lines);
lines.forEach((line, i) => {
const serie = this.tooltip.labelColors[i];
serie.label = line;
this.tooltipSeries.push(serie);
});
}
constructor() { }
}