[42] | 1 | <?php // content="text/plain; charset=utf-8"
|
---|
| 2 | require_once ('jpgraph/jpgraph.php');
|
---|
| 3 | require_once ('jpgraph/jpgraph_bar.php');
|
---|
| 4 | require_once ('jpgraph/jpgraph_line.php');
|
---|
| 5 |
|
---|
| 6 | //bar1
|
---|
| 7 | $data1y=array(115,130,135,130,110,130,130,150,130,130,150,120);
|
---|
| 8 | //bar2
|
---|
| 9 | $data2y=array(180,200,220,190,170,195,190,210,200,205,195,150);
|
---|
| 10 | //bar3
|
---|
| 11 | $data3y=array(220,230,210,175,185,195,200,230,200,195,180,130);
|
---|
| 12 | $data4y=array(40,45,70,80,50,75,70,70,80,75,80,50);
|
---|
| 13 | $data5y=array(20,20,25,22,30,25,35,30,27,25,25,45);
|
---|
| 14 | //line1
|
---|
| 15 | $data6y=array(50,58,60,58,53,58,57,60,58,58,57,50);
|
---|
| 16 | foreach ($data6y as &$y) { $y -=10; }
|
---|
| 17 |
|
---|
| 18 | // Create the graph. These two calls are always required
|
---|
| 19 | $graph = new Graph(750,320,'auto');
|
---|
| 20 | $graph->SetScale("textlin");
|
---|
| 21 | $graph->SetY2Scale("lin",0,90);
|
---|
| 22 | $graph->SetY2OrderBack(false);
|
---|
| 23 |
|
---|
| 24 | $graph->SetMargin(35,50,20,5);
|
---|
| 25 |
|
---|
| 26 | $theme_class = new UniversalTheme;
|
---|
| 27 | $graph->SetTheme($theme_class);
|
---|
| 28 |
|
---|
| 29 | $graph->yaxis->SetTickPositions(array(0,50,100,150,200,250,300,350), array(25,75,125,175,275,325));
|
---|
| 30 | $graph->y2axis->SetTickPositions(array(30,40,50,60,70,80,90));
|
---|
| 31 |
|
---|
| 32 | $months = $gDateLocale->GetShortMonth();
|
---|
| 33 | $months = array_merge(array_slice($months,3,9), array_slice($months,0,3));
|
---|
| 34 | $graph->SetBox(false);
|
---|
| 35 |
|
---|
| 36 | $graph->ygrid->SetFill(false);
|
---|
| 37 | $graph->xaxis->SetTickLabels(array('A','B','C','D'));
|
---|
| 38 | $graph->yaxis->HideLine(false);
|
---|
| 39 | $graph->yaxis->HideTicks(false,false);
|
---|
| 40 | // Setup month as labels on the X-axis
|
---|
| 41 | $graph->xaxis->SetTickLabels($months);
|
---|
| 42 |
|
---|
| 43 | // Create the bar plots
|
---|
| 44 | $b1plot = new BarPlot($data1y);
|
---|
| 45 | $b2plot = new BarPlot($data2y);
|
---|
| 46 |
|
---|
| 47 | $b3plot = new BarPlot($data3y);
|
---|
| 48 | $b4plot = new BarPlot($data4y);
|
---|
| 49 | $b5plot = new BarPlot($data5y);
|
---|
| 50 |
|
---|
| 51 | $lplot = new LinePlot($data6y);
|
---|
| 52 |
|
---|
| 53 | // Create the grouped bar plot
|
---|
| 54 | $gbbplot = new AccBarPlot(array($b3plot,$b4plot,$b5plot));
|
---|
| 55 | $gbplot = new GroupBarPlot(array($b1plot,$b2plot,$gbbplot));
|
---|
| 56 |
|
---|
| 57 | // ...and add it to the graPH
|
---|
| 58 | $graph->Add($gbplot);
|
---|
| 59 | $graph->AddY2($lplot);
|
---|
| 60 |
|
---|
| 61 | $b1plot->SetColor("#0000CD");
|
---|
| 62 | $b1plot->SetFillColor("#0000CD");
|
---|
| 63 | $b1plot->SetLegend("Cliants");
|
---|
| 64 |
|
---|
| 65 | $b2plot->SetColor("#B0C4DE");
|
---|
| 66 | $b2plot->SetFillColor("#B0C4DE");
|
---|
| 67 | $b2plot->SetLegend("Machines");
|
---|
| 68 |
|
---|
| 69 | $b3plot->SetColor("#8B008B");
|
---|
| 70 | $b3plot->SetFillColor("#8B008B");
|
---|
| 71 | $b3plot->SetLegend("First Track");
|
---|
| 72 |
|
---|
| 73 | $b4plot->SetColor("#DA70D6");
|
---|
| 74 | $b4plot->SetFillColor("#DA70D6");
|
---|
| 75 | $b4plot->SetLegend("All");
|
---|
| 76 |
|
---|
| 77 | $b5plot->SetColor("#9370DB");
|
---|
| 78 | $b5plot->SetFillColor("#9370DB");
|
---|
| 79 | $b5plot->SetLegend("Single Only");
|
---|
| 80 |
|
---|
| 81 | $lplot->SetBarCenter();
|
---|
| 82 | $lplot->SetColor("yellow");
|
---|
| 83 | $lplot->SetLegend("Houses");
|
---|
| 84 | $lplot->mark->SetType(MARK_X,'',1.0);
|
---|
| 85 | $lplot->mark->SetWeight(2);
|
---|
| 86 | $lplot->mark->SetWidth(8);
|
---|
| 87 | $lplot->mark->setColor("yellow");
|
---|
| 88 | $lplot->mark->setFillColor("yellow");
|
---|
| 89 |
|
---|
| 90 | $graph->legend->SetFrameWeight(1);
|
---|
| 91 | $graph->legend->SetColumns(6);
|
---|
| 92 | $graph->legend->SetColor('#4E4E4E','#00A78A');
|
---|
| 93 |
|
---|
| 94 | $band = new PlotBand(VERTICAL,BAND_RDIAG,11,"max",'khaki4');
|
---|
| 95 | $band->ShowFrame(true);
|
---|
| 96 | $band->SetOrder(DEPTH_BACK);
|
---|
| 97 | $graph->Add($band);
|
---|
| 98 |
|
---|
| 99 | $graph->title->Set("Combineed Line and Bar plots");
|
---|
| 100 |
|
---|
| 101 | // Display the graph
|
---|
| 102 | $graph->Stroke();
|
---|
| 103 | ?>
|
---|