From 2889e88a97b0031cbceb0dc1e08f4fff40e6c9b0 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Mon, 21 Jun 2021 16:22:28 -0700 Subject: [PATCH] Styling for plot limits (#3917) * Styling for plot limits and colors * Updates to limit provider and css * Change limits related CSS "*--upper" and "*--lower" to "*--upr" and "*--lwr" for better parity with legacy naming; * Refactor limit class to util * Use new classes for sine wave generator for red-low and yellow-high * Added modifier classes for right and below-aligned labels; * Prevent label overlap of limits as much as possible * Add border colors to limit labels for better visual ties to their lines * Add documentation for limit level specification API change Co-authored-by: Shefali Joshi Co-authored-by: Andrew Henry --- API.md | 14 +- example/generator/SinewaveLimitProvider.js | 60 +++- src/api/telemetry/TelemetryAPI.js | 9 +- .../components/telemetry-view.scss | 4 + src/plugins/plot/chart/LimitLabel.vue | 31 +- src/plugins/plot/chart/LimitLine.vue | 28 +- .../plot/chart/MCTChartAlarmLineSet.js | 23 +- src/plugins/plot/chart/MctChart.vue | 40 ++- src/plugins/plot/chart/limitUtil.js | 32 +++ src/plugins/plot/configuration/PlotSeries.js | 12 +- .../plot/legend/PlotLegendItemCollapsed.vue | 4 +- .../plot/legend/PlotLegendItemExpanded.vue | 4 +- src/plugins/plot/lib/ColorHelper.js | 60 ++-- src/plugins/plot/pluginSpec.js | 6 +- .../telemetryTable/components/table.scss | 5 + src/plugins/themes/espresso-theme.scss | 1 + src/plugins/themes/maelstrom-theme.scss | 1 + src/plugins/themes/snow-theme.scss | 1 + src/styles/_constants-espresso.scss | 16 +- src/styles/_constants-maelstrom.scss | 16 +- src/styles/_constants-snow.scss | 10 + src/styles/_legacy-plots.scss | 7 +- src/styles/_limits.scss | 270 ++++++++++++++++++ src/styles/_mixins.scss | 26 ++ src/styles/_status.scss | 26 -- 25 files changed, 577 insertions(+), 129 deletions(-) create mode 100644 src/plugins/plot/chart/limitUtil.js create mode 100644 src/styles/_limits.scss diff --git a/API.md b/API.md index c75c8f141b..229425b94e 100644 --- a/API.md +++ b/API.md @@ -595,9 +595,17 @@ section. #### Limit Evaluators **draft** -Limit evaluators allow a telemetry integrator to define how limits should be -applied to telemetry from a given domain object. For an example of a limit -evaluator, take a look at `examples/generator/SinewaveLimitProvider.js`. +Limit evaluators allow a telemetry integrator to define which limits exist for a +telemetry endpoint and how limits should be applied to telemetry from a given domain object. + +A limit evaluator can implement the `evalute` method which is used to define how limits +should be applied to telemetry and the `getLimits` method which is used to specify +what the limit values are for different limit levels. + +Limit levels can be mapped to one of 5 colors for visualization: +`purple`, `red`, `orange`, `yellow` and `cyan`. + +For an example of a limit evaluator, take a look at `examples/generator/SinewaveLimitProvider.js`. ### Telemetry Consumer APIs **draft** diff --git a/example/generator/SinewaveLimitProvider.js b/example/generator/SinewaveLimitProvider.js index 7f0a344cfb..e714f3f0d4 100644 --- a/example/generator/SinewaveLimitProvider.js +++ b/example/generator/SinewaveLimitProvider.js @@ -26,14 +26,26 @@ define([ ) { - var RED = { + var PURPLE = { + sin: 2.2, + cos: 2.2 + }, + RED = { sin: 0.9, cos: 0.9 }, + ORANGE = { + sin: 0.7, + cos: 0.7 + }, YELLOW = { sin: 0.5, cos: 0.5 }, + CYAN = { + sin: 0.45, + cos: 0.45 + }, LIMITS = { rh: { cssClass: "is-limit--upr is-limit--red", @@ -94,32 +106,66 @@ define([ }; SinewaveLimitProvider.prototype.getLimits = function (domainObject) { + return { limits: function () { - return { + return Promise.resolve({ + WATCH: { + low: { + color: "cyan", + sin: -CYAN.sin, + cos: -CYAN.cos + }, + high: { + color: "cyan", + ...CYAN + } + }, WARNING: { low: { - cssClass: "is-limit--lwr is-limit--yellow", + color: "yellow", sin: -YELLOW.sin, cos: -YELLOW.cos }, high: { - cssClass: "is-limit--upr is-limit--yellow", + color: "yellow", ...YELLOW } }, DISTRESS: { low: { - cssClass: "is-limit--lwr is-limit--red", + color: "orange", + sin: -ORANGE.sin, + cos: -ORANGE.cos + }, + high: { + color: "orange", + ...ORANGE + } + }, + CRITICAL: { + low: { + color: "red", sin: -RED.sin, cos: -RED.cos }, high: { - cssClass: "is-limit--upr is-limit--red", + color: "red", ...RED } + }, + SEVERE: { + low: { + color: "purple", + sin: -PURPLE.sin, + cos: -PURPLE.cos + }, + high: { + color: "purple", + ...PURPLE + } } - }; + }); } }; }; diff --git a/src/api/telemetry/TelemetryAPI.js b/src/api/telemetry/TelemetryAPI.js index b9edaf779b..1e9e84fb32 100644 --- a/src/api/telemetry/TelemetryAPI.js +++ b/src/api/telemetry/TelemetryAPI.js @@ -567,21 +567,24 @@ define([ * @method limits returns a limits object of * type { * level1: { - * low: { key1: value1, key2: value2 }, - * high: { key1: value1, key2: value2 } + * low: { key1: value1, key2: value2, color: }, + * high: { key1: value1, key2: value2, color: } * }, * level2: { * low: { key1: value1, key2: value2 }, * high: { key1: value1, key2: value2 } * } * } + * supported colors are purple, red, orange, yellow and cyan * @memberof module:openmct.TelemetryAPI~TelemetryProvider# */ TelemetryAPI.prototype.getLimits = function (domainObject) { const provider = this.findLimitEvaluator(domainObject); if (!provider || !provider.getLimits) { return { - limits: function () {} + limits: function () { + return Promise.resolve(undefined); + } }; } diff --git a/src/plugins/displayLayout/components/telemetry-view.scss b/src/plugins/displayLayout/components/telemetry-view.scss index 5ad4073b34..0dbfc75ac6 100644 --- a/src/plugins/displayLayout/components/telemetry-view.scss +++ b/src/plugins/displayLayout/components/telemetry-view.scss @@ -21,6 +21,10 @@ margin-left: $interiorMargin; } + &__value { + @include isLimit(); + } + .c-frame & { @include abs(); border: 1px solid transparent; diff --git a/src/plugins/plot/chart/LimitLabel.vue b/src/plugins/plot/chart/LimitLabel.vue index 73948cf4fe..dff4429b31 100644 --- a/src/plugins/plot/chart/LimitLabel.vue +++ b/src/plugins/plot/chart/LimitLabel.vue @@ -1,17 +1,23 @@