[Plot] Requery on event

Requery on a query change event from a time conductor,
WTD-1515
This commit is contained in:
Victor Woeltjen 2015-09-04 15:07:46 -07:00
parent 77d11e1bcf
commit 600ff1a3ee

View File

@ -65,6 +65,7 @@ define(
subPlotFactory = new SubPlotFactory(telemetryFormatter), subPlotFactory = new SubPlotFactory(telemetryFormatter),
cachedObjects = [], cachedObjects = [],
updater, updater,
lastBounds,
handle; handle;
// Populate the scope with axis information (specifically, options // Populate the scope with axis information (specifically, options
@ -139,13 +140,14 @@ define(
} }
// Change the displayable bounds // Change the displayable bounds
function setBasePanZoom(event, bounds) { function setBasePanZoom(unused, bounds) {
var start = bounds.start, var start = bounds.start,
end = bounds.end; end = bounds.end;
if (updater) { if (updater) {
updater.setDomainBounds(start, end); updater.setDomainBounds(start, end);
self.update(); self.update();
} }
lastBounds = bounds;
} }
// Create a new subscription; telemetrySubscriber gets // Create a new subscription; telemetrySubscriber gets
@ -175,6 +177,18 @@ define(
} }
} }
// Initiate a new query for data because query bounds changed
function requery() {
if (handle) {
recreateUpdater();
requestTelemetry();
// Keep any externally-provided bounds
if (lastBounds) {
setBasePanZoom({}, lastBounds);
}
}
}
this.modeOptions = new PlotModeOptions([], subPlotFactory); this.modeOptions = new PlotModeOptions([], subPlotFactory);
this.updateValues = updateValues; this.updateValues = updateValues;
@ -190,6 +204,9 @@ define(
// Respond to external bounds changes // Respond to external bounds changes
$scope.$on("telemetry:display:bounds", setBasePanZoom); $scope.$on("telemetry:display:bounds", setBasePanZoom);
// Respond to external query range changes
$scope.$on("telemetry:query:bounds", throttle(requery, 250));
// Unsubscribe when the plot is destroyed // Unsubscribe when the plot is destroyed
$scope.$on("$destroy", releaseSubscription); $scope.$on("$destroy", releaseSubscription);