I want to draw a pie chart where value will be taken from MySQL database. But it is not working. But if I give the manual value then the pie chart is showing. Below is my code:
<?php
include "libchart/classes/libchart.php";
header("Content-type: image/png");
$chart = new PieChart(500, 260);
$con=mysqli_connect("localhost","root","","bkash");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT count(*) FROM dialer_rate where mno='tnr' and success=1 ");
$result1 = mysqli_query($con,"SELECT count(*) FROM dialer_rate where mno='tnr' and failed=1");
$dataSet = new XYDataSet();
$dataSet->addPoint(new Point("Success", $result));
$dataSet->addPoint(new Point("Failed", $result1));
#$dataSet->addPoint(new Point(" (50)", 50));
$chart->setDataSet($dataSet);
$chart->setTitle("bKash USSD Dialer Success/Fail rate");
$chart->render();
?>
But if I give the manual value in below two fields then it is working. Anyone please help.
$dataSet->addPoint(new Point("Success", 20));
$dataSet->addPoint(new Point("Failed", 80));