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 @@ }" > - <div v-if="singleSeries" - class="gl-plot-label gl-plot-y-label" - :class="{'icon-gear': (yKeyOptions.length > 1)}" + <div + v-if="canShowYAxisLabel" + class="gl-plot-label gl-plot-y-label" + :class="{'icon-gear': (yKeyOptions.length > 1 && singleSeries)}" >{{ yAxisLabel }} </div> @@ -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); }