With the below code I am trying to create a Morris Donut chart. But i am not getting the output as expected. This is the first time i am trying to create a morris chart by fetching data from mysql. So if any big mistake, please forgive me. Here is the code "morris.php"
<?php
require_once('connection.php');
?>
<html>
<head>
<link rel="stylesheet" href="morris.css">
<script src="jquery.min.js"></script>
<script src="raphael-min.js"></script>
<script src="morris.min.js"></script>
<meta charset=utf-8 />
</head>
<body>
<?php
$sql= "select wlt_txn_cat as cat , sum(wlt_txn_amount) as amt from wallet_txns where wlt_txn_type = 'Expense' group by wlt_txn_amount desc";
$result = mysqli_query($GLOBALS["___mysqli_ston"], $sql) or die(((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
if ( mysqli_num_rows($result) >0)
while($row = mysqli_fetch_array($result))
{
?>
<div id="donut-example" style="height: 250px;"></div>
<script type="application/javascript">
Morris.Donut({
element: 'donut-example',
data: [
{label: "<?php echo $row['cat'] ?>", value: "<?php echo $row['amt'] ?>"}
]
});
</script>
<?php } ?>
</body>
</html>
The screen shots....
the actual code for getting the correct output (right side of the image attached is the below one... I am trying to get the 'label' and 'value' from by mysql db by using php.
Morris.Donut({
element: 'donut-example',
data: [
{label: "Download Sales", value: 15},
{label: "In-Store Sales", value: 30},
{label: "Mail-Order Sales", value: 20},
{label: "General Sales", value: 40}
],
backgroundColor: '#ccc',
labelColor: '#060',
colors: ['#DD4B39','#4486F7','#FAC504','#019C5A']
});