sort multibarchart data

This commit is contained in:
Gwenhael Le Moine 2016-08-10 19:34:39 +02:00
parent aac8244ece
commit 433ce16c37

View file

@ -228,7 +228,7 @@ app.controller( 'DashboardCtrl',
.map( function( key ) { .map( function( key ) {
var multiplicator = ( key == "Income" ) ? -1 : 1; var multiplicator = ( key == "Income" ) ? -1 : 1;
return { key: key, 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 date = new Date( value.date );
var period = date.getFullYear() + '-' + ( date.getMonth() < 9 ? '0' : '' ) + ( date.getMonth() + 1 ); var period = date.getFullYear() + '-' + ( date.getMonth() < 9 ? '0' : '' ) + ( date.getMonth() + 1 );
$scope.periods.push( period ); $scope.periods.push( period );
@ -237,6 +237,8 @@ app.controller( 'DashboardCtrl',
x: period, x: period,
y: parseInt( value.amount ) * multiplicator }; y: parseInt( value.amount ) * multiplicator };
} ) } )
.sortBy( function( item ) { return item.x; } )
.value()
}; };
} ) } )
.value() .value()