components/plot-settings-panel/plot-settings-panel.component.ts
Plot settings panel.
selector | app-plot-settings-panel |
imports |
NshmpLibNgPlotSettingsExpansionPanelComponent
|
templateUrl | ./plot-settings-panel.component.html |
styleUrl | ./plot-settings-panel.component.scss |
Properties |
Methods |
constructor(service: AppService)
|
||||||
Parameters :
|
updatePlot | |||||||||
updatePlot(id: string, plot: NshmpPlot)
|
|||||||||
Parameters :
Returns :
void
|
Public service |
Type : AppService
|
import {Component, computed} from '@angular/core';
import {HazardPlots, hazardUtils} from '@ghsc/nshmp-lib-ng/hazard';
import {
NshmpLibNgPlotSettingsExpansionPanelComponent,
NshmpPlot,
PlotSettingsPlots,
} from '@ghsc/nshmp-lib-ng/plot';
import {AppService} from '../../services/app.service';
/**
* Plot settings panel.
*/
@Component({
imports: [NshmpLibNgPlotSettingsExpansionPanelComponent],
selector: 'app-plot-settings-panel',
styleUrl: './plot-settings-panel.component.scss',
templateUrl: './plot-settings-panel.component.html',
})
export class PlotSettingsPanelComponent {
plots = computed<PlotSettingsPlots[]>(() => {
const hazardPlot = this.service.hazardPlotState();
const spectrumPlot = this.service.spectrumPlotState();
const defaultPlots = hazardUtils.hazardDefaultPlots();
return [
{
defaultPlotSetting: defaultPlots
.get(HazardPlots.HAZARD)
.settingsForm.getRawValue(),
plot: hazardPlot,
updatePlot: plot => this.updatePlot(HazardPlots.HAZARD, plot),
},
{
defaultPlotSetting: defaultPlots
.get(HazardPlots.SPECTRUM)
.settingsForm.getRawValue(),
plot: spectrumPlot,
updatePlot: plot => this.updatePlot(HazardPlots.SPECTRUM, plot),
},
];
});
constructor(public service: AppService) {}
updatePlot(id: string, plot: NshmpPlot): void {
const plots = new Map(this.service.plots());
plots.set(id, plot);
this.service.updateState({
plots,
});
}
}
<nshmp-lib-ng-plot-settings-expansion-panel [plots]="plots()" />