Debugging Chart Post Requests & Passing Variables

12 views
Skip to first unread message

Jordan Lovato

unread,
Aug 28, 2011, 8:13:22 PM8/28/11
to Google Chart API
Hey, I'm trying to use a global variable in the construction of my
chart, and I have 2 questions. First off, is there any way to get the
google charts server to ping me back with some debugging info? I have
no idea what I'm actually passing to the chart and it would be really
nice to know.

Secondly, How would I go about passing variables to the posted chart?
Currently I'm just including my file like so:

<?php
echo WP_PLUGIN_DIR . "/widget-dash-replace/index.php";
// Create some random text-encoded data for a line chart.
header('content-type: image/png');
$url = 'https://chart.googleapis.com/chart?chid=' .
md5(uniqid(rand(), true));
$chd = 't:';

global $data_array;
$x_values = array_keys($data_array);
$y_values = array_values($data_array);

$chd .= implode(',', $x_values);
$chd .= '|';
$chd .= implode(',', $y_values);

// Add data, chart type, chart size, and scale to params.
$chart = array(
'cht' => 'lxy',
'chs' => '500x200',
'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));
?>

and then parsing the data that I need as I go along. Is there a better
method to pass data to the img script? I'm not even sure this method
works at all.

duniyadnd

unread,
Aug 29, 2011, 5:05:29 PM8/29/11
to google-c...@googlegroups.com
Hi Jordan, you're in the wrong group, this is about Google Static Charts (the image ones). You need to go to Google Visualization API
Reply all
Reply to author
Forward
0 new messages