[Plot] Throttle updates

Throttle plot updates to subplots; WTD-1202.
This commit is contained in:
Victor Woeltjen 2015-05-29 16:35:14 -07:00
parent e06d11dcb2
commit 35b5fbefd0
4 changed files with 10 additions and 9 deletions

View File

@ -22,7 +22,7 @@
{ {
"key": "PlotController", "key": "PlotController",
"implementation": "PlotController.js", "implementation": "PlotController.js",
"depends": [ "$scope", "telemetryFormatter", "telemetryHandler" ] "depends": [ "$scope", "telemetryFormatter", "telemetryHandler", "throttle" ]
} }
] ]
} }

View File

@ -51,13 +51,14 @@ define(
* *
* @constructor * @constructor
*/ */
function PlotController($scope, telemetryFormatter, telemetryHandler) { function PlotController($scope, telemetryFormatter, telemetryHandler, throttle) {
var subPlotFactory = new SubPlotFactory(telemetryFormatter), var subPlotFactory = new SubPlotFactory(telemetryFormatter),
modeOptions = new PlotModeOptions([], subPlotFactory), modeOptions = new PlotModeOptions([], subPlotFactory),
subplots = [], subplots = [],
cachedObjects = [], cachedObjects = [],
updater, updater,
handle, handle,
scheduleUpdate,
domainOffset; domainOffset;
// Populate the scope with axis information (specifically, options // Populate the scope with axis information (specifically, options
@ -89,9 +90,7 @@ define(
// Update all sub-plots // Update all sub-plots
function update() { function update() {
modeOptions.getModeHandler() scheduleUpdate();
.getSubPlots()
.forEach(updateSubplot);
} }
// Reinstantiate the plot updater (e.g. because we have a // Reinstantiate the plot updater (e.g. because we have a
@ -162,6 +161,12 @@ define(
// Unsubscribe when the plot is destroyed // Unsubscribe when the plot is destroyed
$scope.$on("$destroy", releaseSubscription); $scope.$on("$destroy", releaseSubscription);
// Create a throttled update function
scheduleUpdate = throttle(function () {
modeOptions.getModeHandler().getSubPlots()
.forEach(updateSubplot);
});
return { return {
/** /**

View File

@ -62,8 +62,6 @@ define(
points: buf.getLength() points: buf.getLength()
}; };
}); });
subplot.update();
} }
return { return {

View File

@ -58,8 +58,6 @@ define(
color: PlotPalette.getFloatColor(0), color: PlotPalette.getFloatColor(0),
points: buffer.getLength() points: buffer.getLength()
}]; }];
subplot.update();
} }
function plotTelemetry(prepared) { function plotTelemetry(prepared) {