[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:
Victor Woeltjen 2014-12-10 20:16:23 -08:00
parent eb90a3eeba
commit cd8deca1b3
2 changed files with 74 additions and 3 deletions

View File

@ -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",

View 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;
}
);