Guest User

Untitled

a guest
Jan 25th, 2014
10
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. // Create the grouped bar plot
  22. // $gbplot = new GroupBarPlot(array($b1plot));
  23. // ...and add it to the graPH
  24. $graph->Add($b1plot);
  25.  
  26.  
  27. // $b1plot->SetColor("white");
  28. // $b1plot->SetFillColor("#cc1111");
  29.  
  30. $graph->title->Set("Demo Graph Test");
  31.  
  32. $contentType = 'image/png';
  33. $gdImgHandler = $graph->Stroke(_IMG_HANDLER);
  34.  
  35. // @see http://stackoverflow.com/a/9084110/126431
  36. ob_start();                        // start buffering
  37. $graph->img->Stream();             // print data to buffer
  38. $graphData = ob_get_contents();   // retrieve buffer contents
  39. ob_end_clean();                    // stop buffer
  40.  
  41. // outputting this in a HTML tag would work like this:
  42. // $graphBase64 = "data:$contentType;base64," . base64_encode($graphData);
  43. // echo sprintf('<img src="%s" alt="Graph">', $graphBase64);
  44.  
  45. $pdf->Image('@'.$graphData);
Add Comment
Please, Sign In to add comment