diff --git a/src/plugins/plot/MctPlot.vue b/src/plugins/plot/MctPlot.vue index f7f743324b..ea5d8dd398 100644 --- a/src/plugins/plot/MctPlot.vue +++ b/src/plugins/plot/MctPlot.vue @@ -37,6 +37,7 @@ v-if="seriesModels.length > 0" :tick-width="tickWidth" :single-series="seriesModels.length === 1" + :has-same-range-value="hasSameRangeValue" :series-model="seriesModels[0]" :style="{ left: (plotWidth - tickWidth) + 'px' @@ -250,7 +251,8 @@ export default { loaded: false, isTimeOutOfSync: false, showLimitLineLabels: undefined, - isFrozenOnMouseDown: false + isFrozenOnMouseDown: false, + hasSameRangeValue: true }; }, computed: { @@ -362,6 +364,7 @@ export default { this.setDisplayRange(series, xKey); }, this); this.listenTo(series, 'change:yKey', () => { + this.checkSameRangeValue(); this.loadSeriesData(series); }, this); @@ -369,10 +372,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); }, @@ -488,7 +499,7 @@ export default { }, setDisplayRange(series, xKey) { - if (this.config.series.length !== 1) { + if (this.config.series.models.length !== 1) { return; } diff --git a/src/plugins/plot/axis/YAxis.vue b/src/plugins/plot/axis/YAxis.vue index 85f7946c18..9c18394a15 100644 --- a/src/plugins/plot/axis/YAxis.vue +++ b/src/plugins/plot/axis/YAxis.vue @@ -29,9 +29,9 @@ >
{{ yAxisLabel }}
@@ -76,6 +76,12 @@ export default { return true; } }, + hasSameRangeValue: { + type: Boolean, + default() { + return true; + } + }, seriesModel: { type: Object, default() { @@ -95,6 +101,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 fc355a6bfc..01ab6b2307 100644 --- a/src/plugins/plot/configuration/PlotSeries.js +++ b/src/plugins/plot/configuration/PlotSeries.js @@ -250,6 +250,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); }