SHOW:
|
|
- or go back to the newest paste.
1 | // include your classes above this code | |
2 | $data1y=array(10,55,50,110); | |
3 | ||
4 | // Create the graph. These two calls are always required | |
5 | $graph = new Graph(800,457,'auto'); | |
6 | $graph->SetScale("textlin"); | |
7 | ||
8 | $theme_class=new UniversalTheme; | |
9 | $graph->SetTheme($theme_class); | |
10 | ||
11 | // $graph->yaxis->SetTickPositions(array(0,30,60,90,120,150), array(15,45,75,105,135)); | |
12 | $graph->SetBox(false); | |
13 | ||
14 | $graph->ygrid->SetFill(false); | |
15 | $graph->xaxis->SetTickLabels(array('Minimum Score', 'Section Average', 'Your Score', 'Maximum Score')); | |
16 | $graph->yaxis->HideLine(false); | |
17 | $graph->yaxis->HideTicks(false,false); | |
18 | ||
19 | // Create the bar plots | |
20 | $b1plot = new BarPlot($data1y); | |
21 | - | // Create the grouped bar plot |
21 | + | // ...and add it to the graph |
22 | - | // $gbplot = new GroupBarPlot(array($b1plot)); |
22 | + | |
23 | - | // ...and add it to the graPH |
23 | + | |
24 | $graph->title->Set("Demo Graph Test"); | |
25 | ||
26 | $contentType = 'image/png'; | |
27 | - | // $b1plot->SetColor("white"); |
27 | + | |
28 | - | // $b1plot->SetFillColor("#cc1111"); |
28 | + | |
29 | // @see http://stackoverflow.com/a/9084110/126431 | |
30 | ob_start(); // start buffering | |
31 | $graph->img->Stream(); // print data to buffer | |
32 | $graphData = ob_get_contents(); // retrieve buffer contents | |
33 | ob_end_clean(); // stop buffer | |
34 | ||
35 | // outputting this in a HTML tag would work like this: | |
36 | // $graphBase64 = "data:$contentType;base64," . base64_encode($graphData); | |
37 | // echo sprintf('<img src="%s" alt="Graph">', $graphBase64); | |
38 | ||
39 | $pdf->Image('@'.$graphData); |