Average lines example

The code below is the source for this graph.

<?php
// Average lines example
require_once 'SVGGraph/autoloader.php';

$settings = [
  'back_stroke_width' => 0,
  'back_shadow' => 3,
  'back_colour' => 'white',
  'auto_fit' => true,
  'axis_font' => 'Arial',
  'axis_font_size' => 12,
  'axis_font_weight' => 'bold',
  'axis_text_space' => 5,
  'bar_space' => 15,
  'stroke_width' => 2,
  'stroke_colour' => 'fillColour/brightness(-20%)',
  'structure' => [
    'key' => 0, 'value' => [1, 2, 3,],
  ],
  'show_average' => true,
  'average_title_callback' => function($d, $a) { return sprintf('Average: %.2F', $a); },
  'average_above' => [false, false, true],
  'average_opacity' => 0.8,
  'average_title_colour' => 'fillColour/brightness(40%)',
  'average_title_weight' => 'bold',
  'average_title_position' => 'outside right',
  'pad_right' => 80,
  'graph_title' => 'GroupedBar3DGraph with average lines',
  'graph_subtitle' => 'With shadow and subtitle too',
  'graph_subtitle_font_size' => 11,
  'graph_title_space' => 1,
];

$values = [
  [0, 55, 54, 11 ],
  [1, 34, 20, 11 ],
  [2, 155, 19, 12 ],
  [3, 98, 75, 100 ],
  [4, 122, 54, 99 ],
  [5, 85, 10, 13 ],
  [6, 94, 15, 15 ],
  [7, 112, 45, 11 ],
  [8, 120, 56, 12 ],
  [9, 88, 48, 11 ],
];

$graph = new Goat1000\SVGGraph\SVGGraph(670, 300, $settings);
$graph->values($values);
$graph->colourRangeHexHSL(0, 'red/saturation(180%)/brightness(150%)', 'red/saturation(60%)');
$graph->colourRangeHexHSL(1, 'green/saturation(180%)/brightness(150%)', 'green/saturation(60%)');
$graph->colourRangeHexHSL(2, 'blue/saturation(180%)/brightness(150%)', 'blue/saturation(60%)');
$graph->render('GroupedBar3DGraph');

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.