import { Component, OnInit } from '@angular/core'; import {StateService} from '../state.service'; @Component({ selector: 'app-labels', templateUrl: './labels.component.html', styleUrls: ['./labels.component.css'] }) export class LabelsComponent implements OnInit { public goodLabels = []; public badLabels = []; constructor(private state: StateService) { } ngOnInit(): void { this.state.onNewLabels.subscribe(() => { this.createSubplots(); }); } async createSubplots() { this.goodLabels = []; this.badLabels = []; const labelWindows: number[][][] = await this.state.getWindow(Object.keys(this.state.labels).map(Number)); Object.keys(this.state.labels).forEach((key, i) => { const index = Number(key); const plot = { index, data: [{ x: [...Array(this.state.windowSize).keys()], y: labelWindows[i], type: 'line' }], layout: { title: `Index: ${index.toString()}`, hovermode: 'closest', autosize: true, margin: { l: 30, r: 30, t: 30, b: 5, pad: 4 }, height: 150, width: 150, titlefont: { size: 9 }, xaxis: { showticklabels: false, } } }; if (this.state.labels[key]) { this.goodLabels.push(plot); } else { this.badLabels.push(plot); } }); } }