mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Implemented a forgotten chart.
This commit is contained in:
parent
a8d60388ba
commit
60254dafd7
@ -19,6 +19,7 @@ class ChartJsAccountChartGenerator implements AccountChartGenerator
|
||||
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @param Collection $accounts
|
||||
* @param Carbon $start
|
||||
* @param Carbon $end
|
||||
|
@ -8,9 +8,11 @@
|
||||
|
||||
namespace FireflyIII\Generator\Chart\Bill;
|
||||
|
||||
use Config;
|
||||
use FireflyIII\Models\Bill;
|
||||
use FireflyIII\Models\TransactionJournal;
|
||||
use Illuminate\Support\Collection;
|
||||
use Preferences;
|
||||
|
||||
/**
|
||||
* Class ChartJsBillChartGenerator
|
||||
@ -79,5 +81,45 @@ class ChartJsBillChartGenerator implements BillChartGenerator
|
||||
*/
|
||||
public function single(Bill $bill, Collection $entries)
|
||||
{
|
||||
// language:
|
||||
$language = Preferences::get('language', 'en')->data;
|
||||
$format = Config::get('firefly.month.' . $language);
|
||||
|
||||
$data = [
|
||||
'count' => 3,
|
||||
'labels' => [],
|
||||
'datasets' => [],
|
||||
];
|
||||
|
||||
// dataset: max amount
|
||||
// dataset: min amount
|
||||
// dataset: actual amount
|
||||
|
||||
$minAmount = [];
|
||||
$maxAmount = [];
|
||||
$actualAmount = [];
|
||||
foreach ($entries as $entry) {
|
||||
$data['labels'][] = $entry->date->formatLocalized($format);
|
||||
$minAmount[] = round($bill->amount_min, 2);
|
||||
$maxAmount[] = round($bill->amount_max, 2);
|
||||
$actualAmount[] = round($entry->amount, 2);
|
||||
}
|
||||
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.minAmount'),
|
||||
'data' => $minAmount,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.billEntry'),
|
||||
'data' => $actualAmount,
|
||||
];
|
||||
$data['datasets'][] = [
|
||||
'label' => trans('firefly.maxAmount'),
|
||||
'data' => $maxAmount,
|
||||
];
|
||||
|
||||
$data['count'] = count($data['datasets']);
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,7 @@ class ChartJsBudgetChartGenerator implements BudgetChartGenerator
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
* @param Collection $entries
|
||||
*
|
||||
* @return array
|
||||
|
@ -57,7 +57,7 @@ class BillController extends Controller
|
||||
$cache->addProperty('bills');
|
||||
$cache->addProperty('frontpage');
|
||||
if ($cache->has()) {
|
||||
return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
// return Response::json($cache->get()); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$bills = $repository->getActiveBills();
|
||||
|
@ -1,9 +1,9 @@
|
||||
/* global comboChart, billID */
|
||||
|
||||
$(document).ready(function () {
|
||||
"use strict";
|
||||
if (typeof(comboChart) === 'function' && typeof(billID) !== 'undefined') {
|
||||
comboChart('chart/bill/' + billID, 'bill-overview');
|
||||
}
|
||||
}
|
||||
$(function () {
|
||||
"use strict";
|
||||
if (typeof(comboChart) === 'function' && typeof(billID) !== 'undefined') {
|
||||
comboChart('chart/bill/' + billID, 'bill-overview');
|
||||
}
|
||||
}
|
||||
);
|
@ -84,7 +84,7 @@ var defaultLineOptions = {
|
||||
datasetFill: false,
|
||||
scaleFontSize: 10,
|
||||
responsive: true,
|
||||
scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>",
|
||||
scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>",
|
||||
tooltipFillColor: "rgba(0,0,0,0.5)",
|
||||
tooltipTemplate: "<%if (label){%><%=label%>: <%}%>" + currencySymbol + " <%= value %>",
|
||||
};
|
||||
@ -97,10 +97,10 @@ var defaultColumnOptions = {
|
||||
datasetFill: false,
|
||||
scaleFontSize: 10,
|
||||
responsive: true,
|
||||
scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>",
|
||||
scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>",
|
||||
tooltipFillColor: "rgba(0,0,0,0.5)",
|
||||
tooltipTemplate: "<%if (label){%><%=label%>: <%}%>" + currencySymbol + " <%= value %>",
|
||||
multiTooltipTemplate: "<%=datasetLabel%>: "+currencySymbol+" <%= Number(value).toFixed(2).replace('.', ',') %>"
|
||||
tooltipTemplate: "<%if (label){%><%=label%>: <%}%>" + currencySymbol + " <%= value %>",
|
||||
multiTooltipTemplate: "<%=datasetLabel%>: " + currencySymbol + " <%= Number(value).toFixed(2).replace('.', ',') %>"
|
||||
};
|
||||
|
||||
var defaultStackedColumnOptions = {
|
||||
@ -113,7 +113,7 @@ var defaultStackedColumnOptions = {
|
||||
responsive: true,
|
||||
scaleLabel: "<%= '" + currencySymbol + " ' + Number(value).toFixed(2).replace('.', ',') %>",
|
||||
tooltipFillColor: "rgba(0,0,0,0.5)",
|
||||
multiTooltipTemplate: "<%=datasetLabel%>: "+currencySymbol+" <%= Number(value).toFixed(2).replace('.', ',') %>"
|
||||
multiTooltipTemplate: "<%=datasetLabel%>: " + currencySymbol + " <%= Number(value).toFixed(2).replace('.', ',') %>"
|
||||
|
||||
};
|
||||
|
||||
@ -265,7 +265,8 @@ function stackedColumnChart(URL, container, options) {
|
||||
*/
|
||||
function comboChart(URL, container, options) {
|
||||
"use strict";
|
||||
console.log('no impl for comboChart');
|
||||
columnChart(URL, container, options);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,13 @@
|
||||
<h3 class="box-title">Chart</h3>
|
||||
</div>
|
||||
<div class="box-body">
|
||||
<div id="bill-overview"></div>
|
||||
|
||||
{% if Config.get('firefly.chart') == 'google' %}
|
||||
<div id="bill-overview"></div>
|
||||
{% endif %}
|
||||
{% if Config.get('firefly.chart') == 'chartjs' %}
|
||||
<canvas id="bill-overview" style="width:100%;height:400px;"></canvas>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user