File

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

Description

Plot settings form fields.

Metadata

Index

Properties
Methods

Constructor

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

Methods

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

Properties

plots
Default value : computed<PlotSettingsPlots[]>(() => { const meanPlot = this.service.spectraPlotState(); const sigmaPlot = this.service.sigmaPlotState(); const defaultPlots = this.service.defaultPlots(); return [ { defaultPlotSetting: defaultPlots .get(gmmUtils.PlotType.MEANS) .settingsForm.getRawValue(), plot: meanPlot, updatePlot: plot => this.updatePlot(gmmUtils.PlotType.MEANS, plot), }, { defaultPlotSetting: defaultPlots .get(gmmUtils.PlotType.SIGMA) .settingsForm.getRawValue(), plot: sigmaPlot, updatePlot: plot => this.updatePlot(gmmUtils.PlotType.SIGMA, plot), }, ]; })
Public service
Type : AppService
import {Component, computed} from '@angular/core';
import {gmmUtils} from '@ghsc/nshmp-lib-ng/gmm';
import {
  NshmpLibNgPlotSettingsExpansionPanelComponent,
  PlotSettingsPlots,
} from '@ghsc/nshmp-lib-ng/plot';

import {SpectraPlot} from '../../models/spectra-plot.model';
import {AppService} from '../../services/app.service';

/**
 * Plot settings form fields.
 */
@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 meanPlot = this.service.spectraPlotState();
    const sigmaPlot = this.service.sigmaPlotState();
    const defaultPlots = this.service.defaultPlots();

    return [
      {
        defaultPlotSetting: defaultPlots
          .get(gmmUtils.PlotType.MEANS)
          .settingsForm.getRawValue(),
        plot: meanPlot,
        updatePlot: plot => this.updatePlot(gmmUtils.PlotType.MEANS, plot),
      },
      {
        defaultPlotSetting: defaultPlots
          .get(gmmUtils.PlotType.SIGMA)
          .settingsForm.getRawValue(),
        plot: sigmaPlot,
        updatePlot: plot => this.updatePlot(gmmUtils.PlotType.SIGMA, plot),
      },
    ];
  });

  constructor(public service: AppService) {}

  updatePlot(id: string, plot: SpectraPlot): 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 ""