Colour set and range functions
The code below is the source for this graph.
<?php
// Colour set and range functions
require_once 'SVGGraph/autoloader.php';
$settings = [
'auto_fit' => true,
'back_stroke_width' => 2,
'show_axis_text_h' => false,
'grid_division_v' => 1,
'show_tooltips' => false,
'bar_space' => 5,
'stroke_width' => 0,
'back_colour' => ['#ddd', 'pattern' => 'polkadot3', 'size' => 20],
'show_grid' => true,
'grid_colour' => '#666',
];
$columns = 24;
$values = [];
for($i = 0; $i < $columns; ++$i) {
$values[0][$i] = 1;
$values[1][$i] = 1;
$values[2][$i] = 1;
$values[3][$i] = 1;
$values[4][$i] = 0.75 + 0.25 * cos($i * 2 * M_PI / $columns);
}
$graph = new Goat1000\SVGGraph\SVGGraph(670, 200, $settings);
$colours = [
'red',
'#0f0',
['red','blue'],
['green', 'white', 'h'],
['blue', 'white:0.1', 'blue'],
['red', 'pattern' => 'polkadot'],
['green', 'pattern' => 'line', 'angle' => 45],
'blue',
];
$graph->colourSet(0, $colours);
$graph->colourRangeHexRGB(1, '#f00', '#00f');
$graph->colourRangeHexHSL(2, '#f00', '#00f');
$graph->colourRangeHexHSL(3, '#f00', '#00f', 1);
$graph->values($values);
$graph->render('StackedBarGraph');
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.