Bar and pie graphs in ArrayGraph
The code below is the source for this graph.
<?php
// Bar and pie graphs in ArrayGraph
require_once 'SVGGraph/autoloader.php';
$settings = [
'auto_fit' => true,
'array_graph_type' => [
'StackedBarGraph', null, null, null,
null, null, null, null,
'HorizontalBarGraph', null,
],
'array_graph_dataset' => [
[0,1,2], 2, 3, 4,
5, 6, 7, 8,
9, 10
],
'array_graph_options' => [
[], [], [], [],
[], [], [], [],
['axis_text_angle_h' => 90,], [],
],
'data_label_colour' => '#fff',
];
$values = [
[100, 100, 100, 200, 100, 200],
[50, 100, 120, 400, 100, 50],
[20, 60, 130, 120, 80, 120],
[120, 100, 100, 200, 100, 200],
[54, 100, 110, 400, 100, 40],
[26, 60, 140, 120, 80, 120],
[110, 100, 100, 240, 100, 100],
[150, 100, 120, 400, 120, 150],
[220, 60, 100, 310, 80, 120],
[120, 100, 120, 200, 110, 220],
[350, 140, 120, 400, 100, 50],
];
$width = 670;
$height = 400;
$type = 'ArrayGraph';
$graph = new Goat1000\SVGGraph\SVGGraph($width, $height, $settings);
$graph->colourRangeHexHSL(0, '#f00', '#0066ff');
$graph->colourRangeHexHSL(1, '#f03', '#999966');
$graph->colourRangeHexHSL(2, '#f30', '#306630');
$graph->colourRangeHexHSL(3, '#f3f', '#006600');
$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.