components/plots/plots.component.ts
Main application plots showing magnitude frequency distribution: magnitude vs. rate.
By default all MFD types are show, select menu with ability to change to specific MFD type.
OnInit
OnDestroy
selector | app-plots |
imports |
NshmpLibNgPlotsContainerComponent
NshmpLibNgPlotComponent
NshmpLibNgAppMetadataComponent
MatAccordion
MatExpansionPanel
MatExpansionPanelHeader
MatExpansionPanelTitle
MatDivider
MatFormField
MatLabel
MatSelect
MatOption
ParameterSummaryComponent
ReactiveFormsModule
|
templateUrl | ./plots.component.html |
styleUrl | ./plots.component.scss |
Properties |
Methods |
constructor(service: AppService)
|
||||||
Defined in components/plots/plots.component.ts:79
|
||||||
Parameters :
|
ngOnDestroy |
ngOnDestroy()
|
Defined in components/plots/plots.component.ts:94
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Defined in components/plots/plots.component.ts:83
|
Returns :
void
|
formGroup |
Default value : this.service.formGroup
|
Defined in components/plots/plots.component.ts:54
|
Form field state |
mfdPlotData |
Default value : this.service.mfdPlotData
|
Defined in components/plots/plots.component.ts:57
|
MFD plot data state |
Private mfdSubscription |
Default value : new Subscription()
|
Defined in components/plots/plots.component.ts:79
|
MfdType |
Default value : MfdType
|
Defined in components/plots/plots.component.ts:51
|
mfdTypes |
Default value : computed(() => {
const serviceResponse = this.service.serviceResponse();
if (serviceResponse === null) {
return [];
}
const mfdTypes = serviceResponse.response.branches
.map(branch => {
return branch.mfds.map(mfdInfo => mfdInfo.mfd.props.type);
})
.reduce((prev, curr) => [...prev, ...curr]);
return Array.from(new Set(mfdTypes)).sort((a, b) => a.localeCompare(b));
})
|
Defined in components/plots/plots.component.ts:60
|
MFD types plotted for select menu |
repositories |
Default value : computed(() => this.service.usage()?.metadata.repositories)
|
Defined in components/plots/plots.component.ts:77
|
Repo metadata |
import {Component, computed, OnDestroy, OnInit} from '@angular/core';
import {ReactiveFormsModule} from '@angular/forms';
import {MatOption} from '@angular/material/core';
import {MatDivider} from '@angular/material/divider';
import {
MatAccordion,
MatExpansionPanel,
MatExpansionPanelHeader,
MatExpansionPanelTitle,
} from '@angular/material/expansion';
import {MatFormField, MatLabel} from '@angular/material/form-field';
import {MatSelect} from '@angular/material/select';
import {NshmpLibNgAppMetadataComponent} from '@ghsc/nshmp-lib-ng/nshmp';
import {
NshmpLibNgPlotComponent,
NshmpLibNgPlotsContainerComponent,
} from '@ghsc/nshmp-lib-ng/plot';
import {Subscription} from 'rxjs';
import {MfdType} from '../../models/control-form.model';
import {AppService} from '../../services/app.service';
import {ParameterSummaryComponent} from '../parameter-summary/parameter-summary.component';
/**
* Main application plots showing magnitude frequency distribution: magnitude vs. rate.
*
* By default all MFD types are show, select menu with ability to change to specific MFD type.
*/
@Component({
imports: [
NshmpLibNgPlotsContainerComponent,
NshmpLibNgPlotComponent,
NshmpLibNgAppMetadataComponent,
MatAccordion,
MatExpansionPanel,
MatExpansionPanelHeader,
MatExpansionPanelTitle,
MatDivider,
MatFormField,
MatLabel,
MatSelect,
MatOption,
ParameterSummaryComponent,
ReactiveFormsModule,
],
selector: 'app-plots',
styleUrl: './plots.component.scss',
templateUrl: './plots.component.html',
})
export class PlotsComponent implements OnInit, OnDestroy {
MfdType = MfdType;
/** Form field state */
formGroup = this.service.formGroup;
/** MFD plot data state */
mfdPlotData = this.service.mfdPlotData;
/** MFD types plotted for select menu */
mfdTypes = computed(() => {
const serviceResponse = this.service.serviceResponse();
if (serviceResponse === null) {
return [];
}
const mfdTypes = serviceResponse.response.branches
.map(branch => {
return branch.mfds.map(mfdInfo => mfdInfo.mfd.props.type);
})
.reduce((prev, curr) => [...prev, ...curr]);
return Array.from(new Set(mfdTypes)).sort((a, b) => a.localeCompare(b));
});
/** Repo metadata */
repositories = computed(() => this.service.usage()?.metadata.repositories);
private mfdSubscription = new Subscription();
constructor(private service: AppService) {}
ngOnInit(): void {
this.mfdSubscription =
this.formGroup.controls.mfdType.valueChanges.subscribe(() => {
if (
this.formGroup.controls.mfdType.enabled &&
this.service.serviceResponse() !== null
) {
this.service.createPlots();
}
});
}
ngOnDestroy(): void {
this.mfdSubscription.unsubscribe();
}
}
<nshmp-lib-ng-plots-container>
<mat-accordion multi>
<!-- MFD plot -->
<mat-expansion-panel expanded>
<mat-expansion-panel-header>
<mat-panel-title>Magnitude Frequency Distribution</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider />
<!-- Select MFD type -->
<div>
<mat-form-field class="grid-col-12 padding-top-4 mfd-type-select">
<mat-label>MFD Type</mat-label>
<mat-select [formControl]="formGroup.controls?.mfdType">
<mat-option [value]="MfdType.ALL">
{{ MfdType.ALL }}
</mat-option>
<mat-option [value]="MfdType.TOTAL">
{{ MfdType.TOTAL }}
</mat-option>
@for (mfdType of mfdTypes(); track mfdType) {
<mat-option [value]="mfdType">
{{ mfdType }}
</mat-option>
}
</mat-select>
</mat-form-field>
</div>
@if (mfdPlotData()) {
<nshmp-lib-ng-plot class="mfd-plot" [plot]="mfdPlotData()" />
}
</mat-expansion-panel>
<!-- Parameter summary -->
<mat-expansion-panel expanded>
<mat-expansion-panel-header>
<mat-panel-title>Parameter Summary</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider />
<app-parameter-summary />
</mat-expansion-panel>
<!-- App metadata -->
<mat-expansion-panel expanded>
<mat-expansion-panel-header>
<mat-panel-title>Application Metadata</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider />
<nshmp-lib-ng-app-metadata [repositories]="repositories()" />
</mat-expansion-panel>
</mat-accordion>
</nshmp-lib-ng-plots-container>