Skip to content

Commit 131a2cb

Browse files
committed
Improved chart's esthetics
1 parent f147776 commit 131a2cb

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

plugin/dashboard/block_evaluation_graph/block_evaluation_graph.class.php

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ class BlockEvaluationGraph extends Block {
4444
public function __construct ($user_id) {
4545
$this->path = 'block_evaluation_graph';
4646
$this->user_id = $user_id;
47+
$this->bg_width = 450;
48+
$this->bg_height = 350;
4749
if ($this->is_block_visible_for_user($user_id)) {
4850
/*if (api_is_platform_admin()) {
4951
$this->courses = CourseManager::get_real_course_list();
@@ -157,7 +159,7 @@ public function get_evaluations_base_courses_graph() {
157159
$data_set->AddPoint($avg, "Avg");
158160
$data_set->AddPoint($min, "Min");
159161
$data_set->AddPoint($items, "Items");
160-
$data_set->SetXAxisName(get_lang('Step'));
162+
$data_set->SetXAxisName(get_lang('EvaluationName'));
161163
$data_set->SetYAxisName(get_lang('Percentage'));
162164
$data_set->AddAllSeries();
163165
$data_set->RemoveSerie("Items");
@@ -171,28 +173,31 @@ public function get_evaluations_base_courses_graph() {
171173
$img_file = $cache->GetHash($graph_id, $data);
172174
} else {
173175
// Initialise the graph
174-
$test = new pChart(450,260);
176+
$test = new pChart($this->bg_width,$this->bg_height);
175177
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
176-
$test->setGraphArea(50,30,375,200);
177-
$test->drawFilledRoundedRectangle(7,7,373,223,5,240,240,240);
178-
$test->drawRoundedRectangle(5,5,375,225,5,230,230,230);
178+
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
179+
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
180+
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
179181
$test->drawGraphArea(255,255,255,TRUE);
180182
$test->setFixedScale(0,100,5);
181183
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
182-
$test->setColorPalette(0,125,201,44);
183-
$test->setColorPalette(1,255,138,0);
184+
$test->setColorPalette(0,105,221,34);
185+
$test->setColorPalette(1,255,135,30);
184186
$test->setColorPalette(2,255,0,0);
185187
$test->drawGrid(4,TRUE,230,230,230,50);
186188
// Draw the 0 line
187189
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6);
188190
$test->drawTreshold(0,143,55,72,TRUE,TRUE);
189191
// Draw the bar graph
190-
$test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100);
192+
$test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 90);
191193
// Finish the graph
192194
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
193-
$test->drawLegend(365,20,$data_set->GetDataDescription(),255,255,255);
195+
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
194196
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
195197
//$test->drawTitle(50,22,$course_code,50,50,50,185);
198+
$test->setColorPalette(0,50,50,50);
199+
$test->setColorPalette(1,50,50,50);
200+
$test->setColorPalette(2,50,50,50);
196201
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
197202
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
198203
ob_start();
@@ -243,7 +248,7 @@ public function get_evaluations_courses_in_sessions_graph() {
243248
$data_set->AddPoint($avg, "Avg");
244249
$data_set->AddPoint($min, "Min");
245250
$data_set->AddPoint($items, "Items");
246-
$data_set->SetXAxisName(get_lang('Step'));
251+
$data_set->SetXAxisName(get_lang('EvaluationName'));
247252
$data_set->SetYAxisName(get_lang('Percentage'));
248253
$data_set->AddAllSeries();
249254
$data_set->RemoveSerie("Items");
@@ -257,17 +262,17 @@ public function get_evaluations_courses_in_sessions_graph() {
257262
$img_file = $cache->GetHash($graph_id, $data);
258263
} else {
259264
// Initialise the graph
260-
$test = new pChart(450,260);
265+
$test = new pChart($this->bg_width,$this->bg_height);
261266
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
262-
$test->setGraphArea(50,30,375,200);
263-
$test->drawFilledRoundedRectangle(7,7,373,230,5,240,240,240);
264-
$test->drawRoundedRectangle(5,5,375,225,5,230,230,230);
267+
$test->setGraphArea(50,30,$this->bg_width-75,$this->bg_height-75);
268+
$test->drawFilledRoundedRectangle(7,7,$this->bg_width-20,$this->bg_height-20,5,240,240,240);
269+
$test->drawRoundedRectangle(5,5,$this->bg_width-18,$this->bg_height-18,5,230,230,230);
265270
$test->drawGraphArea(255,255,255,TRUE);
266271
$test->setFixedScale(0,100,5);
267272
$test->drawScale($data_set->GetData(),$data_set->GetDataDescription(),SCALE_ADDALL,150,150,150,TRUE,0,2,TRUE);
268-
$test->setColorPalette(0,125,201,44);
269-
$test->setColorPalette(1,255,138,0);
270-
$test->setColorPalette(2,255,0,0);
273+
$test->setColorPalette(0,105,221,34);
274+
$test->setColorPalette(1,255,135,30);
275+
$test->setColorPalette(2,255,0,0);
271276
$test->drawGrid(4,TRUE,230,230,230,50);
272277
// Draw the 0 line
273278
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',6);
@@ -276,8 +281,11 @@ public function get_evaluations_courses_in_sessions_graph() {
276281
$test->drawOverlayBarGraph($data_set->GetData(),$data_set->GetDataDescription(), 100);
277282
// Finish the graph
278283
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
279-
$test->drawLegend(365,20,$data_set->GetDataDescription(),255,255,255);
284+
$test->drawLegend($this->bg_width-80,20,$data_set->GetDataDescription(),255,255,255);
280285
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',10);
286+
$test->setColorPalette(0,50,50,50);
287+
$test->setColorPalette(1,50,50,50);
288+
$test->setColorPalette(2,50,50,50);
281289
$test->writeValues($data_set->GetData(),$data_set->GetDataDescription(),array("Min", "Max", "Avg"));
282290
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
283291
ob_start();

0 commit comments

Comments
 (0)