mirror of
https://github.com/nasa/openmct.git
synced 2025-04-10 12:50:15 +00:00
[Plot] Add initial stack-plot implementation
Add initial implementation of stacked mode for Plot view. Note that this will not stack correctly due to markup/style issues. WTD-625.
This commit is contained in:
parent
eb90a3eeba
commit
cd8deca1b3
@ -1,15 +1,15 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
["./PlotOverlayMode"],
|
||||
function (PlotOverlayMode, PlotStackedMode) {
|
||||
["./PlotOverlayMode", "./PlotStackMode"],
|
||||
function (PlotOverlayMode, PlotStackMode) {
|
||||
"use strict";
|
||||
|
||||
var STACKED = {
|
||||
key: "stacked",
|
||||
name: "Stacked",
|
||||
glyph: "8",
|
||||
factory: PlotOverlayMode
|
||||
factory: PlotStackMode
|
||||
},
|
||||
OVERLAID = {
|
||||
key: "overlaid",
|
||||
|
71
platform/features/plot/src/modes/PlotStackMode.js
Normal file
71
platform/features/plot/src/modes/PlotStackMode.js
Normal file
@ -0,0 +1,71 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
["../SubPlot", "../elements/PlotPalette", "../elements/PlotPanZoomStack"],
|
||||
function (SubPlot, PlotPalette, PlotPanZoomStack) {
|
||||
"use strict";
|
||||
|
||||
function PlotStackMode(telemetryObjects) {
|
||||
var domainOffset,
|
||||
panZoomStack = new PlotPanZoomStack([], []),
|
||||
subplots = telemetryObjects.map(function (telemetryObject) {
|
||||
return new SubPlot([telemetryObject], panZoomStack);
|
||||
});
|
||||
|
||||
function plotTelemetryTo(subplot, prepared, index) {
|
||||
var buffer = prepared.getBuffers()[index];
|
||||
|
||||
// Track the domain offset, used to bias domain values
|
||||
// to minimize loss of precision when converted to 32-bit
|
||||
// floating point values for display.
|
||||
subplot.setDomainOffset(prepared.getDomainOffset());
|
||||
|
||||
// Draw the buffers. Always use the 0th color
|
||||
subplot.getDrawingObject().lines = [{
|
||||
buffer: buffer,
|
||||
color: PlotPalette.getFloatColor(0),
|
||||
points: buffer.length / 2
|
||||
}];
|
||||
|
||||
subplot.update();
|
||||
}
|
||||
|
||||
function plotTelemetry(prepared) {
|
||||
// Fit to the boundaries of the data, but don't
|
||||
// override any user-initiated pan-zoom changes.
|
||||
panZoomStack.setBasePanZoom(
|
||||
prepared.getOrigin(),
|
||||
prepared.getDimensions()
|
||||
);
|
||||
|
||||
subplots.forEach(function (subplot, index) {
|
||||
plotTelemetryTo(subplot, prepared, index);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
plotTelemetry: plotTelemetry,
|
||||
getSubPlots: function () {
|
||||
return subplots;
|
||||
},
|
||||
isZoomed: function () {
|
||||
return panZoomStack.getDepth() > 1;
|
||||
},
|
||||
stepBackPanZoom: function () {
|
||||
panZoomStack.pop();
|
||||
subplots.forEach(function (subplot) {
|
||||
subplot.update();
|
||||
});
|
||||
},
|
||||
unzoom: function () {
|
||||
panZoomStack.clearPanZoom();
|
||||
subplots.forEach(function (subplot) {
|
||||
subplot.update();
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return PlotStackMode;
|
||||
}
|
||||
);
|
Loading…
x
Reference in New Issue
Block a user