Custom labels
The code below is the source for this graph.
<?php
// Custom labels
require_once 'SVGGraph/autoloader.php';
$settings = [
'auto_fit' => true,
'marker_size' => 0,
'stroke_colour' => '#00f',
'show_tooltips' => false,
'data_label_font' => 'Courier',
'data_label_font_adjust' => 0.6,
'data_label_type' => 'box',
'data_label_space' => 10,
'data_label_padding' => 6,
'data_label_tail_length' => 'auto',
'data_label_tail_end' => 'filled',
'data_label_tail_end_width' => 18,
'data_label_tail_end_angle' => 30,
'label' => [
['g40', 'g100', 'Label above'],
['g40', 'g100', 'Label to right', 'position' => 'right'],
['g40', 'g100', 'Label to left', 'position' => 'left'],
['g40', 'g100', 'Label below', 'position' => 'bottom'],
[200, 100, "This is at (200,100]\nand on two lines", 'type' => 'bubble',
'fill' => ['#ff6','#ffc','#ff6','h'], 'round' => 10,
],
[280, 80, "A label pointing\nto another label", 'type' => 'linebox',
'fill' => '#cef', 'position' => '200 50', 'round' => 10, 'padding' => 10,
'tail_end_width' => 20,
],
[100, 370, 'Labels', 'type' => 'linebox', 'position' => '100 -100',],
[100, 350, 'are', 'type' => 'linebox', 'position' => '100 -60',],
[100, 330, 'drawn', 'type' => 'linebox', 'position' => '100 -20',],
[100, 310, 'in', 'type' => 'linebox', 'position' => '100 20',],
[100, 290, 'array', 'type' => 'linebox', 'position' => '100 60',],
[100, 270, 'order', 'type' => 'linebox', 'position' => '100 100',],
],
];
$values = [];
$count = 80;
$max = 100;
for($i = 0; $i <= $count; ++$i) {
$values[] = $max + $max * cos(2 * $i * M_PI / $count);
}
$graph = new Goat1000\SVGGraph\SVGGraph(670, 400, $settings);
$graph->colourRangeHexHSL(0, '#f00', '#f0f', true);
$graph->values($values);
$graph->render('LineGraph');
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.