From d1d0c5498a4e0e3f9e4f078fdd520de16b3f316b Mon Sep 17 00:00:00 2001 From: Desy Ayurianti Date: Tue, 8 Oct 2024 10:29:38 +0700 Subject: [PATCH] fix(dashboard): fix responsive grafik data --- .../pages/dashboard/page/graph/graph.component.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/agrilink_vocpro/src/app/pages/dashboard/page/graph/graph.component.ts b/agrilink_vocpro/src/app/pages/dashboard/page/graph/graph.component.ts index 6b8f35b..27484b5 100644 --- a/agrilink_vocpro/src/app/pages/dashboard/page/graph/graph.component.ts +++ b/agrilink_vocpro/src/app/pages/dashboard/page/graph/graph.component.ts @@ -47,7 +47,6 @@ export class GraphComponent implements OnInit { }; chart: any; - isChartLoaded = false; labelHourly = [ '01.00', '02.00', '03.00', '04.00', '05.00', '06.00', '07.00', '08.00', '09.00', '10.00', '11.00', '12.00', '13.00', '14.00', '15.00', '16.00', @@ -58,8 +57,8 @@ export class GraphComponent implements OnInit { Chart.register(LineController, LineElement, PointElement, LinearScale, Title, CategoryScale, Tooltip, Filler); this.selectedSensor = 'dht'; this.parameters = this.sensorParameters[this.selectedSensor]; - } + ngAfterViewInit(): void { this.isLoading = true; setTimeout(() => { @@ -67,10 +66,12 @@ export class GraphComponent implements OnInit { this.isLoading = false; }, 2000); - - console.log(this.chartElement.nativeElement); - console.log(this.chart); - console.log(this.isLoading); + window.addEventListener('resize', () => { + if (this.chart) { + this.chart.destroy(); + this.createChart(this.dhtData.temperature, 'Temperature', '#8F5A62', this.labelHourly); + } + }); }