1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Adding charts to reports

This commit is contained in:
Hillel Coren 2018-02-27 09:14:39 +02:00
parent dea48b83e2
commit 954f606a1d
4 changed files with 15 additions and 12 deletions

View File

@ -174,6 +174,10 @@ class AbstractReport
protected function formatDate($date)
{
if (! $date instanceof \DateTime) {
$date = new \DateTime($date);
}
$groupBy = $this->chartGroupBy();
$dateFormat = $groupBy == 'DAY' ? 'z' : ($groupBy == 'MONTH' ? 'm' : '');

View File

@ -55,6 +55,8 @@ class ClientReport extends AbstractReport
foreach ($client->invoices as $invoice) {
$amount += $invoice->amount;
$paid += $invoice->getAmountPaid();
$this->addChartData(ENTITY_INVOICE, $invoice->invoice_date, $invoice->amount);
}
$row = [

View File

@ -39,6 +39,8 @@ class CreditReport extends AbstractReport
foreach ($client->credits as $credit) {
$amount += $credit->amount;
$balance += $credit->balance;
$this->addChartData(ENTITY_CREDIT, $credit->credit_date, $credit->amount);
}
if (! $amount && ! $balance) {

View File

@ -25,19 +25,14 @@ function loadChart(data) {
return moment(item[0].xLabel).format("{{ $account->getMomentDateFormat() }}");
},
label: function(item, data) {
//return label + formatMoney(item.yLabel, chartCurrencyId, account.country_id);
/*
if (item.datasetIndex == 0) {
var label = " {!! trans('texts.invoices') !!}: ";
} else if (item.datasetIndex == 1) {
var label = " {!! trans('texts.payments') !!}: ";
} else if (item.datasetIndex == 2) {
var label = " {!! trans('texts.expenses') !!}: ";
}
return label + formatMoney(item.yLabel, chartCurrencyId, account.country_id);
console.log('tooltip:');
console.log(item);
console.log(data);
*/
return 'test';
return item.yLabel;
}
}
},
@ -76,7 +71,7 @@ var chartGroupBy = "{{ $report->chartGroupBy() }}";
$(function() {
var chartData = {!! json_encode($report->getChartData()) !!};
console.log(chartData);
//console.log(chartData);
loadChart(chartData);
});