import { Component, OnInit } from '@angular/core'; import {CacheService} from '../cache.service'; @Component({ selector: 'app-labels', templateUrl: './labels.component.html', styleUrls: ['./labels.component.css'] }) export class LabelsComponent implements OnInit { public goodLabels = []; public badLabels = []; constructor(private service: CacheService) { } ngOnInit(): void { this.service.onNewLabels.subscribe(() => { this.createSubplots(); }); } async createSubplots() { this.goodLabels = []; this.badLabels = []; const windows = await this.service.getWindow(Object.keys(this.service.labels).map(Number)); Object.keys(this.service.labels).forEach((key, i) => { const index = Number(key); const plot = { index, data: [{ x: [...Array(this.service.windowSize).keys()], y: windows[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.service.labels[key]) { this.goodLabels.push(plot); } else { this.badLabels.push(plot); } }); } }