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("../config/define.php");
  12. //////////// Check Inclusion de pages ////////////
  13. if (!class_exists('auth')){
  14.     include_once("../lib/lib_common.php");
  15.     ReloadIndex('admin');
  16. }
  17. ////////////
  18.  
  19. $scale_id=$_GET['scale_id'];
  20. $id=$_GET['id'];
  21.  
  22.  
  23. include_once("../class/class.sdi.php");
  24. include_once(SQL.".inc.php");
  25.  
  26.  
  27. $req_sdiav=SQL_getAllValue("SCP"$scale_id$id);
  28. $value $sql_object -> DBSelect($req_sdiav);
  29. $req_sdii=SQL_getInfoSdi($id);
  30. $result_sdii $sql_object -> DBSelect($req_sdii);
  31.  
  32. $unit=$result_sdii[0]['sdii_unit'];
  33. $full_title=formatText($result_sdii[0]['sdii_name']);
  34. $title=cutText($full_title500);
  35.  
  36. $is_null_threshold true// is the threshold null or not? to know if we display it
  37. for ($i=0$i<count($value)$i++{
  38.     $ydata[$i]=$value[$i]['sdiv_value'];
  39.     // setting $threshold_value
  40.     // By default initial value
  41.     $ydata2[$i]=$result_sdii[0]['sdii_threshold_value'];
  42.     // if set, we get it from the table
  43.     if(!is_null($value[$i]['sdiv_threshold'])) {
  44.         $ydata2[$i]=$value[$i]['sdiv_threshold'];
  45.     }
  46.     // if at least one numeric value is there test is false
  47.     if(is_numeric($ydata2[$i])) $is_null_threshold false;
  48.     
  49.     list($day$month$year)=explode('-',$value[$i]['date_p']);
  50.     $months[$i$day '-' .$month'-'substr($year22);
  51. }
  52.  
  53.  
  54. /* pChart library inclusions */
  55. include_once("../class/system/pChart/class/pData.class.php");
  56. include_once("../class/system/pChart/class/pDraw.class.php");
  57. include_once("../class/system/pChart/class/pImage.class.php");
  58.  
  59. /* Create and populate the pData object */
  60. $MyData new pData();
  61. //  $MyData->loadPalette("../class/system/pChart/palettes/blind.color",TRUE);
  62. $MyData->setAxisName(0,$unit);
  63. $MyData->addPoints($ydata,$full_title);
  64. $MyData->addPoints($ydata2,"thresholds");
  65. $MyData->addPoints($months,"Dates");
  66. $MyData->setSerieDescription($full_title,$unit);
  67. $MyData->setAbscissa("Dates");
  68.  
  69. $thresholdsSettings array("R"=>254,"G"=>148,"B"=>64);
  70. $MyData->setPalette("thresholds",$thresholdsSettings);
  71. $valuesSettings array("R"=>207,"G"=>228,"B"=>252);
  72. $MyData->setPalette("$full_title",$valuesSettings);
  73.  
  74. /* Create the pChart object */
  75. $myPicture new pImage(500,350,$MyData);
  76.  
  77.  
  78. /* Turn of Antialiasing */
  79. $myPicture->Antialias TRUE;
  80.  
  81. /* Add a border to the picture */
  82. // $myPicture->drawRectangle(0,0,499,349,array("R"=>180,"G"=>180,"B"=>180));
  83.  
  84. /* Set the default font */
  85. $myPicture->setFontProperties(array("FontName"=>"../class/system/pChart/fonts/verdana.ttf","FontSize"=>7,"R"=>80,"G"=>80,"B"=>80));
  86.  
  87. /* Define the chart area */
  88. $myPicture->setGraphArea(50,20,480,300);
  89.  
  90.  
  91. /* Draw the scale */
  92. $scaleSettings array(
  93.         // grid settings
  94.         "GridR"=>160,"GridG"=>160,"GridB"=>160,"GridTicks"=>1"DrawSubTicks"=>TRUE,
  95.         // axis settings
  96.         "AxisR"=>80,"AxisG"=>80,"AxisB"=>80,
  97.         "CycleBackground"=>TRUE'LabelRotation'=>50,
  98.         "DrawArrows"=>FALSE);
  99.  
  100. $myPicture->drawScale($scaleSettings);
  101.  
  102.  
  103. /* Write the chart legend */
  104. //$myPicture->drawLegend(50,5,array("Style"=>LEGEND_NOBORDER,"Mode"=>LEGEND_HORIZONTAL));
  105.  
  106.  
  107.  
  108. /* Draw the chart */
  109. $myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10))/* Turn on shadow computing */
  110. $settings array(
  111.         "InnerBorderR"=>80"InnerBorderG"=>80"InnerBorderB"=>80,
  112.         "BorderR"=>80"BorderG"=>80"BorderB"=>80,
  113.         // color and gradient settings
  114.         "DisplayColor"=>DISPLAY_MANUAL,
  115.         "Gradient"=>TRUE,"GradientStartR"=>207,"GradientStartG"=>228,"GradientStartB"=>252,
  116.         "GradientEndR"=>146"GradientEndG"=>174"GradientEndB"=>206,"GradientAlpha"=>100,
  117.         // label settings
  118.         "DisplayValues"=>FALSE"DisplayPos"=>LABEL_POS_OUTSIDE,"DisplayR"=>115,"DisplayG"=>115,"DisplayB"=>115,"DisplayOrientation"=>ORIENTATION_AUTO,
  119.         "DisplayShadow"=>FALSE,
  120.         "Draw0Line"=>FALSE,
  121.         //"Rounded"=>TRUE, // not working with gradient
  122.         "Surrounding"=>-30,
  123.         "InnerSurrounding"=>0);
  124.  
  125. $MyData->setSerieDrawable($full_title,TRUE);
  126. $MyData->setSerieDrawable("thresholds",FALSE);
  127. $myPicture->drawBarChart($settings);
  128.  
  129. /* Draw the line and plot chart */
  130. $myPicture->setShadow(FALSE)/* Turn off shadow computing */
  131.  
  132. // if at least one threshold is there we display the serie on graph
  133. if(!$is_null_threshold{
  134.     $MyData->setSerieDrawable("thresholds",TRUE);
  135. }
  136. $MyData->setSerieDrawable($full_title,FALSE);
  137. $myPicture->drawSplineChart();
  138. $myPicture->drawPlotChart();
  139.  
  140. /* Render the picture (choose the best way) */
  141. $myPicture->autoOutput("simple.png");
  142.  
  143.  
  144. ?>

Documentation generated on Mon, 08 Apr 2013 18:14:34 +0200 by phpDocumentor 1.4.1