• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1212
  • Last Modified:

jqplot help

Hi

anyone got a example of how to to make jqplot with dynamic php data?

Thanks
0
3xtr3m3d
Asked:
3xtr3m3d
  • 3
  • 2
2 Solutions
 
3xtr3m3dAuthor Commented:
this is my current plot

line = [0,0,0,6,1,0,0,0,0,0,0,0];	
plot = $.jqplot('chartdiv', [line], {
    legend:{show:false},
    title:'Monthly Completed Orders For 2011',
    seriesDefaults:{
        renderer:$.jqplot.BarRenderer,
		rendererOptions:{ varyBarColor : true, barWidth: 20}
    },
    series:[{label:'2011'}],
    axes:{
        xaxis:{
            renderer:$.jqplot.CategoryAxisRenderer, 
            ticks:['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        }, 
        yaxis:{autoscale:true,tickOptions: {formatString: '%d'}}
    },
	seriesColors: [ "#4bb2c5", "#c5b47f"]

});

Open in new window


any idea how to build this line = [0,0,0,6,1,0,0,0,0,0,0,0]; with php and draw plot?
0
 
leakim971PluritechnicianCommented:
you don't like my links? check the first one for example : http://stackoverflow.com/questions/3445962/wait-for-response-with-getjson

on the php side something like :


<?php

$j = array();

$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
if (!$link) {
    die('Could not connect: ' . mysql_error());
}

// example of query
$query = "SELECT quantity FROM orders ORDER BY id DESC LIMIT 12";
$result = mysql_query($query,$link);

if (!$result) {
    $message  = 'Invalid query: ' . mysql_error() . "\n";
    $message .= 'Whole query: ' . $query;
    die($message);
}

var $a = array()

while ($row = mysql_fetch_assoc($result)) {
    $a[] = $row['quantity'];
}

$j["arrayName"] = $a
$j["newTitle"] = "title";

$json = json_encode($j);
header("Content-type: application/json");
echo $json;

?>

Open in new window

0
 
3xtr3m3dAuthor Commented:
you are awesome. Thank you verymuch.
0
 
leakim971PluritechnicianCommented:
You're welcome! Thanks for the points!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now