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

126 lines
3.9 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-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-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()) !!};
loadPieChart(pieChartData);
console.log(pieChartData);
2018-02-26 23:07:08 +01:00
});
</script>
<div class="row">
2018-02-27 09:36:13 +01:00
<div class="col-md-6">
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 09:36:13 +01:00
<div class="col-md-6">
<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>