linea21-modules
[ class tree: linea21-modules ] [ index: linea21-modules ] [ all elements ]

Source for file graph.php

Documentation is available at graph.php

  1. <?php
  2. /**
  3.  * @package linea21.modules
  4.  * @subpackage dashboard
  5.  * @author linea21 <info@linea21.com>
  6.  * @version $id SVN
  7.  * @access public
  8.  * @license http://opensource.org/licenses/gpl-3.0.html
  9.  */
  10.  
  11. include_once("../lib/functions_auth.php");
  12.  
  13. include_once("../config/define.php");
  14. include_once("../config/server.php");
  15. //////////// Check Inclusion de pages //////////// 
  16. if (!function_exists('AuthenthificationProcess')){ 
  17. include_once("../lib/lib_common.php");
  18. ReloadIndex('admin');
  19. }
  20. ////////////
  21.  
  22. $scale_id=$_GET['scale_id'];
  23. $id=$_GET['id'];
  24.  
  25. include("../class/system/class.".SQL.".php");
  26. include("../class/class.sdi.php");
  27. include(SQL.".inc.php");
  28. $sql_entity=SQL;
  29. $sql_object = new $sql_entity;
  30. $sql_object -> DBInitialise();
  31. $sql_object -> DBConnexion();
  32.  
  33. $req_sdiav=SQL_getAllValue("SCP", $scale_id, $id);    
  34. $value = $sql_object -> DBSelect($req_sdiav);
  35. $req_sdii=SQL_getInfoSdi($id);
  36. $result_sdii = $sql_object -> DBSelect($req_sdii);
  37.  
  38. require_once "../class/system/artichow/BarPlot.class.php";
  39. require_once "../class/system/artichow/LinePlot.class.php";
  40.  
  41. $unit=$result_sdii[0]['sdii_unit'];
  42. $title=formatText($result_sdii[0]['sdii_name']);
  43. $title=cutText($title, 50, 0); 
  44. for ($i=0; $i<count($value); $i++) {
  45.     $ydata[$i]=$value[$i]['sdiv_value'];
  46.     $ydata2[$i]=$result_sdii[0]['sdii_threshold_value'];
  47.     list($day, $month, $year)=explode('-',$value[$i]['date_p']);
  48.     $months[$i] = $day . '-' .$month. '-'. substr($year, 2, 2);    
  49. }
  50.  
  51. // Create the graph. 
  52. $graph = new Graph(450,300);
  53. if(function_exists('imageantialias')) {
  54.   $graph->setAntiAliasing(TRUE);
  55. }
  56. $graph->border->setColor(new Color(133, 133, 133, 50));
  57.  
  58. $group = new PlotGroup;
  59. $group->setSpace(5, 5, 5, 0);
  60. $group->setBackgroundColor(
  61.     new Color(244, 244, 244)
  62. );
  63. $group->grid->hideVertical();
  64. $group->grid->setColor(new Color(0, 0, 0, 80));
  65. $group->grid->setType(LINE_DOTTED);
  66. $group->setPadding(40, 15, 20, 50);
  67.  
  68.  
  69. $bplot = new BarPlot($ydata);
  70. //$bplot->setSpace(4, 4, 4, 0);
  71. //$bplot->setPadding(15, 15, 5, 50);
  72. $bplot->SetBarGradient(
  73.     new LinearGradient(
  74.         new Color(207, 228, 252, 0),
  75.         new Color(146, 174, 206, 0),
  76.         90
  77.     )
  78. );    
  79.  
  80. $group->axis->left->title->set($unit);
  81. $group->axis->left->title->setFont(new Tuffy(10));
  82. $group->axis->left->title->move(-4, 0);
  83. $group->axis->left->setTitleAlignment(LABEL_TOP);
  84.  
  85. /**
  86. Affichage des valeurs en haut de colonnes
  87. $bplot->label->set($ydata);
  88. $bplot->label->move(0, -23);
  89. $bplot->label->setBackgroundGradient(
  90.     new LinearGradient(
  91.         new Color(250, 250, 250, 10),
  92.         new Color(255, 200, 200, 30),
  93.         0
  94.     )
  95. );
  96. */
  97.  
  98. $bplot->label->border->setColor(new Color(20, 20, 20, 20));
  99. $bplot->label->setPadding(3, 1, 1, 0);
  100. $bplot->barBorder->setColor(new Color(161, 182, 206, 0));
  101.  
  102. $group->axis->bottom->setLabelText($months); 
  103. $group->axis->bottom->label->setAngle(55);
  104. $group->axis->bottom->label->setFont(new Tuffy(7));
  105.  
  106. $group->add($bplot);
  107.  
  108.  
  109. $plot = new LinePlot($ydata2, LINEPLOT_MIDDLE);
  110. $plot->setFillColor(new Color(254, 148, 64, 50));
  111. $plot->setColor(new Color(254, 148, 64, 0));
  112. $plot->mark->setType(MARK_SQUARE);
  113.  
  114. $plot->mark->setSize(5);
  115. $plot->mark->setFill(new Color(246, 149, 55, 20));
  116. $plot->mark->border->show();
  117. $plot->mark->border->setColor(new Color(254, 148, 64, 0));
  118.  
  119. $group->add($plot);
  120. $graph->add($group);
  121.  
  122.  
  123. $graph->draw();
  124.  
  125. ?>

Documentation generated on Fri, 16 Oct 2009 09:33:22 +0200 by phpDocumentor 1.4.1