Commit b3818ba5 authored by Pascal Engélibert's avatar Pascal Engélibert 🚴
Browse files

Graph delta bars, style

parent 2a33841b
......@@ -114,6 +114,7 @@
$donneurs = [];
$tmp_timestamp = $start_timestamp;
$array_final = [];
$map_delta = [];
foreach ($transactions as $transaction){
$donneur = $transaction->issuers[0];
if ($donneur != $pubkey){
......@@ -129,6 +130,11 @@
if ($timestamp != $tmp_timestamp){
array_push($array_final, ['t'=>$tmp_timestamp*1000, 'y'=>(string) $total]);
}
$tday = 43200 + $tmp_timestamp - $tmp_timestamp%86400;
if(isset($map_delta[$tday]))
$map_delta[$tday] += intval($montant_transaction);
else
$map_delta[$tday] = intval($montant_transaction);
$total += $montant_transaction;
$tmp_timestamp = $timestamp;
}
......@@ -141,6 +147,11 @@
array_push($array_final, ['t'=>$tmp_timestamp*1000, 'y'=>(string) $total]);
array_push($array_final, ['t'=>$today_timestamp*1000, 'y'=>(string) $total]);
$array_line = [['t'=>$start_timestamp*1000, 'y'=>(string) $target],['t'=>$today_timestamp*1000, 'y'=>(string) $target]];
$array_delta = array();
foreach($map_delta as $k=> $v) {
$array_delta[] = array('t'=>$k*1000, 'y'=>$v);
}
}
// Vérification de l'unité
......@@ -243,6 +254,7 @@
container.appendChild(div);
var chartData = {
datasets: [{
type: "line",
label: "<?php echo tr('graph_target'); ?>",
data: <?php echo json_encode($array_line); ?>,
borderColor: '#FF3E3D',
......@@ -250,17 +262,26 @@
radius: 0,
fill: false
},{
type: "bar",
label: '<?php echo tr('graph_delta'); ?>',
data: <?php echo json_encode($array_delta); ?>,
borderColor: 'rgba(0,200,100,0.7)',
backgroundColor: 'rgba(96,200,120,0.7)',
borderWidth: 2
},{
type: "line",
label: '<?php echo tr('graph_title'); ?>',
data: <?php echo json_encode($array_final); ?>,
borderColor: '#0099FF',
backgroundColor: '#80CCFF',
lineTension: 0,
pointRadius: 1,
borderWidth: 2
borderWidth: 2,
steppedLine: true
}]
};
new Chart(canvas.getContext('2d'), {
type: 'line',
type: 'bar',
data: chartData,
options: {
responsive: true,
......@@ -279,6 +300,9 @@
tooltipFormat: dateFormat + ' - ' + hourFormat
}
}]
},
tooltips: {
intersect: false
}
}
});
......@@ -295,4 +319,4 @@
});
</script>
</body>
</html>
\ No newline at end of file
</html>
......@@ -24,6 +24,7 @@ $ttr = array(
'label_remaining_d' => 'days remaining',
'label_contribute' => 'Contribute now !',
'graph_title' => 'Evolution of the funding',
'graph_target' => 'Target'
'graph_target' => 'Target',
'graph_delta' => 'Daily income'
);
?>
......@@ -24,6 +24,7 @@ $ttr = array(
'label_remaining_d' => 'tagoj restas',
'label_contribute' => 'Kontribuu nun !',
'graph_title' => 'Evoluo de la financado',
'graph_target' => 'Celo'
'graph_target' => 'Celo',
'graph_delta' => 'Taga enspezo'
);
?>
......@@ -24,6 +24,7 @@ $ttr = array(
'label_remaining_d' => 'jours restants',
'label_contribute' => 'Contribuez maintenant !',
'graph_title' => 'Montant récolté',
'graph_target' => 'Objectif'
'graph_target' => 'Objectif',
'graph_delta' => 'Contributions du jour'
);
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment