Candlestick graph with some made-up data
The code below is the source for this graph.
<?php
// Candlestick graph with some made-up data
require_once 'SVGGraph/autoloader.php';
$options = [
'back_stroke_width' => 0,
'back_shadow' => 3,
'back_colour' => 'white',
'auto_fit' => true,
'structure' => [
'key' => 0,
'value' => 1, // close
'open' => 2,
'low' => 3,
'high' => 4,
],
'axis_font' => 'Arial',
'axis_text_angle_h' => 90,
'bar_space' => 5,
'axis_min_v' => 1700,
'show_tooltips' => false,
'show_shadow' => true,
'shadow_opacity' => 0.3,
];
$close = 1820;
$seed = 1241231;
srand($seed);
$values = [];
for($i = 1; $i < 32; ++$i) {
$date = sprintf('Oct %02d', $i);
$open = $close;
$close = $close + rand(-30, 40);
$low = min($open, $close) - rand(0, 40);
$high = max($open, $close) + rand(0, 80);
$values[] = [$date, $close, $open, $low, $high];
}
$g = new \Goat1000\SVGGraph\SVGGraph(670, 300, $options);
$g->values($values);
// colour set for rising prices
$g->colourRangeHexHSL(0, '#0c4', '#0c9');
// colour set for falling prices
$g->colourRangeHexHSL(1, '#f00', '#f55');
$g->render('CandlestickGraph');
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.