components/plots/plots.component.ts
Ground motion response spectra mean and sigma plots.
selector | app-plots |
imports |
NshmpLibNgPlotsContainerComponent
NshmpLibNgPlotComponent
NshmpLibNgAppMetadataComponent
MatAccordion
MatExpansionPanel
MatExpansionPanelHeader
MatExpansionPanelTitle
MatDivider
ParameterSummaryComponent
|
templateUrl | ./plots.component.html |
styleUrl | ./plots.component.scss |
Properties |
Methods |
|
constructor(service: AppService)
|
||||||
Defined in components/plots/plots.component.ts:52
|
||||||
Parameters :
|
Private filterData | ||||||||
filterData(plot: PlotlyPlot)
|
||||||||
Defined in components/plots/plots.component.ts:61
|
||||||||
Don't plot PGV values.
Parameters :
Returns :
PlotlyPlot
|
Private splicePgv | |||||||||
splicePgv(data: T[], iPgv: number)
|
|||||||||
Defined in components/plots/plots.component.ts:86
|
|||||||||
Type parameters :
|
|||||||||
Parameters :
Returns :
void
|
repositories |
Default value : computed(() => this.service.usage()?.metadata?.repositories)
|
Defined in components/plots/plots.component.ts:52
|
Repo metadata |
sigmaPlotData |
Default value : computed(() =>
this.filterData(this.service.sigmaPlotState().plotData),
)
|
Defined in components/plots/plots.component.ts:42
|
Sigma plot data |
spectraPlotData |
Default value : computed(() => ({
...this.filterData(this.service.spectraPlotState().plotData),
}))
|
Defined in components/plots/plots.component.ts:47
|
Response spectra plot data |
import {Component, computed} from '@angular/core';
import {MatDivider} from '@angular/material/divider';
import {
MatAccordion,
MatExpansionPanel,
MatExpansionPanelHeader,
MatExpansionPanelTitle,
} from '@angular/material/expansion';
import {gmmUtils} from '@ghsc/nshmp-lib-ng/gmm';
import {NshmpLibNgAppMetadataComponent} from '@ghsc/nshmp-lib-ng/nshmp';
import {
NshmpLibNgPlotComponent,
NshmpLibNgPlotsContainerComponent,
} from '@ghsc/nshmp-lib-ng/plot';
import {PlotlyPlot} from '@ghsc/nshmp-utils-ts/libs/plotly';
import {PlotData} from 'plotly.js';
import {AppService} from '../../services/app.service';
import {ParameterSummaryComponent} from '../parameter-summary/parameter-summary.component';
/**
* Ground motion response spectra mean and sigma plots.
*/
@Component({
imports: [
NshmpLibNgPlotsContainerComponent,
NshmpLibNgPlotComponent,
NshmpLibNgAppMetadataComponent,
MatAccordion,
MatExpansionPanel,
MatExpansionPanelHeader,
MatExpansionPanelTitle,
MatDivider,
ParameterSummaryComponent,
],
selector: 'app-plots',
styleUrl: './plots.component.scss',
templateUrl: './plots.component.html',
})
export class PlotsComponent {
/** Sigma plot data */
sigmaPlotData = computed(() =>
this.filterData(this.service.sigmaPlotState().plotData),
);
/** Response spectra plot data */
spectraPlotData = computed(() => ({
...this.filterData(this.service.spectraPlotState().plotData),
}));
/** Repo metadata */
repositories = computed(() => this.service.usage()?.metadata?.repositories);
constructor(private service: AppService) {}
/**
* Don't plot PGV values.
*
* @param plot The plot
*/
private filterData(plot: PlotlyPlot): PlotlyPlot {
const data = plot.data.map(data => {
const iPgv = data.x.findIndex(x => x === gmmUtils.XS_PGV);
const plotData: Partial<PlotData> = {
...data,
x: [...data.x] as number[],
y: [...data.y] as number[],
};
if (iPgv !== -1) {
this.splicePgv(plotData.x as number[], iPgv);
this.splicePgv(plotData.y as number[], iPgv);
this.splicePgv(plotData.hovertemplate as string[], iPgv);
this.splicePgv(plotData.marker.symbol as string[], iPgv);
}
return plotData;
});
return {
...plot,
data,
};
}
private splicePgv<T>(data: T[], iPgv: number): void {
if (Array.isArray(data)) {
data.splice(iPgv, 1);
}
}
}
<nshmp-lib-ng-plots-container>
<mat-accordion multi>
<!-- Spectra plot -->
<mat-expansion-panel expanded>
<mat-expansion-panel-header>
<mat-panel-title>Response Spectra</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider />
@if (spectraPlotData()) {
<nshmp-lib-ng-plot class="spectra-plot" [plot]="spectraPlotData()" />
}
</mat-expansion-panel>
<!-- Sigma plot -->
<mat-expansion-panel expanded>
<mat-expansion-panel-header>
<mat-panel-title>Standard Deviations</mat-panel-title>
</mat-expansion-panel-header>
<mat-divider />
@if (sigmaPlotData()) {
<nshmp-lib-ng-plot class="sigma-plot" [plot]="sigmaPlotData()" />
}
</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>