Structured data labels
The code below is the source for this graph.
<?php
// Structured data labels
require_once 'SVGGraph/autoloader.php';
$settings = [
'auto_fit' => true,
'back_colour' => '#eee',
'back_stroke_width' => 0,
'back_stroke_colour' => '#eee',
'show_data_labels' => true,
'data_label_type' => ['plain', 'box', 'bubble', 'line',
'circle', 'square', 'linecircle', 'linebox', 'linesquare', 'line2'],
'data_label_space' => 5,
'data_label_back_colour' => ['#ccc', null, null, null, null,
null, null, null, null, null],
'marker_size' => 3,
'bar_space' => 1,
'group_space' => 0,
'show_tooltips' => false,
'axis_font_size' => 12,
'structure' => [
'key' => 0, 'value' => 1,
'data_label_type' => 'dlt',
'data_label_padding' => 'dlp',
'data_label_round' => 'dlr',
'data_label_position' => 'dlpos',
'data_label_fill' => 'dlbg',
'data_label_font' => 'dlf',
'data_label_font_adjust' => 'dlfa',
'label' => 'l',
],
'data_label_back_colour' => null,
'data_label_font_size' => 12,
];
$w = 670;
$type = 'BarGraph';
$values = [
[0, 5, 'dlt' => 'box',],
[1, 6],
[2, 6, 'dlpos' => 'left'],
[3, 7, 'dlt' => 'bubble'],
[4, 6, 'dlt' => 'bubble', 'dlp' => 10, 'dlr' => 8],
[5, 5],
[6, 3, 'dlpos' => 'above', 'dlt' => 'bubble',
'dlf' => 'Times New Roman', 'dlfa' => 0.45,
'dlp' => 10, 'dlr' => 10,
'l' => "Label\nText", 'dlbg' => ['#99f','#fff','#99f','h']],
];
$graph = new Goat1000\SVGGraph\SVGGraph($w, 200, $settings);
$graph->values($values);
$graph->colourRangeHexHSL(0, '#f33', '#f3f');
$graph->colourRangeHexHSL(1, '#36f', '#3ff');
$graph->colourRangeHexHSL(2, '#fc0', '#fff');
$graph->colourRangeHexHSL(3, '#0f0', '#393');
$graph->render($type);
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.