Browse Source

feat(client): implement view child signal

pull/6904/head
KenTandrian 1 week ago
parent
commit
be919909c2
  1. 11
      apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts

11
apps/client/src/app/components/benchmark-comparator/benchmark-comparator.component.ts

@ -27,7 +27,7 @@ import {
OnChanges, OnChanges,
OnDestroy, OnDestroy,
Output, Output,
ViewChild viewChild
} from '@angular/core'; } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { MatSelectModule } from '@angular/material/select'; import { MatSelectModule } from '@angular/material/select';
@ -79,13 +79,14 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy {
@Output() benchmarkChanged = new EventEmitter<string>(); @Output() benchmarkChanged = new EventEmitter<string>();
@ViewChild('chartCanvas') chartCanvas: ElementRef<HTMLCanvasElement>;
public chart: Chart<'line'>; public chart: Chart<'line'>;
public hasPermissionToAccessAdminControl: boolean; public hasPermissionToAccessAdminControl: boolean;
public routerLinkAdminControlMarketData = public routerLinkAdminControlMarketData =
internalRoutes.adminControl.subRoutes.marketData.routerLink; internalRoutes.adminControl.subRoutes.marketData.routerLink;
private readonly chartCanvas =
viewChild.required<ElementRef<HTMLCanvasElement>>('chartCanvas');
public constructor() { public constructor() {
Chart.register( Chart.register(
annotationPlugin, annotationPlugin,
@ -166,7 +167,7 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy {
this.chart.update(); this.chart.update();
} else { } else {
this.chart = new Chart<'line'>(this.chartCanvas.nativeElement, { this.chart = new Chart<'line'>(this.chartCanvas().nativeElement, {
data, data,
options: { options: {
animation: false, animation: false,
@ -250,7 +251,7 @@ export class GfBenchmarkComparatorComponent implements OnChanges, OnDestroy {
} }
}, },
plugins: [ plugins: [
getVerticalHoverLinePlugin(this.chartCanvas, this.colorScheme) getVerticalHoverLinePlugin(this.chartCanvas(), this.colorScheme)
], ],
type: 'line' type: 'line'
}); });

Loading…
Cancel
Save