Gantt chart with multiple task bars/milestones
The code below is the source for this graph.
<?php
// Gantt chart with multiple task bars/milestones
require_once 'SVGGraph/autoloader.php';
$options = [
'auto_fit' => true,
'structure' => [
'key' => 0, 'axis_text' => 1,
'value' => [2,4,6,8,10],
'end' => [3,5,7,9,11],
'complete' => ['c1','c2','c3','c4','c5'],
'milestone' => ['m1','m2','m3','m4','m5'],
'label' => ['l1','l2','l3','l4','l5'],
],
'bar_round' => 10,
'show_data_labels' => true,
'pad_right' => 20,
'gantt_today' => false,
];
$values = [
['A0', 'A simple task', '2022-04-01', '2022-04-13', '2022-05-01', '2022-05-15', '2022-04-20',
'c1' => 50, 'c2' => 25, 'm3' => true],
['A2a', 'Testing', '2022-04-13', '2022-04-15', '2022-05-15', '2022-05-17', '2022-05-21',
'm3' => true, 'l3' => 'OK'],
['A1', 'Second task', '2022-04-05', '2022-04-20', 'c1' => 20],
['A2', 'Testing', '2022-04-20', '2022-04-21'],
['A3', 'Third task', '2022-05-02', '2022-05-17', 'c1' => 60],
['A4', 'Final task', '2022-05-16', '2022-05-20', 'c1' => 78],
['A5', 'Testing', '2022-05-20', '2022-05-20',
'2022-04-05', null, '2022-04-19', 'm2' => true, 'm3' => true,
'l2' => 'Test 1', 'l3' => 'Test 2',],
];
$graph = new Goat1000\SVGGraph\SVGGraph(670, 'auto', $options);
$graph->values($values);
$graph->colourRangeHexHSL(0, '#c50', '#c59');
$graph->colourRangeHexHSL(1, '#6a0', '#6a9');
$graph->render('GanttChart');
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.