Skip to content
Snippets Groups Projects
Commit e8ffce85 authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

add default plots

parent a89e022e
No related branches found
No related tags found
1 merge request!526NCM: default plots
...@@ -4,7 +4,10 @@ import { ...@@ -4,7 +4,10 @@ import {
GeophysicalUsage, GeophysicalUsage,
} from '@ghsc/nshmp-utils-ts/libs/ncm/geophysical'; } from '@ghsc/nshmp-utils-ts/libs/ncm/geophysical';
import {Plots} from './plots.model';
export interface AppState { export interface AppState {
plots: Plots;
serviceCallInfo: ServiceCallInfo; serviceCallInfo: ServiceCallInfo;
serviceResponse: GeophysicalResponse; serviceResponse: GeophysicalResponse;
usageResponse: GeophysicalUsage; usageResponse: GeophysicalUsage;
......
...@@ -5,6 +5,11 @@ import { ...@@ -5,6 +5,11 @@ import {
ServiceCallInfo, ServiceCallInfo,
SpinnerService, SpinnerService,
} from '@ghsc/nshmp-lib-ng/nshmp'; } from '@ghsc/nshmp-lib-ng/nshmp';
import {
DefaultPlotOptions,
NshmpPlot,
plotUtils,
} from '@ghsc/nshmp-lib-ng/plot';
import {GeophysicalUsage} from '@ghsc/nshmp-utils-ts/libs/ncm/geophysical'; import {GeophysicalUsage} from '@ghsc/nshmp-utils-ts/libs/ncm/geophysical';
import deepEqual from 'deep-equal'; import deepEqual from 'deep-equal';
import {environment} from 'projects/nshmp-apps/src/environments/environment'; import {environment} from 'projects/nshmp-apps/src/environments/environment';
...@@ -13,6 +18,7 @@ import {SharedService} from 'projects/nshmp-apps/src/shared/services/shared.serv ...@@ -13,6 +18,7 @@ import {SharedService} from 'projects/nshmp-apps/src/shared/services/shared.serv
import {catchError} from 'rxjs'; import {catchError} from 'rxjs';
import {ControlForm} from '../models/control-form.model'; import {ControlForm} from '../models/control-form.model';
import {Plots} from '../models/plots.model';
import {AppState} from '../models/state.model'; import {AppState} from '../models/state.model';
/** /**
...@@ -43,6 +49,13 @@ export class AppService ...@@ -43,6 +49,13 @@ export class AppService
this.addValidators(); this.addValidators();
} }
/**
* Returns the plots.
*/
get plots(): Signal<Plots> {
return computed(() => this.state().plots);
}
/** /**
* Returns the service call info. * Returns the service call info.
*/ */
...@@ -87,6 +100,43 @@ export class AppService ...@@ -87,6 +100,43 @@ export class AppService
}; };
} }
defaultPlots(): Plots {
const xLabel = 'Depth (meters)';
return {
density: this.defaultPlot({
id: 'density',
title: 'Density Profile',
xLabel,
yLabel: 'Density Profile (kg/m3)',
}),
porosity: this.defaultPlot({
id: 'porosity',
title: 'Porosity Profile',
xLabel,
yLabel: 'Porosity Profile',
}),
temperature: this.defaultPlot({
id: 'temperature',
title: 'Temperature Profile',
xLabel,
yLabel: 'Temperature Profile (°C)',
}),
vp: this.defaultPlot({
id: 'p-wave',
title: 'P-wave Profile',
xLabel,
yLabel: 'P-wave Profile (m/s)',
}),
vs: this.defaultPlot({
id: 's-wave',
title: 'S-wave Profile',
xLabel,
yLabel: 'S-wave Profile (m/s)',
}),
};
}
init(): void { init(): void {
const spinnerRef = this.spinnerService.show( const spinnerRef = this.spinnerService.show(
SpinnerService.MESSAGE_METADATA SpinnerService.MESSAGE_METADATA
...@@ -115,6 +165,7 @@ export class AppService ...@@ -115,6 +165,7 @@ export class AppService
initialState(): AppState { initialState(): AppState {
return { return {
plots: this.defaultPlots(),
serviceCallInfo: { serviceCallInfo: {
serviceCalls: [], serviceCalls: [],
serviceName: 'Geophysical profiles', serviceName: 'Geophysical profiles',
...@@ -150,6 +201,19 @@ export class AppService ...@@ -150,6 +201,19 @@ export class AppService
} }
} }
private defaultPlot(options: DefaultPlotOptions): NshmpPlot {
const plotData = plotUtils.defaultPlot(options);
return {
label: options.title,
plotData,
settingsForm: plotUtils.plotSettingsToFormGroup({
config: plotData.config,
layout: plotUtils.plotlyLayoutToSettings(plotData.layout),
}),
};
}
private resetState(): void { private resetState(): void {
this.updateState({ this.updateState({
serviceCallInfo: { serviceCallInfo: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment