ScatterGraph

The code below is the source for this graph.

<?php
// ScatterGraph
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' => '#333',
  'axis_overlap' => 2,
  'grid_colour' => '#666',
  'label_colour' => '#000',
  'axis_font' => 'Arial',
  'axis_font_size' => 10,
  'pad_right' => 20,
  'pad_left' => 20,
  'marker_type' => ['circle','square'],
  'marker_size' => 3,
  'marker_colour' => ['blue','red'],
  'link_base' => '/',
  'link_target' => '_top',
  'show_labels' => true,
  'label_font' => 'Arial',
  'label_font_size' => '11',
  'sort' => false,
  'show_label_amount' => true,
  'project_angle' => 45,
  'minimum_grid_spacing' => 20,
  'show_subdivisions' => true,
  'show_grid_subdivisions' => true,
  'grid_subdivision_colour' => '#ccc',
  'best_fit' => 'straight',
  'best_fit_colour' => ['red', 'blue', 'green', 'orange'],
  'best_fit_dash' => '2,2',
  'structure' => [ 'key' => 0, 'value' => 1 ],
];

$width = 300;
$height = 200;
$type = 'ScatterGraph';

// make some random-ish values
$values = [];
$my = 0.3;
$jx = 20;
$jy = 10;
$n = 1;
for($i = 30; $i < 500; $i += 5) {
  $row = [$i + rand(-$jx, $jx)];
  for($j = 0; $j < $n; ++$j) {
    $v = 0.5 + $j / $n;
    $row[] = $v * $i * $my + (rand(-$jy, $jy) * sin($i / 30));
  }
  $values[] = $row;
}

$graph = new Goat1000\SVGGraph\SVGGraph($width, $height, $settings);
$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.