[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",
"implementation": "PlotController.js",
"depends": [ "$scope", "telemetryFormatter", "telemetryHandler" ]
"depends": [ "$scope", "telemetryFormatter", "telemetryHandler", "throttle" ]
}
]
}

View File

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

View File

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

View File

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