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