30 lines
931 B
TypeScript
30 lines
931 B
TypeScript
import { Component, Input, OnChanges, ChangeDetectionStrategy } from '@angular/core';
|
|
import { TrendDataPoint, ChartBuilderUtils } from '../../utils/chart-builders';
|
|
|
|
export { TrendDataPoint };
|
|
|
|
@Component({
|
|
selector: 'agm-hours-chart',
|
|
templateUrl: './hours-chart.component.html',
|
|
styleUrls: ['./hours-chart.component.scss'],
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
})
|
|
export class HoursChartComponent implements OnChanges {
|
|
@Input() trendData: TrendDataPoint[] = [];
|
|
@Input() isLoading = false;
|
|
@Input() hasError = false;
|
|
|
|
chartData: any;
|
|
chartOptions: any;
|
|
hasData = false;
|
|
|
|
ngOnChanges(): void {
|
|
if (!this.isLoading && !this.hasError) {
|
|
this.hasData = this.trendData.length > 0 && this.trendData.some(d => d.value > 0);
|
|
const config = ChartBuilderUtils.hoursChart(this.trendData);
|
|
this.chartData = config.chartData;
|
|
this.chartOptions = config.chartOptions;
|
|
}
|
|
}
|
|
}
|