14. Using force_assoc
The code below is the source for this graph.
<?php
// 14. Using force_assoc
require_once 'SVGGraph/autoloader.php';
$settings = [
'auto_fit' => true,
'back_colour' => '#eee',
'back_stroke_width' => 0,
'back_stroke_colour' => '#eee',
'stroke_colour' => '#000',
'axis_colour' => '#333',
'axis_overlap' => 3,
'grid_colour' => '#999',
'label_colour' => '#000',
'axis_font' => 'Arial',
'axis_font_size' => 10,
'pad_right' => 0,
'pad_left' => 10,
'minimum_grid_spacing' => 20,
'bar_space' => 3,
'grid_division_v' => 2,
'force_assoc' => true,
];
$width = 300;
$height = 300;
$type = 'GroupedBarGraph';
$values = [
[1988 => 5, 1992 => 5, 1996 => 1, 2000 => 11, 2004 => 9, 2008 => 19],
[1988 => 10, 1992 => 3, 1996 => 8, 2000 => 10, 2004 => 9, 2008 => 13],
[1988 => 9, 1992 => 12, 1996 => 6, 2000 => 7, 2004 => 12, 2008 => 15],
];
$colours = [
['#663','#fe6','#993','h'],
['#999','#eee','#999','h'],
['#630','#a70','#630','h']
];
$graph = new Goat1000\SVGGraph\SVGGraph($width, $height, $settings);
$graph->colours($colours);
$graph->values($values);
$graph->render($type);
Please note: the source code above comes from a script used to generate one of the example graphs on the site. This is simply a wrapper page to apply highlighting and make the source code easier to read, so there is no content here to describe what the source code is doing.