2

I'm trying to build a structured (multiple) data graph using the PHP SVGGraph script.

I've setup my code based on what I can tell is the correct way but my graph is only outputting the age and excluding the height. Here's a screenshot showing just one column per person instead of 2.

Here is my code. Can you see anything wrong with it?

require_once('SVGGraph/SVGGraph.php');

$settings['structured_data'] = true;
$settings['structure'] = array(
  'key' => 'Name',
  'value' => array('Age', 'Height')
);

$graph = new SVGGraph(600, 400, $settings);

$values = array(
  array('Name' => 'Bob', 'Age' => 40, 'Height' => 180),
  array('Name' => 'Sam', 'Age' => 32, 'Height' => 165),
);

$graph->Values($values);

$graph->Render('BarGraph');
Ben Sinclair
  • 3,896
  • 7
  • 54
  • 94

1 Answers1

0

Turns out I was using the wrong graph type. Changing the last line to the following solved my issue

$graph->Render('GroupedBarGraph');
Ben Sinclair
  • 3,896
  • 7
  • 54
  • 94