我正在设置一份捐赠遗产中收集的金额的报告摘要,我设法从数据库中获取数据并显示在图表上。我打算按月显示按遗产分组的所有付款。
我希望y axis
支付一定的金额,而x axis
拥有几个月的时间,然后按estatename
对结果进行分组,但是我不确定如何正确实施。
这是我所做的事情:
document.addEventListener('DOMContentLoaded', function () {
var line_chart = c3.generate({
bindto: '#c3-line-chart',
point: {
r: 4
},
size: {height: 400},
color: {
pattern: ['#4CAF50', '#F4511E', '#1E88E5']
},
data: {
columns: [
<?php
$allestates=$this->db->query("select distinct(estate) from bookings order by estate desc")->result_array();
if(count($allestates)>0) {
foreach ($allestates as $singleestate):
$thisestate=$singleestate['estate'];
$fetchestate=$this->db->query("select estatename from tbl_estates where id='$thisestate'")->row();
$thisname = $fetchestate->estatename;
echo '['.'\''.ucwords($thisname).'\''.',';
$allpayments = $this->db->query("select amountpaid from bookings where estate='$thisestate'")->result_array();
foreach ($allpayments as $payments):
echo $payments['amountpaid'].',';
endforeach;
echo '],';
endforeach;
}else{
?>
['Hazina', 30, 200, 100, 400, 150, 250],
['Hill Side', 50, 20, 10, 40, 15, 25]
<?php }?>
],
type: 'spline'
},
grid: {
y: {
show: true
}
}
});
// Resize chart on sidebar width change
$(".sidebar-control").on('click', function () {
line_chart.resize();
});
});