Add loading of entries on extremes change in sold chart.
This commit is contained in:
parent
92005e5a56
commit
67db964546
@ -28,6 +28,16 @@ accountantApp.controller(
|
|||||||
// Placeholder for saved value to cancel entry edition
|
// Placeholder for saved value to cancel entry edition
|
||||||
$scope.savedItem = null;
|
$scope.savedItem = null;
|
||||||
|
|
||||||
|
$scope.begin = moment.utc().startOf('month');
|
||||||
|
$scope.end = moment.utc().endOf('month');
|
||||||
|
|
||||||
|
$scope.selectRange = function(e) {
|
||||||
|
$scope.begin = moment.utc(e.min);
|
||||||
|
$scope.end = moment.utc(e.max);
|
||||||
|
|
||||||
|
$scope.loadEntries($scope.account);
|
||||||
|
};
|
||||||
|
|
||||||
// Configure pie chart for categories.
|
// Configure pie chart for categories.
|
||||||
$scope.categoriesChartConfig = {
|
$scope.categoriesChartConfig = {
|
||||||
options: {
|
options: {
|
||||||
@ -86,8 +96,31 @@ accountantApp.controller(
|
|||||||
zoomType: 'x'
|
zoomType: 'x'
|
||||||
},
|
},
|
||||||
rangeSelector: {
|
rangeSelector: {
|
||||||
|
buttons: [{
|
||||||
|
type: 'month',
|
||||||
|
count: 1,
|
||||||
|
text: "1m"
|
||||||
|
}, {
|
||||||
|
type: "month",
|
||||||
|
count: 3,
|
||||||
|
text: "3m"
|
||||||
|
}, {
|
||||||
|
type: "month",
|
||||||
|
count: 6,
|
||||||
|
text: "6m"
|
||||||
|
}, {
|
||||||
|
type: "year",
|
||||||
|
count: 1,
|
||||||
|
text: "1y"
|
||||||
|
}, {
|
||||||
|
type: "all",
|
||||||
|
text: "All"
|
||||||
|
}],
|
||||||
selected: 0,
|
selected: 0,
|
||||||
},
|
},
|
||||||
|
navigator: {
|
||||||
|
enabled: true
|
||||||
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
crosshairs: true,
|
crosshairs: true,
|
||||||
shared: true,
|
shared: true,
|
||||||
@ -117,6 +150,10 @@ accountantApp.controller(
|
|||||||
dateTimeLabelFormats: {
|
dateTimeLabelFormats: {
|
||||||
month: "%e. %b",
|
month: "%e. %b",
|
||||||
year: "%Y"
|
year: "%Y"
|
||||||
|
},
|
||||||
|
minRange: 3600 * 1000 * 24 * 14, // 2 weeks
|
||||||
|
events: {
|
||||||
|
afterSetExtremes: $scope.selectRange
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
@ -186,6 +223,8 @@ accountantApp.controller(
|
|||||||
entry.open, entry.high, entry.low, entry.close
|
entry.open, entry.high, entry.low, entry.close
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$scope.loadEntries($scope.account);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -235,16 +274,14 @@ accountantApp.controller(
|
|||||||
$scope.selectedItem = null;
|
$scope.selectedItem = null;
|
||||||
$scope.savedItem = null;
|
$scope.savedItem = null;
|
||||||
|
|
||||||
if(account && month) {
|
if(account && !$scope.soldChartConfig.loading) {
|
||||||
// Note: Month is 0 indexed.
|
$scope.soldChartConfig.loading = true;
|
||||||
var begin = moment({year: month.year, month: month.month - 1, day: 1});
|
|
||||||
var end = begin.clone().endOf('month');
|
|
||||||
|
|
||||||
$http.get("/api/entries", {
|
$http.get("/api/entries", {
|
||||||
params: {
|
params: {
|
||||||
account: account.id,
|
account: account.id,
|
||||||
begin: begin.format('YYYY-MM-DD'),
|
begin: $scope.begin.format('YYYY-MM-DD'),
|
||||||
end: end.format('YYYY-MM-DD')
|
end: $scope.end.format('YYYY-MM-DD')
|
||||||
}
|
}
|
||||||
}).success($scope.loadEntries_success);
|
}).success($scope.loadEntries_success);
|
||||||
} else {
|
} else {
|
||||||
@ -275,6 +312,8 @@ accountantApp.controller(
|
|||||||
|
|
||||||
$scope.entries = entries;
|
$scope.entries = entries;
|
||||||
|
|
||||||
|
$scope.soldChartConfig.loading = false;
|
||||||
|
|
||||||
$scope.$emit("entriesLoadedEvent", {entries: entries});
|
$scope.$emit("entriesLoadedEvent", {entries: entries});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user