components/plot-settings-panel/plot-settings-panel.component.ts
Settings for all plots.
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
|
import {Component, computed} from '@angular/core';
import {
NshmpLibNgPlotSettingsExpansionPanelComponent,
NshmpPlot,
PlotSettingsPlots,
} from '@ghsc/nshmp-lib-ng/plot';
import {Plots} from '../../models/state.model';
import {AppService} from '../../services/app.service';
/**
* Settings for all plots.
*/
@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 defaultPlots = this.service.plots();
return [
{
defaultPlotSetting: defaultPlots
.get(Plots.HAZARD)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.HAZARD),
updatePlot: plot => this.updatePlot(Plots.HAZARD, plot),
},
{
defaultPlotSetting: defaultPlots
.get(Plots.HAZARD_DIFFERENCES)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.HAZARD_DIFFERENCES),
updatePlot: plot => this.updatePlot(Plots.HAZARD_DIFFERENCES, plot),
},
{
defaultPlotSetting: defaultPlots
.get(Plots.SPECTRUM)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.SPECTRUM),
updatePlot: plot => this.updatePlot(Plots.SPECTRUM, plot),
},
{
defaultPlotSetting: defaultPlots
.get(Plots.SPECTRUM_COMPONENTS)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.SPECTRUM_DIFFERENCES),
updatePlot: plot => this.updatePlot(Plots.SPECTRUM_DIFFERENCES, plot),
},
{
defaultPlotSetting: defaultPlots
.get(Plots.HAZARD_COMPONENTS)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.HAZARD_COMPONENTS),
updatePlot: plot => this.updatePlot(Plots.HAZARD_COMPONENTS, plot),
},
{
defaultPlotSetting: defaultPlots
.get(Plots.SPECTRUM_COMPONENTS)
.settingsForm.getRawValue(),
plot: defaultPlots.get(Plots.SPECTRUM_COMPONENTS),
updatePlot: plot => this.updatePlot(Plots.SPECTRUM_COMPONENTS, plot),
},
];
});
constructor(private service: AppService) {}
updatePlot(id: string, plot: NshmpPlot): void {
const plots = new Map(this.service.state().plots);
plots.set(id, plot);
this.service.updateState({
plots,
});
}
}
<nshmp-lib-ng-plot-settings-expansion-panel [plots]="plots()" />