Text figure markers example
The code below is the source for this graph.
<?php
// Text figure markers example
require_once 'SVGGraph/autoloader.php';
$settings = [
'back_stroke_width' => 0,
'back_shadow' => 3,
'back_colour' => 'white',
'auto_fit' => true,
'axis_font' => 'Arial',
'axis_font_size' => 12,
'axis_font_weight' => 'bold',
'axis_text_space' => 5,
'line_stroke_width' => 1,
'show_tooltips' => false,
'structure' => [
'key' => 0, 'value' => [ 1, 2, 3,],
],
'axis_zero_y' => false,
'marker_type' => ['figure:a', 'figure:b', 'figure:c'],
'datetime_keys' => true,
'minimum_grid_spacing' => 40,
'figure' => [
['surround',
['circle', 'cx' => 0, 'cy' => 0, 'r' => 8, 'fill' => '#eef'],
],
['a',
['figure', 'x' => 0, 'y' => 0, 'name' => 'surround'],
['text', 'x' => 0, 'y' => 5, 'text' => 'A', 'text_align' => 'centre'],
],
['b',
['figure', 'x' => 0, 'y' => 0, 'name' => 'surround'],
['text', 'x' => 0, 'y' => 5, 'text' => 'B', 'text_align' => 'centre'],
],
['c',
['figure', 'x' => 0, 'y' => 0, 'name' => 'surround'],
['text', 'x' => 0, 'y' => -15, 'text' => "If you\ncan read this\nyou are too\nclose",
'text_align' => 'centre', 'transform' => 'scale(0.18)'],
],
],
'shape' => [
'text', 'x' => 60, 'y' => 40, 'text' => "A label would be better,\nbut this works",
],
];
$values = [
["2008-05-02", 318.6, 585.2, 1200,],
["2008-06-13", 134.8, 263.4, ],
["2010-05-07", 312.4, 623.9, ],
["2011-05-06", 181, 449.3, 900,],
["2011-07-22", 176.7, 370.6, ],
["2012-05-04", 623.4, 1519, ],
["2013-05-03", 409, 1215, 1600, ],
["2013-11-08", 206.4, 644.6, ],
["2014-04-04", 259.8, 714.3, ],
["2014-08-01", 333.2, 773.3, ],
["2015-05-01", 459, 1405, ],
["2015-07-17", 180.2, 519.3, 1200],
];
$graph = new Goat1000\SVGGraph\SVGGraph(670, 300, $settings);
$graph->values($values);
$graph->colours(['red/saturation(180%)/brightness(150%)',
'orange/brightness(80%)', '#88f']);
$graph->render('MultiSteppedLineGraph');
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.