Skip to content

Commit

Permalink
#197 Finish chart csv download
Browse files Browse the repository at this point in the history
  • Loading branch information
nadouani committed Nov 21, 2017
1 parent 7627bb4 commit 8bb3570
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
6 changes: 5 additions & 1 deletion ui/app/scripts/directives/dashboard/bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@
scope.getCsv = function() {
var dates = scope.data._date;
var keys = _.keys(scope.data);
var csv = [{data: keys.join(';')}];
var headers = _.extend({_date: 'Date'}, scope.names);

var csv = [{data: _.map(keys, function(key){
return headers[key] || key;
}).join(';')}];

var row = [];
for(var i=0; i<dates.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion ui/app/scripts/directives/dashboard/donut.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

_.each(field.values, function(val, index) {
if(!names[val]) {
names[val] = field.labels[index] || null;
names[val] = field.labels[index] || val;
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions ui/app/scripts/directives/dashboard/line.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,10 @@
scope.getCsv = function() {
var dates = scope.data._date;
var keys = _.keys(scope.data);
var headers = _.extend({_date: 'Date'}, scope.names);

// TODO update headers
var csv = [{data: _.map(keys, function(key){
return scope.names[key] || key;
return headers[key] || key;
}).join(';')}];

var row = [];
Expand Down

0 comments on commit 8bb3570

Please sign in to comment.