瀏覽代碼

Minor - Improve code style - refs CT#7383

Daniel Barreto 10 年之前
父節點
當前提交
df256d6578

+ 27 - 3
main/gradebook/lib/fe/flatviewtable.class.php

@@ -327,7 +327,11 @@ class FlatViewTable extends SortableTable
                             // set font of the axes
                             $Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 8);
 
-                            $Test = $Test->fixHeightByRotation($DataSet->GetData(), $DataSet->GetDataDescription(), $angle);
+                            $Test = $Test->fixHeightByRotation(
+                                $DataSet->GetData(),
+                                $DataSet->GetDataDescription(),
+                                $angle
+                            );
 
                             // Adding the color schemma
                             $Test->loadColorPalette(api_get_path(LIBRARY_PATH) . "pchart/palette/pastel.txt");
@@ -335,7 +339,16 @@ class FlatViewTable extends SortableTable
                             $area_graph_w = $chart_size_w - 130;
                             $Test->setGraphArea(50, 30, $area_graph_w, $chart_size_h - 50);
 
-                            $Test->drawFilledRoundedRectangle(5, 5, $chart_size_w - 1, $Test->YSize - 20, 5, 240, 240, 240);
+                            $Test->drawFilledRoundedRectangle(
+                                5,
+                                5,
+                                $chart_size_w - 1,
+                                $Test->YSize - 20,
+                                5,
+                                240,
+                                240,
+                                240
+                            );
                             //$Test->drawRoundedRectangle(5,5,790,330,5,230,230,230);
                             //background color area & stripe or not
                             $Test->drawGraphArea(255, 255, 255, TRUE);
@@ -349,7 +362,18 @@ class FlatViewTable extends SortableTable
                                 }
                             }
 
-                            $Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALLSTART0, 150, 150, 150, TRUE, 0, 1, FALSE);
+                            $Test->drawScale(
+                                $DataSet->GetData(),
+                                $DataSet->GetDataDescription(),
+                                SCALE_ADDALLSTART0,
+                                150,
+                                150,
+                                150,
+                                TRUE,
+                                0,
+                                1,
+                                FALSE
+                            );
 
                             //background grid
                             $Test->drawGrid(4, TRUE, 230, 230, 230, 50);

+ 11 - 9
main/inc/lib/pchart/pChart.class.php

@@ -3574,22 +3574,24 @@
      function fixHeightByRotation ($data, $dataDescription, $angle)
      {
          $maxTextHeight = 0;
-         foreach ( $data as $key => $values )
-         {
+         foreach ($data as $key => $values) {
              // Get legend value
              $value = $data[$key][$dataDescription["Position"]];
-             if ( $dataDescription["Format"]["X"] == "number" )
+             if ($dataDescription["Format"]["X"] == "number") {
                  $value = $value.$dataDescription["Unit"]["X"];
-             if ( $dataDescription["Format"]["X"] == "time" )
+             } elseif ($dataDescription["Format"]["X"] == "time") {
                  $value = $this->ToTime($value);
-             if ( $dataDescription["Format"]["X"] == "date" )
+             } elseif ($dataDescription["Format"]["X"] == "date") {
                  $value = $this->ToDate($value);
-             if ( $dataDescription["Format"]["X"] == "metric" )
+             } elseif ($dataDescription["Format"]["X"] == "metric") {
                  $value = $this->ToMetric($value);
-             if ( $dataDescription["Format"]["X"] == "currency" )
+             } elseif ($dataDescription["Format"]["X"] == "currency") {
                  $value = $this->ToCurrency($value);
-             $Position   = imageftbbox($this->FontSize,$angle,$this->FontName,$value);
-             $TextHeight = abs($Position[1])+abs($Position[3]);
+             }
+             // Get positions array from label generated
+             $Position = imageftbbox($this->FontSize, $angle, $this->FontName, $value);
+             $TextHeight = abs($Position[1]) + abs($Position[3]);
+             // Save max height
              if ($maxTextHeight < $TextHeight) {
                  $maxTextHeight = $TextHeight;
              }

+ 74 - 12
plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php

@@ -169,13 +169,46 @@ class BlockEvaluationGraph extends Block
                             $angle = -30;
 						    $test = new pChart($this->bg_width,$this->bg_height);
 						    $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
-                            $test = $test->fixHeightByRotation($data_set->GetData(),$data_set->GetDataDescription(), $angle);
-						    $test->setGraphArea(50,30,$this->bg_width-75,$test->YSize - 75);
-						    $test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$test->YSize - 20,5,240,240,240);
-						    $test->drawRoundedRectangle(5,5,$this->bg_width-18,$test->YSize - 18,5,230,230,230);
-						    $test->drawGraphArea(255,255,255,TRUE);
-						    $test->setFixedScale(0,100,5);
-						    $test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,$angle,2,TRUE);
+                            $test = $test->fixHeightByRotation(
+                                $data_set->GetData(),
+                                $data_set->GetDataDescription(),
+                                $angle
+                            );
+                            $test->setGraphArea(50, 30, $this->bg_width-75, $test->YSize - 75);
+                            $test->drawFilledRoundedRectangle(
+                                7,
+                                7,
+                                $this->bg_width-20,
+                                $test->YSize - 20,
+                                5,
+                                240,
+                                240,
+                                240
+                            );
+                            $test->drawRoundedRectangle(
+                                5,
+                                5,
+                                $this->bg_width-18,
+                                $test->YSize - 18,
+                                5,
+                                230,
+                                230,
+                                230
+                            );
+                            $test->drawGraphArea(255,255,255,TRUE);
+                            $test->setFixedScale(0,100,5);
+                            $test->drawScale(
+                                $data_set->GetData(),
+                                $data_set->GetDataDescription(),
+                                SCALE_ADDALL,
+                                150,
+                                150,
+                                150,
+                                TRUE,
+                                $angle,
+                                2,
+                                TRUE
+                            );
 						    $test->setColorPalette(0,105,221,34);
 							$test->setColorPalette(1,255,135,30);
 							$test->setColorPalette(2,255,0,0);
@@ -263,13 +296,42 @@ class BlockEvaluationGraph extends Block
                                 $angle = -30;
 							    $test = new pChart($this->bg_width,$this->bg_height);
 							    $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
-                                $test->fixHeightByRotation($data_set->GetData(),$data_set->GetDataDescription(), $angle);
-							    $test->setGraphArea(50,30,$this->bg_width-75,$test->YSize-75);
-							    $test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$test->YSize-20,5,240,240,240);
-							    $test->drawRoundedRectangle(5,5,$this->bg_width-18,$test->YSize-18,5,230,230,230);
+                                $test->fixHeightByRotation($data_set->GetData(), $data_set->GetDataDescription(), $angle);
+                                $test->setGraphArea(50, 30, $this->bg_width-75, $test->YSize-75);
+                                $test->drawFilledRoundedRectangle(
+                                    7,
+                                    7,
+                                    $this->bg_width-20,
+                                    $test->YSize-20,
+                                    5,
+                                    240,
+                                    240,
+                                    240
+                                );
+                                $test->drawRoundedRectangle(
+                                    5,
+                                    5,
+                                    $this->bg_width-18,
+                                    $test->YSize-18,
+                                    5,
+                                    230,
+                                    230,
+                                    230
+                                );
 							    $test->drawGraphArea(255,255,255,TRUE);
 							    $test->setFixedScale(0,100,5);
-							    $test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,$angle,2,TRUE);
+                                $test->drawScale(
+                                    $data_set->GetData(),
+                                    $data_set->GetDataDescription(),
+                                    SCALE_ADDALL,
+                                    150,
+                                    150,
+                                    150,
+                                    TRUE,
+                                    $angle,
+                                    2,
+                                    TRUE
+                                );
 							    $test->setColorPalette(0,105,221,34);
 								$test->setColorPalette(1,255,135,30);
 								$test->setColorPalette(2,255,0,0);

+ 13 - 2
plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@@ -147,12 +147,23 @@ class BlockTeacherGraph extends Block
                 $angle = -30;
 				$test = new pChart($bg_width+10,$bg_height+20);
 				$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
-                $test = $test->fixHeightByRotation($data_set->GetData(),$data_set->GetDataDescription(), $angle);
+                $test = $test->fixHeightByRotation($data_set->GetData(), $data_set->GetDataDescription(), $angle);
 				$test->setGraphArea(65,30,$bg_width-70,$bg_height-50);
 				$test->drawFilledRoundedRectangle(7,7,$bg_width,$bg_height,5,240,240,240);
 				$test->drawRoundedRectangle(5,5,$bg_width+2,$bg_height+2,5,230,230,230);
 				$test->drawGraphArea(255,255,255,TRUE);
-				$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_NORMAL,150,150,150,TRUE,$angle,2,TRUE);
+                $test->drawScale(
+                    $data_set->GetData(),
+                    $data_set->GetDataDescription(),
+                    SCALE_NORMAL,
+                    150,
+                    150,
+                    150,
+                    TRUE,
+                    $angle,
+                    2,
+                    TRUE
+                );
 				$test->drawGrid(4,TRUE,230,230,230,50);
 
 				// Drawing lines