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

@Component({
  selector: 'app-query-window',
  templateUrl: './query-window.component.html',
  styleUrls: ['./query-window.component.css']
})
export class QueryWindowComponent implements OnInit {

  public plot;

  constructor(private service: CacheService) { }

  ngOnInit(): void {
    this.service.onNewQuery.subscribe(() => {
      if (this.service.query) {
        this.initializePlot();
      }
    });
  }

  initializePlot(): void {
    this.plot =
      {
        index: this.service.query,
        data: [{
          x: this.service.rawIndices.slice(this.service.query, this.service.query + this.service.windowSize),
          y: this.service.rawValues.slice(this.service.query, this.service.query + this.service.windowSize),
          type: 'line'
        }],
        layout: {
          title: `Index: ${this.service.query.toString()}`,
          hovermode: 'closest',
          autosize: true,
          margin: {
37
            l: 50,
38
39
40
41
42
43
44
45
46
            r: 30,
            t: 30,
            pad: 4
          },
          height: 200,
          width: 150,
          titlefont: {
            size: 9
          },
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
47
48
49
          xaxis: {
            showticklabels: false,
          }
50
51
52
53
54
55
56
57
        }
      };
  }

  get query(): number {
    return this.service.query;
  }
}