1

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? enter image description here

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. enter image description here

2
  • 1
    maybe you need to check this question: stackoverflow.com/questions/30928840/… Commented Aug 14, 2017 at 11:17
  • thanks for the link @Sulyman i will try these and update if i will face some problems. Commented Aug 14, 2017 at 11:44

1 Answer 1

1

the main idea is to change the static data to dynamic data from database so when you have the data in a variable pass it istead of the static one. and it depends on the language you are using

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.