From bf3cad3f6eefe6b06eba46b0853edde556353827 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Thu, 14 Apr 2022 11:05:43 -0700 Subject: [PATCH] fix missing y-axis label fix units missing from plot legend --- src/plugins/plot/MctPlot.vue | 12 +++++++++++- src/plugins/plot/axis/YAxis.vue | 18 +++++++++++++++--- src/plugins/plot/configuration/PlotSeries.js | 1 + 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/plugins/plot/MctPlot.vue b/src/plugins/plot/MctPlot.vue index 18df788e27..0c49a8239a 100644 --- a/src/plugins/plot/MctPlot.vue +++ b/src/plugins/plot/MctPlot.vue @@ -223,7 +223,8 @@ export default { loaded: false, isTimeOutOfSync: false, showLimitLineLabels: undefined, - isFrozenOnMouseDown: false + isFrozenOnMouseDown: false, + hasSameRangeValue: true }; }, computed: { @@ -321,6 +322,7 @@ export default { this.setDisplayRange(series, xKey); }, this); this.listenTo(series, 'change:yKey', () => { + this.checkSameRangeValue(); this.loadSeriesData(series); }, this); @@ -328,10 +330,18 @@ export default { this.loadSeriesData(series); }, this); + this.checkSameRangeValue(); this.loadSeriesData(series); }, + checkSameRangeValue() { + this.hasSameRangeValue = this.seriesModels.every((model) => { + return model.get('yKey') === this.seriesModels[0].get('yKey'); + }); + }, + removeSeries(plotSeries) { + this.checkSameRangeValue(); this.stopListening(plotSeries); }, diff --git a/src/plugins/plot/axis/YAxis.vue b/src/plugins/plot/axis/YAxis.vue index fec2e3a5f6..09840c704e 100644 --- a/src/plugins/plot/axis/YAxis.vue +++ b/src/plugins/plot/axis/YAxis.vue @@ -27,9 +27,10 @@ }" > -
{{ yAxisLabel }}
@@ -71,6 +72,12 @@ export default { return true; } }, + hasSameRangeValue: { + type: Boolean, + default() { + return true; + } + }, seriesModel: { type: Object, default() { @@ -90,6 +97,11 @@ export default { loaded: false }; }, + computed: { + canShowYAxisLabel() { + return this.singleSeries === true || this.hasSameRangeValue === true; + } + }, mounted() { this.yAxis = this.getYAxisFromConfig(); this.loaded = true; diff --git a/src/plugins/plot/configuration/PlotSeries.js b/src/plugins/plot/configuration/PlotSeries.js index d6dc502c8a..bf8623ad7e 100644 --- a/src/plugins/plot/configuration/PlotSeries.js +++ b/src/plugins/plot/configuration/PlotSeries.js @@ -232,6 +232,7 @@ export default class PlotSeries extends Model { this.evaluate = function (datum) { return this.limitEvaluator.evaluate(datum, valueMetadata); }.bind(this); + this.set('unit', valueMetadata.unit); const format = this.formats[newKey]; this.getYVal = format.parse.bind(format); }