budynki-GRAPH.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. include('./phpgraphlib/phpgraphlib.php');
  3. //$graph = new PHPGraphLib(800,600);
  4. session_start();
  5. function RandomColorGenerator(){
  6. //global $red, $green, $blue, $color;
  7. $color = array(rand(50,255), rand(50,255), rand(50,255)); //generates random RGB color;
  8. $red = $color[0]; //red value;
  9. $green = $color[1]; //green value;
  10. $blue = $color[2]; //blue value;
  11. $ret=$red.",".$green.",".$blue;
  12. // $ret="255,5,5";
  13. return($ret);
  14. }
  15. //$ARR['DATE_CHART'][$DWA->C2][$DWA->C1_Y][$DWA->C1_M][$DWA->C1_D]++;
  16. foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $C2=>$C2V) {
  17. $i=0;
  18. // echo "\n wstawiam dla C2 ".$C2." dane ".$C2V;
  19. // $data_color[$C2]=RandomColorGenerator();
  20. foreach($C2V as $C1_Y=>$C1_YV) {
  21. // echo "\n wstawiam dla C1_Y ".$C1_Y." dane ".$C1_YV;
  22. foreach($C1_YV as $C1_M=>$C1_MV) {
  23. // echo "\n wstawiam dla C1_M ".$C1_M." dane ".$C1_MV;
  24. foreach($C1_MV as $C1_D=>$C1_DV) {
  25. // echo "\n wstawiam dla ".$C1_MV." dane ".$C1_DV;
  26. $data[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV['COUNT'];
  27. // $data_hrs[$C2][substr($C1_Y,-2)."-".$C1_M."-".$C1_D]=$C1_DV;
  28. $i+=$C1_DV['COUNT'];
  29. //if($i>14) break;
  30. }
  31. }
  32. }
  33. $_SESSION['CHART']['ARR']['DATE_CHART'][$C2]['SIZE']=$i;
  34. $data_size[$C2]=$i;
  35. // break;
  36. }
  37. /*
  38. $data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
  39. "5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
  40. "10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
  41. "14" => .0028, "15" => .0025);
  42. */
  43. //Sortujemy i uzupelniamy daty prac o brakujace indeksy
  44. foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $user_i=>$user) { //lecimy ARR[User]
  45. foreach($user as $TABLEE_I=>$TABLE_V) { //Lecimy ARR[User][Rok]
  46. foreach($TABLE_V as $TABLEE_II=>$TABLE_VV) { //Lecimy ARR[User][Rok][m-c]
  47. foreach($TABLE_VV as $TABLEE_III=>$TABLE_VVV) { //Lecimy ARR[User][Rok][m-c][day]
  48. foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $test_user_i=>$test_user_v) { //arr[user]
  49. if(!isset($test_user_v[$TABLEE_I][$TABLEE_II][$TABLEE_III])) {
  50. echo "\n W user ".$test_user_i." tabeli ".$TABLEE_I."-".$TABLEE_II."-".$TABLEE_III." brakuje!";
  51. $_SESSION['CHART']['ARR']['DATE_CHART'][$test_user_i][$TABLEE_I][$TABLEE_II][$TABLEE_III]['COUNT']=0;
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. foreach($_SESSION['CHART']['ARR']['DATE_CHART'] as $user_i=>$user) { //lecimy ARR[User]
  59. ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i]);
  60. foreach($user as $TABLEE_I=>$TABLE_V) { //Lecimy ARR[User][Rok]
  61. ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I]);
  62. foreach($TABLE_V as $TABLEE_II=>$TABLE_VV) { //Lecimy ARR[User][Rok][m-c]
  63. ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I][$TABLEE_II]);
  64. foreach($TABLE_VV as $TABLEE_III=>$TABLE_VVV) { //Lecimy ARR[User][Rok][m-c][day]
  65. ksort($_SESSION['CHART']['ARR']['DATE_CHART'][$user_i][$TABLEE_I][$TABLEE_II][$TABLEE_III]);
  66. }
  67. }
  68. }
  69. }
  70. include('phpgraphlib.php');
  71. $graph=new PHPGraphLib(800,400);
  72. /*foreach($data as $data_add_i=>$data_add_v) {
  73. //$graph->addData($data['gubarewp']);
  74. if($data_size[$data_add_i]>50) {
  75. $graph->addData($data[$data_add_i]);
  76. $graph->setBarColor(RandomColorGenerator());
  77. // setLineColor("red");
  78. $graph->setLegendTitle(substr($data_add_i,0,5));
  79. }
  80. }
  81. */
  82. //$_GET['C2']=stripslashes($GET['C2']);
  83. $graph->addData($data[$_GET['C2']]);
  84. $graph->setBarColor('green');
  85. // $graph->setBarColor(RandomColorGenerator());
  86. // setLineColor("red");
  87. $graph->setLegendTitle($_GET['C2']);
  88. if($_GET['C22']) {
  89. $graph->addData($data[$_GET['C22']]);
  90. // $graph->setBarColor(RandomColorGenerator());
  91. $graph->setBarColor('red');
  92. // setLineColor("red");
  93. $graph->setLegendTitle($_GET['C22']);
  94. }
  95. $graph->setGoalLine(100,"green");
  96. $graph->setGoalLine(200,"red");
  97. //$graph->setGoalLineColor("red","green");
  98. //$graph->setTitle('Company Production');
  99. $graph->setupYAxis(12, 'blue');
  100. $graph->setupXAxis(20);
  101. $graph->setGrid(false);
  102. $graph->setLegend(true);
  103. $graph->setTitleLocation('left');
  104. $graph->setTitleColor('blue');
  105. $graph->setLegendOutlineColor('white');
  106. //$graph->setLegendTitle('Week-37', 'Week-38');
  107. $graph->setXValuesHorizontal(false);
  108. $graph->createGraph();
  109. ?>