php - Displaying values from a database (using mySQL) on a Flot graph -


i'm trying read in values db using php (mysql) have them show on graph in flot. know values read in correctly , i'm not getting errors graph won't show. little help?

thanks in advance.

<?php while ($row = mysql_fetch_array($result, mysql_num)) {     $graphdata[] =  array( (int)$row[0], (int)$row[1] ); } ?> /////  <div id="placeholder" style="width:600px;height:300px"></div>  <script language="javascript" type="text/javascript">  var dataset1 = <?php echo json_encode($graphdata);?>; var data = [             {                 label: "random values",                 data: dataset1             }         ]; var plotarea = $("#placeholder");          $.plot( plotarea , data); </script> 

the contents of pastebin show json string you're outputting invalid json.

var data = [{ label: "random values",data: dataset1}]; 

will validate if it's changed to:

var data = [{"label": "random values","data": "dataset1"}] 

that's example, suspect flot looking different format, you'll have verify they're looking against documentation. i'm going through same exercise right fusioncharts, i'm feeling pain. jsonlint.com friend on one, output json , verify frequently. i'd recommend working, start string of json (even 1 copy examples) put right in code. chart working first, work on getting php duplicate example json string separately.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -