Beispiel 26 - Guideline

Mit einer Guideline kann man z.B. eine Durchschnittslinie ziehen. Eine Guideline ist immer genau horizontal.

Quellcode zum Beispiel

<?php
// siehe https://www.goat1000.com/svggraph-source/guideline1
// SVGGraph 3 uses an autoloader and namespace
// require 'svggraph/autoloader.php';
require '../../svggraph/autoloader.php';
$settings = array(
  'auto_fit' => true,
  'axis_colour' => '#333',
  'axis_font' => 'Arial',
  'axis_font_size' => 10,
  'axis_overlap' => 3,
  'axis_min_v' => 0,
  'axis_max_v' => 700,
  'axis_text_angle_h' => 90,
  'back_colour' => '#eee',
  'back_stroke_width' => 0,
  'back_stroke_colour' => '#eee',
  'data_label_font_size' => 8,
  //'data_label_type' => 'linecircle',
  'stroke_colour' => '#669',
  'graph_title'=> 'Sterblichkeit nach Bundesländern je Mio Einwohner bis 27.12.2020',
  'grid_colour' => '#bbb',
  'label_colour' => '#000',
  'marker_type' => 'circle',
  'marker_size' => 0,
  'marker_colour' => 'blue',
  'minimum_grid_spacing' => 20,
  'pad_right' => 10,
  'pad_left' => 10,
  'show_data_labels' => true,
  'guideline_above' => true,
  'guideline' => array(358, "Durchschnitt Deutschland 358 pro Mio", 'colour' => '#066'),
);
$settings['structured_data'] = true;
$settings['structure'] = array(
  'key' => 0,
  'value' => array(1,2),
  'legend_text' => array('l1', 'l2')
);
$settings['legend_position'] = "top right -100 -3";
$settings['legend_entries'] = array(
  'Bis 37.KW','Ab 38.KW'
);

// $width = 600;
// $height = 200;

$values = array(
  array('BW', 168,232),
  array('BY', 201,272),
  array('BE', 61,246),
  array('BB', 67,243),
  array('HB', 85,182),
  array('HH', 145,172),
  array('HE', 86,309),
  array('MV', 12,76),
  array('NI', 83,140),
  array('NW', 102,230),
  array('RP', 60,247),
  array('SL', 177,234),
  array('SN', 56,609),
  array('ST', 30,202),
  array('SH', 55,71),
  array('TH', 88,300),
);

$colours = [ ['yellow', 'white'],['red', 'white'] ];

$graph = new Goat1000\SVGGraph\SVGGraph(400, 300, $settings);
$graph->colours($colours);
$graph->values($values);
$graph->Render('StackedBarGraph');
?>