From 5309bf3707e280226f14be148e48de11b4895daa Mon Sep 17 00:00:00 2001 From: Brandon Clayton <bclayton@usgs.gov> Date: Fri, 22 Nov 2024 09:26:04 -0700 Subject: [PATCH] swap x and y for data table --- .../components/data/data.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/projects/nshmp-apps/src/app/ncm/geophysical-profiles/components/data/data.component.ts b/projects/nshmp-apps/src/app/ncm/geophysical-profiles/components/data/data.component.ts index 49959c1a2..d0970c9db 100644 --- a/projects/nshmp-apps/src/app/ncm/geophysical-profiles/components/data/data.component.ts +++ b/projects/nshmp-apps/src/app/ncm/geophysical-profiles/components/data/data.component.ts @@ -7,6 +7,7 @@ import { TableData, } from '@ghsc/nshmp-lib-ng/nshmp'; import {NshmpPlot, plotUtils} from '@ghsc/nshmp-lib-ng/plot'; +import {DataTitle} from 'plotly.js'; import {AppService} from '../../services/app.service'; @@ -61,16 +62,28 @@ export class DataComponent { index: number, hideX = true ): TableData[] { + const data = plot.plotData.data[index]; + return plotUtils.plotDataToTableData( { ...plot, plotData: { ...plot.plotData, - data: [plot.plotData.data[index]], + data: [ + { + ...data, + x: data.y, + y: data.x, + }, + ], }, }, { hideX, + xLabelTransform: () => + (plot.plotData.layout.yaxis.title as DataTitle).text, + yLabelTransform: () => + (plot.plotData.layout.xaxis.title as DataTitle).text, yValueFormat: (y: number) => y.toFixed(4), } ); -- GitLab