I'm trying to get a flot graph to show my jsonencoded array seen below:
[["aa",71],["ab",69],["ac",66],["ad",61],["ae",79],["af",78]]
In the array the first is what i want on the xaxis and the second is the corresponding value.
Right now my flot graph outputs an empty chart and I'm thinking that the array need to be all numbers. Previously I have predefined the xaxis names like this ticks:[[0,'Räckvidd']
But now I dont know what the expected name will be since the database is growing.
Now i don't really know how to proceed so if anybody here have experience of flot graphs and know of a solution to my problem I would be eternally grateful!
This is what I've done so far:
<div class="graph small tab-content" id="plotarea"></div>
<?PHP
$sql = mysql_query("SELECT Name,Value,Id FROM DB ORDER BY Id");
while($result = mysql_fetch_array($sql))
{
$data[] = array($result['Name'],$result['Value']);
}
$TEST = json_encode(($data), JSON_NUMERIC_CHECK);
?>
And the flot script:
<script type="text/javascript">
$(window).load(function () {
var options = {
lines: { show: true },
points: { show: true },
xaxis: { min:0,max:5 },
yaxis: { min:1 ,max:60},
};
var TEST = <?php echo $TEST; ?>;
$.plot($("#plotarea"),TEST,options)});
</script>
Over and out
Adam