code_junkie

Best graph and diagram toolset for PHP [closed]

Nov 11th, 2011
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. <?php
  2. /*
  3. * This work is hereby released into the Public Domain.
  4. * To view a copy of the public domain dedication,
  5. * visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
  6. * Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
  7. *
  8. */
  9.  
  10. require_once "../../BarPlot.class.php";
  11.  
  12. $graph = new Graph(450, 400);
  13.  
  14. $graph->setAntiAliasing(TRUE);
  15.  
  16. $blue = new Color(0, 0, 200);
  17. $red = new Color(200, 0, 0);
  18.  
  19. $group = new PlotGroup;
  20. $group->setPadding(40, 40);
  21. $group->setBackgroundColor(
  22. new Color(240, 240, 240)
  23. );
  24.  
  25. $values = array(12, 8, 20, 32, 15, 5);
  26.  
  27. $plot = new BarPlot($values, 1, 2);
  28. $plot->setBarColor($blue);
  29. $plot->setYAxis(Plot::LEFT);
  30.  
  31. $group->add($plot);
  32. $group->axis->left->setColor($blue);
  33. $group->axis->left->title->set("Blue bars");
  34.  
  35. $values = array(6, 12, 14, 2, 11, 7);
  36.  
  37. $plot = new BarPlot($values, 2, 2);
  38. $plot->setBarColor($red);
  39. $plot->setYAxis(Plot::RIGHT);
  40.  
  41. $group->add($plot);
  42. $group->axis->right->setColor($red);
  43. $group->axis->right->title->set("Red bars");
  44.  
  45. $graph->add($group);
  46. $graph->draw();
  47. ?>
  48.  
  49. class page_line extends Page {
  50. function init(){
  51. parent::init();
  52.  
  53. $p=$this;
  54.  
  55. $this->api->template->append('css_include', '<link type="text/css"
  56. href="./atk4-addons/sterling/jqplot/templates/js/jqplot/jquery.jqplot.css" rel="stylesheet" />'."n");
  57.  
  58. $this->api->template->append('ie_include','<script type="text/javascript"
  59. src="./atk4-addons/sterling/jqplot/templates/js/jqplot/excanvas.min.js"></script>'."n");
  60. $this->api->template->append('js_include','<script type="text/javascript"
  61. src="./atk4-addons/sterling/jqplot/templates/js/jqplot/jquery.jqplot.min.js"></script>'."n");
  62.  
  63. $this->js()->_load('jqplot_helper');
  64. $chart = $p->add('jqplot', null, 'chart1');
  65. $chart->setSeries(array(array(3,7,9,1,4,6,8,2,5)));
  66. }
  67. function defaultTemplate(){
  68. return array('page/line');
  69. }
  70. }
Add Comment
Please, Sign In to add comment