mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 17:38:54 +00:00
allow defaults for existing visualizations, link time label to time interval
This commit is contained in:
parent
bf88d8b578
commit
0990d93b03
@ -5,8 +5,7 @@
|
||||
|
||||
var editTemplate = '<cohort-editor></cohort-editor>';
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -5,10 +5,4 @@
|
||||
<option value="weekly">Weekly</option>
|
||||
<option value="monthly">Monthly</option>
|
||||
</select>
|
||||
<label class="control-label">Time Label </label>
|
||||
<select class="form-control" ng-model="visualization.options.timeLabel">
|
||||
<option value="day">Day</option>
|
||||
<option value="week">Week</option>
|
||||
<option value="month">Month</option>
|
||||
</select>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user