diff options
author | Sonja Galovic <galovicsonja@gmail.com> | 2022-05-18 14:00:44 +0200 |
---|---|---|
committer | Sonja Galovic <galovicsonja@gmail.com> | 2022-05-18 14:00:44 +0200 |
commit | f3e4093e5a29eadd61a00a3a05668e3e24b7d40d (patch) | |
tree | 613df1a3ed2afa08f450267667732854dcd51134 /frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts | |
parent | 9233e6f193f68a0477e2900ac7a82928ab7f4adc (diff) | |
parent | aa71097de7e95658c0cfa3e7d212f018aa917baf (diff) |
Merge branch 'redesign' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into redesign
# Conflicts:
# frontend/src/app/_elements/column-table/column-table.component.html
# frontend/src/app/_pages/experiment/experiment.component.ts
Diffstat (limited to 'frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts')
-rw-r--r-- | frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts index e873618c..89a76a44 100644 --- a/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts +++ b/frontend/src/app/_elements/_charts/line-chart/line-chart.component.ts @@ -1,4 +1,4 @@ -import { Component, AfterViewInit, ViewChild } from '@angular/core'; +import { Component, AfterViewInit, ElementRef, ViewChild } from '@angular/core'; import { Chart } from 'chart.js'; @Component({ @@ -19,11 +19,27 @@ export class LineChartComponent implements AfterViewInit { dataValLoss:number[]=[]; dataEpoch: number[] = []; + @ViewChild('wrapper') + wrapper!: ElementRef; + @ViewChild('canvas') + canvas!: ElementRef; + constructor() { + } - + width = 700; + height = 400; + myChart!: Chart; - + resize() { + this.width = this.wrapper.nativeElement.offsetWidth; + this.height = this.wrapper.nativeElement.offsetHeight; + + if (this.canvas) { + this.canvas.nativeElement.width = this.width; + this.canvas.nativeElement.height = this.height; + } + } update(myEpochs: number[], myAcc: number[], myLoss: number[], myMae: number[], myMse: number[], myValAcc:number[],myValLoss:number[],myValMae:number[],myValMse:number[]) { this.dataAcc.length = 0; this.dataAcc.push(...myAcc); @@ -56,6 +72,9 @@ export class LineChartComponent implements AfterViewInit { } ngAfterViewInit(): void { + + window.addEventListener('resize', () => { this.resize() }); + this.resize(); this.myChart = new Chart("myChart", { type: 'line', @@ -69,7 +88,7 @@ export class LineChartComponent implements AfterViewInit { }, { - label: 'VAl_Accuracy', + label: 'Val_Accuracy', data: this.dataMSE, borderWidth: 1 }, @@ -150,3 +169,4 @@ export class LineChartComponent implements AfterViewInit { ); } } + |