table-overview.component.ts 1.44 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
import { Component, OnInit } from '@angular/core';
import {CacheService} from '../cache.service';

@Component({
  selector: 'app-table-overview',
  templateUrl: './table-overview.component.html',
  styleUrls: ['./table-overview.component.css']
})
export class TableOverviewComponent implements OnInit {
  public subplots;
  constructor(private service: CacheService) { }

  ngOnInit(): void {
    this.service.onNewTables.subscribe(() => this.createPlots());
  }

  public get tables() {
    return this.service.tables;
  }

  createPlots() {
    this.subplots = [];
    for (const tableIndex in this.tables) {
      const table = this.tables[tableIndex];
      this.subplots.push(
        {
          data: [{
            x: Object.keys(table.entries).map((hash: string) => {
29
              return Number('0b' + hash);
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
              }
            ),
            y: Object.values(table.entries).map((values: number[]) => values.length / this.service.windows.length),
            type: 'bar'
          }],
          layout: {
            hovermode: 'closest',
            autosize: true,
            margin: {
              l: 10,
              r: 10,
              t: 10,
              b: 10,
              pad: 4
            },
            xaxis: {
              showticklabels: false
            },
            yaxis: {
              showticklabels: false
            },
            height: 100,
            width: screen.width * 0.1,
          }
        }
      );
    }
  }
}