From 3a0e80d3604a628f08da1ea096dfb735ac053d78 Mon Sep 17 00:00:00 2001 From: Victor Woeltjen Date: Wed, 10 Dec 2014 18:29:18 -0800 Subject: [PATCH] [Plot] Add switcher for Stacked/Overlaid Add switcher to handle changing between Stacked and Overlaid plots. WTD-625. --- .../features/plot/res/templates/plot.html | 27 ++++++++++++-- platform/features/plot/src/PlotController.js | 21 +++++++++-- .../plot/src/modes/PlotModeOptions.js | 36 +++++++++++++++++++ 3 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 platform/features/plot/src/modes/PlotModeOptions.js diff --git a/platform/features/plot/res/templates/plot.html b/platform/features/plot/res/templates/plot.html index 5bf79c1fda..1c83f00e39 100644 --- a/platform/features/plot/res/templates/plot.html +++ b/platform/features/plot/res/templates/plot.html @@ -19,8 +19,7 @@
-
+
{{axes[1].active.name}}
@@ -66,6 +65,7 @@
I + +
diff --git a/platform/features/plot/src/PlotController.js b/platform/features/plot/src/PlotController.js index f1fee47f31..e29c2afae3 100644 --- a/platform/features/plot/src/PlotController.js +++ b/platform/features/plot/src/PlotController.js @@ -11,7 +11,8 @@ define( "./elements/PlotPosition", "./elements/PlotTickGenerator", "./elements/PlotFormatter", - "./elements/PlotAxis" + "./elements/PlotAxis", + "./modes/PlotModeOptions" ], function ( PlotPreparer, @@ -20,7 +21,8 @@ define( PlotPosition, PlotTickGenerator, PlotFormatter, - PlotAxis + PlotAxis, + PlotModeOptions ) { "use strict"; @@ -47,6 +49,7 @@ define( marqueeStart, panZoomStack = new PlotPanZoomStack([], []), formatter = new PlotFormatter(), + modeOptions, domainOffset; // Utility, for map/forEach loops. Index 0 is domain, @@ -217,6 +220,11 @@ define( updateTicks(); } + function setupModes(telemetryObjects) { + modeOptions = new PlotModeOptions(telemetryObjects); + } + + $scope.$watch("telemetry.getTelemetryObjects()", setupModes); $scope.$watch("telemetry.getMetadata()", setupAxes); $scope.$on("telemetryUpdate", plotTelemetry); $scope.draw = {}; @@ -297,6 +305,15 @@ define( unzoom: function () { panZoomStack.clearPanZoom(); updateDrawingBounds(); + }, + getModeOptions: function () { + return modeOptions && modeOptions.getModeOptions(); + }, + getMode: function () { + return modeOptions && modeOptions.getModeOptions()[0]; + }, + setMode: function (mode) { + console.log(mode); } }; diff --git a/platform/features/plot/src/modes/PlotModeOptions.js b/platform/features/plot/src/modes/PlotModeOptions.js new file mode 100644 index 0000000000..0fbbf8590a --- /dev/null +++ b/platform/features/plot/src/modes/PlotModeOptions.js @@ -0,0 +1,36 @@ +/*global define*/ + +define( + [], + function (PlotOverlayMode, PlotStackedMode) { + "use strict"; + + var STACKED = { + key: "stacked", + name: "Stacked", + glyph: "8" + }, + OVERLAID = { + key: "overlaid", + name: "Overlaid", + glyph: "6" + }; + + function PlotModeOptions(telemetryObjects) { + var options = telemetryObjects.length > 1 ? + [ STACKED, OVERLAID ] : [ OVERLAID, STACKED ]; + + + return { + getModeOptions: function () { + return options; + }, + getMode: function (option) { + + } + }; + } + + return PlotModeOptions; + } +); \ No newline at end of file