diff --git a/platform/features/plot/bundle.json b/platform/features/plot/bundle.json index ab8cf89b7c..21d98cc4e7 100644 --- a/platform/features/plot/bundle.json +++ b/platform/features/plot/bundle.json @@ -22,7 +22,7 @@ { "key": "PlotController", "implementation": "PlotController.js", - "depends": [ "$scope", "telemetryFormatter", "telemetryHandler" ] + "depends": [ "$scope", "telemetryFormatter", "telemetryHandler", "throttle" ] } ] } diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index 0f06ddccb4..fcce051968 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -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 { /** diff --git a/platform/features/plot/src/modes/PlotOverlayMode.js b/platform/features/plot/src/modes/PlotOverlayMode.js index ec32f2300d..501d4b0e78 100644 --- a/platform/features/plot/src/modes/PlotOverlayMode.js +++ b/platform/features/plot/src/modes/PlotOverlayMode.js @@ -62,8 +62,6 @@ define( points: buf.getLength() }; }); - - subplot.update(); } return { diff --git a/platform/features/plot/src/modes/PlotStackMode.js b/platform/features/plot/src/modes/PlotStackMode.js index 4b6c5cbbb9..5d54b461f1 100644 --- a/platform/features/plot/src/modes/PlotStackMode.js +++ b/platform/features/plot/src/modes/PlotStackMode.js @@ -58,8 +58,6 @@ define( color: PlotPalette.getFloatColor(0), points: buffer.getLength() }]; - - subplot.update(); } function plotTelemetry(prepared) {