diff --git a/accountant/frontend/static/js/entries.js b/accountant/frontend/static/js/entries.js index 1b74f11..8caa3da 100644 --- a/accountant/frontend/static/js/entries.js +++ b/accountant/frontend/static/js/entries.js @@ -79,6 +79,60 @@ accountantApp.controller( }] }; + // Configure chart for entries. + $scope.soldChartConfig = { + options: { + chart: { + zoomType: 'x' + }, + rangeSelector: { + selected: 0, + }, + tooltip: { + crosshairs: true, + shared: true, + valueDecimals: 2, + valueSuffix: '€' + } + }, + series: [{ + type: "ohlc", + name: "Sold", + data: [], + dataGrouping : { + units : [[ + 'week', // unit name + [1] // allowed multiples + ], [ + 'month', + [1, 2, 3, 4, 6] + ]] + } + }], + title: { + text: "Sold evolution" + }, + xAxis: { + type: "datetime", + dateTimeLabelFormats: { + month: "%e. %b", + year: "%Y" + } + }, + yAxis: { + plotLines: [{ + color: "orange", + width: 2, + value: 0.0 + }, { + color: "red", + width: 2, + value: 0.0 + }] + }, + useHighStocks: true + }; + // Load categories, mainly to populate the pie chart. $scope.loadCategories = function() { $http.get("/api/categories", { @@ -111,6 +165,27 @@ accountantApp.controller( // Note: expenses and revenues must be in the same order than in series[0]. config.series[1].data = revenues.concat(expenses); + + $scope.loadSolds(); + }); + }; + + $scope.loadSolds = function() { + $http.get("/api/solds", { + params: { + account: $scope.account.id, + } + }).success(function(data) { + var config = $scope.soldChartConfig; + + config.series[0].data = []; + + angular.forEach(data, function(entry) { + config.series[0].data.push([ + moment.utc(entry.operation_date).valueOf(), + entry.open, entry.high, entry.low, entry.close + ]); + }); }); }; @@ -144,6 +219,8 @@ accountantApp.controller( color: colors[3], }]; + $scope.soldChartConfig.yAxis.plotLines[1].value = status.authorized_overdraft; + $scope.loadCategories(); }); }; diff --git a/accountant/frontend/templates/index.html b/accountant/frontend/templates/index.html index 19890b3..db3a5e4 100644 --- a/accountant/frontend/templates/index.html +++ b/accountant/frontend/templates/index.html @@ -20,10 +20,10 @@
- + - - + +
diff --git a/accountant/frontend/templates/layout.html b/accountant/frontend/templates/layout.html index a6a6f34..68c827a 100644 --- a/accountant/frontend/templates/layout.html +++ b/accountant/frontend/templates/layout.html @@ -74,9 +74,6 @@ - -