File

components/plot-settings-panel/plot-settings-panel.component.ts

Description

Settings for all plots.

Metadata

Index

Properties
Methods

Constructor

constructor(service: AppService)
Parameters :
Name Type Optional
service AppService No

Methods

updatePlot
updatePlot(id: string, plot: NshmpPlot)
Parameters :
Name Type Optional
id string No
plot NshmpPlot No
Returns : void

Properties

plots
Default value : 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), }, ]; })
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()" />
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""