6. Horizontal graph with same options

The code below is the source for this graph.

<?php
// 6. Horizontal graph with same options
require_once 'SVGGraph/autoloader.php';

$settings = [
  'auto_fit' => true,
  'back_colour' => '#fff',
  'back_stroke_width' => 2,
  'back_stroke_colour' => '#000',
  'stroke_colour' => '#000',
  'axis_colour' => '#333',
  'axis_overlap' => 3,
  'grid_colour' => '#999',
  'label_colour' => '#000',
  'axis_font' => 'Arial',
  'axis_font_size' => 10,
  'fill_under' => true,
  'pad_right' => 10,
  'pad_left' => 10,
  'minimum_grid_spacing' => 20,
  'bar_space' => 5,
  'graph_title' => 'The graph title',
  'label_h' => "Days of the week",
  'label_v' => 'Hours awake',
  'minimum_grid_spacing_h' => 25,
  'minimum_grid_spacing_v' => 15,
];

$width = 300;
$height = 200;
$type = 'HorizontalBarGraph';
$values = [
  'Mon' => 18, 'Tue' => 17, 'Wed' => 14, 'Thu' => 15,
  'Fri' => 13, 'Sat' => 16, 'Sun' => 12
];

$colours = [
  ['red','orange','h'],
  ['orange','yellow','h'],
  ['yellow','green','h'],
  ['green','blue','h'],
  ['blue','indigo','h'],
  ['indigo','violet','h'],
  ['violet','black','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.

This site uses cookies - details here.