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.queryWindow) { this.initializePlot(); } }); } initializePlot(): void { this.plot = { data: [{ x: [...Array(this.service.queryWindow.length).keys()], y: this.service.queryWindow, type: 'line' }], layout: { hovermode: 'closest', autosize: true, margin: { l: 50, r: 30, t: 30, b: 5, pad: 4 }, height: 150, width: 150, titlefont: { size: 9 }, xaxis: { showgrid: false, zeroline: false, showticklabels: false, }, yaxis: { zeroline: false, showticklabels: false, } } }; } get isQuerySet(): boolean { return !!this.service.queryWindow; } public newQuery() { this.service.querySelectionMode = true; } }