Guest User

Untitled

a guest
Jan 25th, 2014
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. // ...and add it to the graph
  22. $graph->Add($b1plot);
  23.  
  24. $graph->title->Set("Demo Graph Test");
  25.  
  26. $contentType = 'image/png';
  27. $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
  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);
Add Comment
Please, Sign In to add comment