there is no documentation of chart.js regarding the connection of getting the data from the database, that is why i'm still curious of how to implement my bar graph from an external graph data. and as of now i'm using codeigniter framework and i dont think CI do have library of chart graph. so in second thought how would i implement properly the graph in my framework. so first i loaded an offline chart.js:
<script src="<?php echo base_url('assets/js/Chart.min.js')?>"></script>
next i implement the bar chart with fixed data:
var ctx = document.getElementById('myChart').getContext('2d');
var chart = new Chart(ctx, {
type: 'bar',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
datasets: [{
label: "Monthly Percentage of Project Completion",
backgroundColor: 'rgb(3, 0, 102)',
data: [90, 10, 5, 2, 20, 30, 45, 35, 56, 45, 2, 100],
}]
},
options: {}
});
how do i get my database data to show in my barchart graph?
and also want to have this scenario where my datasets will be dependent on my year data 2017,2018,2016 or more years to come and the percentage will be on the left side.