budynki-GRAPH-TABLE.php 3.1 KB

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