ScatterGraph - height against age
The code below is the source for this graph.
<?php
// ScatterGraph - height against age
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' => '#111',
'axis_overlap' => 2,
'grid_colour' => '#999',
'label_colour' => '#000',
'axis_font' => 'Arial',
'axis_font_size' => 12,
'pad_bottom' => 5,
'minimum_grid_spacing' => 20,
'show_subdivisions' => true,
'show_grid_subdivisions' => true,
'grid_subdivision_colour' => '#ccc',
'bar_label_colour' => '#fff',
'bar_label_font_size' => 11,
'structure' => [
'key' => 'Age',
'value' => 'Height',
'tooltip' => 'Name',
],
];
$type = 'ScatterGraph';
$width = 300;
$height = 200;
$colours = [ [ 'red', 'yellow' ], [ 'blue', 'white' ] ];
$values = [
['Id' => 1, 'Name' => 'Bob', 'Age' => 51, 'Height' => 170],
['Id' => 2, 'Name' => 'Alice', 'Age' => 45, 'Height' => 175],
['Id' => 3, 'Name' => 'Frank', 'Age' => 32, 'Height' => 182],
['Id' => 4, 'Name' => 'Susan', 'Age' => 35, 'Height' => 185],
];
$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.