11. Horizontal bar graph
The code below is the source for this graph.
<?php
// 11. Horizontal bar graph
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_h' => 1,
'axis_min_h' => 27,
'axis_max_h' => 32,
'pad_right' => 10,
];
$width = 300;
$height = 300;
$type = 'HorizontalBarGraph';
$values = [
'Jan' => 31, 'Feb' => 28, 'Mar' => 31, 'Apr' => 30,
'May' => 31, 'Jun' => 30, 'Jul' => 31, 'Aug' => 31,
'Sep' => 30, 'Oct' => 31, 'Nov' => 30, 'Dec' => 31,
];
$hot = ['red','yellow'];
$warm = ['yellow','blue','white'];
$cold = ['blue','white'];
$colours = [$cold,$cold,$cold,$warm,$hot,$hot,$hot,$hot,$warm,$warm,$cold,$cold];
$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.