Added a bunch of stuff

This commit is contained in:
jfusia
2024-05-22 14:07:00 -04:00
parent 547783aa73
commit 17f5b675b9
70 changed files with 45689 additions and 365 deletions

View File

@@ -0,0 +1,54 @@
import {
AfterViewInit,
Component,
ElementRef,
OnDestroy,
ViewChild,
} from '@angular/core';
import { Chart, ChartOptions } from 'chart.js';
import { PluginNodata } from './plugin-nodata';
import { PluginMoreColors } from './plugin-more-colors';
import { ChartType, IData } from './chart-type';
@Component({
selector: 'fbi-chart',
standalone: true,
imports: [],
templateUrl: './chart.component.html',
styleUrl: './chart.component.scss',
})
export class ChartComponent implements AfterViewInit, OnDestroy {
@ViewChild('chart') canvas!: ElementRef;
private chart: any = undefined;
private data: IData = {
labels: [],
labelsSource: [],
datasets: [],
};
constructor() {}
ngAfterViewInit(): void {
this.initChart();
}
ngOnDestroy(): void {
this.chart?.destroy?.();
}
initChart() {
this.chart?.destroy?.();
const opts: ChartOptions = {};
opts.responsive = true;
opts.maintainAspectRatio = false;
this.chart = new Chart(this.canvas.nativeElement, {
type: ChartType.Bar,
data: this.data,
options: opts,
plugins: [PluginNodata.config(), PluginMoreColors.config()] as any[],
});
}
}