mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
fix(vipergc-660): identify axis keys upon adding object to composition (#7897)
* fix: identify axis keys upon adding object to composition * fix: set yKey to 'none' if nonArrayValues
This commit is contained in:
parent
3e23dceb64
commit
518b55cf0f
@ -332,7 +332,11 @@ export default {
|
|||||||
this.domainObject.configuration.axes.xKey === undefined ||
|
this.domainObject.configuration.axes.xKey === undefined ||
|
||||||
this.domainObject.configuration.axes.yKey === 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 = [];
|
let xValues = [];
|
||||||
@ -431,6 +435,30 @@ export default {
|
|||||||
subscribeToAll() {
|
subscribeToAll() {
|
||||||
const telemetryObjects = Object.values(this.telemetryObjects);
|
const telemetryObjects = Object.values(this.telemetryObjects);
|
||||||
telemetryObjects.forEach(this.subscribeToObject);
|
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 = 'none';
|
||||||
|
} else {
|
||||||
|
// Fallback if no valid xKey or yKey is found
|
||||||
|
xKey = 'none';
|
||||||
|
yKey = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
return { xKey, yKey };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user