labels.component.ts 1.45 KB
Newer Older
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
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(); });
  }

  createSubplots(): void {
    this.goodLabels = [];
    this.badLabels = [];
    console.log(this.service.labels);
    for (const key of Object.keys(this.service.labels)) {
      const index = Number(key);
      const plot =
        {
          index,
          data: [{
            x: this.service.rawIndices.slice(index, index + this.service.windowSize),
            y: this.service.rawValues.slice(index, index + this.service.windowSize),
            type: 'line'
          }],
          layout: {
            title: `Index: ${index.toString()}`,
            hovermode: 'closest',
            autosize: true,
            margin: {
              l: 30,
              r: 30,
              t: 30,
              pad: 4
            },
            height: 200,
            width: 150,
            titlefont: {
              size: 9
            },
          }
        };
      if (this.service.labels[key]) {
        this.goodLabels.push(plot);
      } else {
        this.badLabels.push(plot);
      }
    }
  }

}