mirror of
https://github.com/nasa/openmct.git
synced 2025-06-16 14:18:16 +00:00
Plots y axis and legend fixes (#5062)
* [5058] Change the unit if the yKey changes after initialization * [5057] Show y axis label when more than one series is present with the same range value * Fix typo for model length check Co-authored-by: David Tsay <3614296+davetsay@users.noreply.github.com>
This commit is contained in:
@ -37,6 +37,7 @@
|
|||||||
v-if="seriesModels.length > 0"
|
v-if="seriesModels.length > 0"
|
||||||
:tick-width="tickWidth"
|
:tick-width="tickWidth"
|
||||||
:single-series="seriesModels.length === 1"
|
:single-series="seriesModels.length === 1"
|
||||||
|
:has-same-range-value="hasSameRangeValue"
|
||||||
:series-model="seriesModels[0]"
|
:series-model="seriesModels[0]"
|
||||||
:style="{
|
:style="{
|
||||||
left: (plotWidth - tickWidth) + 'px'
|
left: (plotWidth - tickWidth) + 'px'
|
||||||
@ -250,7 +251,8 @@ export default {
|
|||||||
loaded: false,
|
loaded: false,
|
||||||
isTimeOutOfSync: false,
|
isTimeOutOfSync: false,
|
||||||
showLimitLineLabels: undefined,
|
showLimitLineLabels: undefined,
|
||||||
isFrozenOnMouseDown: false
|
isFrozenOnMouseDown: false,
|
||||||
|
hasSameRangeValue: true
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -362,6 +364,7 @@ export default {
|
|||||||
this.setDisplayRange(series, xKey);
|
this.setDisplayRange(series, xKey);
|
||||||
}, this);
|
}, this);
|
||||||
this.listenTo(series, 'change:yKey', () => {
|
this.listenTo(series, 'change:yKey', () => {
|
||||||
|
this.checkSameRangeValue();
|
||||||
this.loadSeriesData(series);
|
this.loadSeriesData(series);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
@ -369,10 +372,18 @@ export default {
|
|||||||
this.loadSeriesData(series);
|
this.loadSeriesData(series);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
this.checkSameRangeValue();
|
||||||
this.loadSeriesData(series);
|
this.loadSeriesData(series);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
checkSameRangeValue() {
|
||||||
|
this.hasSameRangeValue = this.seriesModels.every((model) => {
|
||||||
|
return model.get('yKey') === this.seriesModels[0].get('yKey');
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
removeSeries(plotSeries) {
|
removeSeries(plotSeries) {
|
||||||
|
this.checkSameRangeValue();
|
||||||
this.stopListening(plotSeries);
|
this.stopListening(plotSeries);
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -488,7 +499,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setDisplayRange(series, xKey) {
|
setDisplayRange(series, xKey) {
|
||||||
if (this.config.series.length !== 1) {
|
if (this.config.series.models.length !== 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,9 +29,9 @@
|
|||||||
>
|
>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="singleSeries"
|
v-if="canShowYAxisLabel"
|
||||||
class="gl-plot-label gl-plot-y-label"
|
class="gl-plot-label gl-plot-y-label"
|
||||||
:class="{'icon-gear': (yKeyOptions.length > 1)}"
|
:class="{'icon-gear': (yKeyOptions.length > 1 && singleSeries)}"
|
||||||
>{{ yAxisLabel }}
|
>{{ yAxisLabel }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -76,6 +76,12 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
hasSameRangeValue: {
|
||||||
|
type: Boolean,
|
||||||
|
default() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
},
|
||||||
seriesModel: {
|
seriesModel: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default() {
|
default() {
|
||||||
@ -95,6 +101,11 @@ export default {
|
|||||||
loaded: false
|
loaded: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
canShowYAxisLabel() {
|
||||||
|
return this.singleSeries === true || this.hasSameRangeValue === true;
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.yAxis = this.getYAxisFromConfig();
|
this.yAxis = this.getYAxisFromConfig();
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
|
@ -250,6 +250,7 @@ export default class PlotSeries extends Model {
|
|||||||
this.evaluate = function (datum) {
|
this.evaluate = function (datum) {
|
||||||
return this.limitEvaluator.evaluate(datum, valueMetadata);
|
return this.limitEvaluator.evaluate(datum, valueMetadata);
|
||||||
}.bind(this);
|
}.bind(this);
|
||||||
|
this.set('unit', valueMetadata.unit);
|
||||||
const format = this.formats[newKey];
|
const format = this.formats[newKey];
|
||||||
this.getYVal = format.parse.bind(format);
|
this.getYVal = format.parse.bind(format);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user