I want to constract a 3d interactive pie chart. Firstly I use google charts but unfortunately this doesn't work offline. I used charts from jpgraph, jscharts and rgraph but doesn't have the effect that I want. I want a graph which must be free, work offline and has approximately the same appearance with google graph. Any advice? Thanks in advance!
Important I want to use results from my db. I write this code but dont work:
data: [{
name: 'Present',
y: <?php
while( $row2 = mysql_fetch_assoc($res2)){
echo $row2["COUNT(*)"];
}
}, {
name: 'absentees',
y: <?php
while( $row1 = mysql_fetch_assoc($res1)){
echo $row1["COUNT(*)"];
}
I have those queries:
SELECT COUNT(*)
FROM staff s, work w, absence a
WHERE s.id=a.id_staff
AND s.id_work=w.id
AND w.name='sales manager'
AND a.name='disease'
SELECT COUNT(*)
FROM staff s, work w, absence a
WHERE s.id=a.id_staff
AND s.id_work=w.id
AND w.name='sales manager'
AND a.name='vacation'
I try this but doesnt work
series: [{
type: 'pie',
name: 'Absent',
data: [
['Absent Illness', <?php
while( $row1 = mysql_fetch_assoc($res1)){
while( $row2 = mysql_fetch_assoc($res2)){
$row['COUNT(*)']=$row2['COUNT(*)'] - $row1['COUNT(*)'];
echo $row["COUNT(*)"];
}
}
?>],
['Absent Vacation',
<?php
while( $row1 = mysql_fetch_assoc($res1)){
echo $row1["COUNT(*)"];
}
?>]
]
}]
});
Please use highchart because it provide the varrious type of charts and you can also use it offline mode also. https://www.highcharts.com/
Highcharts easy to add interactive, mobile-optimized charts to your web and mobile projects. It's free, offline which serves your requirement. "https://www.highcharts.com/demo"
Let me guide to display mysql results onto the pie chart.
function functionname() { $.ajax({ url : 'POST API LINK', type : 'GET', dataType : 'json', success : function(data) { var chart = new CanvasJS.Chart("chartContainer", { title : { text : "A suitable title" }, animationEnabled : true, zoomEnabled : false, data : [ { type : "pie", dataPoints : [ { y : data.active, indexLabel : "Active part=" + data.active }, { y : data.Inactive, indexLabel : "Inactive part=" + data.Inactive }, ] } ] }); chart.render(); }, error : function() { alert('sorry!Somthing went wrong in Pie chart'); } }); }
This is how you display MySQL results.
Here In data,I am getting active and inactive value from my DB.
For the UI, Please check this fiddle link.
Kindly let me know if you have any queries.