<?php
$dataPoints = array();
try{
    $link = new \PDO(   'mysql:host=localhost;dbname=wwwagury_dbtkcorp;charset=utf8mb4', 
                        'wwwagury_usrtkcorp', //'root',
                        'RTzUHXMWl)JV', //'',
                        array(
                            \PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                            \PDO::ATTR_PERSISTENT => false
                        )
                    );
	
    $handle = $link->prepare("select (SELECT count(*) from tbl_transaction where transaction_status='pending') as x, COUNT(*) as y from tbl_transaction"); 
    $handle->execute(); 
    $result = $handle->fetchAll(\PDO::FETCH_OBJ);
		
    foreach($result as $row){
        array_push($dataPoints, array("x"=> $row->x, "y"=> $row->y));
    }
	$link = null;
}
catch(\PDOException $ex){
    print($ex->getMessage());
}
?>
<!DOCTYPE HTML>
<html>
<head>
<script>
window.onload = function() {
 
var chart = new CanvasJS.Chart("chartContainer", {
	animationEnabled: true,
	theme: "light2",
	title:{
		text: ""
	},
	axisY: {
		title: "Total Orders"
	},
	axisX: {
		title: "Pending Orders"
	},
	data: [{
		type: "column",
		xValueFormatString: "Pending Orders #,##",
		yValueFormatString: "Total Orders #,##",
		dataPoints: <?php echo json_encode($dataPoints, JSON_NUMERIC_CHECK); ?>
	}]
});
chart.render();
 
}
</script>
</head>
<body>
<div id="chartContainer" style="height: 350px; width: 100%;"></div>
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
</body>
</html>              