budynki-GRAPH-HOUR.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. //hours
  31. foreach($C1_DV['HOURS'] as $C1_H=>$C1_HV) {
  32. // echo "\n wstawiam dla C1_H ".$C1_H." dane ".$C1_HV;
  33. $data_hours[$C2][$C1_H]+=$C1_HV;
  34. }
  35. }
  36. }
  37. }
  38. // break;
  39. }
  40. /*
  41. $data = array("1" => .0032, "2" => .0028, "3" => .0021, "4" => .0033,
  42. "5" => .0034, "6" => .0031, "7" => .0036, "8" => .0027, "9" => .0024,
  43. "10" => .0021, "11" => .0026, "12" => .0024, "13" => .0036,
  44. "14" => .0028, "15" => .0025);
  45. */
  46. //tabela z godzinami pracy
  47. foreach($data_hours as $user_i=>$user) {
  48. foreach($user as $TABLEE_I=>$TABLE_V) {
  49. foreach($data_hours as $test_user_i=>$test_user_v) {
  50. if(!isset($test_user_v[$TABLEE_I])) {
  51. //echo "\n W user ".$test_user_i." tabeli ".$TABLEE_I." brakuje!";
  52. $data_hours[$test_user_i][$TABLEE_I]=0;
  53. }
  54. }
  55. }
  56. }
  57. foreach($data_hours as $user_i=>$user) {
  58. ksort($data_hours[$user_i]);
  59. }
  60. include('phpgraphlib.php');
  61. $graph=new PHPGraphLib(800,400);
  62. /*foreach($data as $data_add_i=>$data_add_v) {
  63. //$graph->addData($data['gubarewp']);
  64. if($data_size[$data_add_i]>50) {
  65. $graph->addData($data[$data_add_i]);
  66. $graph->setBarColor(RandomColorGenerator());
  67. // setLineColor("red");
  68. $graph->setLegendTitle(substr($data_add_i,0,5));
  69. }
  70. }
  71. */
  72. //$_GET['C2']=stripslashes($GET['C2']);
  73. $graph->addData($data_hours[$_GET['C2']]);
  74. //$graph->setBarColor(RandomColorGenerator());
  75. $graph->setBarColor('green');
  76. $graph->setLegendTitle($_GET['C2']);
  77. if($_GET['C22']) {
  78. $graph->addData($data_hours[$_GET['C22']]);
  79. // $graph->setBarColor(RandomColorGenerator());
  80. $graph->setBarColor('red');
  81. $graph->setLegendTitle($_GET['C22']);
  82. }
  83. $graph->setGoalLine(100,"green");
  84. $graph->setGoalLine(200,"red");
  85. //$graph->setGoalLineColor("red","green");
  86. //$graph->setTitle('Company Production');
  87. $graph->setupYAxis(12, 'blue');
  88. $graph->setupXAxis(20);
  89. $graph->setGrid(false);
  90. $graph->setLegend(true);
  91. $graph->setTitleLocation('left');
  92. $graph->setTitleColor('blue');
  93. $graph->setLegendOutlineColor('white');
  94. //$graph->setLegendTitle('Week-37', 'Week-38');
  95. $graph->setXValuesHorizontal(false);
  96. $graph->createGraph();
  97. ?>