I am trying to use jquery sparkline with mysql data for showing how much money every user make in every day... Here I show you the money about one user example which is in the mysql DB:
[{"m":"01 noviembre 2014","d":"15.00"},{"m":"02 noviembre 2014","d":"200.00"},{"m":"03 noviembre 2014","d":"25.00"}]
but not show nothing ...can you help me and show me where is my error?
This is the JS library I am use to try to show the graph:
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery.sparkline.min.js" type="text/javascript"></script>
Here the javascript in the page:
<?php include_once('graficas/users.php'); ?>
<script type="text/javascript">
$(function() {
var myvalues = <?php echo json_encode($users);?>;
$('.dynamicsparkline').sparkline(myvalues);
$('.dynamicbar').sparkline(myvalues, {type: 'bar', barColor: 'blue'} );
});
</script>
Here the code in users.php
<?php
include 'cons.php';
$sql = $conn->prepare("SELECT DATE_FORMAT(start, '%d %M %Y') AS date, SUM(abono) AS total_diario
FROM GANANCIAS WHERE id_user = '1' AND YEAR(start) = YEAR(current_date) GROUP BY date ASC ORDER BY YEAR(start) ASC");
$sql->execute();
while($row = $sql->fetch(PDO::FETCH_ASSOC)) {
$doctores[] = array('m'=>$row['date'], 'd'=>$row['total_diario']);
}
?>
And for last the id to show the graph:
<p>
<span class="dynamicbar">Loading..</span>
</p>
always show me only loading...
EDIT
I changed this part of the code inside of users.php
$doctores[] = array('m'=>$row['date'], 'd'=>$row['total_diario']);
TO
doctores[] = $row['total_diario'];
And now show me the graph with these values:
var myvalues=["25.00","25.00","20.00","15.00"]
But the graph is showed with every separated numbers and dots....
", 2,5,.,0,0,",,....and so on
nevermind! Now is working properly and show me all the data per user!