Refactor charts to use @ViewChild instead of @Input
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { cardElevation } from '../../style';
|
||||
import { SystemConfigService } from 'src/app/system-config.service';
|
||||
import { DonutChartComponent } from '../donut-chart/donut-chart.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-device-chart',
|
||||
@@ -8,16 +9,21 @@ import { SystemConfigService } from 'src/app/system-config.service';
|
||||
styleUrls: ['./device-chart.component.scss']
|
||||
})
|
||||
export class DeviceChartComponent implements OnInit {
|
||||
@ViewChild(DonutChartComponent) donutChart: DonutChartComponent;
|
||||
|
||||
chartID: string = 'devicesChart';
|
||||
elevation: string = cardElevation;
|
||||
data: number[];
|
||||
|
||||
constructor(private systemConfigService: SystemConfigService) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
}
|
||||
|
||||
ngAfterViewInit(): void {
|
||||
this.systemConfigService.getDevices().subscribe(
|
||||
data => {
|
||||
this.data = [0, 230, 32, 40];
|
||||
devices => {
|
||||
this.donutChart.data([0, 230, 32, 40]);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user