Blame view

site/jpgraph/Examples/new_bar1.php 1.17 KB
8ec98c9f   Guillaume   MAJ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
  <?php // content="text/plain; charset=utf-8"
  require_once ('jpgraph/jpgraph.php');
  require_once ('jpgraph/jpgraph_bar.php');
  
  $data1y=array(47,80,40,116);
  $data2y=array(61,30,82,105);
  $data3y=array(115,50,70,93);
  
  
  // Create the graph. These two calls are always required
  $graph = new Graph(350,200,'auto');
  $graph->SetScale("textlin");
  
  $theme_class=new UniversalTheme;
  $graph->SetTheme($theme_class);
  
  $graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135));
  $graph->SetBox(false);
  
  $graph->ygrid->SetFill(false);
  $graph->xaxis->SetTickLabels(array('A','B','C','D'));
  $graph->yaxis->HideLine(false);
  $graph->yaxis->HideTicks(false,false);
  
  // Create the bar plots
  $b1plot = new BarPlot($data1y);
  $b2plot = new BarPlot($data2y);
  $b3plot = new BarPlot($data3y);
  
  // Create the grouped bar plot
  $gbplot = new GroupBarPlot(array($b1plot,$b2plot,$b3plot));
  // ...and add it to the graPH
  $graph->Add($gbplot);
  
  
  $b1plot->SetColor("white");
  $b1plot->SetFillColor("#cc1111");
  
  $b2plot->SetColor("white");
  $b2plot->SetFillColor("#11cccc");
  
  $b3plot->SetColor("white");
  $b3plot->SetFillColor("#1111cc");
  
  $graph->title->Set("Bar Plots");
  
  // Display the graph
  $graph->Stroke();
  ?>