From 0990d93b0395b528067f549f1a5c7914995e44d1 Mon Sep 17 00:00:00 2001 From: nathanlubchenco Date: Wed, 16 Sep 2015 10:34:22 -0600 Subject: [PATCH] allow defaults for existing visualizations, link time label to time interval --- rd_ui/app/scripts/visualizations/cohort.js | 14 +++++++++----- rd_ui/app/views/visualizations/cohort_editor.html | 6 ------ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rd_ui/app/scripts/visualizations/cohort.js b/rd_ui/app/scripts/visualizations/cohort.js index 45677ce3..31f222de 100644 --- a/rd_ui/app/scripts/visualizations/cohort.js +++ b/rd_ui/app/scripts/visualizations/cohort.js @@ -5,8 +5,7 @@ var editTemplate = ''; var defaultOptions = { - 'timeInterval': 'daily', - 'timeLabel': 'day' + 'timeInterval': 'daily' }; VisualizationProvider.registerVisualization({ @@ -27,7 +26,7 @@ template: "", replace: false, link: function($scope, element, attrs) { - $scope.$watch('[queryResult && queryResult.getData(), visualization.options.timeInterval, visualization.options.timeLabel]', function () { + $scope.$watch('[queryResult && queryResult.getData(), visualization.options.timeInterval ]', function () { if ($scope.queryResult.getData() == null) { } else { @@ -49,6 +48,11 @@ var initialDate = moment(sortedData[0].date).toDate(), container = angular.element(element)[0]; + $scope.visualization.options.timeInterval = $scope.visualization.options.timeInterval || 'daily'; + + var timeLabels = {'daily': 'Day', 'weekly': 'Week', 'monthly': 'Month'}; + var timeLabel = timeLabels[$scope.visualization.options.timeInterval]; + Cornelius.draw({ initialDate: initialDate, container: container, @@ -56,11 +60,11 @@ title: null, timeInterval: $scope.visualization.options.timeInterval, labels: { - time: 'Activation ' + $scope.visualization.options.timeLabel, + time: 'Activation ' + timeLabel, people: 'Users' }, formatHeaderLabel: function (i) { - return $scope.visualization.options.timeLabel + (i - 1); + return timeLabel + (i - 1); } }); } diff --git a/rd_ui/app/views/visualizations/cohort_editor.html b/rd_ui/app/views/visualizations/cohort_editor.html index 41cca4f1..a5947edd 100644 --- a/rd_ui/app/views/visualizations/cohort_editor.html +++ b/rd_ui/app/views/visualizations/cohort_editor.html @@ -5,10 +5,4 @@ - -