From 433ce16c37778d586e37f49177cef1315e2bf9f0 Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Wed, 10 Aug 2016 19:34:39 +0200 Subject: [PATCH] sort multibarchart data --- public/app/js/controllers/DashboardCtrl.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/app/js/controllers/DashboardCtrl.js b/public/app/js/controllers/DashboardCtrl.js index 5ff06cde..4b5a8f29 100644 --- a/public/app/js/controllers/DashboardCtrl.js +++ b/public/app/js/controllers/DashboardCtrl.js @@ -228,7 +228,7 @@ app.controller( 'DashboardCtrl', .map( function( key ) { var multiplicator = ( key == "Income" ) ? -1 : 1; return { key: key, - values: _(response.data[ key ]).map( function( value ) { + values: _.chain(response.data[ key ]).map( function( value ) { var date = new Date( value.date ); var period = date.getFullYear() + '-' + ( date.getMonth() < 9 ? '0' : '' ) + ( date.getMonth() + 1 ); $scope.periods.push( period ); @@ -237,6 +237,8 @@ app.controller( 'DashboardCtrl', x: period, y: parseInt( value.amount ) * multiplicator }; } ) + .sortBy( function( item ) { return item.x; } ) + .value() }; } ) .value()