1 | <?php
|
---|
2 | include ("../jpgraph.php");
|
---|
3 | include ("../jpgraph_bar.php");
|
---|
4 | include ("../jpgraph_table.php");
|
---|
5 |
|
---|
6 | $datay = array(
|
---|
7 | array('Jan','Feb','Mar','Apr','May','Jun'),
|
---|
8 | array(12,18,19,7,17,6),
|
---|
9 | array(3,5,2,7,5,25),
|
---|
10 | array(6,1.5,2.4,2.1,6.9,12.3))
|
---|
11 | ;
|
---|
12 |
|
---|
13 | // Some basic defines to specify the shape of the bar+table
|
---|
14 | $nbrbar = 6;
|
---|
15 | $cellwidth = 50;
|
---|
16 | $tableypos = 200;
|
---|
17 | $tablexpos = 60;
|
---|
18 | $tablewidth = $nbrbar*$cellwidth;
|
---|
19 | $rightmargin = 30;
|
---|
20 |
|
---|
21 | // Overall graph size
|
---|
22 | $height = 320;
|
---|
23 | $width = $tablexpos+$tablewidth+$rightmargin;
|
---|
24 |
|
---|
25 | // Create the basic graph.
|
---|
26 | $graph = new Graph($width,$height);
|
---|
27 | $graph->img->SetMargin($tablexpos,$rightmargin,30,$height-$tableypos);
|
---|
28 | $graph->SetScale("textlin");
|
---|
29 | $graph->SetMarginColor('white');
|
---|
30 |
|
---|
31 | // Setup titles and fonts
|
---|
32 | $graph->title->Set('Bar and table');
|
---|
33 | $graph->title->SetFont(FF_VERDANA,FS_NORMAL,14);
|
---|
34 | $graph->yaxis->title->Set("Flow");
|
---|
35 | $graph->yaxis->title->SetFont(FF_ARIAL,FS_NORMAL,12);
|
---|
36 | $graph->yaxis->title->SetMargin(10);
|
---|
37 |
|
---|
38 | // Create the bars and the accbar plot
|
---|
39 | $bplot = new BarPlot($datay[3]);
|
---|
40 | $bplot->SetFillColor("orange");
|
---|
41 | $bplot2 = new BarPlot($datay[2]);
|
---|
42 | $bplot2->SetFillColor("red");
|
---|
43 | $bplot3 = new BarPlot($datay[1]);
|
---|
44 | $bplot3->SetFillColor("darkgreen");
|
---|
45 | $accbplot = new AccBarPlot(array($bplot,$bplot2,$bplot3));
|
---|
46 | $accbplot->value->Show();
|
---|
47 | $graph->Add($accbplot);
|
---|
48 |
|
---|
49 | //Setup the table
|
---|
50 | $table = new GTextTable();
|
---|
51 | $table->Set($datay);
|
---|
52 | $table->SetPos($tablexpos,$tableypos+1);
|
---|
53 |
|
---|
54 | // Basic table formatting
|
---|
55 | $table->SetFont(FF_ARIAL,FS_NORMAL,10);
|
---|
56 | $table->SetAlign('right');
|
---|
57 | $table->SetMinColWidth($cellwidth);
|
---|
58 | $table->SetNumberFormat('%0.1f');
|
---|
59 |
|
---|
60 | // Format table header row
|
---|
61 | $table->SetRowFillColor(0,'teal@0.7');
|
---|
62 | $table->SetRowFont(0,FF_ARIAL,FS_BOLD,11);
|
---|
63 | $table->SetRowAlign(0,'center');
|
---|
64 |
|
---|
65 | // .. and add it to the graph
|
---|
66 | $graph->Add($table);
|
---|
67 |
|
---|
68 | $graph->Stroke();
|
---|
69 |
|
---|
70 | ?>
|
---|