From 7b5d4e829d9b9dfe772338cdf0c095144f005cbe Mon Sep 17 00:00:00 2001 From: "Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC]" Date: Thu, 17 Oct 2024 11:52:57 -0700 Subject: [PATCH 1/2] fix: identify axis keys upon adding object to composition --- src/plugins/charts/bar/BarGraphView.vue | 30 ++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index 0bc90e3ebb9..8fa9fe7e7a9 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -332,7 +332,11 @@ export default { this.domainObject.configuration.axes.xKey === undefined || this.domainObject.configuration.axes.yKey === undefined ) { - return; + const { xKey, yKey } = this.identifyAxesKeys(axisMetadata); + this.openmct.objects.mutate(this.domainObject, 'configuration.axes', { + xKey, + yKey + }); } let xValues = []; @@ -431,6 +435,30 @@ export default { subscribeToAll() { const telemetryObjects = Object.values(this.telemetryObjects); telemetryObjects.forEach(this.subscribeToObject); + }, + identifyAxesKeys(metadata) { + const { xAxisMetadata, yAxisMetadata } = metadata; + + let xKey; + let yKey; + + // If xAxisMetadata contains array values, use the first one for xKey + const arrayValues = xAxisMetadata.filter((metaDatum) => metaDatum.isArrayValue); + const nonArrayValues = xAxisMetadata.filter((metaDatum) => !metaDatum.isArrayValue); + + if (arrayValues.length > 0) { + xKey = arrayValues[0].key; + yKey = arrayValues.length > 1 ? arrayValues[1].key : yAxisMetadata.key; + } else if (nonArrayValues.length > 0) { + xKey = nonArrayValues[0].key; + yKey = yAxisMetadata ? yAxisMetadata.key : 'none'; + } else { + // Fallback if no valid xKey or yKey is found + xKey = 'none'; + yKey = 'none'; + } + + return { xKey, yKey }; } } }; From 6777c76e46f6a830c3bb8c7df79a7b3d9d4bfd2c Mon Sep 17 00:00:00 2001 From: "Mazzella, Jesse D. (ARC-TI)[KBR Wyle Services, LLC]" Date: Thu, 17 Oct 2024 14:53:37 -0700 Subject: [PATCH 2/2] fix: set yKey to 'none' if nonArrayValues --- src/plugins/charts/bar/BarGraphView.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/charts/bar/BarGraphView.vue b/src/plugins/charts/bar/BarGraphView.vue index 8fa9fe7e7a9..07c24932d63 100644 --- a/src/plugins/charts/bar/BarGraphView.vue +++ b/src/plugins/charts/bar/BarGraphView.vue @@ -451,7 +451,7 @@ export default { yKey = arrayValues.length > 1 ? arrayValues[1].key : yAxisMetadata.key; } else if (nonArrayValues.length > 0) { xKey = nonArrayValues[0].key; - yKey = yAxisMetadata ? yAxisMetadata.key : 'none'; + yKey = 'none'; } else { // Fallback if no valid xKey or yKey is found xKey = 'none';