Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 1x 2x 2x 15x 2x 3x 3x 2x | import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { ChangeDetectionStrategy, Component, inject } from '@angular/core'; import { first, map, switchMap, timer } from 'rxjs'; import { IRadarChartDataNode, IRadarChartOptions } from '../../interfaces/radar-chart.interface'; /** Radar chart example. */ @Component({ selector: 'app-chart-examples-radar', templateUrl: './chart-examples-radar.component.html', styleUrls: ['./chart-examples-radar.component.scss'], changeDetection: ChangeDetectionStrategy.OnPush, standalone: false, }) export class AppChartExamplesRadaraComponent { private readonly breakpointObserver = inject(BreakpointObserver); /** The chart data. */ private get chartData() { return [ [ { axis: 'one', value: 1, unit: 'x' }, { axis: 'two', value: 2, unit: 'x' }, { axis: 'three', value: 3, unit: 'x' }, { axis: 'four', value: 4, unit: 'x' }, { axis: 'five', value: 5, unit: 'x' }, { axis: 'six', value: 6, unit: 'x' }, { axis: 'seven', value: 7, unit: 'x' }, { axis: 'eight', value: 8, unit: 'x' }, { axis: 'nine (long labels are wrapped)', value: 9, unit: 'x' }, ], [ { axis: 'one', value: 9, unit: 'y' }, { axis: 'two', value: 8, unit: 'y' }, { axis: 'three', value: 7, unit: 'y' }, { axis: 'four', value: 6, unit: 'y' }, { axis: 'five', value: 5, unit: 'y' }, { axis: 'six', value: 4, unit: 'y' }, { axis: 'seven', value: 3, unit: 'y' }, { axis: 'eight', value: 2, unit: 'y' }, { axis: 'nine (long labels are wrapped)', value: 1, unit: 'y' }, ], ] as IRadarChartDataNode[][]; } /** The chart options. */ private get chartOptions() { return { chartTitle: 'Example radar chart', } as Partial<IRadarChartOptions>; } /** The breakpoint observer stream. */ private readonly breakpoint$ = this.breakpointObserver .observe([Breakpoints.XSmall, Breakpoints.Small, Breakpoints.Medium, Breakpoints.Large, Breakpoints.XLarge]) .pipe(map(result => Object.keys(result.breakpoints).find(item => result.breakpoints[item]) ?? 'unknown')); /** The chart configuration stream. */ public readonly chartConfig$ = this.breakpoint$.pipe( switchMap(() => { const timeout = 100; return timer(timeout).pipe( first(), map(() => ({ data: this.chartData, options: this.chartOptions })), ); }), ); } |