Label positions
The code below is the source for this graph.
<?php
// Label positions
require_once 'SVGGraph/autoloader.php';
$w = 670;
$left = 150;
$centre = $w / 2;
$right = $w - $left;
$rwidth = $right - $left;
$h = 250;
$top = 30;
$bottom = $h - $top;
$middle = $h / 2;
$rheight = $bottom - $top;
$settings = [
'auto_fit' => true,
'back_colour' => '#eee',
'back_stroke_width' => 0,
'show_data_labels' => true,
'data_label_space' => 4,
'data_label_type' => 'box',
'data_label_outline_colour' => '#ccc',
'data_label_shadow_opacity' => 0,
'data_label_font_size' => 11,
'shape' => [
[
'rect',
'x' => $left, 'y' => $top,
'width' => $rwidth, 'height' => $rheight,
'fill' => ['#f0f0f0', 'pattern' => 'check']
],
],
'label' => [
[
$centre, $middle, 'Bar', 'position' => 'centre',
'font' => 'Arial Black',
'font_weight' => 'bold',
'font_size' => 72,
'type' => 'plain',
'colour' => '#ccc',
],
[$left, $top, "outside top left", 'position' => 'top left'],
[$left, $top, "outside top inside left", 'position' => 'top right'],
[$centre, $top, "outside top", 'position' => 'top'],
[$right, $top, "outside top inside right", 'position' => 'top left'],
[$right, $top, "outside top right", 'position' => 'top right'],
[$left, $top, "inside top outside left", 'position' => 'bottom left'],
[$left, $top, "top left", 'position' => 'bottom right'],
[$centre, $top, "top", 'position' => 'bottom'],
[$right, $top, "top right", 'position' => 'bottom left'],
[$right, $top, "inside top outside right", 'position' => 'bottom right'],
[$left, $middle, "outside left", 'position' => 'left'],
[$left, $middle, "left", 'position' => 'right'],
[$centre, $middle, "centre", 'position' => 'centre'],
[$right, $middle, "right", 'position' => 'left'],
[$right, $middle, "outside right", 'position' => 'right'],
[$left, $bottom, "inside bottom outside left", 'position' => 'top left'],
[$left, $bottom, "bottom left", 'position' => 'top right'],
[$centre, $bottom, "bottom", 'position' => 'top'],
[$right, $bottom, "bottom right", 'position' => 'top left'],
[$right, $bottom, "inside bottom outside right", 'position' => 'top right'],
[$left, $bottom, "outside bottom left", 'position' => 'bottom left'],
[$left, $bottom, "outside bottom inside left", 'position' => 'bottom right'],
[$centre, $bottom, "outside bottom", 'position' => 'bottom'],
[$right, $bottom, "outside bottom inside right", 'position' => 'bottom left'],
[$right, $bottom, "outside bottom right", 'position' => 'bottom right'],
],
];
$graph = new Goat1000\SVGGraph\SVGGraph($w, $h, $settings);
$graph->render('EmptyGraph');
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.