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
37
38
39
40
import { Component, ViewChild, ElementRef, AfterViewInit, OnDestroy } from '@angular/core';
import { Subscription } from 'rxjs';
import { DeaggResponse, Deaggregation, DeaggregationGraphView } from '@nshmp/disagg-d3/src/disagg';
import { Collection } from '@nshmp/disagg-d3/src/mvc';
import { AppService } from './app.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements AfterViewInit, OnDestroy {
title = 'example';
@ViewChild('example')
el: ElementRef<HTMLElement>;
sub: Subscription;
constructor(private service: AppService) {}
ngAfterViewInit(): void {
this.sub = this.service.callDeagg$.subscribe((usageResponse) => {
const response = new DeaggResponse(usageResponse.response.pop());
const deaggs = response.get<Collection<Deaggregation>>('deaggregations').data();
const collection = new Collection(deaggs);
collection.select(collection.data()[0]);
const view = new DeaggregationGraphView({
el: this.el.nativeElement,
collection,
});
});
}
ngOnDestroy(): void {
this.sub.unsubscribe();
}
}