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>
35 lines (26 loc) • 1.06 kB
text/typescript
import { Component, EventEmitter, Input, OnChanges, Output, HostBinding } from '@angular/core';
import { arrToRgba, generateColors } from './../../../directives/base-chart.directive';
export class UniChartLegendComponent implements OnChanges {
componentClass = true;
editable = true;
series: Array<any> = [];
colors: Array<number[]> = [];
serieToggle = new EventEmitter<boolean>();
defaultColors = [];
arrToRgba = arrToRgba;
ngOnChanges(changes) {
if (this.series && (!this.colors || this.colors.length !== this.series.length)) {
this.colors = generateColors(this.series.length);
}
}
constructor() { }
toggleItem(index: number) {
if (!this.editable) { return; }
this.series[index].inactive = this.series[index].inactive ? false : true;
}
}