6. Legend on MultiLineGraph

The code below is the source for this graph.

<?php
// 6. Legend on MultiLineGraph
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',
  'grid_back_stripe' => true,
  'grid_back_colour' => '#ccf',
  'label_colour' => '#000',
  'axis_font' => 'Arial',
  'axis_font_size' => 10,
  'fill_under' => true,
  'pad_right' => 10,
  'pad_left' => 10,
  'marker_size' => 5,
  'marker_type' => ['pentagon','triangle','square'],
  'marker_colour' => ['blue','purple','green'],
  'minimum_grid_spacing' => 20,
  'graph_title' => 'Wakefulness by hour',
  'label_x' => 'Hour of the day',
  'label_y' => 'Eye openness',
  'axis_max_v' => 10,
  'legend_entry_height' => 10,
  'legend_title' => 'Legend',
  'legend_text_side' => 'left',
  'legend_position' => 'top left 4 4',
  'legend_round' => 5,
  'legend_back_colour' => '#f0f0ff',
  'legend_entries' => [
    'Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sunday'
  ],
];

$width = 300;
$height = 200;
$type = 'MultiLineGraph';
$values = [
  [1,0,0,0,0,0,0,2,8,9,8,7,5],
  [2,1,1,0,0,1,1,4,6,7,6,4,4],
  [3,2,1.5,0.5,0.5,1.5,1.5,3,6,6,5,3,1],
];

$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.