1<?php // content="text/plain; charset=utf-8"
2// $Id: bar_csimex3.php,v 1.3 2002/08/31 20:03:46 aditus Exp $
3// Horiontal bar graph with image maps
4require_once '../../vendor/autoload.php';
5use Amenadiel\JpGraph\Graph;
6use Amenadiel\JpGraph\Plot;
7
8$data1y = array(5, 8, 19, 3, 10, 5);
9$data2y = array(12, 2, 12, 7, 14, 4);
10
11// Setup the basic parameters for the graph
12$graph = new Graph\Graph(400, 700);
13$graph->SetAngle(90);
14$graph->SetScale("textlin");
15
16// The negative margins are necessary since we
17// have rotated the image 90 degress and shifted the
18// meaning of width, and height. This means that the
19// left and right margins now becomes top and bottom
20// calculated with the image width and not the height.
21$graph->img->SetMargin(-80, -80, 210, 210);
22
23$graph->SetMarginColor('white');
24
25// Setup title for graph
26$graph->title->Set('Horizontal bar graph');
27$graph->title->SetFont(FF_FONT2, FS_BOLD);
28$graph->subtitle->Set("With image map\nNote: The URL just points back to this image");
29
30// Setup X-axis.
31$graph->xaxis->SetTitle("X-title", 'center');
32$graph->xaxis->title->SetFont(FF_FONT1, FS_BOLD);
33$graph->xaxis->title->SetAngle(90);
34$graph->xaxis->SetTitleMargin(30);
35$graph->xaxis->SetLabelMargin(15);
36$graph->xaxis->SetLabelAlign('right', 'center');
37
38// Setup Y-axis
39
40// First we want it at the bottom, i.e. the 'max' value of the
41// x-axis
42$graph->yaxis->SetPos('max');
43
44// Arrange the title
45$graph->yaxis->SetTitle("Turnaround (mkr)", 'center');
46$graph->yaxis->SetTitleSide(SIDE_RIGHT);
47$graph->yaxis->title->SetFont(FF_FONT2, FS_BOLD);
48$graph->yaxis->title->SetAngle(0);
49$graph->yaxis->title->Align('center', 'top');
50$graph->yaxis->SetTitleMargin(30);
51
52// Arrange the labels
53$graph->yaxis->SetLabelSide(SIDE_RIGHT);
54$graph->yaxis->SetLabelAlign('center', 'top');
55
56// Create the bar plots with image maps
57$b1plot = new Plot\BarPlot($data1y);
58$b1plot->SetFillColor("orange");
59$targ = array("bar_clsmex2.php#1", "bar_clsmex2.php#2", "bar_clsmex2.php#3",
60    "bar_clsmex2.php#4", "bar_clsmex2.php#5", "bar_clsmex2.php#6");
61$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
62$b1plot->SetCSIMTargets($targ, $alts);
63
64$b2plot = new Plot\BarPlot($data2y);
65$b2plot->SetFillColor("blue");
66$targ = array("bar_clsmex2.php#7", "bar_clsmex2.php#8", "bar_clsmex2.php#9",
67    "bar_clsmex2.php#10", "bar_clsmex2.php#11", "bar_clsmex2.php#12");
68$alts = array("val=%d", "val=%d", "val=%d", "val=%d", "val=%d", "val=%d");
69$b2plot->SetCSIMTargets($targ, $alts);
70
71// Create the accumulated bar plot
72$abplot = new Plot\AccBarPlot(array($b1plot, $b2plot));
73$abplot->SetShadow();
74
75// We want to display the value of each bar at the top
76$abplot->value->Show();
77$abplot->value->SetFont(FF_FONT1, FS_NORMAL);
78$abplot->value->SetAlign('left', 'center');
79$abplot->value->SetColor("black", "darkred");
80$abplot->value->SetFormat('%.1f mkr');
81
82// ...and add it to the graph
83$graph->Add($abplot);
84
85// Send back the HTML page which will call this script again
86// to retrieve the image.
87$graph->StrokeCSIM();
88