1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-16 08:02:40 +01:00
invoiceninja/resources/views/reports/chart_builder.blade.php

83 lines
2.5 KiB
PHP
Raw Normal View History

2018-02-26 23:07:08 +01:00
<script type="text/javascript">
2018-02-27 08:43:58 +01:00
function loadLineChart(data) {
var ctx = document.getElementById('lineChartCanvas').getContext('2d');
2018-03-03 22:47:55 +01:00
@if (! $report->isPieChartEnabled())
document.getElementById('lineChartCanvas').height = 80;
@endif
2018-02-27 09:36:13 +01:00
new Chart(ctx, {
2018-02-27 08:43:58 +01:00
type: 'line',
data: data,
options: {
tooltips: {
mode: 'x-axis',
titleFontSize: 15,
titleMarginBottom: 12,
bodyFontSize: 15,
bodySpacing: 10,
callbacks: {
title: function(item) {
return moment(item[0].xLabel).format("{{ $account->getMomentDateFormat() }}");
},
label: function(item, data) {
//return label + formatMoney(item.yLabel, chartCurrencyId, account.country_id);
return item.yLabel;
2018-02-26 23:07:08 +01:00
}
}
2018-02-27 08:43:58 +01:00
},
scales: {
xAxes: [{
type: 'time',
gridLines: {
display: false,
},
}],
yAxes: [{
ticks: {
beginAtZero: true,
callback: function(label, index, labels) {
return roundSignificant(label);
}
},
}]
2018-02-26 23:07:08 +01:00
}
2018-02-27 08:43:58 +01:00
}
});
2018-02-26 23:07:08 +01:00
}
2018-02-27 09:36:13 +01:00
function loadPieChart(data) {
2018-02-27 20:19:46 +01:00
var ctx = document.getElementById('pieChartCanvas').getContext('2d');
new Chart(ctx, {
type: 'doughnut',
data: data,
});
2018-02-27 09:36:13 +01:00
}
2018-02-27 21:20:27 +01:00
@if ($report->isLineChartEnabled())
2018-02-26 23:07:08 +01:00
$(function() {
2018-02-27 08:43:58 +01:00
var lineChartData = {!! json_encode($report->getLineChartData()) !!};
loadLineChart(lineChartData);
2018-02-27 09:36:13 +01:00
var pieChartData = {!! json_encode($report->getPieChartData()) !!};
2018-02-27 21:20:27 +01:00
if (pieChartData) {
loadPieChart(pieChartData);
}
2018-02-26 23:07:08 +01:00
});
2018-02-27 21:20:27 +01:00
@endif
2018-02-26 23:07:08 +01:00
</script>
2018-02-27 21:20:27 +01:00
@if ($report->isLineChartEnabled())
2018-02-26 23:07:08 +01:00
<div class="row">
2018-02-27 21:20:27 +01:00
<div class="col-md-{{ $report->isPieChartEnabled() ? 6 : 12 }}">
2018-02-27 08:43:58 +01:00
<canvas id="lineChartCanvas" style="background-color:white; padding:20px; width:100%; height: 250px;"></canvas>
2018-02-26 23:07:08 +01:00
</div>
2018-02-27 21:20:27 +01:00
<div class="col-md-6" style="display:{{ $report->isPieChartEnabled() ? 'block' : 'none' }}">
2018-02-27 09:36:13 +01:00
<canvas id="pieChartCanvas" style="background-color:white; padding:20px; width:100%; height: 250px;"></canvas>
</div>
2018-02-26 23:07:08 +01:00
</div>
<p>&nbsp;</p>
2018-02-27 21:20:27 +01:00
@endif