mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-21 17:01:00 -04:00
Working on charts
This commit is contained in:
parent
31b8437dc6
commit
e94e7cca80
@ -198,7 +198,6 @@ class AbstractReport
|
|||||||
|
|
||||||
$datasets = [];
|
$datasets = [];
|
||||||
$labels = [];
|
$labels = [];
|
||||||
$totals = new stdClass();
|
|
||||||
|
|
||||||
foreach ($this->chartData as $dimension => $data) {
|
foreach ($this->chartData as $dimension => $data) {
|
||||||
$endDate->modify('+1 '.$groupBy);
|
$endDate->modify('+1 '.$groupBy);
|
||||||
@ -220,6 +219,7 @@ class AbstractReport
|
|||||||
}
|
}
|
||||||
|
|
||||||
$color = '51,122,183';
|
$color = '51,122,183';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if ($entityType == ENTITY_INVOICE) {
|
if ($entityType == ENTITY_INVOICE) {
|
||||||
$color = '51,122,183';
|
$color = '51,122,183';
|
||||||
@ -234,7 +234,7 @@ class AbstractReport
|
|||||||
$record->data = $records;
|
$record->data = $records;
|
||||||
$record->label = trans("texts.{$dimension}");
|
$record->label = trans("texts.{$dimension}");
|
||||||
$record->lineTension = 0;
|
$record->lineTension = 0;
|
||||||
$record->borderWidth = 4;
|
$record->borderWidth = 3;
|
||||||
$record->borderColor = "rgba({$color}, 1)";
|
$record->borderColor = "rgba({$color}, 1)";
|
||||||
$record->backgroundColor = "rgba({$color}, 0.1)";
|
$record->backgroundColor = "rgba({$color}, 0.1)";
|
||||||
$datasets[] = $record;
|
$datasets[] = $record;
|
||||||
@ -249,6 +249,40 @@ class AbstractReport
|
|||||||
|
|
||||||
public function getPieChartData()
|
public function getPieChartData()
|
||||||
{
|
{
|
||||||
|
$datasets = [];
|
||||||
|
$labels = [];
|
||||||
|
$totals = [];
|
||||||
|
|
||||||
|
$color = '51,122,183';
|
||||||
|
|
||||||
|
foreach ($this->chartData as $dimension => $data) {
|
||||||
|
foreach ($data as $date => $value) {
|
||||||
|
if (! isset($totals[$dimension])) {
|
||||||
|
$totals[$dimension] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$totals[$dimension] += $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = new stdClass();
|
||||||
|
$response->labels = [];
|
||||||
|
|
||||||
|
$datasets = new stdClass();
|
||||||
|
$datasets->data = [];
|
||||||
|
$datasets->backgroundColor = [];
|
||||||
|
|
||||||
|
foreach ($totals as $dimension => $value) {
|
||||||
|
$response->labels[] = $dimension;
|
||||||
|
$datasets->data[] = $value;
|
||||||
|
$datasets->lineTension = 0;
|
||||||
|
$datasets->borderWidth = 3;
|
||||||
|
$datasets->borderColor = "rgba({$color}, 1)";
|
||||||
|
$datasets->backgroundColor = "rgba({$color}, 0.1)";
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->datasets = [$datasets];
|
||||||
|
|
||||||
|
return $response;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,51 @@ function loadLineChart(data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loadPieChart(data) {
|
function loadPieChart(data) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,11 +106,9 @@ $(function() {
|
|||||||
loadLineChart(lineChartData);
|
loadLineChart(lineChartData);
|
||||||
//console.log(chartData);
|
//console.log(chartData);
|
||||||
|
|
||||||
/*
|
|
||||||
var pieChartData = {!! json_encode($report->getPieChartData()) !!};
|
var pieChartData = {!! json_encode($report->getPieChartData()) !!};
|
||||||
loadPieChart(pieChartData);
|
loadPieChart(pieChartData);
|
||||||
console.log(pieChartData);
|
console.log(pieChartData);
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user