Minor - Improve code style - refs CT#7383

1.9.x
Daniel Barreto 11 years ago
parent 6c3ab74967
commit df256d6578
  1. 30
      main/gradebook/lib/fe/flatviewtable.class.php
  2. 16
      main/inc/lib/pchart/pChart.class.php
  3. 76
      plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php
  4. 13
      plugin/dashboard/block_teacher_graph/block_teacher_graph.class.php

@ -327,7 +327,11 @@ class FlatViewTable extends SortableTable
// set font of the axes // set font of the axes
$Test->setFontProperties(api_get_path(LIBRARY_PATH) . "pchart/fonts/tahoma.ttf", 8); $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 // Adding the color schemma
$Test->loadColorPalette(api_get_path(LIBRARY_PATH) . "pchart/palette/pastel.txt"); $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; $area_graph_w = $chart_size_w - 130;
$Test->setGraphArea(50, 30, $area_graph_w, $chart_size_h - 50); $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); //$Test->drawRoundedRectangle(5,5,790,330,5,230,230,230);
//background color area & stripe or not //background color area & stripe or not
$Test->drawGraphArea(255, 255, 255, TRUE); $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 //background grid
$Test->drawGrid(4, TRUE, 230, 230, 230, 50); $Test->drawGrid(4, TRUE, 230, 230, 230, 50);

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

@ -169,13 +169,46 @@ class BlockEvaluationGraph extends Block
$angle = -30; $angle = -30;
$test = new pChart($this->bg_width,$this->bg_height); $test = new pChart($this->bg_width,$this->bg_height);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8); $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(50, 30, $this->bg_width-75, $test->YSize - 75); $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->drawFilledRoundedRectangle(
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$test->YSize - 18,5,230,230,230); 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->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5); $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(0,105,221,34);
$test->setColorPalette(1,255,135,30); $test->setColorPalette(1,255,135,30);
$test->setColorPalette(2,255,0,0); $test->setColorPalette(2,255,0,0);
@ -265,11 +298,40 @@ class BlockEvaluationGraph extends Block
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8); $test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
$test->fixHeightByRotation($data_set->GetData(), $data_set->GetDataDescription(), $angle); $test->fixHeightByRotation($data_set->GetData(), $data_set->GetDataDescription(), $angle);
$test->setGraphArea(50, 30, $this->bg_width-75, $test->YSize-75); $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->drawFilledRoundedRectangle(
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$test->YSize-18,5,230,230,230); 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->drawGraphArea(255,255,255,TRUE);
$test->setFixedScale(0,100,5); $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(0,105,221,34);
$test->setColorPalette(1,255,135,30); $test->setColorPalette(1,255,135,30);
$test->setColorPalette(2,255,0,0); $test->setColorPalette(2,255,0,0);

@ -152,7 +152,18 @@ class BlockTeacherGraph extends Block
$test->drawFilledRoundedRectangle(7,7,$bg_width,$bg_height,5,240,240,240); $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->drawRoundedRectangle(5,5,$bg_width+2,$bg_height+2,5,230,230,230);
$test->drawGraphArea(255,255,255,TRUE); $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); $test->drawGrid(4,TRUE,230,230,230,50);
// Drawing lines // Drawing lines

Loading…
Cancel
Save