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>
42 lines (31 loc) • 1.29 kB
text/typescript
import { Component, EventEmitter, Input, OnChanges, Output, ViewContainerRef, HostBinding } from '@angular/core';
import { Color } from './../../../directives/base-chart.directive';
({
selector: 'uni-chart',
templateUrl: 'chart.component.html',
styleUrls: ['chart.component.scss'],
})
export class UniChartComponent implements OnChanges {
('class.uni-chart') componentClass = true;
() chartTitle: string;
() size: 'tiny' | 'small' | 'medium' | 'large' = 'medium';
() type: 'line' | 'bar' | 'pie' | 'radar' | 'doughnut' | 'polarArea' | 'horizontalBar';
() series: Array<{ label: string, data: [number], color: Color }> = [];
() labels: string[] = [];
() options = {};
() chartHover = new EventEmitter();
() chartClick = new EventEmitter();
tooltip: any = {};
defaultOptions = {
responsive: false,
maintainAspectRatio: false,
tooltips: { enabled: false, custom: tooltip => this.tooltip = tooltip }
};
ngOnChanges(changes) {
if (changes.type || changes.options) {
this.options = Object.assign(this.options, this.defaultOptions);
}
}
constructor(private view: ViewContainerRef) {
}
}