I wish to add pie chart using charts.js in my project. I searched and found some code for simple chart. Part of my code for chart is below:
printf( '<script type="text/javascript" src="extlib/Chart.js"></script>' );
printf( '<script type="text/javascript" src="extlib/jquery-min.js"></script>' );
printf( '<p style="text-align: center;">' );
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);
<?php
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.
With the above code the label is not visible explicitly(only on mouse over).
Please suggest me the way.