This commit is contained in:
James Cole
2018-07-01 09:43:44 +02:00
parent db149ca6e1
commit c24cac68f6
5 changed files with 41 additions and 20 deletions

View File

@@ -90,7 +90,9 @@ class ChartJsGenerator implements GeneratorInterface
if (isset($set['currency_symbol'])) { if (isset($set['currency_symbol'])) {
$currentSet['currency_symbol'] = $set['currency_symbol']; $currentSet['currency_symbol'] = $set['currency_symbol'];
} }
if(isset($set['backgroundColor'])) {
$currentSet['backgroundColor'] = $set['backgroundColor'];
}
$chartData['datasets'][] = $currentSet; $chartData['datasets'][] = $currentSet;
} }

View File

@@ -112,14 +112,16 @@ class ReportController extends Controller
$source = $this->getChartData($accounts, $start, $end); $source = $this->getChartData($accounts, $start, $end);
$chartData = [ $chartData = [
[ [
'label' => trans('firefly.income'), 'label' => trans('firefly.income'),
'type' => 'bar', 'type' => 'bar',
'entries' => [], 'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
'entries' => [],
], ],
[ [
'label' => trans('firefly.expenses'), 'label' => trans('firefly.expenses'),
'type' => 'bar', 'type' => 'bar',
'entries' => [], 'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
'entries' => [],
], ],
]; ];
@@ -189,17 +191,19 @@ class ReportController extends Controller
$chartData = [ $chartData = [
[ [
'label' => (string)trans('firefly.income'), 'label' => (string)trans('firefly.income'),
'type' => 'bar', 'type' => 'bar',
'entries' => [ 'backgroundColor' => 'rgba(0, 141, 76, 0.5)', // green
'entries' => [
(string)trans('firefly.sum_of_period') => $numbers['sum_earned'], (string)trans('firefly.sum_of_period') => $numbers['sum_earned'],
(string)trans('firefly.average_in_period') => $numbers['avg_earned'], (string)trans('firefly.average_in_period') => $numbers['avg_earned'],
], ],
], ],
[ [
'label' => trans('firefly.expenses'), 'label' => trans('firefly.expenses'),
'type' => 'bar', 'type' => 'bar',
'entries' => [ 'backgroundColor' => 'rgba(219, 68, 55, 0.5)', // red
'entries' => [
(string)trans('firefly.sum_of_period') => $numbers['sum_spent'], (string)trans('firefly.sum_of_period') => $numbers['sum_spent'],
(string)trans('firefly.average_in_period') => $numbers['avg_spent'], (string)trans('firefly.average_in_period') => $numbers['avg_spent'],
], ],

View File

@@ -26,12 +26,12 @@ var allCharts = {};
*/ */
var colourSet = [ var colourSet = [
[53, 124, 165], [53, 124, 165],
[0, 141, 76], [0, 141, 76], // green
[219, 139, 11], [219, 139, 11],
[202, 25, 90], [202, 25, 90], // paars rood-ish #CA195A
[85, 82, 153], [85, 82, 153],
[66, 133, 244], [66, 133, 244],
[219, 68, 55], [219, 68, 55], // red #DB4437
[244, 180, 0], [244, 180, 0],
[15, 157, 88], [15, 157, 88],
[171, 71, 188], [171, 71, 188],
@@ -205,6 +205,21 @@ function columnChart(URI, container) {
} }
/**
*
* @param URI
* @param container
*/
function columnChartCustomColours(URI, container) {
"use strict";
var colorData = false;
var options = $.extend(true, {}, defaultChartOptions);
var chartType = 'bar';
drawAChart(URI, container, chartType, options, colorData);
}
/** /**
* *
* @param URI * @param URI

View File

@@ -23,8 +23,8 @@
$(function () { $(function () {
"use strict"; "use strict";
lineChart(netWorthUri, 'net-worth'); lineChart(netWorthUri, 'net-worth');
columnChart(opChartUri, 'income-expenses-chart'); columnChartCustomColours(opChartUri, 'income-expenses-chart');
columnChart(sumChartUri, 'income-expenses-sum-chart'); columnChartCustomColours(sumChartUri, 'income-expenses-sum-chart');
loadAjaxPartial('budgetPeriodReport', budgetPeriodReportUri); loadAjaxPartial('budgetPeriodReport', budgetPeriodReportUri);
loadAjaxPartial('categoryExpense', categoryExpenseUri); loadAjaxPartial('categoryExpense', categoryExpenseUri);

View File

@@ -23,8 +23,8 @@
$(function () { $(function () {
"use strict"; "use strict";
lineChart(netWorthUri, 'net-worth'); lineChart(netWorthUri, 'net-worth');
columnChart(opChartUri, 'income-expenses-chart'); columnChartCustomColours(opChartUri, 'income-expenses-chart');
columnChart(sumChartUri, 'income-expenses-sum-chart'); columnChartCustomColours(sumChartUri, 'income-expenses-sum-chart');
loadAjaxPartial('budgetPeriodReport', budgetPeriodReportUri); loadAjaxPartial('budgetPeriodReport', budgetPeriodReportUri);
loadAjaxPartial('categoryExpense', categoryExpenseUri); loadAjaxPartial('categoryExpense', categoryExpenseUri);