Browse Source

feat(client): use viewChild signals

pull/6859/head
KenTandrian 1 day ago
parent
commit
31f0b10053
  1. 14
      apps/client/src/app/components/investment-chart/investment-chart.component.ts

14
apps/client/src/app/components/investment-chart/investment-chart.component.ts

@ -24,7 +24,7 @@ import {
Input, Input,
OnChanges, OnChanges,
OnDestroy, OnDestroy,
ViewChild viewChild
} from '@angular/core'; } from '@angular/core';
import { import {
BarController, BarController,
@ -66,7 +66,8 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
@Input() public locale = getLocale(); @Input() public locale = getLocale();
@Input() public savingsRate = 0; @Input() public savingsRate = 0;
@ViewChild('chartCanvas') private chartCanvas: ElementRef<HTMLCanvasElement>; private readonly chartCanvas =
viewChild.required<ElementRef<HTMLCanvasElement>>('chartCanvas');
private chart: Chart<'bar' | 'line'>; private chart: Chart<'bar' | 'line'>;
private investments: InvestmentItem[]; private investments: InvestmentItem[];
@ -172,7 +173,9 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart<'bar' | 'line'>(this.chartCanvas.nativeElement, { this.chart = new Chart<'bar' | 'line'>(
this.chartCanvas().nativeElement,
{
data: chartData, data: chartData,
options: { options: {
animation: false, animation: false,
@ -278,10 +281,11 @@ export class GfInvestmentChartComponent implements OnChanges, OnDestroy {
} }
}, },
plugins: [ plugins: [
getVerticalHoverLinePlugin(this.chartCanvas, this.colorScheme) getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme)
], ],
type: this.groupBy ? 'bar' : 'line' type: this.groupBy ? 'bar' : 'line'
}); }
);
} }
} }
} }

Loading…
Cancel
Save