From a09db30b32e00aff5fcd570a6ce95506f952d832 Mon Sep 17 00:00:00 2001 From: Shefali Joshi Date: Thu, 7 Jul 2022 16:44:09 -0700 Subject: [PATCH] Allow endpoints with a single enum metadata value in Bar/Line graphs (#5443) * If there is only 1 metadata value, set yKey to none. Also, fix bug for determining the name of a metadata value * Update tests for enum metadata values Co-authored-by: John Hill Co-authored-by: Andrew Henry --- .../charts/bar/inspector/BarGraphOptions.vue | 6 ++-- src/plugins/charts/bar/pluginSpec.js | 33 +++++++++++-------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/plugins/charts/bar/inspector/BarGraphOptions.vue b/src/plugins/charts/bar/inspector/BarGraphOptions.vue index 2a6ffcab83..13dee4e28d 100644 --- a/src/plugins/charts/bar/inspector/BarGraphOptions.vue +++ b/src/plugins/charts/bar/inspector/BarGraphOptions.vue @@ -281,11 +281,11 @@ export default { this.xKeyOptions.push( metadataValues.reduce((previousValue, currentValue) => { return { - name: `${previousValue.name}, ${currentValue.name}`, + name: previousValue?.name ? `${previousValue.name}, ${currentValue.name}` : `${currentValue.name}`, value: currentValue.key, isArrayValue: currentValue.isArrayValue }; - }) + }, {name: ''}) ); } @@ -336,6 +336,8 @@ export default { return option; }); + } else if (this.xKey !== undefined && this.domainObject.configuration.axes.yKey === undefined) { + this.domainObject.configuration.axes.yKey = 'none'; } this.xKeyOptions = this.xKeyOptions.map((option, index) => { diff --git a/src/plugins/charts/bar/pluginSpec.js b/src/plugins/charts/bar/pluginSpec.js index feea71b81b..b63906bd50 100644 --- a/src/plugins/charts/bar/pluginSpec.js +++ b/src/plugins/charts/bar/pluginSpec.js @@ -367,19 +367,26 @@ describe("the plugin", function () { type: "test-object", name: "Test Object", telemetry: { - values: [{ - key: "some-key", - name: "Some attribute", - hints: { - domain: 1 - } - }, { - key: "some-other-key", - name: "Another attribute", - hints: { - range: 1 - } - }] + values: [ + { + key: "some-key", + source: "some-key", + name: "Some attribute", + format: "enum", + enumerations: [ + { + value: 0, + string: "OFF" + }, + { + value: 1, + string: "ON" + } + ], + hints: { + range: 1 + } + }] } }; const composition = openmct.composition.get(parent);