[Plot] Initially implement synced pan/zoom stack

Initially implement a synchronized pan/zoom stack,
which maintains the same domain axis bounds for all
subplots in a stacked plot view, but allows each to
have independent range axes. WTD-625.
This commit is contained in:
Victor Woeltjen 2014-12-11 17:27:44 -08:00
parent 9344809998
commit 0ce0517e09
2 changed files with 80 additions and 1 deletions
platform/features/plot/src

View File

@ -0,0 +1,79 @@
/*global define*/
define(
['./PlotPanZoomStack'],
function (PlotPanZoomStack) {
"use strict";
function PlotPanZoomStackGroup(count) {
var stacks = [],
decoratedStacks = [],
i;
function pushPanZoom(origin, dimensions, index) {
stacks.forEach(function (stack, i) {
if (i === index) {
stack.pushPanZoom(origin, dimensions);
} else {
stack.pushPanZoom(
[ origin[0], stack.getOrigin[1] ],
[ dimensions[0], stack.getDimensions[1] ]
);
}
});
}
function setBasePanZoom(origin, dimensions, index) {
stacks.forEach(function (stack, i) {
stack.setBasePanZoom(origin, dimensions);
});
}
function popPanZoom() {
stacks.forEach(function (stack) {
stack.popPanZoom();
});
}
function clearPanZoom() {
stacks.forEach(function (stack) {
stack.popPanZoom();
});
}
function decorateStack(stack, index) {
var result = Object.create(stack);
result.pushPanZoom = function (origin, dimensions) {
pushPanZoom(origin, dimensions, index);
};
result.setBasePanZoom = function (origin, dimensions) {
};
result.popPanZoom = popPanZoom;
result.clearPanZoom = clearPanZoom;
}
for (i = 0; i < count; i += 1) {
stacks.push(new PlotPanZoomStack([], []));
}
decoratedStacks = stacks.map(decorateStack);
return {
popPanZoom: popPanZoom,
clearPanZoom: clearPanZoom,
getDepth: function () {
return stacks.length > 0 ?
stacks[0].getDepth() : 0;
},
getPanZoomStack: function (index) {
return decoratedStacks[index];
}
};
}
return PlotPanZoomStackGroup;
}
);

View File

@ -45,7 +45,7 @@ define(
return panZoomStack.getDepth() > 1;
},
stepBackPanZoom: function () {
panZoomStack.pop();
panZoomStack.popPanZoom();
subplot.update();
},
unzoom: function () {