Replace method to use get with range in paramters.
This commit is contained in:
@ -113,7 +113,16 @@ var EntryController = function($scope, $http, $rootScope, $filter) {
|
||||
$scope.savedItem = null;
|
||||
|
||||
if(account && month) {
|
||||
$http.get("/api/entries/" + account.id + "/" + month.year + "/" + month.month).success($scope.loadEntries_success);
|
||||
// Note: Month is 0 indexed.
|
||||
var begin = moment({year: month.year, month: month.month - 1, day: 1});
|
||||
var end = begin.clone().endOf('month');
|
||||
|
||||
$http.get("/api/entries",
|
||||
{params: {
|
||||
account: account.id,
|
||||
begin: begin.format('YYYY-MM-DD'),
|
||||
end: end.format('YYYY-MM-DD')
|
||||
}}).success($scope.loadEntries_success);
|
||||
} else {
|
||||
$scope.loadEntries_success(null);
|
||||
}
|
||||
@ -367,14 +376,14 @@ var EntryController = function($scope, $http, $rootScope, $filter) {
|
||||
today.setHours(0);
|
||||
today.setMinutes(0);
|
||||
|
||||
// Find first and last days to set limits of the x axis.
|
||||
var day = 24 * 60 * 60 * 1000;
|
||||
// FIXME Alexis Lahouze 2015-06-12 Date format.
|
||||
|
||||
var firstDate = $filter('date')(new Date(Date.parse(entries[0][0]).valueOf() - day), 'yyyy-MM-dd');
|
||||
var lastDate = $filter('date')(new Date(Date.parse(entries[entries.length -1][0]).valueOf() + day), 'yyyy-MM-dd');
|
||||
// Find first and last days to set limits of the x axis.
|
||||
var firstDate = moment(entries[0][0]).subtract(1, 'day').format();
|
||||
var lastDate = moment(entries[entries.length - 1][0]).add(1, 'day').format();
|
||||
|
||||
var chart = nv.models.lineChart().options({
|
||||
x: function(d) { return d3.time.format("%Y-%m-%d").parse(d[0]); },
|
||||
x: function(d) { return d3.time.format.utc(d[0]); },
|
||||
y: function(d) { return new Number(d[1]); },
|
||||
transitionDuration: 250,
|
||||
showXAxis: true,
|
||||
@ -388,7 +397,7 @@ var EntryController = function($scope, $http, $rootScope, $filter) {
|
||||
chart.xAxis
|
||||
.axisLabel("Date")
|
||||
.tickFormat(function(d) {
|
||||
return d3.time.format("%Y-%m-%d")(new Date(d));
|
||||
return d3.time.format.iso(new Date(d));
|
||||
});
|
||||
//chart.xAxis.scale().range([firstDate, lastDate]);
|
||||
|
||||
|
Reference in New Issue
Block a user