Auto-fit graph included in page
The code below is the source for this graph.
<?php
// Auto-fit graph included in page
require_once 'SVGGraph/autoloader.php';
$settings = [
'grid_division_v' => 0.5,
'grid_division_h' => 2,
'decimal_digits_y' => 1,
'bar_space' => 6,
'back_stroke_width' => 0,
'stroke_width' => 0,
'show_grid' => true,
'grid_colour' => '#aaa',
'auto_fit' => true,
'axis_font_size' => 24,
'axis_text_space' => 10,
'tooltip_font_size' => 24,
'tooltip_offset' => 30,
'crosshairs' => true,
'crosshairs_text_font_size' => 20,
];
$columns = 24;
$values = [];
for($i = 0; $i < $columns; ++$i) {
$s = 0.25 * cos($i * 2 * M_PI / $columns);
$values[0][$i] = 1 - $s;
$values[1][$i] = 1 + $s;
}
$graph = new Goat1000\SVGGraph\SVGGraph(700, 220, $settings);
$graph->colourRangeHexHSL(0, '#f00', '#00f', 1);
$graph->colourRangeHexRGB(1, '#f00', '#00f');
$graph->values($values);
echo $graph->fetch('GroupedBarGraph');
echo $graph->fetchJavascript();
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.