Skip to content
Snippets Groups Projects
app.component.ts 1.02 KiB
Newer Older
import { AfterViewInit, Component, ElementRef, OnInit, ViewChild } from '@angular/core';
import { nshmpHaz } from '@ghsc/nshmp-web-utils';
import { DisaggGraphView, Disaggregation, DisaggResponse } from '@nshmp/disagg-d3/src/disagg';
import { Collection } from '@nshmp/disagg-d3/src/mvc';

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
import deagg from '../assets/deagg.json';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss'],
})
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
export class AppComponent implements AfterViewInit {
  title = 'Disaggregation';

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  data = deagg.response as nshmpHaz.disaggService.DisaggResponseData;

  @ViewChild('example')
  el: ElementRef<HTMLElement>;

Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
  constructor() {}

  ngAfterViewInit(): void {
Clayton, Brandon Scott's avatar
Clayton, Brandon Scott committed
    const response = new DisaggResponse(this.data);
    const deaggs = response.get<Collection<Disaggregation>>('disaggregations').data();
    const collection = new Collection(deaggs);
    collection.select(collection.data()[0]);

    const view = new DisaggGraphView({
      el: this.el.nativeElement,
      collection,