Click here to Skip to main content
15,888,037 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I wish to add code snippets for pie chart in my project. I searched and found some code for simple chart.Part of my page for chart is below:

PHP
printf( '<script type="text/javascript" src="extlib/Chart.js"></script>' );
printf( '<script type="text/javascript" src="extlib/jquery-min.js"></script>' );
printf( '<canvas id="mycanvas" width="256" height="256"></canvas>' );
printf( '<script type="text/javascript">' );
 
    var ctx = $("#mycanvas").get(0).getContext("2d");
    var piedata = [
    {
    value:30,
    color:"green",
    label:"sta1",
    labelColor : 'white'
    },
    {
    value:60,
    color:"red",
    label:"sta1",
    labelColor : 'white'
    },
    {
    value:50,
    color:"blue"
    }
    ]

    new Chart(ctx).Pie(piedata);
        printf( '</script>' ); 



What can I do for dynamic chart.That is the value should come from MySQL DB. Number of data value from DB will differ every time.Each data value has specific colors.


Please suggest me the way of how to do with mysql and Chart.js
Posted
Updated 5-Oct-15 21:53pm
v3

1 solution

 
Share this answer
 
Comments
Member 12035784 6-Oct-15 2:59am    
Hi Thanks for the response.but I need pie chart with mysql data.I have alreday included chart.js in my code.How to pass value for pie chart from database?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900