Jump to content

google charts?


jacko_162

Recommended Posts

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;

 

chart?chf=bg,s,FFFFFF00&cht=bvs&chs=230x160&chco=D5DF3D&chbh=3,1,0&chg=14.89,14.29,1,5,6.38&chds=0,35&chxt=x,y&chxl=0:|13.04|04.04|21.03|07.03|1:|0|5|10|15|20|25|30|35&chxp=0,100,80.9,51.1,21.3&chd=s:yyyyy0000000yywwwwwwwwwwwwwwwwwwyyyyyyyyyyyyyyww

 

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??

Link to comment
https://forums.phpfreaks.com/topic/198419-google-charts/
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041303
Share on other sites

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.

 

 

Link to comment
https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041314
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/198419-google-charts/#findComment-1041495
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.