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-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);
|
|
|
|
/*
|
|
|
|
console.log('tooltip:');
|
|
|
|
console.log(item);
|
|
|
|
console.log(data);
|
|
|
|
*/
|
|
|
|
return item.yLabel;
|
2018-02-26 23:07:08 +01:00
|
|
|
}
|
|
|
|
}
|
2018-02-27 08:43:58 +01:00
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
xAxes: [{
|
|
|
|
type: 'time',
|
|
|
|
time: {
|
|
|
|
unit: "{{ $report->chartGroupBy() }}",
|
|
|
|
round: "{{ $report->chartGroupBy() }}",
|
|
|
|
},
|
|
|
|
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,
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
scales: {
|
|
|
|
xAxes: [{
|
|
|
|
type: 'time',
|
|
|
|
time: {
|
|
|
|
unit: "{{ $report->chartGroupBy() }}",
|
|
|
|
round: "{{ $report->chartGroupBy() }}",
|
|
|
|
},
|
|
|
|
gridLines: {
|
|
|
|
display: false,
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
yAxes: [{
|
|
|
|
ticks: {
|
|
|
|
beginAtZero: true,
|
|
|
|
callback: function(label, index, labels) {
|
|
|
|
return roundSignificant(label);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
});
|
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
|
|
|
//console.log(chartData);
|
|
|
|
|
|
|
|
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> </p>
|
2018-02-27 21:20:27 +01:00
|
|
|
@endif
|