query-window.component.ts 1.39 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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(() => {
17
      if (this.service.queryWindow) {
18
19
20
21
22
23
24
25
26
        this.initializePlot();
      }
    });
  }

  initializePlot(): void {
    this.plot =
      {
        data: [{
27
28
          x: [...Array(this.service.queryWindow.length).keys()],
          y: this.service.queryWindow,
29
30
31
32
33
34
          type: 'line'
        }],
        layout: {
          hovermode: 'closest',
          autosize: true,
          margin: {
35
            l: 50,
36
37
            r: 30,
            t: 30,
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
38
            b: 5,
39
40
            pad: 4
          },
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
41
          height: 150,
42
43
44
45
          width: 150,
          titlefont: {
            size: 9
          },
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
46
          xaxis: {
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
47
48
            showgrid: false,
            zeroline: false,
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
49
            showticklabels: false,
50
51
          },
          yaxis: {
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
52
            zeroline: false,
53
            showticklabels: false,
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
54
          }
55
56
57
58
        }
      };
  }

59
60
  get isQuerySet(): boolean {
    return !!this.service.queryWindow;
61
  }
Kruyff,D.L.W. (Dylan)'s avatar
Kruyff,D.L.W. (Dylan) committed
62
63
64
65

  public newQuery() {
    this.service.querySelectionMode = true;
  }
66
}