I\'m trying to make a chart from the google chart api but I can\'t get my php variable into the script: I get a blank page.
PHP
$columns = array(
Your data structure is incorrect for the Visualization API's DataTable constructor.
The correct format for the columns is an array of column objects, where each object has type (mandatory), label, id, and p (all optional) properties. type is a string with possible values string, number, boolean, date, datetime, and timeofday. label and id are strings. p is an object of column properties.
The correct format for rows is an array of row objects, where each object has c and p properties. c is an array of cell objects. p is an object of row properties. The cell objects have v, f, and p properties, where v is the value of the cell, f is the string-formatted value of the cell, and p is an object of cell properties.
Supported properties for all properties objects vary depending on the type of chart(s) you are drawing.
Using PHP's json_encode function, associative arrays are translated into objects and non-associative arrays are turned into arrays. The appropriate structure for your table should look something like this:
$columns = array(
array('type' => 'string', 'label' => 'x'),
array('type' => 'number', 'label' => 'values'),
// each interval should have its own unique id,
// but leaving them the same won't break anything for your chart as-is
array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),
array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),
array('type' => 'number', 'label' => 'OtherValues'),
array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval')),
array('type' => 'number', 'id' => 'i1', 'p' => array('role' => 'interval'))
);
$test = array(
array('c' => array(
array('v' => 'a'),
array('v' => 100),
array('v' => 90),
array('v' => 150),
array('v' => 15),
array('v' => 10),
array('v' => 20)
)),
// etc
);
$table['cols'] = $columns;
$table['rows'] = $test;