jacko_162 Posted April 13, 2010 Share Posted April 13, 2010 anyone used this before? im looking into charting a set of data in a table for each given user and displaying a graph such as; i want to call the data from the database using php and mysql, but i can manually add the title, and axis names. can anyone help me code something please?? Quote Link to comment https://forums.phpfreaks.com/topic/198419-google-charts/ Share on other sites More sharing options...
jacko_162 Posted April 13, 2010 Author Share Posted April 13, 2010 can anyone help me out, point me in right direction. just want an image based nice looking chart Quote Link to comment https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041286 Share on other sites More sharing options...
oni-kun Posted April 13, 2010 Share Posted April 13, 2010 can anyone help me out, point me in right direction. just want an image based nice looking chart You could read the documentation: http://code.google.com/apis/chart/docs/making_charts.html But here are a few examples: http://psychopyko.com/tutorial/how-to-use-google-charts/ http://charts.hohli.com/ (Some sort of generator) Quote Link to comment https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041303 Share on other sites More sharing options...
jacko_162 Posted April 13, 2010 Author Share Posted April 13, 2010 thanks for the links, i have been reading through them and found the following code: <?php // Create some random text-encoded data for a line chart. header('content-type', 'image/png'); $url = 'http://chart.apis.google.com/chart'; $chd = 't:'; for ($i = 0; $i < 150; ++$i) { $data = rand(0, 100000); $chd .= $data . ','; } $chd = substr($chd, 0, -1); // Add data, chart type, chart size, and scale to params. $chart = array( 'cht' => 'lc', 'chs' => '600x200', 'chds' => '0,100000', 'chd' => $chd); // Send the request, and print out the returned bytes. $context = stream_context_create( array('http' => array( 'method' => 'POST', 'content' => http_build_query($chart)))); fpassthru(fopen($url, 'r', false, $context)); ?> how can i query the database and turn the information into an array, i want to show test results from my "tests" table, each result has a date and a value. each graph only need to chart 1 piece of information and show the last 8 test results. Quote Link to comment https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041314 Share on other sites More sharing options...
jacko_162 Posted April 14, 2010 Author Share Posted April 14, 2010 can anyone help me gather data from a sql command and allow it into the above array please? according to the code posted by google; // Create some random text-encoded data for a line chart. header('content-type', 'image/png'); $url = 'http://chart.apis.google.com/chart'; $chd = 't:'; for ($i = 0; $i < 150; ++$i) { $data = rand(0, 100000); $chd .= $data . ','; } $chd = substr($chd, 0, -1); the above generates random numbers, and outputs $chd as: "t:40,20,50,20,100" so if i can pull my tests results from database in same way i would be 1 step closer. Quote Link to comment https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.