labels.component.ts 1.52 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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(); });
  }

Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
19
  async createSubplots() {
20
21
    this.goodLabels = [];
    this.badLabels = [];
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
22
23
    const windows = await this.service.getWindow(Object.keys(this.service.labels).map(Number));
    Object.keys(this.service.labels).forEach((key, i) => {
24
25
26
27
28
      const index = Number(key);
      const plot =
        {
          index,
          data: [{
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
29
30
            x: [...Array(this.service.windowSize).keys()],
            y: windows[i],
31
32
33
34
35
36
37
38
39
40
            type: 'line'
          }],
          layout: {
            title: `Index: ${index.toString()}`,
            hovermode: 'closest',
            autosize: true,
            margin: {
              l: 30,
              r: 30,
              t: 30,
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
41
              b: 5,
42
43
              pad: 4
            },
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
44
            height: 150,
45
46
47
48
            width: 150,
            titlefont: {
              size: 9
            },
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
49
50
51
            xaxis: {
              showticklabels: false,
            }
52
53
54
55
56
57
58
          }
        };
      if (this.service.labels[key]) {
        this.goodLabels.push(plot);
      } else {
        this.badLabels.push(plot);
      }
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
59
    });
60
61
62
  }

}