View difference between Paste ID: uQAAHEUy and GNk53PpJ
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));
11+
12
13
$graph->ygrid->SetFill(false);
14
$graph->xaxis->SetTickLabels(array('Minimum Score', 'Section Average', 'Your Score', 'Maximum Score'));
15
$graph->yaxis->HideLine(false);
16
$graph->yaxis->HideTicks(false,false);
17
18
// Create the bar plots
19
$b1plot = new BarPlot($data1y);
20
// ...and add it to the graph
21
$graph->Add($b1plot);
22
23
$graph->title->Set("Demo Graph Test");
24
25
$contentType = 'image/png';
26
$gdImgHandler = $graph->Stroke(_IMG_HANDLER);
27
28
// @see http://stackoverflow.com/a/9084110/126431
29
ob_start();                        // start buffering
30
$graph->img->Stream();             // print data to buffer
31
$graphData = ob_get_contents();   // retrieve buffer contents
32
ob_end_clean();                    // stop buffer
33
34
// outputting this in a HTML tag would work like this:
35
// $graphBase64 = "data:$contentType;base64," . base64_encode($graphData);
36
// echo sprintf('<img src="%s" alt="Graph">', $graphBase64);
37
38
$pdf->Image('@'.$graphData);