Completed
Pull Request — master (#2171)
by Christian
10:51
created
boinc/modules/contrib/privatemsg/privatemsg_filter/privatemsg_filter.module 1 patch
Indentation   +314 added lines, -314 removed lines patch added patch discarded remove patch
@@ -9,34 +9,34 @@  discard block
 block discarded – undo
9 9
  * Implements hook_perm().
10 10
  */
11 11
 function privatemsg_filter_perm() {
12
-  return array(
12
+    return array(
13 13
     'filter private messages',
14 14
     'tag private messages',
15 15
     'create private message tags',
16
-  );
16
+    );
17 17
 }
18 18
 
19 19
 /**
20 20
  * Implements hook_menu().
21 21
  */
22 22
 function privatemsg_filter_menu() {
23
-  $items['admin/settings/messages/filter'] = array(
23
+    $items['admin/settings/messages/filter'] = array(
24 24
     'title'            => 'Filter',
25 25
     'description'      => 'Configure filter settings.',
26 26
     'page callback'    => 'drupal_get_form',
27 27
     'page arguments'   => array('privatemsg_filter_admin'),
28 28
     'access arguments' => array('administer privatemsg settings'),
29 29
     'type'             => MENU_LOCAL_TASK,
30
-  );
31
-  $items['admin/settings/messages/tags'] = array(
30
+    );
31
+    $items['admin/settings/messages/tags'] = array(
32 32
     'title'            => 'Tags',
33 33
     'description'      => 'Configure tags.',
34 34
     'page callback'    => 'privatemsg_tags_admin',
35 35
     'access arguments' => array('administer privatemsg settings'),
36 36
     'type'             => MENU_LOCAL_TASK,
37 37
     'file'             => 'privatemsg_filter.admin.inc',
38
-  );
39
-  $items['admin/settings/messages/tags/list'] = array(
38
+    );
39
+    $items['admin/settings/messages/tags/list'] = array(
40 40
     'title'            => 'List',
41 41
     'description'      => 'Configure tags.',
42 42
     'page callback'    => 'privatemsg_tags_admin',
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
     'type'             => MENU_DEFAULT_LOCAL_TASK,
45 45
     'file'             => 'privatemsg_filter.admin.inc',
46 46
     'weight'           => -10,
47
-  );
48
-  $items['admin/settings/messages/tags/add'] = array(
47
+    );
48
+    $items['admin/settings/messages/tags/add'] = array(
49 49
     'title'            => 'Add',
50 50
     'description'      => 'Configure tags.',
51 51
     'page callback'    => 'drupal_get_form',
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
     'access arguments' => array('administer privatemsg settings'),
54 54
     'type'             => MENU_LOCAL_TASK,
55 55
     'file'             => 'privatemsg_filter.admin.inc',
56
-  );
57
-  $items['admin/settings/messages/tags/edit/%'] = array(
56
+    );
57
+    $items['admin/settings/messages/tags/edit/%'] = array(
58 58
     'title'            => 'Add',
59 59
     'description'      => 'Configure tags.',
60 60
     'page callback'    => 'drupal_get_form',
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
     'access arguments' => array('administer privatemsg settings'),
63 63
     'type'             => MENU_CALLBACK,
64 64
     'file'             => 'privatemsg_filter.admin.inc',
65
-  );
66
-  $items['admin/settings/messages/tags/delete/%'] = array(
65
+    );
66
+    $items['admin/settings/messages/tags/delete/%'] = array(
67 67
     'title'            => 'Add',
68 68
     'description'      => 'Configure tags.',
69 69
     'page callback'    => 'drupal_get_form',
@@ -71,62 +71,62 @@  discard block
 block discarded – undo
71 71
     'access arguments' => array('administer privatemsg settings'),
72 72
     'type'             => MENU_CALLBACK,
73 73
     'file'             => 'privatemsg_filter.admin.inc',
74
-  );
75
-  $items['messages/inbox'] = array(
74
+    );
75
+    $items['messages/inbox'] = array(
76 76
     'title'            => 'Inbox',
77 77
     'page callback'    => 'drupal_get_form',
78 78
     'page arguments'   => array('privatemsg_list', 'inbox'),
79 79
     'access callback'  => 'privatemsg_user_access',
80 80
     'type'             => variable_get('privatemsg_filter_default_list', 0) ? MENU_LOCAL_TASK : MENU_DEFAULT_LOCAL_TASK,
81 81
     'weight'           => -15,
82
-  );
83
-  $items['messages/sent'] = array(
82
+    );
83
+    $items['messages/sent'] = array(
84 84
     'title'            => 'Sent messages',
85 85
     'page callback'    => 'drupal_get_form',
86 86
     'page arguments'   => array('privatemsg_list', 'sent'),
87 87
     'access callback'  => 'privatemsg_user_access',
88 88
     'type'             => MENU_LOCAL_TASK,
89 89
     'weight'           => -12,
90
-  );
91
-  $items['messages/filter/user-name-autocomplete'] = array(
90
+    );
91
+    $items['messages/filter/user-name-autocomplete'] = array(
92 92
     'page callback'    => 'privatemsg_user_name_autocomplete',
93 93
     'access callback'  => 'privatemsg_user_access',
94 94
     'access arguments' => array('write privatemsg'),
95 95
     'type'             => MENU_CALLBACK,
96
-  );
97
-  $items['messages/filter/tag-autocomplete'] = array(
96
+    );
97
+    $items['messages/filter/tag-autocomplete'] = array(
98 98
     'page callback'    => 'privatemsg_filter_tags_autocomplete',
99 99
     'access callback'  => 'privatemsg_user_access',
100 100
     'access arguments' => array('tag private messages'),
101 101
     'type'             => MENU_CALLBACK,
102 102
     'weight'           => -10,
103
-  );
104
-  return $items;
103
+    );
104
+    return $items;
105 105
 }
106 106
 
107 107
 /**
108 108
  * Implements hook_menu_alter().
109 109
  */
110 110
 function privatemsg_filter_menu_alter(&$items) {
111
-  // Rename messages to "All messages".
112
-  $items['messages/list']['title'] = 'All messages';
111
+    // Rename messages to "All messages".
112
+    $items['messages/list']['title'] = 'All messages';
113 113
 
114
-  if (variable_get('privatemsg_filter_default_list', 0) == 0) {
114
+    if (variable_get('privatemsg_filter_default_list', 0) == 0) {
115 115
     // Change default argument of /messages to inbox. and set the task to MENU_LOCAL_TASK.
116 116
     $items['messages']['page arguments'] = array('privatemsg_list', 'inbox');
117 117
     $items['messages/list']['type'] = MENU_LOCAL_TASK;
118
-  }
118
+    }
119 119
 }
120 120
 
121 121
 function privatemsg_filter_admin() {
122
-  $form = array();
122
+    $form = array();
123 123
 
124
-  $form['privatemsg_filter_searchbody'] = array(
124
+    $form['privatemsg_filter_searchbody'] = array(
125 125
     '#type'          => 'checkbox',
126 126
     '#title'         => t('Search message body'),
127 127
     '#description'   => t('WARNING: turning on this feature will slow down search performance by a large factor. Gets worse as your messages database increases.'),
128 128
     '#default_value' => variable_get('privatemsg_filter_searchbody', FALSE),
129
-  );
129
+    );
130 130
 
131 131
     $form['privatemsg_filter_tagfield_weight'] = array(
132 132
     '#type'          => 'textfield',
@@ -134,9 +134,9 @@  discard block
 block discarded – undo
134 134
     '#description'   => t('Use higher values to push the form lower down the page, lower or negative values to raise it higher.'),
135 135
     '#size'          => 4,
136 136
     '#default_value' => variable_get('privatemsg_filter_tagfield_weight', 10),
137
-  );
137
+    );
138 138
 
139
-  return system_settings_form($form);
139
+    return system_settings_form($form);
140 140
 }
141 141
 
142 142
 /**
@@ -145,26 +145,26 @@  discard block
 block discarded – undo
145 145
  * Add a filter widget to the message listing pages.
146 146
  */
147 147
 function privatemsg_filter_form_private_message_settings_alter(&$form, $form_state) {
148
-  $form['privatemsg_listing']['privatemsg_filter_default_list'] = array(
148
+    $form['privatemsg_listing']['privatemsg_filter_default_list'] = array(
149 149
     '#type' => 'radios',
150 150
     '#default_value' => variable_get('privatemsg_filter_default_list', 0),
151 151
     '#options' => array(t('Inbox'), t('All messages')),
152 152
     '#title' => t('Choose the default list option'),
153 153
     '#description' => t('Choose which of the two lists are shown by default when following the messages link.'),
154
-  );
155
-  // Add tags to the list of possible columns.
156
-  $form['privatemsg_listing']['privatemsg_display_fields']['#options']['tags'] = t('Tags');
154
+    );
155
+    // Add tags to the list of possible columns.
156
+    $form['privatemsg_listing']['privatemsg_display_fields']['#options']['tags'] = t('Tags');
157 157
 
158
-  $form['#submit'][] = 'privatemsg_filter_settings_submit';
158
+    $form['#submit'][] = 'privatemsg_filter_settings_submit';
159 159
 }
160 160
 
161 161
 /**
162 162
  * Rebuilding the menu if necessary.
163 163
  */
164 164
 function privatemsg_filter_settings_submit($form, &$form_state) {
165
-  if ($form['privatemsg_listing']['privatemsg_filter_default_list']['#default_value'] != $form_state['values']['privatemsg_filter_default_list']) {
165
+    if ($form['privatemsg_listing']['privatemsg_filter_default_list']['#default_value'] != $form_state['values']['privatemsg_filter_default_list']) {
166 166
     menu_rebuild();
167
-  }
167
+    }
168 168
 }
169 169
 
170 170
 /**
@@ -174,33 +174,33 @@  discard block
 block discarded – undo
174 174
  *   A single tag or an array of tags.
175 175
  */
176 176
 function privatemsg_filter_create_tags($tags) {
177
-  if (!is_array($tags)) {
177
+    if (!is_array($tags)) {
178 178
     $tags = array($tags);
179
-  }
179
+    }
180 180
 
181
-  $tag_ids = array();
181
+    $tag_ids = array();
182 182
 
183
-  foreach ($tags as $tag) {
183
+    foreach ($tags as $tag) {
184 184
     $tag = trim($tag);
185 185
     if (empty($tag)) {
186
-      // Do not save a blank tag.
187
-      continue;
186
+        // Do not save a blank tag.
187
+        continue;
188 188
     }
189 189
 
190 190
     // Check if the tag already exists and only create the tag if it does not.
191 191
     $tag_id = db_result(db_query("SELECT tag_id FROM {pm_tags} WHERE tag = '%s'", $tag));
192 192
     if (empty($tag_id) && privatemsg_user_access('create private message tags')) {
193
-      db_query("INSERT INTO {pm_tags} (tag) VALUES ('%s')", $tag);
194
-      $tag_id = db_last_insert_id('pm_tags', 'tag_id');
193
+        db_query("INSERT INTO {pm_tags} (tag) VALUES ('%s')", $tag);
194
+        $tag_id = db_last_insert_id('pm_tags', 'tag_id');
195 195
     }
196 196
     elseif (empty($tag_id)) {
197
-      // The user does not have permission to create new tags - disregard this tag and move onto the next.
198
-      drupal_set_message(t('Tag %tag was ignored because you do not have permission to create new tags.', array('%tag' => $tag)));
199
-      continue;
197
+        // The user does not have permission to create new tags - disregard this tag and move onto the next.
198
+        drupal_set_message(t('Tag %tag was ignored because you do not have permission to create new tags.', array('%tag' => $tag)));
199
+        continue;
200 200
     }
201 201
     $tag_ids[] = $tag_id;
202
-  }
203
-  return $tag_ids;
202
+    }
203
+    return $tag_ids;
204 204
 }
205 205
 
206 206
 /**
@@ -212,21 +212,21 @@  discard block
 block discarded – undo
212 212
  *   Id of the tag.
213 213
  */
214 214
 function privatemsg_filter_add_tags($threads, $tag_id, $account = NULL) {
215
-  if (!is_array($threads)) {
215
+    if (!is_array($threads)) {
216 216
     $threads = array($threads);
217
-  }
218
-  if (empty($account)) {
217
+    }
218
+    if (empty($account)) {
219 219
     global $user;
220 220
     $account = drupal_clone($user);
221
-  }
221
+    }
222 222
 
223
-  foreach ($threads as $thread) {
223
+    foreach ($threads as $thread) {
224 224
     // Make sure that we don't add a tag to a thread twice,
225 225
     // only insert if there is no such tag yet.
226 226
     if (db_result(db_query('SELECT COUNT(*) FROM {pm_tags_index} WHERE tag_id = %d AND (uid = %d AND thread_id = %d)', $tag_id, $account->uid, $thread)) == 0) {
227
-      db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $account->uid, $thread);
227
+        db_query('INSERT INTO {pm_tags_index} (tag_id, uid, thread_id) VALUES (%d, %d, %d)', $tag_id, $account->uid, $thread);
228
+    }
228 229
     }
229
-  }
230 230
 }
231 231
 
232 232
 /**
@@ -238,238 +238,238 @@  discard block
 block discarded – undo
238 238
  *   Id of the tag - set to NULL to remove all tags.
239 239
  */
240 240
 function privatemsg_filter_remove_tags($threads, $tag_id = NULL, $account = NULL) {
241
-  if (!is_array($threads)) {
241
+    if (!is_array($threads)) {
242 242
     $threads = array($threads);
243
-  }
244
-  if (empty($account)) {
243
+    }
244
+    if (empty($account)) {
245 245
     global $user;
246 246
     $account = drupal_clone($user);
247
-  }
247
+    }
248 248
 
249
-  if (is_null($tag_id)) {
249
+    if (is_null($tag_id)) {
250 250
     // Delete all tag mapping.
251 251
     foreach ($threads as $thread) {
252
-      db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d', $account->uid, $thread);
252
+        db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d', $account->uid, $thread);
253
+    }
253 254
     }
254
-  }
255
-  else {
255
+    else {
256 256
     // Delete tag mapping for the specified tag.
257 257
     foreach ($threads as $thread) {
258
-      db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d AND tag_id = %d', $account->uid, $thread, $tag_id);
258
+        db_query('DELETE FROM {pm_tags_index} WHERE uid = %d AND thread_id = %d AND tag_id = %d', $account->uid, $thread, $tag_id);
259
+    }
259 260
     }
260
-  }
261 261
 }
262 262
 
263 263
 function privatemsg_filter_get_filter($account) {
264
-  $filter = array();
265
-  if (isset($_GET['tags'])) {
264
+    $filter = array();
265
+    if (isset($_GET['tags'])) {
266 266
     $_GET['tags'] = urldecode($_GET['tags']);
267 267
     $tag_data = privatemsg_filter_get_tags_data($account);
268 268
     foreach (explode(',', $_GET['tags']) as $tag) {
269
-      if (isset($tag_data[$tag])) {
269
+        if (isset($tag_data[$tag])) {
270 270
         $filter['tags'][$tag] = $tag;
271
-      }
272
-      elseif (in_array($tag, $tag_data)) {
271
+        }
272
+        elseif (in_array($tag, $tag_data)) {
273 273
         $filter['tags'][array_search($tag, $tag_data)] = array_search($tag, $tag_data);
274
-      }
274
+        }
275
+    }
275 276
     }
276
-  }
277 277
 
278
-  if (isset($_GET['author'])) {
278
+    if (isset($_GET['author'])) {
279 279
     list($filter['author']) = _privatemsg_parse_userstring($_GET['author']);
280
-  }
280
+    }
281 281
 
282
-  if (isset($_GET['search'])) {
282
+    if (isset($_GET['search'])) {
283 283
     $filter['search'] = $_GET['search'];
284
-  }
284
+    }
285 285
 
286
-  if (!empty($filter)) {
286
+    if (!empty($filter)) {
287 287
     return $filter;
288
-  }
288
+    }
289 289
 
290
-  if (!empty($_SESSION['privatemsg_filter'])) {
290
+    if (!empty($_SESSION['privatemsg_filter'])) {
291 291
     return $_SESSION['privatemsg_filter'];
292
-  }
292
+    }
293 293
 
294 294
 }
295 295
 
296 296
 function privatemsg_filter_get_tags_data($account) {
297
-  static $tag_data;
297
+    static $tag_data;
298 298
 
299
-  if (is_array($tag_data)) {
299
+    if (is_array($tag_data)) {
300 300
     return $tag_data;
301
-  }
301
+    }
302 302
 
303
-  // Only show the tags that a user have used.
304
-  $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $account);
305
-  $results = db_query($query['query']);
303
+    // Only show the tags that a user have used.
304
+    $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $account);
305
+    $results = db_query($query['query']);
306 306
 
307
-  $tag_data = array();
308
-  while ($result = db_fetch_object($results)) {
307
+    $tag_data = array();
308
+    while ($result = db_fetch_object($results)) {
309 309
     $tag_data[$result->tag_id] = $result->tag;
310
-  }
311
-  return $tag_data;
310
+    }
311
+    return $tag_data;
312 312
 }
313 313
 
314 314
 function privatemsg_filter_dropdown(&$form_state, $account) {
315 315
 
316
-  drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css');
316
+    drupal_add_css(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg_filter.css');
317 317
 
318
-  $form['filter'] = array(
318
+    $form['filter'] = array(
319 319
     '#type' => 'fieldset',
320 320
     '#title' => t('Filter messages'),
321 321
     '#collapsible' => TRUE,
322 322
     '#collapsed' => TRUE,
323
-  );
324
-  $form['filter']['search'] = array(
323
+    );
324
+    $form['filter']['search'] = array(
325 325
     '#type' => 'textfield',
326 326
     '#title' => variable_get('privatemsg_filter_searchbody', FALSE) ? t('Search messages') : t('Search subjects'),
327 327
     '#weight' => -20
328
-  );
328
+    );
329 329
 
330
-  $form['filter']['author'] = array(
330
+    $form['filter']['author'] = array(
331 331
     '#type'               => 'textfield',
332 332
     '#title'              => t('Participants'),
333 333
     '#description'        => t('Separate multiple names with commas.'),
334 334
     '#weight'             => -5,
335 335
     '#size'               => 50,
336 336
     '#autocomplete_path'  => 'messages/filter/user-name-autocomplete',
337
-  );
337
+    );
338 338
 
339
-  // Only show form if the user has some messages tagged.
340
-  if (count($tag_data = privatemsg_filter_get_tags_data($account))) {
339
+    // Only show form if the user has some messages tagged.
340
+    if (count($tag_data = privatemsg_filter_get_tags_data($account))) {
341 341
     $form['filter']['tags'] = array(
342
-      '#type' => 'select',
343
-      '#title' => t('Tags'),
344
-      '#options' => $tag_data,
345
-      '#multiple' => TRUE,
346
-      '#size' => 5,
347
-      '#weight' => 0
348
-    );
349
-  }
342
+        '#type' => 'select',
343
+        '#title' => t('Tags'),
344
+        '#options' => $tag_data,
345
+        '#multiple' => TRUE,
346
+        '#size' => 5,
347
+        '#weight' => 0
348
+    );
349
+    }
350 350
     $form['filter']['submit'] = array(
351
-      '#type'     => 'submit',
352
-      '#value'    => t('Filter'),
353
-      '#prefix'   => '<div id="privatemsg-filter-buttons">',
354
-      '#weight'   => 10,
355
-      '#submit'   => array('privatemsg_filter_dropdown_submit'),
351
+        '#type'     => 'submit',
352
+        '#value'    => t('Filter'),
353
+        '#prefix'   => '<div id="privatemsg-filter-buttons">',
354
+        '#weight'   => 10,
355
+        '#submit'   => array('privatemsg_filter_dropdown_submit'),
356 356
     );
357 357
 
358 358
     $form['filter']['save'] = array(
359
-      '#type'     => 'submit',
360
-      '#value'    => t('Save filter'),
361
-      '#suffix'   => '</div>',
362
-      '#weight'   => 11,
363
-      '#submit'   => array('privatemsg_filter_dropdown_submit'),
359
+        '#type'     => 'submit',
360
+        '#value'    => t('Save filter'),
361
+        '#suffix'   => '</div>',
362
+        '#weight'   => 11,
363
+        '#submit'   => array('privatemsg_filter_dropdown_submit'),
364 364
     );
365 365
 
366 366
     if ($filter = privatemsg_filter_get_filter($account)) {
367
-      privatemsg_filter_dropdown_set_active($form, $filter);
367
+        privatemsg_filter_dropdown_set_active($form, $filter);
368 368
     }
369 369
 
370 370
     return $form;
371 371
 }
372 372
 
373 373
 function privatemsg_filter_dropdown_set_active(&$form, $filter) {
374
-  $form['filter']['#title'] = t('Filter messages (active)');
375
-  $form['filter']['#collapsed'] = FALSE;
374
+    $form['filter']['#title'] = t('Filter messages (active)');
375
+    $form['filter']['#collapsed'] = FALSE;
376 376
 
377
-  if (isset($filter['author'])) {
377
+    if (isset($filter['author'])) {
378 378
     $string = '';
379 379
     foreach ($filter['author'] as $author) {
380
-      $string .= $author->name . ', ';
380
+        $string .= $author->name . ', ';
381 381
     }
382 382
     $form['filter']['author']['#default_value'] = $string;
383
-  }
384
-  if (isset($filter['tags'])) {
383
+    }
384
+    if (isset($filter['tags'])) {
385 385
     $form['filter']['tags']['#default_value'] = $filter['tags'];
386
-  }
387
-  if (isset($filter['search'])) {
386
+    }
387
+    if (isset($filter['search'])) {
388 388
     $form['filter']['search']['#default_value'] = $filter['search'];
389
-  }
390
-
391
-  $form['filter']['reset'] = array(
392
-      '#type'     => 'submit',
393
-      '#value'    => t('Reset'),
394
-      '#suffix'   => '</div>',
395
-      '#weight'   => 12,
396
-      '#submit'   => array('privatemsg_filter_dropdown_submit'),
397
-  );
398
-  unset($form['filter']['save']['#suffix']);
389
+    }
390
+
391
+    $form['filter']['reset'] = array(
392
+        '#type'     => 'submit',
393
+        '#value'    => t('Reset'),
394
+        '#suffix'   => '</div>',
395
+        '#weight'   => 12,
396
+        '#submit'   => array('privatemsg_filter_dropdown_submit'),
397
+    );
398
+    unset($form['filter']['save']['#suffix']);
399 399
 }
400 400
 
401 401
 function privatemsg_filter_dropdown_submit($form, &$form_state) {
402 402
 
403
-  if (!empty($form_state['values']['author'])) {
403
+    if (!empty($form_state['values']['author'])) {
404 404
     list($form_state['values']['author']) = _privatemsg_parse_userstring($form_state['values']['author']);
405
-  }
405
+    }
406 406
 
407
-  switch ($form_state['values']['op']) {
407
+    switch ($form_state['values']['op']) {
408 408
     case t('Save filter'):
409 409
       $filter = array();
410
-      if (!empty($form_state['values']['tags'])) {
410
+        if (!empty($form_state['values']['tags'])) {
411 411
         $filter['tags'] = $form_state['values']['tags'];
412
-      }
413
-      if (!empty($form_state['values']['author'])) {
412
+        }
413
+        if (!empty($form_state['values']['author'])) {
414 414
         $filter['author'] = $form_state['values']['author'];
415
-      }
416
-      if (!empty($form_state['values']['search'])) {
415
+        }
416
+        if (!empty($form_state['values']['search'])) {
417 417
         $filter['search'] = $form_state['values']['search'];
418
-      }
419
-      $_SESSION['privatemsg_filter'] = $filter;
420
-      break;
418
+        }
419
+        $_SESSION['privatemsg_filter'] = $filter;
420
+        break;
421 421
     case t('Filter'):
422 422
       drupal_goto($_GET['q'], privatemsg_filter_create_get_query($form_state['values']));
423
-      return;
424
-      break;
423
+        return;
424
+        break;
425 425
     case t('Reset'):
426 426
       $_SESSION['privatemsg_filter'] = array();
427
-      break;
428
-  }
429
-  $form_state['redirect'] = $_GET['q'];
427
+        break;
428
+    }
429
+    $form_state['redirect'] = $_GET['q'];
430 430
 }
431 431
 
432 432
 function privatemsg_filter_create_get_query($filter) {
433
-  $query = array();
434
-  if (isset($filter['tags']) && !empty($filter['tags'])) {
433
+    $query = array();
434
+    if (isset($filter['tags']) && !empty($filter['tags'])) {
435 435
     $ids = array();
436 436
     foreach ($filter['tags'] as $tag) {
437
-      if ((int)$tag > 0) {
437
+        if ((int)$tag > 0) {
438 438
         $ids[] = $tag;
439
-      }
440
-      else {
439
+        }
440
+        else {
441 441
         $query['tags'][] = $tag;
442
-      }
442
+        }
443 443
     }
444 444
     $sql = 'SELECT pmt.tag FROM {pm_tags} pmt WHERE pmt.tag_id IN ('. implode(', ', $filter['tags']) .')';
445 445
     $result = db_query($sql);
446 446
     while ($row = db_fetch_object($result)) {
447
-      $query['tags'][] = $row->tag;
447
+        $query['tags'][] = $row->tag;
448 448
     }
449 449
 
450 450
     if (isset($query['tags'])) {
451
-      $query['tags'] = implode(',', $query['tags']);
451
+        $query['tags'] = implode(',', $query['tags']);
452
+    }
452 453
     }
453
-  }
454 454
 
455
-  if (isset($filter['author']) && !empty($filter['author'])) {
455
+    if (isset($filter['author']) && !empty($filter['author'])) {
456 456
     foreach ($filter['author'] as $author) {
457
-      if (is_object($author) && isset($author->uid) && isset($author->name)) {
457
+        if (is_object($author) && isset($author->uid) && isset($author->name)) {
458 458
         $query['author'][] = $author->name;
459
-      }
460
-      elseif ($author_obj = user_load($author)) {
459
+        }
460
+        elseif ($author_obj = user_load($author)) {
461 461
         $query['author'][] = $author_obj->name;
462
-      }
462
+        }
463 463
     }
464 464
     if (isset($query['author'])) {
465
-      $query['author'] = implode(',', $query['author']);
465
+        $query['author'] = implode(',', $query['author']);
466
+    }
466 467
     }
467
-  }
468 468
 
469
-  if (isset($filter['search']) && !empty($filter['search'])) {
469
+    if (isset($filter['search']) && !empty($filter['search'])) {
470 470
     $query['search'] = $filter['search'];
471
-  }
472
-  return $query;
471
+    }
472
+    return $query;
473 473
 }
474 474
 
475 475
 /**
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
  * Adds a filter widget to the message listing pages.
479 479
  */
480 480
 function privatemsg_filter_form_privatemsg_list_alter(&$form, $form_state) {
481
-  global $user;
481
+    global $user;
482 482
 
483
-  if (privatemsg_user_access('filter private messages') && !empty($form['#data'])) {
483
+    if (privatemsg_user_access('filter private messages') && !empty($form['#data'])) {
484 484
     $form += privatemsg_filter_dropdown($form_state, $form['#account']);
485
-  }
485
+    }
486 486
 
487
-  $fields = array_filter(variable_get('privatemsg_display_fields', array('participants')));
488
-  if (in_array('tags', $fields)) {
487
+    $fields = array_filter(variable_get('privatemsg_display_fields', array('participants')));
488
+    if (in_array('tags', $fields)) {
489 489
     // Load thread id's of the current list.
490 490
     $threads = array_keys($form['#data']);
491 491
 
@@ -495,21 +495,21 @@  discard block
 block discarded – undo
495 495
     // Add them to #data
496 496
     $result = db_query($query['query']);
497 497
     while ($tag = db_fetch_array($result)) {
498
-      $form['#data'][$tag['thread_id']]['tags'][$tag['tag_id']] = $tag['tag'];
498
+        $form['#data'][$tag['thread_id']]['tags'][$tag['tag_id']] = $tag['tag'];
499
+    }
499 500
     }
500
-  }
501 501
 
502
-  $tags = privatemsg_filter_get_tags_data($user);
503
-  if (privatemsg_user_access('tag private messages') && !empty($tags) && !empty($form['#data'])) {
502
+    $tags = privatemsg_filter_get_tags_data($user);
503
+    if (privatemsg_user_access('tag private messages') && !empty($tags) && !empty($form['#data'])) {
504 504
     $options = array();
505 505
     $options[] = t('Apply tag...');
506 506
     foreach ($tags as $tag_id => $tag) {
507
-      $options[$tag_id] = $tag;
507
+        $options[$tag_id] = $tag;
508 508
     }
509 509
     $form['actions']['tag-add'] = array(
510
-      '#type'          => 'select',
511
-      '#options'       => $options,
512
-      '#default_value' => 0,
510
+        '#type'          => 'select',
511
+        '#options'       => $options,
512
+        '#default_value' => 0,
513 513
     );
514 514
     $form['actions']['tag-add-submit'] = array(
515 515
         '#prefix'     => '<div class="privatemsg-tag-add-submit">',
@@ -521,9 +521,9 @@  discard block
 block discarded – undo
521 521
     );
522 522
     $options[0] = t('Remove Tag...');
523 523
     $form['actions']['tag-remove'] = array(
524
-      '#type'          => 'select',
525
-      '#options'       => $options,
526
-      '#default_value' => 0,
524
+        '#type'          => 'select',
525
+        '#options'       => $options,
526
+        '#default_value' => 0,
527 527
     );
528 528
     $form['actions']['tag-remove-submit'] = array(
529 529
         '#prefix'     => '<div class="privatemsg-tag-remove-submit">',
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 
537 537
     // JS for hiding the submit buttons.
538 538
     drupal_add_js(drupal_get_path('module', 'privatemsg_filter') .'/privatemsg-filter-list.js');
539
-  }
539
+    }
540 540
 }
541 541
 
542 542
 /**
@@ -545,12 +545,12 @@  discard block
 block discarded – undo
545 545
  * @see theme_privatemsg_list_header()
546 546
  */
547 547
 function phptemplate_privatemsg_list_header__tags() {
548
-   return array(
548
+    return array(
549 549
     'data' => t('Tags'),
550 550
     'key' => 'tags',
551 551
     'class' => 'privatemsg-header-tags',
552 552
     '#weight' => -42,
553
-  );
553
+    );
554 554
 }
555 555
 
556 556
 
@@ -560,48 +560,48 @@  discard block
 block discarded – undo
560 560
  * @see theme_privatemsg_list_field()
561 561
  */
562 562
 function phptemplate_privatemsg_list_field__tags($thread) {
563
-  if (!empty($thread['tags'])) {
563
+    if (!empty($thread['tags'])) {
564 564
     $tags = array();
565 565
 
566 566
     foreach ($thread['tags'] as $tag_id => $tag) {
567
-      $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array(
567
+        $tags[] = l(strlen($tag) > 15 ? substr($tag, 0, 13) . '...' : $tag, 'messages', array(
568 568
         'attributes' => array('title' => $tag),
569 569
         'query' => array('tags' => $tag)
570
-      ));
570
+        ));
571 571
     }
572 572
     return array(
573
-      'data'  => implode(', ', $tags),
574
-      'class' => 'privatemsg-list-tags',
573
+        'data'  => implode(', ', $tags),
574
+        'class' => 'privatemsg-list-tags',
575 575
     );
576
-  }
576
+    }
577 577
 }
578 578
 
579 579
 /**
580 580
  * Form callback for adding a tag to threads.
581 581
  */
582 582
 function privatemsg_filter_add_tag_submit($form, &$form_state) {
583
-  $operation = array(
583
+    $operation = array(
584 584
     'callback' => 'privatemsg_filter_add_tags',
585 585
     'callback arguments' => array('tag_id' => $form_state['values']['tag-add']),
586 586
     'undo callback' => 'privatemsg_filter_remove_tags',
587 587
     'undo callback arguments' => array('tag_id' => $form_state['values']['tag-add']),
588
-  );
589
-  drupal_set_message(t('The selected conversations have been tagged.'));
590
-  privatemsg_operation_execute($operation, $form_state['values']['threads']);
588
+    );
589
+    drupal_set_message(t('The selected conversations have been tagged.'));
590
+    privatemsg_operation_execute($operation, $form_state['values']['threads']);
591 591
 }
592 592
 
593 593
 /**
594 594
  * Form callback for removing a tag to threads.
595 595
  */
596 596
 function privatemsg_filter_remove_tag_submit($form, &$form_state) {
597
-  $operation = array(
597
+    $operation = array(
598 598
     'callback' => 'privatemsg_filter_remove_tags',
599 599
     'callback arguments' => array('tag_id' => $form_state['values']['tag-remove']),
600 600
     'undo callback' => 'privatemsg_filter_add_tags',
601 601
     'undo callback arguments' => array('tag_id' => $form_state['values']['tag-remove']),
602
-  );
603
-  drupal_set_message(t('The tag has been removed from the selected conversations.'));
604
-  privatemsg_operation_execute($operation, $form_state['values']['threads']);
602
+    );
603
+    drupal_set_message(t('The tag has been removed from the selected conversations.'));
604
+    privatemsg_operation_execute($operation, $form_state['values']['threads']);
605 605
 }
606 606
 
607 607
 /**
@@ -609,114 +609,114 @@  discard block
 block discarded – undo
609 609
  */
610 610
 function privatemsg_filter_privatemsg_sql_list_alter(&$fragments, $account, $argument) {
611 611
 
612
-  // Check if its a filtered view.
613
-  if ($argument == 'sent') {
612
+    // Check if its a filtered view.
613
+    if ($argument == 'sent') {
614 614
     $fragments['where'][]       = "pm.author = %d";
615 615
     $fragments['query_args']['where'][]   = $account->uid;
616
-  }
617
-  if ($argument == 'inbox') {
616
+    }
617
+    if ($argument == 'inbox') {
618 618
     $fragments['having'][]       = '((SELECT pmf.author FROM {pm_message} pmf WHERE pmf.mid = pmi.thread_id) = %d AND COUNT(pmi.thread_id) > 1) OR (SELECT COUNT(*) FROM {pm_message} pmf INNER JOIN {pm_index} pmif ON (pmf.mid = pmif.mid) WHERE pmif.thread_id = pmi.thread_id AND pmf.author <> %d) > 0';
619 619
     $fragments['query_args']['having'][]   = $account->uid;
620 620
     $fragments['query_args']['having'][]   = $account->uid;
621
-  }
621
+    }
622 622
 
623
-  // Filter the message listing by any set tags.
624
-  if ($filter = privatemsg_filter_get_filter($account)) {
623
+    // Filter the message listing by any set tags.
624
+    if ($filter = privatemsg_filter_get_filter($account)) {
625 625
     $count = 0;
626 626
     if (isset($filter['tags']) && !empty($filter['tags'])) {
627
-      foreach ($filter['tags'] as $tag) {
627
+        foreach ($filter['tags'] as $tag) {
628 628
         $fragments['inner_join'][]  = "INNER JOIN {pm_tags_index} pmti$count ON (pmti$count.thread_id = pmi.thread_id AND pmti$count.uid = pmi.uid)";
629 629
         $fragments['where'][]       = "pmti$count.tag_id = %d";
630 630
         $fragments['query_args']['where'][]   = $tag;
631 631
         $count++;
632
-      }
632
+        }
633 633
     }
634 634
 
635 635
     if (isset($filter['author']) && !empty($filter['author'])) {
636
-      foreach ($filter['author'] as $author) {
636
+        foreach ($filter['author'] as $author) {
637 637
         $fragments['inner_join'][]  = "INNER JOIN {pm_index} pmi$count ON (pmi$count.mid = pm.mid)";
638 638
         $fragments['where'][]       = "pmi$count.uid = %d";
639 639
         $fragments['query_args']['where'][]   = $author->uid;
640 640
         $count++;
641
-      }
641
+        }
642 642
     }
643 643
 
644 644
     if (isset($filter['search']) && !empty($filter['search'])) {
645
-      if (variable_get('privatemsg_filter_searchbody', FALSE)) {
645
+        if (variable_get('privatemsg_filter_searchbody', FALSE)) {
646 646
         $fragments['where'][]       = "pm.subject LIKE '%s' OR pm.body LIKE '%s'";
647 647
         $fragments['query_args']['where'][]    = '%%'. $filter['search'] .'%%';
648 648
         $fragments['query_args']['where'][]    = '%%'. $filter['search'] .'%%';
649
-      }
650
-      else {
649
+        }
650
+        else {
651 651
         $fragments['where'][]       = "pm.subject LIKE '%s'";
652 652
         $fragments['query_args']['where'][]    = '%%'. $filter['search'] .'%%';
653
-      }
653
+        }
654
+    }
654 655
     }
655
-  }
656 656
 }
657 657
 
658 658
 /**
659 659
  * Hook into the view messages page to add a form for tagging purposes.
660 660
  */
661 661
 function privatemsg_filter_privatemsg_view_messages_alter(&$content, $thread) {
662
-  if (count($thread['messages']) > 0) {
662
+    if (count($thread['messages']) > 0) {
663 663
     $content['tags']['#value'] = drupal_get_form('privatemsg_filter_form');
664 664
     $content['tags']['#weight'] = variable_get('privatemsg_filter_tagfield_weight', 10);
665
-  }
665
+    }
666 666
 }
667 667
 
668 668
 /**
669 669
  * Form to show and allow modification of tagging information of a conversation.
670 670
  */
671 671
 function privatemsg_filter_form(&$form_state) {
672
-  global $user;
673
-  $thread_id = arg(2);
674
-
675
-  // Get a list of current tags for this thread
676
-  $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id));
677
-  $results = db_query($query['query']);
678
-  $count = db_result(db_query($query['count']));
679
-  $tags = '';
680
-  while ($tag = db_fetch_array($results)) {
672
+    global $user;
673
+    $thread_id = arg(2);
674
+
675
+    // Get a list of current tags for this thread
676
+    $query = _privatemsg_assemble_query(array('tags', 'privatemsg_filter'), $user, array($thread_id));
677
+    $results = db_query($query['query']);
678
+    $count = db_result(db_query($query['count']));
679
+    $tags = '';
680
+    while ($tag = db_fetch_array($results)) {
681 681
     $tags .= $tag['tag'] . ', ';
682
-  }
682
+    }
683 683
 
684
-  $form['tags'] = array(
684
+    $form['tags'] = array(
685 685
     '#type' => 'fieldset',
686 686
     '#title' => t('Tags'),
687 687
     '#access' => privatemsg_user_access('tag private messages'),
688 688
     '#collapsible' => TRUE,
689 689
     '#collapsed' => empty($count) ? TRUE : FALSE,
690
-  );
691
-  $form['tags']['user_id'] = array(
690
+    );
691
+    $form['tags']['user_id'] = array(
692 692
     '#type' => 'value',
693 693
     '#value' => $user->uid,
694
-  );
695
-  $form['tags']['thread_id'] = array(
694
+    );
695
+    $form['tags']['thread_id'] = array(
696 696
     '#type' => 'value',
697 697
     '#value' => $thread_id,
698
-  );
698
+    );
699 699
 
700
-  $form['tags']['tags'] = array(
700
+    $form['tags']['tags'] = array(
701 701
     '#type'               => 'textfield',
702 702
     '#title'              => t('Tags for this conversation'),
703 703
     '#description'        => t('Separate multiple tags with commas.'),
704 704
     '#size'               => 50,
705 705
     '#default_value'      => $tags,
706 706
     '#autocomplete_path'  => 'messages/filter/tag-autocomplete',
707
-  );
707
+    );
708 708
 
709
-  $form['tags']['submit'] = array(
709
+    $form['tags']['submit'] = array(
710 710
     '#type'     => 'submit',
711 711
     '#value'    => t('Tag this conversation'),
712 712
     '#submit'   => array('privatemsg_filter_form_submit'),
713
-  );
713
+    );
714 714
 
715
-  return $form;
715
+    return $form;
716 716
 }
717 717
 
718 718
 function privatemsg_filter_form_submit($form, &$form_state) {
719
-  if (isset($form_state['values']['submit'])) {
719
+    if (isset($form_state['values']['submit'])) {
720 720
     $tags = explode(',', $form_state['values']['tags']);
721 721
 
722 722
     // Step 1 - Delete all tag mapping. I cannot think of a better way to remove tags that are no longer in the textfield, so ideas welcome.
@@ -727,10 +727,10 @@  discard block
 block discarded – undo
727 727
 
728 728
     // Step 3 - Save all the tagging data.
729 729
     foreach ($tag_ids as $tag_id) {
730
-      privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_id);
730
+        privatemsg_filter_add_tags($form_state['values']['thread_id'], $tag_id);
731 731
     }
732 732
     drupal_set_message(t('Tagging information has been saved.'));
733
-  }
733
+    }
734 734
 }
735 735
 
736 736
 /**
@@ -741,28 +741,28 @@  discard block
 block discarded – undo
741 741
  */
742 742
 function privatemsg_filter_tags_autocomplete($string) {
743 743
 
744
-  // 1: Parse $string and build a list of tags.
745
-  $tags = array();
746
-  $fragments = explode(',', $string);
747
-  foreach ($fragments as $index => $tag) {
744
+    // 1: Parse $string and build a list of tags.
745
+    $tags = array();
746
+    $fragments = explode(',', $string);
747
+    foreach ($fragments as $index => $tag) {
748 748
     $tag = trim($tag);
749 749
     $tags[$tag] = $tag;
750
-  }
750
+    }
751 751
 
752
-  // 2: Find the next tag suggestion.
753
-  $fragment = array_pop($tags);
754
-  $matches = array();
755
-  if (!empty($fragment)) {
752
+    // 2: Find the next tag suggestion.
753
+    $fragment = array_pop($tags);
754
+    $matches = array();
755
+    if (!empty($fragment)) {
756 756
     $query = _privatemsg_assemble_query(array('tags_autocomplete', 'privatemsg_filter'), $fragment, $tags);
757 757
     $result = db_query_range($query['query'], $fragment, 0, 10);
758 758
     $prefix = count($tags) ? implode(", ", $tags) .", " : '';
759 759
     // 3: Build proper suggestions and print.
760 760
     while ($tag = db_fetch_object($result)) {
761
-      $matches[$prefix . $tag->tag .", "] = $tag->tag;
761
+        $matches[$prefix . $tag->tag .", "] = $tag->tag;
762 762
     }
763
-  }
764
-  // convert to object to prevent drupal bug, see http://drupal.org/node/175361
765
-  drupal_json((object)$matches);
763
+    }
764
+    // convert to object to prevent drupal bug, see http://drupal.org/node/175361
765
+    drupal_json((object)$matches);
766 766
 }
767 767
 
768 768
 /**
@@ -781,19 +781,19 @@  discard block
 block discarded – undo
781 781
  *   Array of names that are already part of the autocomplete field.
782 782
  */
783 783
 function privatemsg_filter_privatemsg_sql_autocomplete_alter(&$fragments, $search, $names) {
784
-  global $user;
785
-  // arg(1) is an additional URL argument passed to the URL when only
786
-  // users that are listed as recipient for threads of that user should be
787
-  // displayed.
788
-  // @todo: Check if these results can be grouped to avoid unecessary loops.
789
-  if (arg(1) == 'filter') {
784
+    global $user;
785
+    // arg(1) is an additional URL argument passed to the URL when only
786
+    // users that are listed as recipient for threads of that user should be
787
+    // displayed.
788
+    // @todo: Check if these results can be grouped to avoid unecessary loops.
789
+    if (arg(1) == 'filter') {
790 790
     // JOIN on index entries where the to be selected user is a recipient.
791 791
     $fragments['inner_join'][] = 'INNER JOIN {pm_index} pip ON pip.uid = u.uid';
792 792
     // JOIN on rows where the current user is the recipient and that have the
793 793
     // same mid as those above.
794 794
     $fragments['inner_join'][] = 'INNER JOIN {pm_index} piu ON piu.uid = %d AND pip.mid = piu.mid';
795 795
     $fragments['query_args']['join'][] = $user->uid;
796
-  }
796
+    }
797 797
 }
798 798
 
799 799
 /**
@@ -809,19 +809,19 @@  discard block
 block discarded – undo
809 809
  *   Limit the number of tags *per thread*.
810 810
  */
811 811
 function privatemsg_filter_sql_tags(&$fragments, $user = NULL, $threads = NULL, $limit = NULL) {
812
-  $fragments['primary_table'] = '{pm_tags} t';
813
-  $fragments['select'][] = 't.tag';
814
-  $fragments['select'][] = 't.tag_id';
815
-  $fragments['select'][] = 't.public';
812
+    $fragments['primary_table'] = '{pm_tags} t';
813
+    $fragments['select'][] = 't.tag';
814
+    $fragments['select'][] = 't.tag_id';
815
+    $fragments['select'][] = 't.public';
816 816
 
817
-  if (!empty($threads)) {
817
+    if (!empty($threads)) {
818 818
     // If the tag list needs to be for specific threads.
819 819
     $fragments['select'][] = 'ti.thread_id';
820 820
     $fragments['inner_join'][]  = 'INNER JOIN {pm_tags_index} ti on ti.tag_id = t.tag_id';
821 821
     $fragments['where'][] = 'ti.thread_id IN (' . db_placeholders($threads) . ')';
822 822
     $fragments['query_args']['where'] += $threads;
823
-  }
824
-  else {
823
+    }
824
+    else {
825 825
     // Tag usage counter is only used when we select all tags.
826 826
     $fragments['select'][]      = 'COUNT(ti.thread_id) as count';
827 827
     // LEFT JOIN so that unused tags are displayed too.
@@ -829,33 +829,33 @@  discard block
 block discarded – undo
829 829
     $fragments['group_by'][]    = 't.tag_id';
830 830
     $fragments['group_by'][]    = 't.tag';
831 831
     $fragments['group_by'][]    = 't.public';
832
-  }
833
-  if (!empty($user)) {
832
+    }
833
+    if (!empty($user)) {
834 834
     $fragments['where'][]       = 'ti.uid = %d';
835 835
     $fragments['query_args']['where'][] = $user->uid;
836
-  }
837
-
838
-  // Only select n tags per thread (ordered per tag_id), see
839
-  // http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/.
840
-  //
841
-  // It does select how many tags for that thread/uid combination exist that
842
-  // have a lower tag_id and does only select those that have less than $limit.
843
-  //
844
-  // This should only have a very minor performance impact as most users won't
845
-  // tag a thread with 1000 different tags.
846
-  //
847
-  if ($limit) {
836
+    }
837
+
838
+    // Only select n tags per thread (ordered per tag_id), see
839
+    // http://www.xaprb.com/blog/2006/12/07/how-to-select-the-firstleastmax-row-per-group-in-sql/.
840
+    //
841
+    // It does select how many tags for that thread/uid combination exist that
842
+    // have a lower tag_id and does only select those that have less than $limit.
843
+    //
844
+    // This should only have a very minor performance impact as most users won't
845
+    // tag a thread with 1000 different tags.
846
+    //
847
+    if ($limit) {
848 848
     $fragments['where'][] = '(SELECT count(*) FROM {pm_tags_index} AS pmtic
849 849
                               WHERE pmtic.thread_id = ti.thread_id
850 850
                               AND pmtic.uid = ti.uid
851 851
                               AND pmtic.tag_id < ti.tag_id) < %d';
852 852
     $fragments['query_args']['where'][] = $limit;
853
-  }
854
-  elseif (!empty($threads) || !empty($user)) {
853
+    }
854
+    elseif (!empty($threads) || !empty($user)) {
855 855
     // Only add a sort when we are not loading the tags for the admin page.
856 856
     // Sorting is handled through tablesort_sql() then.
857 857
     $fragments['order_by'][] = 't.tag ASC';
858
-  }
858
+    }
859 859
 }
860 860
 
861 861
 /**
@@ -869,25 +869,25 @@  discard block
 block discarded – undo
869 869
  *   Array of tags not to be used as suggestions.
870 870
  */
871 871
 function privatemsg_filter_sql_tags_autocomplete(&$fragments, $search, $tags) {
872
-  global $user;
873
-
874
-  $fragments['primary_table'] = '{pm_tags} pmt';
875
-  $fragments['select'][] = 'pmt.tag';
876
-  $fragments['where'][] = "pmt.tag LIKE '%s'";
877
-  // Escape % to get through the placeholder replacement.
878
-  $fragments['query_args']['where'][] = $search .'%%';
879
-  if (!empty($tags)) {
872
+    global $user;
873
+
874
+    $fragments['primary_table'] = '{pm_tags} pmt';
875
+    $fragments['select'][] = 'pmt.tag';
876
+    $fragments['where'][] = "pmt.tag LIKE '%s'";
877
+    // Escape % to get through the placeholder replacement.
878
+    $fragments['query_args']['where'][] = $search .'%%';
879
+    if (!empty($tags)) {
880 880
     // Exclude tags.
881 881
     $fragments['where'][] = "pmt.tag NOT IN (". db_placeholders($tags, 'text') .")";
882 882
     $fragments['query_args']['where'] += $tags;
883
-  }
884
-  // LEFT JOIN to be able to load public, unused tags.
885
-  $fragments['inner_join'][]  = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d';
886
-  $fragments['query_args']['join'][] = $user->uid;
887
-  // Autocomplete should only display Tags used by that user or public tags.
888
-  // This is done to avoid information disclosure as part of tag names.
889
-  $fragments['where'][] = '(pmti.uid IS NOT NULL OR pmt.public = 1)';
890
-  $fragments['order_by'][] = 'pmt.tag ASC';
883
+    }
884
+    // LEFT JOIN to be able to load public, unused tags.
885
+    $fragments['inner_join'][]  = 'LEFT JOIN {pm_tags_index} pmti ON pmt.tag_id = pmti.tag_id AND pmti.uid = %d';
886
+    $fragments['query_args']['join'][] = $user->uid;
887
+    // Autocomplete should only display Tags used by that user or public tags.
888
+    // This is done to avoid information disclosure as part of tag names.
889
+    $fragments['where'][] = '(pmti.uid IS NOT NULL OR pmt.public = 1)';
890
+    $fragments['order_by'][] = 'pmt.tag ASC';
891 891
 }
892 892
 
893 893
 /**
@@ -898,10 +898,10 @@  discard block
 block discarded – undo
898 898
  * Implement hook_user().
899 899
  */
900 900
 function privatemsg_filter_user($op, &$edit, &$account, $category = NULL) {
901
-  switch ($op) {
902
-      case 'delete':
901
+    switch ($op) {
902
+        case 'delete':
903 903
       // Delete tag information of that user.
904 904
       db_query("DELETE FROM {pm_tags_index} WHERE uid = %d", $account->uid, $account->uid);
905
-      break;
906
-  }
905
+        break;
906
+    }
907 907
 }
Please login to merge, or discard this patch.
drupal/sites/default/boinc/modules/contrib/privatemsg/privatemsg.theme.inc 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @see theme_privatemsg_list_field()
76 76
  */
77 77
 function phptemplate_privatemsg_list_field__participants($thread) {
78
-  $participants = _privatemsg_generate_user_array($thread['participants'], -4);
79
-  $field = array();
80
-  $field['data'] = _privatemsg_format_participants($participants, 3, TRUE);
81
-  $field['class'] = 'privatemsg-list-participants';
82
-  return $field;
78
+    $participants = _privatemsg_generate_user_array($thread['participants'], -4);
79
+    $field = array();
80
+    $field['data'] = _privatemsg_format_participants($participants, 3, TRUE);
81
+    $field['class'] = 'privatemsg-list-participants';
82
+    return $field;
83 83
 }
84 84
 
85 85
 /**
@@ -88,16 +88,16 @@  discard block
 block discarded – undo
88 88
  * @see theme_privatemsg_list_field()
89 89
  */
90 90
 function phptemplate_privatemsg_list_field__subject($thread) {
91
-  $field = array();
92
-  $options = array();
93
-  $is_new = '';
94
-  if (!empty($thread['is_new'])) {
91
+    $field = array();
92
+    $options = array();
93
+    $is_new = '';
94
+    if (!empty($thread['is_new'])) {
95 95
     $is_new = theme_mark(MARK_NEW);
96 96
     $options['fragment'] = 'new';
97
-  }
98
-  $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new;
99
-  $field['class'] = 'privatemsg-list-subject';
100
-  return $field;
97
+    }
98
+    $field['data'] = l($thread['subject'], 'messages/view/' . $thread['thread_id'], $options) . $is_new;
99
+    $field['class'] = 'privatemsg-list-subject';
100
+    return $field;
101 101
 }
102 102
 
103 103
 /**
@@ -106,15 +106,15 @@  discard block
 block discarded – undo
106 106
  * @see theme_privatemsg_list_field()
107 107
  */
108 108
 function phptemplate_privatemsg_list_field__count($thread) {
109
-  $field = array();
110
-  $field['data'] = $thread['count'];
111
-  $options = array();
112
-  if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) {
109
+    $field = array();
110
+    $field['data'] = $thread['count'];
111
+    $options = array();
112
+    if (!empty($thread['is_new']) && $thread['is_new'] < $thread['count']) {
113 113
     $options['fragment'] = 'new';
114 114
     $field['data'] .= '<br />' . l((format_plural($thread['is_new'], '(1 new)', '(@count new)')), 'messages/view/' . $thread['thread_id'], $options);
115
-  }
116
-  $field['class'] = 'privatemsg-list-count';
117
-  return $field;
115
+    }
116
+    $field['class'] = 'privatemsg-list-count';
117
+    return $field;
118 118
 }
119 119
 
120 120
 /**
@@ -123,10 +123,10 @@  discard block
 block discarded – undo
123 123
  * @see theme_privatemsg_list_field()
124 124
  */
125 125
 function phptemplate_privatemsg_list_field__last_updated($thread) {
126
-  $field = array();
127
-  $field['data'] = format_date($thread['last_updated'], 'small');
128
-  $field['class'] = 'privatemsg-list-date';
129
-  return $field;
126
+    $field = array();
127
+    $field['data'] = format_date($thread['last_updated'], 'small');
128
+    $field['class'] = 'privatemsg-list-date';
129
+    return $field;
130 130
 }
131 131
 
132 132
 /**
@@ -135,10 +135,10 @@  discard block
 block discarded – undo
135 135
  * @see theme_privatemsg_list_field()
136 136
  */
137 137
 function phptemplate_privatemsg_list_field__thread_started($thread) {
138
-  $field = array();
139
-  $field['data'] = format_date($thread['thread_started'], 'small');
140
-  $field['class'] = 'privatemsg-list-date-started';
141
-  return $field;
138
+    $field = array();
139
+    $field['data'] = format_date($thread['thread_started'], 'small');
140
+    $field['class'] = 'privatemsg-list-date-started';
141
+    return $field;
142 142
 }
143 143
 
144 144
 /**
@@ -162,13 +162,13 @@  discard block
 block discarded – undo
162 162
  * @see theme_privatemsg_list_header()
163 163
  */
164 164
 function phptemplate_privatemsg_list_header__subject() {
165
-  return array(
165
+    return array(
166 166
     'data'    => t('Subject'),
167 167
     'field'   => 'subject',
168 168
     'key'     => 'subject',
169 169
     'class'   => 'privatemsg-header-subject',
170 170
     '#weight' => -40,
171
-  );
171
+    );
172 172
 }
173 173
 
174 174
 /**
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
  * @see theme_privatemsg_list_header()
178 178
  */
179 179
 function phptemplate_privatemsg_list_header__count() {
180
-  return array(
180
+    return array(
181 181
     'data'    => t('Messages'),
182 182
     'key'     => 'count',
183 183
     'class'   => 'privatemsg-header-count',
184 184
     '#weight' => -25,
185
-  );
185
+    );
186 186
 }
187 187
 
188 188
 /**
@@ -191,12 +191,12 @@  discard block
 block discarded – undo
191 191
  * @see theme_privatemsg_list_header()
192 192
  */
193 193
 function phptemplate_privatemsg_list_header__participants() {
194
-  return array(
194
+    return array(
195 195
     'data'    => t('Participants'),
196 196
     'key'     => 'participants',
197 197
     'class'   => 'privatemsg-header-participants',
198 198
     '#weight' => -30,
199
-  );
199
+    );
200 200
 }
201 201
 
202 202
 /**
@@ -205,14 +205,14 @@  discard block
 block discarded – undo
205 205
  * @see theme_privatemsg_list_header()
206 206
  */
207 207
 function phptemplate_privatemsg_list_header__last_updated() {
208
-  return array(
208
+    return array(
209 209
     'data'    => t('Last Updated'),
210 210
     'field'   => 'last_updated',
211 211
     'key'     => 'last_updated',
212 212
     'sort'    => 'desc',
213 213
     'class'   => 'privatemsg-header-lastupdated',
214 214
     '#weight' => -20,
215
-  );
215
+    );
216 216
 }
217 217
 
218 218
 /**
@@ -221,13 +221,13 @@  discard block
 block discarded – undo
221 221
  * @see theme_privatemsg_list_header()
222 222
  */
223 223
 function phptemplate_privatemsg_list_header__thread_started() {
224
-  return array(
224
+    return array(
225 225
     'data'    => t('Started'),
226 226
     'field'   => 'thread_started',
227 227
     'key'     => 'thread_started',
228 228
     'class'   => 'privatemsg-header-threadstarted',
229 229
     '#weight' => -15,
230
-  );
230
+    );
231 231
 }
232 232
 
233 233
 /**
@@ -237,70 +237,70 @@  discard block
 block discarded – undo
237 237
  * by the header and field theme patterns.
238 238
  */
239 239
 function theme_privatemsg_list($form) {
240
-  $has_posts = !empty($form['#data']);
240
+    $has_posts = !empty($form['#data']);
241 241
 
242
-  drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css');
242
+    drupal_add_css(drupal_get_path('module', 'privatemsg') .'/styles/privatemsg-list.css');
243 243
 
244
-  // Load the table columns.
245
-  $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants'))));
244
+    // Load the table columns.
245
+    $columns = array_merge(array('subject', 'last_updated'), array_filter(variable_get('privatemsg_display_fields', array('participants'))));
246 246
 
247
-  // Load the themed list headers based on the available data.
248
-  $headers = _privatemsg_list_headers(!empty($form['#data']), $columns);
249
-  // sort the headers array based on the #weight property.
250
-  usort($headers, 'element_sort');
247
+    // Load the themed list headers based on the available data.
248
+    $headers = _privatemsg_list_headers(!empty($form['#data']), $columns);
249
+    // sort the headers array based on the #weight property.
250
+    usort($headers, 'element_sort');
251 251
 
252
-  $themed_rows = array();
253
-  // Check if there is atleast a single thread.
254
-  if ($has_posts) {
252
+    $themed_rows = array();
253
+    // Check if there is atleast a single thread.
254
+    if ($has_posts) {
255 255
     foreach ($form['#data'] as $thread_id => $data) {
256
-      // Theme the row.
257
-      $row = _privatemsg_list_thread($data);
258
-      $data = array();
259
-      // Render the checkbox.
260
-      $data[] = array('data' => drupal_render($form['threads'][$thread_id]), 'class' => 'privatemsg-list-select');
256
+        // Theme the row.
257
+        $row = _privatemsg_list_thread($data);
258
+        $data = array();
259
+        // Render the checkbox.
260
+        $data[] = array('data' => drupal_render($form['threads'][$thread_id]), 'class' => 'privatemsg-list-select');
261 261
 
262
-      // Store the #rows data in the same order as the header is, the key property of the header refers to the field that belongs to it.
263
-      foreach ($headers as $header) {
262
+        // Store the #rows data in the same order as the header is, the key property of the header refers to the field that belongs to it.
263
+        foreach ($headers as $header) {
264 264
         if (!empty($header['key'])) {
265
-          if (isset($row['data'][$header['key']])) {
265
+            if (isset($row['data'][$header['key']])) {
266 266
             $data[] = $row['data'][$header['key']];
267
-          }
268
-          else {
267
+            }
268
+            else {
269 269
             // Store a empty value so that the order is still correct.
270 270
             $data[] = '';
271
-          }
271
+            }
272
+        }
272 273
         }
273
-      }
274
-      // Replace the data
275
-      $row['data'] = $data;
276
-      $themed_rows[] = $row;
274
+        // Replace the data
275
+        $row['data'] = $data;
276
+        $themed_rows[] = $row;
277 277
     }
278
-  }
279
-  else {
278
+    }
279
+    else {
280 280
     // Display a message if now messages are available.
281 281
     $themed_rows[] = array(array('data' => t('No messages available.'), 'colspan' => count($headers)));
282
-  }
282
+    }
283 283
 
284
-  // Remove any data in header that we don't need anymore.
285
-  foreach ($headers as $id => $header) {
284
+    // Remove any data in header that we don't need anymore.
285
+    foreach ($headers as $id => $header) {
286 286
     unset($headers[$id]['key']);
287 287
     unset($headers[$id]['#weight']);
288
-  }
288
+    }
289 289
 
290
-  // Theme the table, pass all generated information to the table theme function.
291
-  $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'privatemsg-list')), '#weight' => 5);
292
-  return drupal_render($form);
290
+    // Theme the table, pass all generated information to the table theme function.
291
+    $form['list'] = array('#value' => theme('table', $headers, $themed_rows, array('class' => 'privatemsg-list')), '#weight' => 5);
292
+    return drupal_render($form);
293 293
 }
294 294
 
295 295
 /**
296 296
  * Theme a block which displays the number of new messages a user has.
297 297
  */
298 298
 function theme_privatemsg_new_block($count) {
299
-  $text = format_plural($count, 'You have a new message, click here to read it',
299
+    $text = format_plural($count, 'You have a new message, click here to read it',
300 300
                         'You have @count new messages, click here to read them',
301 301
                         array('@count' => $count));
302 302
 
303
-  return l($text, 'messages', array('attributes' => array('id' => 'privatemsg-new-link')));
303
+    return l($text, 'messages', array('attributes' => array('id' => 'privatemsg-new-link')));
304 304
 }
305 305
 
306 306
 /**
Please login to merge, or discard this patch.
default/boinc/modules/contrib/privatemsg/pm_block_user/pm_block_user.module 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -19,17 +19,17 @@  discard block
 block discarded – undo
19 19
  * Implements hook_help().
20 20
  */
21 21
 function pm_block_user_help($path) {
22
-  switch ($path) {
22
+    switch ($path) {
23 23
     case 'admin/settings/messages/block':
24 24
       return '<p>' . t('This area is used to define user blocking rules for the Privatemsg module. Rules allow control of who may block messages from whom. By default all users are allowed to block messages from anyone else. However, a site may have groups of users that need to contact or get information to others, for example: the site may have administrative staff or be a forum with moderators. Groups of users are defined by roles, which can be managed on the <a href="@roles">roles configuration page</a>.', array('@roles' => url('admin/user/roles'))) . '</p>';
25
-  }
25
+    }
26 26
 }
27 27
 
28 28
 /**
29 29
  * Implements hook_menu().
30 30
  */
31 31
 function pm_block_user_menu() {
32
-  $items['messages/block/%user'] = array(
32
+    $items['messages/block/%user'] = array(
33 33
     'title'            => 'Block user messages',
34 34
     'page callback'    => 'drupal_get_form',
35 35
     'page arguments'   => array('pm_block_user_form', 2),
@@ -37,61 +37,61 @@  discard block
 block discarded – undo
37 37
     'access arguments' => array(2),
38 38
     'type'             => MENU_CALLBACK,
39 39
     'weight'           => -10,
40
-  );
40
+    );
41 41
 
42
-  $items['admin/settings/messages/block'] = array(
42
+    $items['admin/settings/messages/block'] = array(
43 43
     'title'            => 'User blocking rules',
44 44
     'description'      => 'Configure rules for which users may block each other.',
45 45
     'page callback'    => 'drupal_get_form',
46 46
     'page arguments'   => array('pm_block_user_settings'),
47 47
     'access arguments' => array('administer privatemsg settings'),
48 48
     'type'             => MENU_LOCAL_TASK,
49
-  );
49
+    );
50 50
 
51
-  $items['messages/block/js'] = array(
51
+    $items['messages/block/js'] = array(
52 52
     'title' => 'Javascript block actions form',
53 53
     'page callback' => 'pm_block_user_js',
54 54
     'access arguments' => array('administer privatemsg settings'),
55 55
     'type' => MENU_CALLBACK,
56
-  );
56
+    );
57 57
 
58
-  return $items;
58
+    return $items;
59 59
 }
60 60
 
61 61
 /**
62 62
  * Menu callback for blocked user settings.
63 63
  */
64 64
 function pm_block_user_settings(&$form_state) {
65
-  drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
66
-  // Need to cache form for AHAH, so it can be rebuilt from cache later.
67
-  $form = array(
65
+    drupal_add_css(drupal_get_path('module', 'pm_block_user') .'/pm_block_user.css');
66
+    // Need to cache form for AHAH, so it can be rebuilt from cache later.
67
+    $form = array(
68 68
     '#cache' => TRUE,
69
-  );
69
+    );
70 70
 
71
-  // Container for just the actions, used for AHAH.
72
-  $form['block_actions'] = array(
71
+    // Container for just the actions, used for AHAH.
72
+    $form['block_actions'] = array(
73 73
     '#tree' => TRUE,
74 74
     '#prefix' => '<div id="block-actions">',
75 75
     '#suffix' => '</div>',
76 76
     '#theme' => 'pm_block_user_actions',
77
-  );
77
+    );
78 78
 
79
-  // Should we populate the form with data from $form_state or the database?
80
-  if (!isset($form_state['pm_block_user']['block_actions'])) {
79
+    // Should we populate the form with data from $form_state or the database?
80
+    if (!isset($form_state['pm_block_user']['block_actions'])) {
81 81
     $block_actions = variable_get('pm_block_user_actions', array());
82
-  }
83
-  else {
82
+    }
83
+    else {
84 84
     $block_actions = $form_state['pm_block_user']['block_actions'];
85
-  }
86
-  // Work through each rule, adding it as a new element in
87
-  // $form['block_actions'] ready to be themed later.
88
-  foreach ($block_actions as $delta => $details) {
85
+    }
86
+    // Work through each rule, adding it as a new element in
87
+    // $form['block_actions'] ready to be themed later.
88
+    foreach ($block_actions as $delta => $details) {
89 89
     $details['delta'] = $delta;
90 90
     $form['block_actions'][$delta] = _pm_block_user_actions_form($details);
91
-  }
91
+    }
92 92
 
93
-  // The magic AHAH callback button that adds more rows.
94
-  $form['pm_block_actions_more'] = array(
93
+    // The magic AHAH callback button that adds more rows.
94
+    $form['pm_block_actions_more'] = array(
95 95
     '#type' => 'submit',
96 96
     '#value' => t('More'),
97 97
     '#weight' => 1,
@@ -99,20 +99,20 @@  discard block
 block discarded – undo
99 99
     '#suffix' => '<label for="edit-pm-block-actions-more">' . t('Add new rule') . '</label></div>',
100 100
     '#submit' => array('pm_block_user_more_submit'),
101 101
     '#ahah' => array(
102
-      'path' => 'messages/block/js',
103
-      'wrapper' => 'block-actions',
104
-      'method' => 'replace',
105
-      'effect' => 'fade',
102
+        'path' => 'messages/block/js',
103
+        'wrapper' => 'block-actions',
104
+        'method' => 'replace',
105
+        'effect' => 'fade',
106 106
     ),
107
-  );
107
+    );
108 108
 
109
-  $form['submit_form'] = array(
109
+    $form['submit_form'] = array(
110 110
     '#type' => 'submit',
111 111
     '#weight' => 10,
112 112
     '#value' => t('Save configuration'),
113
-  );
113
+    );
114 114
 
115
-  return $form;
115
+    return $form;
116 116
 }
117 117
 
118 118
 /**
@@ -132,50 +132,50 @@  discard block
 block discarded – undo
132 132
  *   Part of a form with controls for sending, receiving and actions.
133 133
  */
134 134
 function _pm_block_user_actions_form($details, $blacklist = TRUE) {
135
-  $form = array(
135
+    $form = array(
136 136
     '#tree' => TRUE,
137
-  );
138
-  $delta = $details['delta'];
139
-  // FALSE by default, or if the user has checked the 'Enabled' check box for
140
-  // this row.
141
-  $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE);
137
+    );
138
+    $delta = $details['delta'];
139
+    // FALSE by default, or if the user has checked the 'Enabled' check box for
140
+    // this row.
141
+    $row_disabled = (isset($details['enabled']) ? !$details['enabled'] : FALSE);
142 142
 
143
-  $form['author'] = array(
143
+    $form['author'] = array(
144 144
     '#type' => 'select',
145 145
     '#options' => user_roles(TRUE),
146 146
     '#default_value' => (isset($details['author']) ? $details['author'] : DRUPAL_AUTHENTICATED_RID),
147 147
     '#disabled' => $row_disabled,
148
-  );
149
-  $form['recipient'] = array(
148
+    );
149
+    $form['recipient'] = array(
150 150
     '#type' => 'select',
151 151
     '#options' => user_roles(TRUE),
152 152
     '#default_value' => (isset($details['recipient']) ? $details['recipient'] : DRUPAL_AUTHENTICATED_RID),
153 153
     '#disabled' => $row_disabled,
154
-  );
154
+    );
155 155
 
156
-  // Provide different action radios if we're using a whitelist or a blacklist.
157
-  if ($blacklist) {
156
+    // Provide different action radios if we're using a whitelist or a blacklist.
157
+    if ($blacklist) {
158 158
     $options = array(
159
-      PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'),
160
-      PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'),
159
+        PM_BLOCK_USER_DISALLOW_BLOCKING => t('Disallow blocking author'),
160
+        PM_BLOCK_USER_DISALLOW_SENDING => t('Disallow sending message'),
161 161
     );
162 162
     $default_value = (isset($details['action']) ? $details['action'] : PM_BLOCK_USER_DISALLOW_BLOCKING);
163
-  }
164
-  else {
163
+    }
164
+    else {
165 165
     // @todo: add whitelist options/default_value here.
166
-  }
167
-  $form['action']  = array(
166
+    }
167
+    $form['action']  = array(
168 168
     '#type' => 'radios',
169 169
     '#options' => $options,
170 170
     '#disabled' => $row_disabled,
171 171
     '#default_value' => $default_value,
172
-  );
172
+    );
173 173
 
174
-  $form['enabled'] = array(
174
+    $form['enabled'] = array(
175 175
     '#type' => 'checkbox',
176 176
     '#default_value' => (isset($details['enabled']) ? $details['enabled'] : TRUE),
177
-  );
178
-  $form['remove'] = array(
177
+    );
178
+    $form['remove'] = array(
179 179
     '#type' => 'submit',
180 180
     '#submit' => array('pm_block_user_remove_submit'),
181 181
     '#value' => t('Remove'),
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
     '#prefix' => '<div id="remove-rule-button">',
184 184
     '#suffix' => '<label for="edit-remove">' . t('Remove rule') . '</label></div>',
185 185
     '#ahah' => array(
186
-      'path' => 'messages/block/js',
187
-      'wrapper' => 'block-actions',
188
-      'method' => 'replace',
189
-      'effect' => 'fade',
186
+        'path' => 'messages/block/js',
187
+        'wrapper' => 'block-actions',
188
+        'method' => 'replace',
189
+        'effect' => 'fade',
190 190
     ),
191
-  );
191
+    );
192 192
 
193
-  return $form;
193
+    return $form;
194 194
 }
195 195
 
196 196
 /**
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
  * @see pm_block_user_remove_submit()
200 200
  */
201 201
 function pm_block_user_more_submit($form, &$form_state) {
202
-  unset($form_state['submit_handlers']);
203
-  form_execute_handlers('submit', $form, $form_state);
204
-  // Get the submitted actions, then put them into a special area of
205
-  // the $form_state.
206
-  $submitted_values = $form_state['values'];
207
-  // Add an empty action.
208
-  $submitted_values['block_actions'][] = array();
209
-  $form_state['pm_block_user'] = $submitted_values;
210
-  // Rebuild the form by passing our $form_state through the
211
-  // pm_block_user_settings() builder function.
212
-  $form_state['rebuild'] = TRUE;
202
+    unset($form_state['submit_handlers']);
203
+    form_execute_handlers('submit', $form, $form_state);
204
+    // Get the submitted actions, then put them into a special area of
205
+    // the $form_state.
206
+    $submitted_values = $form_state['values'];
207
+    // Add an empty action.
208
+    $submitted_values['block_actions'][] = array();
209
+    $form_state['pm_block_user'] = $submitted_values;
210
+    // Rebuild the form by passing our $form_state through the
211
+    // pm_block_user_settings() builder function.
212
+    $form_state['rebuild'] = TRUE;
213 213
 }
214 214
 
215 215
 /**
@@ -218,33 +218,33 @@  discard block
 block discarded – undo
218 218
  * @see pm_block_user_more_submit()
219 219
  */
220 220
 function pm_block_user_remove_submit($form, &$form_state) {
221
-  unset($form_state['submit_handlers']);
222
-  form_execute_handlers('submit', $form, $form_state);
223
-  $submitted_values = $form_state['values'];
224
-  // Remove the requested action.
225
-  $delta = $form_state['clicked_button']['#parents'][1];
226
-  unset($submitted_values['block_actions'][$delta]);
227
-  $form_state['pm_block_user'] = $submitted_values;
228
-  $form_state['rebuild'] = TRUE;
221
+    unset($form_state['submit_handlers']);
222
+    form_execute_handlers('submit', $form, $form_state);
223
+    $submitted_values = $form_state['values'];
224
+    // Remove the requested action.
225
+    $delta = $form_state['clicked_button']['#parents'][1];
226
+    unset($submitted_values['block_actions'][$delta]);
227
+    $form_state['pm_block_user'] = $submitted_values;
228
+    $form_state['rebuild'] = TRUE;
229 229
 }
230 230
 
231 231
 /**
232 232
  * Submit handler for admin form.
233 233
  */
234 234
 function pm_block_user_settings_submit($form, &$form_state) {
235
-  // We don't want it to submit when we're adding/removing actions.
236
-  if ($form_state['clicked_button']['#id'] == 'edit-submit-form') {
235
+    // We don't want it to submit when we're adding/removing actions.
236
+    if ($form_state['clicked_button']['#id'] == 'edit-submit-form') {
237 237
     // If the form's 'block_actions' aren't set, the user has deleted all the
238 238
     // rows in the table, so we save an empty array to stop errors in the form
239 239
     // builder.
240 240
     if (isset($form_state['values']['block_actions'])) {
241
-      variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions']));
241
+        variable_set('pm_block_user_actions', _pm_block_user_settings_filter($form_state['values']['block_actions']));
242 242
     }
243 243
     else {
244
-      variable_set('pm_block_user_actions', array());
244
+        variable_set('pm_block_user_actions', array());
245 245
     }
246 246
     drupal_set_message(t('The configuration options have been saved.'));
247
-  }
247
+    }
248 248
 }
249 249
 
250 250
 /**
@@ -259,60 +259,60 @@  discard block
 block discarded – undo
259 259
  * @see pm_block_user_settings_submit()
260 260
  */
261 261
 function _pm_block_user_settings_filter($settings) {
262
-  // Add-in the names of any settings to be saved into the array below.
263
-  $save_keys = array('author', 'recipient', 'action', 'enabled');
264
-  $matching = array();
265
-  // Run through each of the keys we want to save, creating a new array.
266
-  // It's not possible to simply check for unwanted values and unset() them as
267
-  // the array is multi-dimensional.
268
-  foreach ($save_keys as $save_key) {
262
+    // Add-in the names of any settings to be saved into the array below.
263
+    $save_keys = array('author', 'recipient', 'action', 'enabled');
264
+    $matching = array();
265
+    // Run through each of the keys we want to save, creating a new array.
266
+    // It's not possible to simply check for unwanted values and unset() them as
267
+    // the array is multi-dimensional.
268
+    foreach ($save_keys as $save_key) {
269 269
     if (isset($settings[$save_key])) {
270
-      $matching[$save_key] = $settings[$save_key];
270
+        $matching[$save_key] = $settings[$save_key];
271
+    }
271 272
     }
272
-  }
273
-  if (count($matching) > 0) {
273
+    if (count($matching) > 0) {
274 274
     return $matching;
275
-  }
276
-  else {
275
+    }
276
+    else {
277 277
     return array_map('_pm_block_user_settings_filter', $settings);
278
-  }
278
+    }
279 279
 }
280 280
 
281 281
 /**
282 282
  * Menu callback for AHAH handling.
283 283
  */
284 284
 function pm_block_user_js() {
285
-  // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
286
-  $form_state = array('storage' => NULL, 'submitted' => FALSE);
287
-  $form_build_id = $_POST['form_build_id'];
288
-  $form = form_get_cache($form_build_id, $form_state);
289
-  $args = $form['#parameters'];
290
-  $form_id = array_shift($args);
291
-  $form['#post'] = $_POST;
292
-  $form['#redirect'] = FALSE;
293
-  $form['#programmed'] = FALSE;
294
-  $form_state['post'] = $_POST;
295
-  drupal_process_form($form_id, $form, $form_state);
296
-  $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
297
-  $output_form = $form['block_actions'];
298
-  unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers.
299
-  $output = theme('status_messages') . drupal_render($output_form);
300
-
301
-  // Hack to make behaviours attach to new HTML controls (delete buttons in
302
-  // this case).
303
-  $javascript = drupal_add_js(NULL, NULL, 'header');
304
-  drupal_json(array('status' => TRUE, 'data' => $output));
285
+    // See: http://drupal.org/node/331941 for the philosophy of Drupal AHAH.
286
+    $form_state = array('storage' => NULL, 'submitted' => FALSE);
287
+    $form_build_id = $_POST['form_build_id'];
288
+    $form = form_get_cache($form_build_id, $form_state);
289
+    $args = $form['#parameters'];
290
+    $form_id = array_shift($args);
291
+    $form['#post'] = $_POST;
292
+    $form['#redirect'] = FALSE;
293
+    $form['#programmed'] = FALSE;
294
+    $form_state['post'] = $_POST;
295
+    drupal_process_form($form_id, $form, $form_state);
296
+    $form = drupal_rebuild_form($form_id, $form_state, $args, $form_build_id);
297
+    $output_form = $form['block_actions'];
298
+    unset($output_form['#prefix'], $output_form['#suffix']); // Prevent duplicate wrappers.
299
+    $output = theme('status_messages') . drupal_render($output_form);
300
+
301
+    // Hack to make behaviours attach to new HTML controls (delete buttons in
302
+    // this case).
303
+    $javascript = drupal_add_js(NULL, NULL, 'header');
304
+    drupal_json(array('status' => TRUE, 'data' => $output));
305 305
 }
306 306
 
307 307
 /**
308 308
  * Implements hook_theme().
309 309
  */
310 310
 function pm_block_user_theme() {
311
-  return array(
311
+    return array(
312 312
     'pm_block_user_actions' => array(
313
-      'arguments' => array('form' => NULL),
313
+        'arguments' => array('form' => NULL),
314 314
     ),
315
-  );
315
+    );
316 316
 }
317 317
 
318 318
 /**
@@ -321,49 +321,49 @@  discard block
 block discarded – undo
321 321
  * @ingroup themeable
322 322
  */
323 323
 function theme_pm_block_user_actions($form) {
324
-  $rows = array();
325
-  $headers = array(
324
+    $rows = array();
325
+    $headers = array(
326 326
     t('If the author has the role'),
327 327
     t('And the recipient has the role'),
328 328
     t('Action'),
329 329
     t('Enabled'),
330 330
     '',
331
-  );
332
-  $form_data = element_children($form);
331
+    );
332
+    $form_data = element_children($form);
333 333
 
334
-  foreach ($form_data as $key) {
334
+    foreach ($form_data as $key) {
335 335
     // Build the table row.
336 336
     $row = array(
337
-      'data' => array(
337
+        'data' => array(
338 338
         array('data' => drupal_render($form[$key]['author'])),
339 339
         array('data' => drupal_render($form[$key]['recipient'])),
340 340
         array('data' => drupal_render($form[$key]['action'])),
341 341
         array('data' => drupal_render($form[$key]['enabled'])),
342 342
         array('data' => drupal_render($form[$key]['remove'])),
343
-      ),
343
+        ),
344 344
     );
345 345
 
346 346
     // Add additional attributes to the row, such as a class for this row.
347 347
     if (isset($form[$key]['#attributes'])) {
348
-      $row = array_merge($row, $form[$key]['#attributes']);
348
+        $row = array_merge($row, $form[$key]['#attributes']);
349 349
     }
350 350
     $rows[] = $row;
351
-  }
351
+    }
352 352
 
353
-  // If there are no rows, output some instructions for the user.
354
-  if (empty($form_data)) {
353
+    // If there are no rows, output some instructions for the user.
354
+    if (empty($form_data)) {
355 355
     $rows[] = array(
356
-      array(
356
+        array(
357 357
         'data' => t("No rules have been added. All users may block private messages from each other. To limit which users may be blocked, click 'Add new rule'."),
358 358
         'colspan' => '5',
359
-      ),
359
+        ),
360 360
     );
361
-  }
361
+    }
362 362
 
363
-  $output = theme('table', $headers, $rows);
364
-  $output .= drupal_render($form);
363
+    $output = theme('table', $headers, $rows);
364
+    $output .= drupal_render($form);
365 365
 
366
-  return $output;
366
+    return $output;
367 367
 }
368 368
 
369 369
 /**
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
  *   TRUE if the user is allowed to block $account, or FALSE if not.
378 378
  */
379 379
 function _pm_block_user_access($account) {
380
-  global $user;
381
-  if (!privatemsg_user_access('read privatemsg', $user)) {
380
+    global $user;
381
+    if (!privatemsg_user_access('read privatemsg', $user)) {
382 382
     return FALSE;
383
-  }
384
-  if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
383
+    }
384
+    if (_pm_block_user_rule_exists($account, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
385 385
     return FALSE;
386
-  }
387
-  return TRUE;
386
+    }
387
+    return TRUE;
388 388
 }
389 389
 
390 390
 /**
@@ -406,179 +406,179 @@  discard block
 block discarded – undo
406 406
  *   TRUE if a rule exists for the combination of author recipient and action.
407 407
  */
408 408
 function _pm_block_user_rule_exists($author, $recipient, $action = PM_BLOCK_USER_DISALLOW_BLOCKING) {
409
-  $block_actions = variable_get('pm_block_user_actions', array());
410
-  foreach ($block_actions as $delta => $details) {
409
+    $block_actions = variable_get('pm_block_user_actions', array());
410
+    foreach ($block_actions as $delta => $details) {
411 411
     // If this rule doesn't relate to $action, or it's disabled
412 412
     // ignore it and go to next loop iteration.
413 413
     if ($details['action'] != $action || !$details['enabled']) {
414
-      continue;
414
+        continue;
415 415
     }
416 416
     // There are no rules governing user one, but user one may have roles that
417 417
     // affect other users, so these exceptions are narrow in scope.
418 418
     // Disallow sending affects private message authors.
419 419
     if ($author->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_SENDING) {
420
-      continue;
420
+        continue;
421 421
     }
422 422
     // Disallow blocking affects private message recipients.
423 423
     if ($recipient->uid == 1 && $action == PM_BLOCK_USER_DISALLOW_BLOCKING) {
424
-      continue;
424
+        continue;
425 425
     }
426 426
     // The author has a role matching the rule and so does the recipient.
427 427
     if (isset($author->roles[$details['author']]) && isset($recipient->roles[$details['recipient']])) {
428
-      return TRUE;
428
+        return TRUE;
429
+    }
429 430
     }
430
-  }
431
-  return FALSE;
431
+    return FALSE;
432 432
 }
433 433
 
434 434
 function pm_block_user_form($form_state, $author) {
435
-  global $user;
435
+    global $user;
436 436
 
437
-  $form['author'] = array(
437
+    $form['author'] = array(
438 438
     '#type' => 'value',
439 439
     '#value' => $author->uid,
440
-  );
440
+    );
441 441
     $form['recipient'] = array(
442 442
     '#type' => 'value',
443 443
     '#value' => $user->uid,
444
-  );
445
-  $form['author_name'] = array(
444
+    );
445
+    $form['author_name'] = array(
446 446
     '#type' => 'value',
447 447
     '#value' => $author->name,
448
-  );
449
-  $form['destination'] = array(
448
+    );
449
+    $form['destination'] = array(
450 450
     '#type' => 'value',
451 451
     '#value' => isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
452
-  );
452
+    );
453 453
 
454
-  if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) {
454
+    if (db_result(db_query('SELECT COUNT(recipient) FROM {pm_block_user} WHERE author = %d AND recipient = %d', $author->uid, $user->uid))) {
455 455
     $form['block_action'] = array(
456
-      '#type' => 'value',
457
-      '#value' => 'unblock_user',
456
+        '#type' => 'value',
457
+        '#value' => 'unblock_user',
458 458
     );
459 459
     return confirm_form($form,
460
-      t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)),
461
-      isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
462
-      t('This action cannot be undone.'),
463
-      t('Unblock @author', array('@author' => $author->name)),
464
-      t('Cancel')
460
+        t('You have previously blocked "@author" from sending you any more messages. Are you sure you want to unblock this user?', array('@author' => $author->name)),
461
+        isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
462
+        t('This action cannot be undone.'),
463
+        t('Unblock @author', array('@author' => $author->name)),
464
+        t('Cancel')
465 465
     );
466
-  }
467
-  else {
466
+    }
467
+    else {
468 468
     $form['block_action'] = array(
469
-      '#type' => 'value',
470
-      '#value' => 'block_user',
469
+        '#type' => 'value',
470
+        '#value' => 'block_user',
471 471
     );
472 472
     return confirm_form($form,
473
-      t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)),
474
-      isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
475
-      '',
476
-      t('Block @author', array('@author' => $author->name)),
477
-      t('Cancel')
473
+        t('Are you sure you want to block "@author" from sending you any more messages?', array('@author' => $author->name)),
474
+        isset($_GET['destination']) ? $_GET['destination'] : 'messages/',
475
+        '',
476
+        t('Block @author', array('@author' => $author->name)),
477
+        t('Cancel')
478 478
     );
479
-  }
479
+    }
480 480
 }
481 481
 
482 482
 /**
483 483
  * Implements hook_form_submit().
484 484
  */
485 485
 function pm_block_user_form_submit($form, &$form_state) {
486
-  if ($form_state['values']['confirm']) {
486
+    if ($form_state['values']['confirm']) {
487 487
     switch ($form_state['values']['block_action']) {
488
-      case 'block_user':
488
+        case 'block_user':
489 489
         db_query('INSERT INTO {pm_block_user} (author, recipient) VALUES (%d, %d)', $form_state['values']['author'], $form_state['values']['recipient']);
490 490
         drupal_set_message(t('@author has been blocked from sending you any further messages.', array('@author' => $form_state['values']['author_name'])));
491
-      break;
492
-      case 'unblock_user':
491
+        break;
492
+        case 'unblock_user':
493 493
         db_query('DELETE FROM {pm_block_user} WHERE author = %d AND recipient = %d', $form_state['values']['author'], $form_state['values']['recipient']);
494 494
         drupal_set_message(t('@author is now allowed to send you new messages.', array('@author' => $form_state['values']['author_name'])));
495
-      break;
495
+        break;
496
+    }
496 497
     }
497
-  }
498
-  $form_state['redirect'] = $form_state['values']['destination'];
498
+    $form_state['redirect'] = $form_state['values']['destination'];
499 499
 }
500 500
 
501 501
 /**
502 502
  * Implements hook_privatemsg_block_message().
503 503
  */
504 504
 function pm_block_user_privatemsg_block_message($author, $recipients) {
505
-  $blocked = array();
506
-  // Loop through each recipient and ensure there is no rule blocking this
507
-  // author from sending them private messages. Use a reference, so when
508
-  // user_load() is needed here the array is updated, negating the need for
509
-  // further calls to user_load() later in the code.
510
-  foreach (array_keys($recipients) as $uid) {
505
+    $blocked = array();
506
+    // Loop through each recipient and ensure there is no rule blocking this
507
+    // author from sending them private messages. Use a reference, so when
508
+    // user_load() is needed here the array is updated, negating the need for
509
+    // further calls to user_load() later in the code.
510
+    foreach (array_keys($recipients) as $uid) {
511 511
 
512 512
     // Ensure we have a recipient user object which includes roles.
513 513
     if (!isset($recipients[$uid]->roles)) {
514
-      $recipients[$uid] = user_load($uid);
514
+        $recipients[$uid] = user_load($uid);
515 515
     }
516 516
     // Note: this is checks whether the author may send the message (see third
517 517
     // parameter). Further below is a check whether the recipient may block it.
518 518
     if (_pm_block_user_rule_exists($author, $recipients[$uid], PM_BLOCK_USER_DISALLOW_SENDING)) {
519
-      $blocked[] = array(
519
+        $blocked[] = array(
520 520
         'uid' => $uid,
521 521
         'message' => t('Sorry, private messaging rules forbid sending messages to !name.', array('!name' => $recipients[$uid]->name)),
522
-      );
522
+        );
523
+    }
523 524
     }
524
-  }
525 525
 
526
-  $args = array_merge(array($author->uid), array_keys($recipients));
527
-  $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args);
528
-  while ($row = db_fetch_array($result)) {
526
+    $args = array_merge(array($author->uid), array_keys($recipients));
527
+    $result = db_query('SELECT recipient FROM {pm_block_user} WHERE author = %d AND recipient IN ('. db_placeholders($recipients) .') GROUP BY recipient', $args);
528
+    while ($row = db_fetch_array($result)) {
529 529
     $recipient = $recipients[$row['recipient']];
530 530
     // If there's a rule disallowing blocking of this message, send it anyway.
531 531
     if (_pm_block_user_rule_exists($author, $recipient, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
532
-      continue;
532
+        continue;
533 533
     }
534 534
     $blocked[] = array(
535
-      'uid' => $row['recipient'],
536
-      'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name))
535
+        'uid' => $row['recipient'],
536
+        'message' => t('%name has chosen to not recieve any more messages from you.', array('%name' => $recipients[$row['recipient']]->name))
537 537
     );
538
-  }
539
-  return $blocked;
538
+    }
539
+    return $blocked;
540 540
 }
541 541
 
542 542
 function pm_block_user_privatemsg_sql_load_alter(&$fragments, $pmid, $uid) {
543
-  $fragments['select'][] = 'pmbu.recipient AS is_blocked';
543
+    $fragments['select'][] = 'pmbu.recipient AS is_blocked';
544 544
 
545
-  $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)';
545
+    $fragments['inner_join'][] = 'LEFT JOIN {pm_block_user} pmbu ON (pm.author = pmbu.author AND pmi.uid = pmbu.recipient)';
546 546
 }
547 547
 
548 548
 /**
549 549
  * Implements hook_privatemsg_message_view_alter().
550 550
  */
551 551
 function pm_block_user_privatemsg_message_view_alter(&$vars) {
552
-  global $user;
552
+    global $user;
553 553
 
554
-  $author = $vars['message']['author'];
555
-  if (_pm_block_user_rule_exists($author, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
554
+    $author = $vars['message']['author'];
555
+    if (_pm_block_user_rule_exists($author, $user, PM_BLOCK_USER_DISALLOW_BLOCKING)) {
556 556
     return;
557
-  }
558
-  if (!isset($vars['message']['thread_id'])) {
557
+    }
558
+    if (!isset($vars['message']['thread_id'])) {
559 559
     // No thread id, this is probably only a preview
560 560
     return;
561
-  }
562
-  $thread_id = $vars['message']['thread_id'];
561
+    }
562
+    $thread_id = $vars['message']['thread_id'];
563 563
 
564
-  if ($user->uid <> $author->uid) {
564
+    if ($user->uid <> $author->uid) {
565 565
     if ($vars['message']['is_blocked']) {
566
-      $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
566
+        $vars['message_actions']['unblock_author'] = array('title' => t('Unblock author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
567 567
     }
568 568
     else {
569
-      $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
569
+        $vars['message_actions']['block_author'] = array('title' => t('Block author'), 'href' => 'messages/block/'. $author->uid, 'query' => 'destination=messages/view/' . $thread_id);
570
+    }
570 571
     }
571
-  }
572 572
 }
573 573
 
574 574
 /**
575 575
  * Implement hook_user().
576 576
  */
577 577
 function pm_block_user_user($op, &$edit, &$account, $category = NULL) {
578
-  switch ($op) {
579
-      case 'delete':
578
+    switch ($op) {
579
+        case 'delete':
580 580
       // Delete blocking rules which involve this user.
581 581
       db_query("DELETE FROM {pm_block_user} WHERE author = %d OR recipient = %d", $account->uid, $account->uid);
582
-      break;
583
-  }
582
+        break;
583
+    }
584 584
 }
Please login to merge, or discard this patch.
sites/default/boinc/modules/node_comment_block/node_comment_block.module 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -9,45 +9,45 @@  discard block
 block discarded – undo
9 9
  * Implements hook_block() for Drupal 6 compatibility
10 10
  */
11 11
 function node_comment_block_block($op = 'list', $delta = 0, $edit = array()) {
12
-  switch ($op) {
13
-  case 'view':
12
+    switch ($op) {
13
+    case 'view':
14 14
     //$block = node_comment_block_block_view($delta);
15 15
     $block = array();
16 16
     if ($delta == 'node_comments') {
17
-      if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) {
17
+        if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) {
18 18
         $node = node_load($nid);
19 19
         if ($node->comment !== 0) {
20
-          $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements.
21
-          $block['content'] = '';
22
-          if ($node->comment) {
20
+            $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements.
21
+            $block['content'] = '';
22
+            if ($node->comment) {
23 23
             $block['content'] .= comment_render($node);
24
-          }
24
+            }
25
+        }
25 26
         }
26
-      }
27 27
     }
28 28
     break;
29
-  case 'list':
29
+    case 'list':
30 30
     $blocks = node_comment_block_block_info();
31 31
     return $blocks;
32 32
     break;
33
-  default:
33
+    default:
34 34
   }
35
-  return $block;
35
+    return $block;
36 36
 }
37 37
 
38 38
 /**
39 39
  * Port Drupal 7 render() function to Drupal 6
40 40
  */
41 41
 function render(&$element) {
42
-  if (is_array($element)) {
42
+    if (is_array($element)) {
43 43
     show($element);
44 44
     return drupal_render($element);
45
-  }
46
-  else {
45
+    }
46
+    else {
47 47
     // Safe-guard for inappropriate use of render() on flat variables: return
48 48
     // the variable as-is.
49 49
     return $element;
50
-  }
50
+    }
51 51
 }
52 52
 
53 53
 
@@ -56,50 +56,50 @@  discard block
 block discarded – undo
56 56
  * Implements hook_block_info().
57 57
  */
58 58
 function node_comment_block_block_info() {
59
-  $blocks['node_comments'] = array(
59
+    $blocks['node_comments'] = array(
60 60
     'info' => t('Node comments'),
61
-  );
61
+    );
62 62
 
63
-  return $blocks;
63
+    return $blocks;
64 64
 }
65 65
 
66 66
 /**
67 67
  * Implements hook_block_view().
68 68
  */
69 69
 function node_comment_block_block_view($delta = '') {
70
-  $block = array();
70
+    $block = array();
71 71
 
72
-  if ($delta == 'node_comments') {
72
+    if ($delta == 'node_comments') {
73 73
     if (arg(0) == 'node' && is_numeric($nid = arg(1)) && !arg(2)) {
74
-      $node = node_load($nid);
74
+        $node = node_load($nid);
75 75
 
76
-      if ($node->comment !== 0) {
76
+        if ($node->comment !== 0) {
77 77
         $block['subject'] = NULL; // This should be NULL otherwise there will be duplicate h2 elements.
78 78
         $block['content'] = '';
79 79
 
80 80
         $node = node_view($node);
81 81
 
82 82
         if ($node['comments']) {
83
-          $block['content'] .= render($node['comments']);
83
+            $block['content'] .= render($node['comments']);
84
+        }
84 85
         }
85
-      }
86 86
     }
87
-  }
87
+    }
88 88
 
89
-  return $block;
89
+    return $block;
90 90
 }
91 91
 
92 92
 /**
93 93
  * Implements hook_preprocess_HOOK() for nodes.
94 94
  */
95 95
 function node_comment_block_preprocess_node(&$variables) {
96
-  $node = $variables['node'];
97
-  // Only hide standard comments for news content
98
-  if ($variables['type'] == 'news') {
96
+    $node = $variables['node'];
97
+    // Only hide standard comments for news content
98
+    if ($variables['type'] == 'news') {
99 99
     $variables['node']->comment = 0;
100
-  }
100
+    }
101 101
   
102
-  /* Drupal 7...
102
+    /* Drupal 7...
103 103
   if ($node->comment !== 0 && $variables['view_mode'] == 'full') {
104 104
     if (isset($variables['content']['comments'])) {
105 105
       unset($variables['content']['comments']);
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
  * Implements hook_form_FORM_ID_alter() for block_admin_configure.
114 114
  */
115 115
 function node_comment_block_form_block_admin_configure_alter(&$form, &$form_state) {
116
-  if (isset($form['delta'])) {
116
+    if (isset($form['delta'])) {
117 117
     if ($form['delta']['#value'] == 'node_comments') {
118
-      $form['settings']['title']['#disabled'] = TRUE;
119
-      $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.');
118
+        $form['settings']['title']['#disabled'] = TRUE;
119
+        $form['settings']['title']['#description'] = t('The title for this block cannot be overridden.');
120
+    }
120 121
     }
121
-  }
122 122
 }
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pBarcode39.class.php 1 patch
Indentation   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pBarcode39 - class to create barcodes (39B)
4 4
 
5 5
      Version     : 2.1.3
@@ -13,188 +13,188 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- /* pData class definition */
17
- class pBarcode39
18
-  {
19
-   var $Codes;
20
-   var $Reverse;
21
-   var $Result;
22
-   var $pChartObject;
23
-   var $CRC;
24
-   var $MOD43;
25
-
26
-   /* Class creator */
27
-   function pBarcode39($BasePath="",$EnableMOD43=FALSE)
16
+    /* pData class definition */
17
+    class pBarcode39
28 18
     {
29
-     $this->MOD43  = $EnableMOD43;
30
-     $this->Codes   = "";
31
-     $this->Reverse = "";
19
+    var $Codes;
20
+    var $Reverse;
21
+    var $Result;
22
+    var $pChartObject;
23
+    var $CRC;
24
+    var $MOD43;
25
+
26
+    /* Class creator */
27
+    function pBarcode39($BasePath="",$EnableMOD43=FALSE)
28
+    {
29
+        $this->MOD43  = $EnableMOD43;
30
+        $this->Codes   = "";
31
+        $this->Reverse = "";
32 32
 
33
-     $FileHandle = @fopen($BasePath."data/39.db", "r");
33
+        $FileHandle = @fopen($BasePath."data/39.db", "r");
34 34
 
35
-     if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."data/39.db)."); }
35
+        if (!$FileHandle) { die("Cannot find barcode database (".$BasePath."data/39.db)."); }
36 36
 
37
-     while (!feof($FileHandle))
38
-      {
39
-       $Buffer = fgets($FileHandle,4096);
40
-       $Buffer = str_replace(chr(10),"",$Buffer);
41
-       $Buffer = str_replace(chr(13),"",$Buffer);
42
-       $Values = preg_split("/;/",$Buffer);
37
+        while (!feof($FileHandle))
38
+        {
39
+        $Buffer = fgets($FileHandle,4096);
40
+        $Buffer = str_replace(chr(10),"",$Buffer);
41
+        $Buffer = str_replace(chr(13),"",$Buffer);
42
+        $Values = preg_split("/;/",$Buffer);
43 43
 
44
-       $this->Codes[$Values[0]] = $Values[1];
45
-      }
46
-     fclose($FileHandle);
44
+        $this->Codes[$Values[0]] = $Values[1];
45
+        }
46
+        fclose($FileHandle);
47 47
     }
48 48
 
49
-   /* Return the projected size of a barcode */
50
-   function getSize($TextString,$Format="")
49
+    /* Return the projected size of a barcode */
50
+    function getSize($TextString,$Format="")
51 51
     {
52
-     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
53
-     $ShowLegend	= isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
54
-     $LegendOffset	= isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
55
-     $DrawArea		= isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
56
-     $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
57
-     $Height		= isset($Format["Height"]) ? $Format["Height"] : 30;
52
+        $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
53
+        $ShowLegend	= isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
54
+        $LegendOffset	= isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
55
+        $DrawArea		= isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
56
+        $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : 12;
57
+        $Height		= isset($Format["Height"]) ? $Format["Height"] : 30;
58 58
 
59
-     $TextString    = $this->encode39($TextString);
60
-     $BarcodeLength = strlen($this->Result);
59
+        $TextString    = $this->encode39($TextString);
60
+        $BarcodeLength = strlen($this->Result);
61 61
 
62
-     if ( $DrawArea )   { $WOffset = 20; } else { $WOffset = 0; }
63
-     if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; }
62
+        if ( $DrawArea )   { $WOffset = 20; } else { $WOffset = 0; }
63
+        if ( $ShowLegend ) { $HOffset = $FontSize+$LegendOffset+$WOffset; } else { $HOffset = 0; }
64 64
 
65
-     $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength);
66
-     $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength);
65
+        $X1 = cos($Angle * PI / 180) * ($WOffset+$BarcodeLength);
66
+        $Y1 = sin($Angle * PI / 180) * ($WOffset+$BarcodeLength);
67 67
 
68
-     $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height);
69
-     $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height);
68
+        $X2 = $X1 + cos(($Angle+90) * PI / 180) * ($HOffset+$Height);
69
+        $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * ($HOffset+$Height);
70 70
 
71 71
 
72
-     $AreaWidth  = max(abs($X1),abs($X2));
73
-     $AreaHeight = max(abs($Y1),abs($Y2));
72
+        $AreaWidth  = max(abs($X1),abs($X2));
73
+        $AreaHeight = max(abs($Y1),abs($Y2));
74 74
 
75
-     return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight));
75
+        return(array("Width"=>$AreaWidth,"Height"=>$AreaHeight));
76 76
     }
77 77
 
78
-   /* Create the encoded string */
79
-   function encode39($Value)
78
+    /* Create the encoded string */
79
+    function encode39($Value)
80 80
     {
81
-     $this->Result = "100101101101"."0";
82
-     $TextString   = "";
83
-     for($i=1;$i<=strlen($Value);$i++)
84
-      {
85
-       $CharCode = ord($this->mid($Value,$i,1));
86
-       if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; }
87
-
88
-       if ( isset($this->Codes[chr($CharCode)]) )
81
+        $this->Result = "100101101101"."0";
82
+        $TextString   = "";
83
+        for($i=1;$i<=strlen($Value);$i++)
84
+        {
85
+        $CharCode = ord($this->mid($Value,$i,1));
86
+        if ( $CharCode >= 97 && $CharCode <= 122 ) { $CharCode = $CharCode - 32; }
87
+
88
+        if ( isset($this->Codes[chr($CharCode)]) )
89 89
         {
90
-         $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0";
91
-         $TextString = $TextString.chr($CharCode);
90
+            $this->Result = $this->Result.$this->Codes[chr($CharCode)]."0";
91
+            $TextString = $TextString.chr($CharCode);
92
+        }
92 93
         }
93
-      }
94 94
 
95
-     if ( $this->MOD43 )
96
-      {
97
-       $Checksum = $this->checksum($TextString);
98
-       $this->Result = $this->Result.$this->Codes[$Checksum]."0";
99
-      }
95
+        if ( $this->MOD43 )
96
+        {
97
+        $Checksum = $this->checksum($TextString);
98
+        $this->Result = $this->Result.$this->Codes[$Checksum]."0";
99
+        }
100 100
 
101
-     $this->Result = $this->Result."100101101101";
102
-     $TextString   = "*".$TextString."*";
101
+        $this->Result = $this->Result."100101101101";
102
+        $TextString   = "*".$TextString."*";
103 103
 
104
-     return($TextString);
104
+        return($TextString);
105 105
     }
106 106
 
107
-   /* Create the encoded string */
108
-   function draw($Object,$Value,$X,$Y,$Format="")
107
+    /* Create the encoded string */
108
+    function draw($Object,$Value,$X,$Y,$Format="")
109 109
     {
110
-     $this->pChartObject = $Object;
111
-
112
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
113
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
114
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
115
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
116
-     $Height		= isset($Format["Height"]) ? $Format["Height"] : 30;
117
-     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
118
-     $ShowLegend	= isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
119
-     $LegendOffset	= isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
120
-     $DrawArea		= isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
121
-     $AreaR		= isset($Format["AreaR"]) ? $Format["AreaR"] : 255;
122
-     $AreaG		= isset($Format["AreaG"]) ? $Format["AreaG"] : 255;
123
-     $AreaB		= isset($Format["AreaB"]) ? $Format["AreaB"] : 255;
124
-     $AreaBorderR	= isset($Format["AreaBorderR"]) ? $Format["AreaBorderR"] : $AreaR;
125
-     $AreaBorderG	= isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG;
126
-     $AreaBorderB	= isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB;
127
-
128
-     $TextString   = $this->encode39($Value);
129
-
130
-     if ( $DrawArea )
131
-      {
132
-       $X1 = $X + cos(($Angle-135) * PI / 180) * 10;
133
-       $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10;
134
-
135
-       $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20);
136
-       $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20);
137
-
138
-       if ( $ShowLegend )
110
+        $this->pChartObject = $Object;
111
+
112
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
113
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
114
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
115
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
116
+        $Height		= isset($Format["Height"]) ? $Format["Height"] : 30;
117
+        $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
118
+        $ShowLegend	= isset($Format["ShowLegend"]) ? $Format["ShowLegend"] : FALSE;
119
+        $LegendOffset	= isset($Format["LegendOffset"]) ? $Format["LegendOffset"] : 5;
120
+        $DrawArea		= isset($Format["DrawArea"]) ? $Format["DrawArea"] : FALSE;
121
+        $AreaR		= isset($Format["AreaR"]) ? $Format["AreaR"] : 255;
122
+        $AreaG		= isset($Format["AreaG"]) ? $Format["AreaG"] : 255;
123
+        $AreaB		= isset($Format["AreaB"]) ? $Format["AreaB"] : 255;
124
+        $AreaBorderR	= isset($Format["AreaBorderR"]) ? $Format["AreaBorderR"] : $AreaR;
125
+        $AreaBorderG	= isset($Format["AreaBorderG"]) ? $Format["AreaBorderG"] : $AreaG;
126
+        $AreaBorderB	= isset($Format["AreaBorderB"]) ? $Format["AreaBorderB"] : $AreaB;
127
+
128
+        $TextString   = $this->encode39($Value);
129
+
130
+        if ( $DrawArea )
139 131
         {
140
-         $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
141
-         $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
132
+        $X1 = $X + cos(($Angle-135) * PI / 180) * 10;
133
+        $Y1 = $Y + sin(($Angle-135) * PI / 180) * 10;
134
+
135
+        $X2 = $X1 + cos($Angle * PI / 180) * (strlen($this->Result)+20);
136
+        $Y2 = $Y1 + sin($Angle * PI / 180) * (strlen($this->Result)+20);
137
+
138
+        if ( $ShowLegend )
139
+        {
140
+            $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
141
+            $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset+$this->pChartObject->FontSize+10);
142 142
         }
143
-       else
143
+        else
144 144
         {
145
-         $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20);
146
-         $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20);
145
+            $X3 = $X2 + cos(($Angle+90) * PI / 180) * ($Height+20);
146
+            $Y3 = $Y2 + sin(($Angle+90) * PI / 180) * ($Height+20);
147 147
         }
148 148
 
149
-       $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
150
-       $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
149
+        $X4 = $X3 + cos(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
150
+        $Y4 = $Y3 + sin(($Angle+180) * PI / 180) * (strlen($this->Result)+20);
151 151
 
152
-       $Polygon  = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4);
153
-       $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB);
154
-       $this->pChartObject->drawPolygon($Polygon,$Settings);
155
-      }
152
+        $Polygon  = array($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4);
153
+        $Settings = array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"BorderR"=>$AreaBorderR,"BorderG"=>$AreaBorderG,"BorderB"=>$AreaBorderB);
154
+        $this->pChartObject->drawPolygon($Polygon,$Settings);
155
+        }
156 156
 
157
-     for($i=1;$i<=strlen($this->Result);$i++)
158
-      {
159
-       if ( $this->mid($this->Result,$i,1) == 1 )
157
+        for($i=1;$i<=strlen($this->Result);$i++)
158
+        {
159
+        if ( $this->mid($this->Result,$i,1) == 1 )
160 160
         {
161
-         $X1 = $X + cos($Angle * PI / 180) * $i;
162
-         $Y1 = $Y + sin($Angle * PI / 180) * $i;
163
-         $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height;
164
-         $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height;
161
+            $X1 = $X + cos($Angle * PI / 180) * $i;
162
+            $Y1 = $Y + sin($Angle * PI / 180) * $i;
163
+            $X2 = $X1 + cos(($Angle+90) * PI / 180) * $Height;
164
+            $Y2 = $Y1 + sin(($Angle+90) * PI / 180) * $Height;
165 165
 
166
-         $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
167
-         $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings);
166
+            $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
167
+            $this->pChartObject->drawLine($X1,$Y1,$X2,$Y2,$Settings);
168
+        }
168 169
         }
169
-      }
170 170
 
171
-     if ( $ShowLegend )
172
-      {
173
-       $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2);
174
-       $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2);
171
+        if ( $ShowLegend )
172
+        {
173
+        $X1 = $X + cos($Angle * PI / 180) * (strlen($this->Result)/2);
174
+        $Y1 = $Y + sin($Angle * PI / 180) * (strlen($this->Result)/2);
175 175
 
176
-       $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
177
-       $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
176
+        $LegendX = $X1 + cos(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
177
+        $LegendY = $Y1 + sin(($Angle+90) * PI / 180) * ($Height+$LegendOffset);
178 178
 
179
-       $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE);
180
-       $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings);
181
-      }
179
+        $Settings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Angle"=>-$Angle,"Align"=>TEXT_ALIGN_TOPMIDDLE);
180
+        $this->pChartObject->drawText($LegendX,$LegendY,$TextString,$Settings);
181
+        }
182 182
     }
183 183
 
184
-   function checksum( $string )
184
+    function checksum( $string )
185 185
     {
186
-     $checksum = 0;
187
-     $length   = strlen( $string );
188
-     $charset  = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%';
186
+        $checksum = 0;
187
+        $length   = strlen( $string );
188
+        $charset  = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%';
189 189
 
190
-     for( $i=0; $i < $length; ++$i )
191
-      $checksum += strpos( $charset, $string[$i] );
190
+        for( $i=0; $i < $length; ++$i )
191
+        $checksum += strpos( $charset, $string[$i] );
192 192
  
193
-     return substr( $charset, ($checksum % 43), 1 );
193
+        return substr( $charset, ($checksum % 43), 1 );
194 194
     }
195 195
 
196
-   function left($value,$NbChar) { return substr($value,0,$NbChar); }  
197
-   function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); }  
198
-   function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); }  
199
-  }
196
+    function left($value,$NbChar) { return substr($value,0,$NbChar); }  
197
+    function right($value,$NbChar) { return substr($value,strlen($value)-$NbChar,$NbChar); }  
198
+    function mid($value,$Depart,$NbChar) { return substr($value,$Depart-1,$NbChar); }  
199
+    }
200 200
 ?>
201 201
\ No newline at end of file
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pIndicator.class.php 1 patch
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pIndicator - class to draw indicators
4 4
 
5 5
      Version     : 2.1.3
@@ -13,229 +13,229 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("INDICATOR_CAPTION_DEFAULT"	, 700001);
17
- define("INDICATOR_CAPTION_EXTENDED"	, 700002);
16
+    define("INDICATOR_CAPTION_DEFAULT"	, 700001);
17
+    define("INDICATOR_CAPTION_EXTENDED"	, 700002);
18 18
 
19
- define("INDICATOR_CAPTION_INSIDE"	, 700011);
20
- define("INDICATOR_CAPTION_BOTTOM"	, 700012);
19
+    define("INDICATOR_CAPTION_INSIDE"	, 700011);
20
+    define("INDICATOR_CAPTION_BOTTOM"	, 700012);
21 21
 
22
- define("INDICATOR_VALUE_BUBBLE"	, 700021);
23
- define("INDICATOR_VALUE_LABEL"		, 700022);
22
+    define("INDICATOR_VALUE_BUBBLE"	, 700021);
23
+    define("INDICATOR_VALUE_LABEL"		, 700022);
24 24
 
25
- /* pIndicator class definition */
26
- class pIndicator
27
-  {
28
-   var $pChartObject;
25
+    /* pIndicator class definition */
26
+    class pIndicator
27
+    {
28
+    var $pChartObject;
29 29
 
30
-   /* Class creator */
31
-   function pIndicator($pChartObject)
30
+    /* Class creator */
31
+    function pIndicator($pChartObject)
32 32
     {
33
-     $this->pChartObject = $pChartObject;
33
+        $this->pChartObject = $pChartObject;
34 34
     }
35 35
 
36
-   /* Draw an indicator */
37
-   function draw($X,$Y,$Width,$Height,$Format="")
36
+    /* Draw an indicator */
37
+    function draw($X,$Y,$Width,$Height,$Format="")
38 38
     {
39
-     $Values			= isset($Format["Values"]) ? $Format["Values"] : VOID;
40
-     $IndicatorSections		= isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL;
41
-     $ValueDisplay		= isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE;
42
-     $SectionsMargin		= isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4;
43
-     $DrawLeftHead		= isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE;
44
-     $DrawRightHead		= isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE;
45
-     $HeadSize			= isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4);
46
-     $TextPadding		= isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4;
47
-     $CaptionLayout		= isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED;
48
-     $CaptionPosition		= isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE;
49
-     $CaptionColorFactor	= isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL;
50
-     $CaptionR			= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
51
-     $CaptionG			= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
52
-     $CaptionB			= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
53
-     $CaptionAlpha		= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
54
-     $SubCaptionColorFactor	= isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL;
55
-     $SubCaptionR		= isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50;
56
-     $SubCaptionG		= isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50;
57
-     $SubCaptionB		= isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50;
58
-     $SubCaptionAlpha		= isset($Format["SubCaptionAlpha"]) ? $Format["SubCaptionAlpha"] : 100;
59
-     $ValueFontName		= isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName;
60
-     $ValueFontSize		= isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize;
61
-     $CaptionFontName		= isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName;
62
-     $CaptionFontSize		= isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize;
63
-     $Unit			= isset($Format["Unit"]) ? $Format["Unit"] : "";
64
-
65
-     /* Convert the Values to display to an array if needed */
66
-     if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; }
67
-
68
-     /* No section, let's die */
69
-     if ( $IndicatorSections == NULL ) { return(0); }
70
-
71
-     /* Determine indicator visual configuration */
72
-     $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"];
73
-     foreach ($IndicatorSections as $Key => $Settings)
74
-      {
75
-       if ( $Settings["End"] > $OverallMax )   { $OverallMax = $Settings["End"]; }
76
-       if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; }
77
-      }
78
-     $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin;
79
-     $XScale    = $RealWidth / ($OverallMax-$OverallMin);
80
-
81
-     $X1 = $X; $ValuesPos = "";
82
-     foreach ($IndicatorSections as $Key => $Settings)
83
-      {
84
-       $Color      = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]);
85
-       $Caption    = $Settings["Caption"];
86
-       $SubCaption = $Settings["Start"]." - ".$Settings["End"];
87
-
88
-       $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale;
89
-
90
-       if ( $Key == 0 && $DrawLeftHead )
39
+        $Values			= isset($Format["Values"]) ? $Format["Values"] : VOID;
40
+        $IndicatorSections		= isset($Format["IndicatorSections"]) ? $Format["IndicatorSections"] : NULL;
41
+        $ValueDisplay		= isset($Format["ValueDisplay"]) ? $Format["ValueDisplay"] : INDICATOR_VALUE_BUBBLE;
42
+        $SectionsMargin		= isset($Format["SectionsMargin"]) ? $Format["SectionsMargin"] : 4;
43
+        $DrawLeftHead		= isset($Format["DrawLeftHead"]) ? $Format["DrawLeftHead"] : TRUE;
44
+        $DrawRightHead		= isset($Format["DrawRightHead"]) ? $Format["DrawRightHead"] : TRUE;
45
+        $HeadSize			= isset($Format["HeadSize"]) ? $Format["HeadSize"] : floor($Height/4);
46
+        $TextPadding		= isset($Format["TextPadding"]) ? $Format["TextPadding"] : 4;
47
+        $CaptionLayout		= isset($Format["CaptionLayout"]) ? $Format["CaptionLayout"] : INDICATOR_CAPTION_EXTENDED;
48
+        $CaptionPosition		= isset($Format["CaptionPosition"]) ? $Format["CaptionPosition"] : INDICATOR_CAPTION_INSIDE;
49
+        $CaptionColorFactor	= isset($Format["CaptionColorFactor"]) ? $Format["CaptionColorFactor"] : NULL;
50
+        $CaptionR			= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
51
+        $CaptionG			= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
52
+        $CaptionB			= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
53
+        $CaptionAlpha		= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
54
+        $SubCaptionColorFactor	= isset($Format["SubCaptionColorFactor"]) ? $Format["SubCaptionColorFactor"] : NULL;
55
+        $SubCaptionR		= isset($Format["SubCaptionR"]) ? $Format["SubCaptionR"] : 50;
56
+        $SubCaptionG		= isset($Format["SubCaptionG"]) ? $Format["SubCaptionG"] : 50;
57
+        $SubCaptionB		= isset($Format["SubCaptionB"]) ? $Format["SubCaptionB"] : 50;
58
+        $SubCaptionAlpha		= isset($Format["SubCaptionAlpha"]) ? $Format["SubCaptionAlpha"] : 100;
59
+        $ValueFontName		= isset($Format["ValueFontName"]) ? $Format["ValueFontName"] : $this->pChartObject->FontName;
60
+        $ValueFontSize		= isset($Format["ValueFontSize"]) ? $Format["ValueFontSize"] : $this->pChartObject->FontSize;
61
+        $CaptionFontName		= isset($Format["CaptionFontName"]) ? $Format["CaptionFontName"] : $this->pChartObject->FontName;
62
+        $CaptionFontSize		= isset($Format["CaptionFontSize"]) ? $Format["CaptionFontSize"] : $this->pChartObject->FontSize;
63
+        $Unit			= isset($Format["Unit"]) ? $Format["Unit"] : "";
64
+
65
+        /* Convert the Values to display to an array if needed */
66
+        if ( !is_array($Values) ) { $Value = $Values; $Values = ""; $Values[] = $Value; }
67
+
68
+        /* No section, let's die */
69
+        if ( $IndicatorSections == NULL ) { return(0); }
70
+
71
+        /* Determine indicator visual configuration */
72
+        $OverallMin = $IndicatorSections[0]["End"]; $OverallMax = $IndicatorSections[0]["Start"];
73
+        foreach ($IndicatorSections as $Key => $Settings)
74
+        {
75
+        if ( $Settings["End"] > $OverallMax )   { $OverallMax = $Settings["End"]; }
76
+        if ( $Settings["Start"] < $OverallMin ) { $OverallMin = $Settings["Start"]; }
77
+        }
78
+        $RealWidth = $Width - (count($IndicatorSections)-1)*$SectionsMargin;
79
+        $XScale    = $RealWidth / ($OverallMax-$OverallMin);
80
+
81
+        $X1 = $X; $ValuesPos = "";
82
+        foreach ($IndicatorSections as $Key => $Settings)
83
+        {
84
+        $Color      = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"]);
85
+        $Caption    = $Settings["Caption"];
86
+        $SubCaption = $Settings["Start"]." - ".$Settings["End"];
87
+
88
+        $X2 = $X1 + ($Settings["End"] - $Settings["Start"]) * $XScale;
89
+
90
+        if ( $Key == 0 && $DrawLeftHead )
91 91
         {
92
-         $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2);
93
-         $this->pChartObject->drawPolygon($Poly,$Color);
94
-         $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color);
95
-         $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color);
92
+            $Poly = ""; $Poly[] = $X1-1; $Poly[] = $Y; $Poly[] = $X1-1; $Poly[] = $Y+$Height; $Poly[] = $X1-1-$HeadSize; $Poly[] = $Y+($Height/2);
93
+            $this->pChartObject->drawPolygon($Poly,$Color);
94
+            $this->pChartObject->drawLine($X1-2,$Y,$X1-2-$HeadSize,$Y+($Height/2),$Color);
95
+            $this->pChartObject->drawLine($X1-2,$Y+$Height,$X1-2-$HeadSize,$Y+($Height/2),$Color);
96 96
         }
97 97
 
98
-       /* Determine the position of the breaks */
99
-       $Break = "";
100
-       foreach($Values as $iKey => $Value)
98
+        /* Determine the position of the breaks */
99
+        $Break = "";
100
+        foreach($Values as $iKey => $Value)
101 101
         {
102
-         if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] )
103
-          {
104
-           $XBreak  = $X1 + ($Value - $Settings["Start"]) * $XScale;
105
-           $ValuesPos[$Value] = $XBreak;
106
-           $Break[] = floor($XBreak);
107
-          }
102
+            if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] )
103
+            {
104
+            $XBreak  = $X1 + ($Value - $Settings["Start"]) * $XScale;
105
+            $ValuesPos[$Value] = $XBreak;
106
+            $Break[] = floor($XBreak);
107
+            }
108 108
         }
109 109
 
110
-       if ( $ValueDisplay == INDICATOR_VALUE_LABEL )
110
+        if ( $ValueDisplay == INDICATOR_VALUE_LABEL )
111 111
         {
112
-         if ( $Break == "" )
113
-          $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color);
114
-         else
115
-          {
116
-           sort($Break);
117
-           $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE;
118
-           foreach($Break as $iKey => $Value)
112
+            if ( $Break == "" )
113
+            $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color);
114
+            else
115
+            {
116
+            sort($Break);
117
+            $Poly = ""; $Poly[] = $X1; $Poly[] = $Y; $LastPointWritten = FALSE;
118
+            foreach($Break as $iKey => $Value)
119 119
             {
120
-             if ( $Value-5 >= $X1 )
121
-              { $Poly[] = $Value-5; $Poly[] = $Y; }
122
-             elseif ($X1 - ($Value-5) > 0 )
123
-              {
124
-               $Offset = $X1 - ($Value-5);
125
-               $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset;
126
-              }
127
-
128
-             $Poly[] = $Value;   $Poly[] = $Y+5;
129
-
130
-             if ( $Value+5 <= $X2 )
131
-              { $Poly[] = $Value+5; $Poly[] = $Y; }
132
-             elseif (($Value+5) > $X2 )
133
-              {
134
-               $Offset = ($Value+5) - $X2;
135
-               $Poly[] = $X2; $Poly[] = $Y + $Offset;
136
-               $LastPointWritten = TRUE;
137
-              }
120
+                if ( $Value-5 >= $X1 )
121
+                { $Poly[] = $Value-5; $Poly[] = $Y; }
122
+                elseif ($X1 - ($Value-5) > 0 )
123
+                {
124
+                $Offset = $X1 - ($Value-5);
125
+                $Poly = ""; $Poly[] = $X1; $Poly[] = $Y + $Offset;
126
+                }
127
+
128
+                $Poly[] = $Value;   $Poly[] = $Y+5;
129
+
130
+                if ( $Value+5 <= $X2 )
131
+                { $Poly[] = $Value+5; $Poly[] = $Y; }
132
+                elseif (($Value+5) > $X2 )
133
+                {
134
+                $Offset = ($Value+5) - $X2;
135
+                $Poly[] = $X2; $Poly[] = $Y + $Offset;
136
+                $LastPointWritten = TRUE;
137
+                }
138 138
 
139 139
             }
140
-           if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; }
141
-           $Poly[] = $X2; $Poly[] = $Y+$Height;
142
-           $Poly[] = $X1; $Poly[] = $Y+$Height;
140
+            if ( !$LastPointWritten ) { $Poly[] = $X2; $Poly[] = $Y; }
141
+            $Poly[] = $X2; $Poly[] = $Y+$Height;
142
+            $Poly[] = $X1; $Poly[] = $Y+$Height;
143 143
 
144
-           $this->pChartObject->drawPolygon($Poly,$Color);
145
-          }
144
+            $this->pChartObject->drawPolygon($Poly,$Color);
145
+            }
146 146
         }
147
-       else
147
+        else
148 148
         $this->pChartObject->drawFilledRectangle($X1,$Y,$X2,$Y+$Height,$Color);
149 149
 
150
-       if ( $Key == count($IndicatorSections)-1 && $DrawRightHead )
150
+        if ( $Key == count($IndicatorSections)-1 && $DrawRightHead )
151 151
         {
152
-         $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2);
153
-         $this->pChartObject->drawPolygon($Poly,$Color);
154
-         $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color);
155
-         $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color);
152
+            $Poly = ""; $Poly[] = $X2+1; $Poly[] = $Y; $Poly[] = $X2+1; $Poly[] = $Y+$Height; $Poly[] = $X2+1+$HeadSize; $Poly[] = $Y+($Height/2);
153
+            $this->pChartObject->drawPolygon($Poly,$Color);
154
+            $this->pChartObject->drawLine($X2+1,$Y,$X2+1+$HeadSize,$Y+($Height/2),$Color);
155
+            $this->pChartObject->drawLine($X2+1,$Y+$Height,$X2+1+$HeadSize,$Y+($Height/2),$Color);
156 156
         }
157 157
 
158
-       if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE )
158
+        if ( $CaptionPosition == INDICATOR_CAPTION_INSIDE )
159 159
         {
160
-         $TxtPos  = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption);
161
-         $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding;
160
+            $TxtPos  = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption);
161
+            $YOffset = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding;
162 162
 
163
-         if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED )
164
-          {
165
-           $TxtPos  = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption);
166
-           $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2;
167
-          }
163
+            if ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED )
164
+            {
165
+            $TxtPos  = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$SubCaption);
166
+            $YOffset = $YOffset + ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]) + $TextPadding*2;
167
+            }
168 168
 
169
-         $XOffset = $TextPadding;
169
+            $XOffset = $TextPadding;
170 170
         }
171
-       else
171
+        else
172 172
         { $YOffset = 0; $XOffset = 0; }
173 173
 
174
-       if ( $CaptionColorFactor == NULL )
174
+        if ( $CaptionColorFactor == NULL )
175 175
         { $CaptionColor    = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha); }
176
-       else
176
+        else
177 177
         { $CaptionColor    = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$CaptionColorFactor,"G"=>$Settings["G"]+$CaptionColorFactor,"B"=>$Settings["B"]+$CaptionColorFactor); }
178 178
 
179
-       if ( $SubCaptionColorFactor == NULL )
179
+        if ( $SubCaptionColorFactor == NULL )
180 180
         $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$SubCaptionR,"G"=>$SubCaptionG,"B"=>$SubCaptionB,"Alpha"=>$SubCaptionAlpha);
181
-       else
181
+        else
182 182
         $SubCaptionColor = array("Align"=>TEXT_ALIGN_TOPLEFT,"FontName"=>$CaptionFontName,"FontSize"=>$CaptionFontSize,"R"=>$Settings["R"]+$SubCaptionColorFactor,"G"=>$Settings["G"]+$SubCaptionColorFactor,"B"=>$Settings["B"]+$SubCaptionColorFactor);
183 183
 
184
-       $RestoreShadow = $this->pChartObject->Shadow;
185
-       $this->pChartObject->Shadow = FALSE;
184
+        $RestoreShadow = $this->pChartObject->Shadow;
185
+        $this->pChartObject->Shadow = FALSE;
186 186
 
187
-       if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT )
187
+        if ( $CaptionLayout == INDICATOR_CAPTION_DEFAULT )
188 188
         $this->pChartObject->drawText($X1,$Y+$Height+$TextPadding,$Caption,$CaptionColor);
189
-       elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED )
189
+        elseif ( $CaptionLayout == INDICATOR_CAPTION_EXTENDED )
190 190
         {
191
-         $TxtPos        = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption);
192
-         $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"];
191
+            $TxtPos        = $this->pChartObject->getTextBox($X1,$Y+$Height+$TextPadding,$CaptionFontName,$CaptionFontSize,0,$Caption);
192
+            $CaptionHeight = $TxtPos[0]["Y"] - $TxtPos[2]["Y"];
193 193
 
194
-         $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor);
195
-         $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor);
194
+            $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$TextPadding,$Caption,$CaptionColor);
195
+            $this->pChartObject->drawText($X1+$XOffset,$Y+$Height-$YOffset+$CaptionHeight+$TextPadding*2,$SubCaption,$SubCaptionColor);
196 196
         }
197 197
 
198
-       $this->pChartObject->Shadow = $RestoreShadow;
198
+        $this->pChartObject->Shadow = $RestoreShadow;
199 199
 
200
-       $X1 = $X2 + $SectionsMargin;
201
-      }
200
+        $X1 = $X2 + $SectionsMargin;
201
+        }
202 202
 
203
-     $RestoreShadow = $this->pChartObject->Shadow;
204
-     $this->pChartObject->Shadow = FALSE;
203
+        $RestoreShadow = $this->pChartObject->Shadow;
204
+        $this->pChartObject->Shadow = FALSE;
205 205
 
206
-     foreach($Values as $Key => $Value)
207
-      {
208
-       if ( $Value >= $OverallMin && $Value <= $OverallMax )
206
+        foreach($Values as $Key => $Value)
207
+        {
208
+        if ( $Value >= $OverallMin && $Value <= $OverallMax )
209 209
         {
210
-         foreach ($IndicatorSections as $Key => $Settings)
211
-          {
212
-           if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] )
210
+            foreach ($IndicatorSections as $Key => $Settings)
213 211
             {
214
-             $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale;
215
-
216
-             if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE )
217
-              {
218
-               $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit);
219
-               $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2);
220
-
221
-               $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20));
222
-               $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255));
223
-
224
-               $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize);
225
-               $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings);
226
-              }
227
-             elseif( $ValueDisplay == INDICATOR_VALUE_LABEL )
228
-              {
229
-               $Caption = "";
230
-               $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit);
231
-               $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption);
232
-              }
212
+            if ( $Value >= $Settings["Start"] && $Value <= $Settings["End"] )
213
+            {
214
+                $X1 = $ValuesPos[$Value]; //$X + $Key*$SectionsMargin + ($Value - $OverallMin) * $XScale;
215
+
216
+                if ( $ValueDisplay == INDICATOR_VALUE_BUBBLE )
217
+                {
218
+                $TxtPos = $this->pChartObject->getTextBox($X1,$Y,$ValueFontName,$ValueFontSize,0,$Value.$Unit);
219
+                $Radius = floor(($TxtPos[1]["X"] - $TxtPos[0]["X"] + $TextPadding*4)/2);
220
+
221
+                $this->pChartObject->drawFilledCircle($X1,$Y,$Radius+4,array("R"=>$Settings["R"]+20,"G"=>$Settings["G"]+20,"B"=>$Settings["B"]+20));
222
+                $this->pChartObject->drawFilledCircle($X1,$Y,$Radius,array("R"=>255,"G"=>255,"B"=>255));
223
+
224
+                $TextSettings = array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontName"=>$ValueFontName,"FontSize"=>$ValueFontSize);
225
+                $this->pChartObject->drawText($X1-1,$Y-1,$Value.$Unit,$TextSettings);
226
+                }
227
+                elseif( $ValueDisplay == INDICATOR_VALUE_LABEL )
228
+                {
229
+                $Caption = "";
230
+                $Caption[] = array("Format"=>array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>100),"Caption"=>$Value.$Unit);
231
+                $this->pChartObject->drawLabelBox(floor($X1),floor($Y)+2,"Value - ".$Settings["Caption"],$Caption);
232
+                }
233
+            }
234
+            $X1 = $X2 + $SectionsMargin;
233 235
             }
234
-           $X1 = $X2 + $SectionsMargin;
235
-          }
236 236
         }
237
-      }
238
-     $this->pChartObject->Shadow = $RestoreShadow;
237
+        }
238
+        $this->pChartObject->Shadow = $RestoreShadow;
239
+    }
239 240
     }
240
-  }
241 241
 ?>
242 242
\ No newline at end of file
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pSpring.class.php 1 patch
Indentation   +665 added lines, -665 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pSpring - class to draw spring graphs
4 4
 
5 5
      Version     : 2.1.3
@@ -13,856 +13,856 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("NODE_TYPE_FREE"	, 690001);
17
- define("NODE_TYPE_CENTRAL"	, 690002);
18
-
19
- define("NODE_SHAPE_CIRCLE"	, 690011);
20
- define("NODE_SHAPE_TRIANGLE"	, 690012);
21
- define("NODE_SHAPE_SQUARE"	, 690013);
22
-
23
- define("ALGORITHM_RANDOM"	, 690021);
24
- define("ALGORITHM_WEIGHTED"	, 690022);
25
- define("ALGORITHM_CIRCULAR"	, 690023);
26
- define("ALGORITHM_CENTRAL"	, 690024);
27
-
28
- define("LABEL_CLASSIC"		, 690031);
29
- define("LABEL_LIGHT"		, 690032);
30
-
31
- /* pSpring class definition */
32
- class pSpring
33
-  {
34
-   var $History;
35
-   var $pChartObject;
36
-   var $Data;
37
-   var $Links;
38
-   var $X1;
39
-   var $Y1;
40
-   var $X2;
41
-   var $Y2;
42
-   var $AutoComputeFreeZone;
43
-   var $Labels;
44
-
45
-   /* Class creator */
46
-   function pSpring()
16
+    define("NODE_TYPE_FREE"	, 690001);
17
+    define("NODE_TYPE_CENTRAL"	, 690002);
18
+
19
+    define("NODE_SHAPE_CIRCLE"	, 690011);
20
+    define("NODE_SHAPE_TRIANGLE"	, 690012);
21
+    define("NODE_SHAPE_SQUARE"	, 690013);
22
+
23
+    define("ALGORITHM_RANDOM"	, 690021);
24
+    define("ALGORITHM_WEIGHTED"	, 690022);
25
+    define("ALGORITHM_CIRCULAR"	, 690023);
26
+    define("ALGORITHM_CENTRAL"	, 690024);
27
+
28
+    define("LABEL_CLASSIC"		, 690031);
29
+    define("LABEL_LIGHT"		, 690032);
30
+
31
+    /* pSpring class definition */
32
+    class pSpring
47 33
     {
48
-     /* Initialise data arrays */
49
-     $this->Data = "";
50
-     $this->Links = "";
51
-
52
-     /* Set nodes defaults */
53
-     $this->Default["R"]		= 255;
54
-     $this->Default["G"]		= 255;
55
-     $this->Default["B"]		= 255;
56
-     $this->Default["Alpha"]		= 100;
57
-     $this->Default["BorderR"]		= 0;
58
-     $this->Default["BorderG"]		= 0;
59
-     $this->Default["BorderB"]		= 0;
60
-     $this->Default["BorderAlpha"]	= 100;
61
-     $this->Default["Surrounding"]	= NULL;
62
-     $this->Default["BackgroundR"]	= 255;
63
-     $this->Default["BackgroundG"]	= 255;
64
-     $this->Default["BackgroundB"]	= 255;
65
-     $this->Default["BackgroundAlpha"]	= 0;
66
-     $this->Default["Force"]		= 1;
67
-     $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
-     $this->Default["Size"]		= 5;
69
-     $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
-     $this->Default["FreeZone"]		= 40;
71
-     $this->Default["LinkR"]		= 0;
72
-     $this->Default["LinkG"]		= 0;
73
-     $this->Default["LinkB"]		= 0;
74
-     $this->Default["LinkAlpha"]	= 0;
75
-
76
-     $this->Labels["Type"]		= LABEL_CLASSIC;
77
-     $this->Labels["R"]			= 0;
78
-     $this->Labels["G"]			= 0;
79
-     $this->Labels["B"]			= 0;
80
-     $this->Labels["Alpha"]		= 100;
81
-
82
-     $this->AutoComputeFreeZone         = FALSE;
34
+    var $History;
35
+    var $pChartObject;
36
+    var $Data;
37
+    var $Links;
38
+    var $X1;
39
+    var $Y1;
40
+    var $X2;
41
+    var $Y2;
42
+    var $AutoComputeFreeZone;
43
+    var $Labels;
44
+
45
+    /* Class creator */
46
+    function pSpring()
47
+    {
48
+        /* Initialise data arrays */
49
+        $this->Data = "";
50
+        $this->Links = "";
51
+
52
+        /* Set nodes defaults */
53
+        $this->Default["R"]		= 255;
54
+        $this->Default["G"]		= 255;
55
+        $this->Default["B"]		= 255;
56
+        $this->Default["Alpha"]		= 100;
57
+        $this->Default["BorderR"]		= 0;
58
+        $this->Default["BorderG"]		= 0;
59
+        $this->Default["BorderB"]		= 0;
60
+        $this->Default["BorderAlpha"]	= 100;
61
+        $this->Default["Surrounding"]	= NULL;
62
+        $this->Default["BackgroundR"]	= 255;
63
+        $this->Default["BackgroundG"]	= 255;
64
+        $this->Default["BackgroundB"]	= 255;
65
+        $this->Default["BackgroundAlpha"]	= 0;
66
+        $this->Default["Force"]		= 1;
67
+        $this->Default["NodeType"]		= NODE_TYPE_FREE;
68
+        $this->Default["Size"]		= 5;
69
+        $this->Default["Shape"]		= NODE_SHAPE_CIRCLE;
70
+        $this->Default["FreeZone"]		= 40;
71
+        $this->Default["LinkR"]		= 0;
72
+        $this->Default["LinkG"]		= 0;
73
+        $this->Default["LinkB"]		= 0;
74
+        $this->Default["LinkAlpha"]	= 0;
75
+
76
+        $this->Labels["Type"]		= LABEL_CLASSIC;
77
+        $this->Labels["R"]			= 0;
78
+        $this->Labels["G"]			= 0;
79
+        $this->Labels["B"]			= 0;
80
+        $this->Labels["Alpha"]		= 100;
81
+
82
+        $this->AutoComputeFreeZone         = FALSE;
83 83
     }
84 84
 
85
-   /* Set default links options */
86
-   function setLinkDefaults($Settings="")
85
+    /* Set default links options */
86
+    function setLinkDefaults($Settings="")
87 87
     {
88
-     if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
-     if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
-     if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
-     if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
88
+        if ( isset($Settings["R"]) )     { $this->Default["LinkR"] = $Settings["R"]; }
89
+        if ( isset($Settings["G"]) )     { $this->Default["LinkG"] = $Settings["G"]; }
90
+        if ( isset($Settings["B"]) )     { $this->Default["LinkB"] = $Settings["B"]; }
91
+        if ( isset($Settings["Alpha"]) ) { $this->Default["LinkAlpha"] = $Settings["Alpha"]; }
92 92
     }
93 93
 
94
-   /* Set default links options */
95
-   function setLabelsSettings($Settings="")
94
+    /* Set default links options */
95
+    function setLabelsSettings($Settings="")
96 96
     {
97
-     if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
-     if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
-     if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
-     if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
-     if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
97
+        if ( isset($Settings["Type"]) )  { $this->Labels["Type"] = $Settings["Type"]; }
98
+        if ( isset($Settings["R"]) )     { $this->Labels["R"] = $Settings["R"]; }
99
+        if ( isset($Settings["G"]) )     { $this->Labels["G"] = $Settings["G"]; }
100
+        if ( isset($Settings["B"]) )     { $this->Labels["B"] = $Settings["B"]; }
101
+        if ( isset($Settings["Alpha"]) ) { $this->Labels["Alpha"] = $Settings["Alpha"]; }
102 102
     }
103 103
 
104
-   /* Auto compute the FreeZone size based on the number of connections */
105
-   function autoFreeZone()
104
+    /* Auto compute the FreeZone size based on the number of connections */
105
+    function autoFreeZone()
106 106
     {
107
-     /* Check connections reciprocity */
108
-     foreach($this->Data as $Key => $Settings)
109
-      {
110
-       if ( isset($Settings["Connections"]) )
107
+        /* Check connections reciprocity */
108
+        foreach($this->Data as $Key => $Settings)
109
+        {
110
+        if ( isset($Settings["Connections"]) )
111 111
         { $this->Data[$Key]["FreeZone"] = count($Settings["Connections"])*10 + 20; }
112
-       else
112
+        else
113 113
         { $this->Data[$Key]["FreeZone"] = 20; }
114
-      }
114
+        }
115 115
 
116 116
     }
117 117
 
118
-   /* Set link properties */
119
-   function linkProperties($FromNode,$ToNode,$Settings)
118
+    /* Set link properties */
119
+    function linkProperties($FromNode,$ToNode,$Settings)
120 120
     {
121
-     if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
-     if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
-
124
-     $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
-     $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
-     $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
-     $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
-
131
-     $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
-     $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
-     $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
-     $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
-     $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
-     $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
121
+        if ( !isset($this->Data[$FromNode]) ) { return(0); }
122
+        if ( !isset($this->Data[$ToNode]) )   { return(0); }
123
+
124
+        $R			= isset($Settings["R"]) ? $Settings["R"] : 0;
125
+        $G			= isset($Settings["G"]) ? $Settings["G"] : 0;
126
+        $B			= isset($Settings["B"]) ? $Settings["B"] : 0;
127
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : 100;
128
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : NULL;
129
+        $Ticks		= isset($Settings["Ticks"]) ? $Settings["Ticks"] : NULL;
130
+
131
+        $this->Links[$FromNode][$ToNode]["R"] = $R;         $this->Links[$ToNode][$FromNode]["R"] = $R;
132
+        $this->Links[$FromNode][$ToNode]["G"] = $G;         $this->Links[$ToNode][$FromNode]["G"] = $G;
133
+        $this->Links[$FromNode][$ToNode]["B"] = $B;         $this->Links[$ToNode][$FromNode]["B"] = $B;
134
+        $this->Links[$FromNode][$ToNode]["Alpha"] = $Alpha; $this->Links[$ToNode][$FromNode]["Alpha"] = $Alpha;
135
+        $this->Links[$FromNode][$ToNode]["Name"] = $Name;   $this->Links[$ToNode][$FromNode]["Name"] = $Name;
136
+        $this->Links[$FromNode][$ToNode]["Ticks"] = $Ticks; $this->Links[$ToNode][$FromNode]["Ticks"] = $Ticks;
137 137
     }
138 138
 
139
-   function setNodeDefaults($Settings="")
139
+    function setNodeDefaults($Settings="")
140 140
     {
141
-     if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
-     if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
-     if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
-     if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
-     if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
-     if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
-     if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
-     if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
-     if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
-     if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
-     if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
-     if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
-     if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
-     if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
-     if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
-     if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
-     if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
141
+        if ( isset($Settings["R"]) ) { $this->Default["R"]					= $Settings["R"]; }
142
+        if ( isset($Settings["G"]) ) { $this->Default["G"]					= $Settings["G"]; }
143
+        if ( isset($Settings["B"]) ) { $this->Default["B"]					= $Settings["B"]; }
144
+        if ( isset($Settings["Alpha"]) ) { $this->Default["Alpha"]				= $Settings["Alpha"]; }
145
+        if ( isset($Settings["BorderR"]) ) { $this->Default["BorderR"]			= $Settings["BorderR"]; }
146
+        if ( isset($Settings["BorderG"]) ) { $this->Default["BorderG"]			= $Settings["BorderG"]; }
147
+        if ( isset($Settings["BorderB"]) ) { $this->Default["BorderB"]			= $Settings["BorderB"]; }
148
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Default["BorderAlpha"]		= $Settings["BorderAlpha"]; }
149
+        if ( isset($Settings["Surrounding"]) ) { $this->Default["Surrounding"]		= $Settings["Surrounding"]; }
150
+        if ( isset($Settings["BackgroundR"]) ) { $this->Default["BackgroundR"]		= $Settings["BackgroundR"]; }
151
+        if ( isset($Settings["BackgroundG"]) ) { $this->Default["BackgroundG"]		= $Settings["BackgroundG"]; }
152
+        if ( isset($Settings["BackgroundB"]) ) { $this->Default["BackgroundB"]		= $Settings["BackgroundB"]; }
153
+        if ( isset($Settings["BackgroundAlpha"]) ) { $this->Default["BackgroundAlpha"]	= $Settings["BackgroundAlpha"]; }
154
+        if ( isset($Settings["NodeType"]) ) { $this->Default["NodeType"]			= $Settings["NodeType"]; }
155
+        if ( isset($Settings["Size"]) ) { $this->Default["Size"]				= $Settings["Size"]; }
156
+        if ( isset($Settings["Shape"]) ) { $this->Default["Shape"]				= $Settings["Shape"]; }
157
+        if ( isset($Settings["FreeZone"]) ) { $this->Default["FreeZone"]			= $Settings["FreeZone"]; }
158 158
     }
159 159
 
160
-   /* Add a node */
161
-   function addNode($NodeID,$Settings="")
160
+    /* Add a node */
161
+    function addNode($NodeID,$Settings="")
162 162
     {
163
-     /* if the node already exists, ignore */
164
-     if (isset($this->Data[$NodeID])) { return(0); }
165
-
166
-     $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
-     $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
-
169
-     $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
-     $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
-     $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
-     $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
-     $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
-     $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
-     $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
-     $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
-     $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
-     $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
-     $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
-     $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
-     $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
-     $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
-     $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
-     $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
-     $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
-     $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
-
188
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
-
190
-     $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
-     $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
-     $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
-     $this->Data[$NodeID]["Name"]		= $Name;
194
-     $this->Data[$NodeID]["Force"]		= $Force;
195
-     $this->Data[$NodeID]["Type"]		= $NodeType;
196
-     $this->Data[$NodeID]["Size"]		= $Size;
197
-     $this->Data[$NodeID]["Shape"]		= $Shape;
198
-     $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
-     if ( $Connections != NULL )
200
-      {
201
-       if ( is_array($Connections ) )
202
-        {
203
-         foreach($Connections as $Key => $Value)
204
-          $this->Data[$NodeID]["Connections"][] = $Value;
205
-        }
206
-       else
163
+        /* if the node already exists, ignore */
164
+        if (isset($this->Data[$NodeID])) { return(0); }
165
+
166
+        $Name		= isset($Settings["Name"]) ? $Settings["Name"] : "Node ".$NodeID;
167
+        $Connections	= isset($Settings["Connections"]) ? $Settings["Connections"] : NULL;
168
+
169
+        $R			= isset($Settings["R"]) ? $Settings["R"] : $this->Default["R"];
170
+        $G			= isset($Settings["G"]) ? $Settings["G"] : $this->Default["G"];
171
+        $B			= isset($Settings["B"]) ? $Settings["B"] : $this->Default["B"];
172
+        $Alpha		= isset($Settings["Alpha"]) ? $Settings["Alpha"] : $this->Default["Alpha"];
173
+        $BorderR		= isset($Settings["BorderR"]) ? $Settings["BorderR"] : $this->Default["BorderR"];
174
+        $BorderG		= isset($Settings["BorderG"]) ? $Settings["BorderG"] : $this->Default["BorderG"];
175
+        $BorderB		= isset($Settings["BorderB"]) ? $Settings["BorderB"] : $this->Default["BorderB"];
176
+        $BorderAlpha	= isset($Settings["BorderAlpha"]) ? $Settings["BorderAlpha"] : $this->Default["BorderAlpha"];
177
+        $Surrounding	= isset($Settings["Surrounding"]) ? $Settings["Surrounding"] : $this->Default["Surrounding"];
178
+        $BackgroundR	= isset($Settings["BackgroundR"]) ? $Settings["BackgroundR"] : $this->Default["BackgroundR"];
179
+        $BackgroundG	= isset($Settings["BackgroundG"]) ? $Settings["BackgroundG"] : $this->Default["BackgroundG"];
180
+        $BackgroundB	= isset($Settings["BackgroundB"]) ? $Settings["BackgroundB"] : $this->Default["BackgroundB"];
181
+        $BackgroundAlpha	= isset($Settings["BackgroundAlpha"]) ? $Settings["BackgroundAlpha"] : $this->Default["BackgroundAlpha"];
182
+        $Force		= isset($Settings["Force"]) ? $Settings["Force"] :  $this->Default["Force"];
183
+        $NodeType		= isset($Settings["NodeType"]) ? $Settings["NodeType"] : $this->Default["NodeType"];
184
+        $Size		= isset($Settings["Size"]) ? $Settings["Size"] : $this->Default["Size"];
185
+        $Shape		= isset($Settings["Shape"]) ? $Settings["Shape"] : $this->Default["Shape"];
186
+        $FreeZone		= isset($Settings["FreeZone"]) ? $Settings["FreeZone"] : $this->Default["FreeZone"];
187
+
188
+        if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
189
+
190
+        $this->Data[$NodeID]["R"] = $R; $this->Data[$NodeID]["G"] = $G; $this->Data[$NodeID]["B"] = $B; $this->Data[$NodeID]["Alpha"] = $Alpha;
191
+        $this->Data[$NodeID]["BorderR"] = $BorderR; $this->Data[$NodeID]["BorderG"] = $BorderG; $this->Data[$NodeID]["BorderB"] = $BorderB; $this->Data[$NodeID]["BorderAlpha"] = $BorderAlpha;
192
+        $this->Data[$NodeID]["BackgroundR"]	= $BackgroundR; $this->Data[$NodeID]["BackgroundG"] = $BackgroundG; $this->Data[$NodeID]["BackgroundB"] = $BackgroundB; $this->Data[$NodeID]["BackgroundAlpha"] = $BackgroundAlpha;
193
+        $this->Data[$NodeID]["Name"]		= $Name;
194
+        $this->Data[$NodeID]["Force"]		= $Force;
195
+        $this->Data[$NodeID]["Type"]		= $NodeType;
196
+        $this->Data[$NodeID]["Size"]		= $Size;
197
+        $this->Data[$NodeID]["Shape"]		= $Shape;
198
+        $this->Data[$NodeID]["FreeZone"]		= $FreeZone;
199
+        if ( $Connections != NULL )
200
+        {
201
+        if ( is_array($Connections ) )
202
+        {
203
+            foreach($Connections as $Key => $Value)
204
+            $this->Data[$NodeID]["Connections"][] = $Value;
205
+        }
206
+        else
207 207
         $this->Data[$NodeID]["Connections"][] = $Connections;
208
-      }
208
+        }
209 209
     }
210 210
 
211
-   /* Set color attribute for a list of nodes */
212
-   function setNodesColor($Nodes,$Settings="")
211
+    /* Set color attribute for a list of nodes */
212
+    function setNodesColor($Nodes,$Settings="")
213 213
     {
214
-     if ( is_array($Nodes) )
215
-      {
216
-       foreach ($Nodes as $Key => $NodeID)
217
-        {
218
-         if (isset($this->Data[$NodeID]) )
219
-          {
220
-           if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
-           if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
-           if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
-           if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
-           if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
-           if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
-           if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
-           if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
-           if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
-          }
230
-        }
231
-      }
232
-     else
233
-      {
234
-       if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
-       if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
-       if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
-       if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
-       if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
-       if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
-       if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
-       if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
-       if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
-      }
214
+        if ( is_array($Nodes) )
215
+        {
216
+        foreach ($Nodes as $Key => $NodeID)
217
+        {
218
+            if (isset($this->Data[$NodeID]) )
219
+            {
220
+            if ( isset($Settings["R"]) ) { $this->Data[$NodeID]["R"] = $Settings["R"]; }
221
+            if ( isset($Settings["G"]) ) { $this->Data[$NodeID]["G"] = $Settings["G"]; }
222
+            if ( isset($Settings["B"]) ) { $this->Data[$NodeID]["B"] = $Settings["B"]; }
223
+            if ( isset($Settings["Alpha"]) ) { $this->Data[$NodeID]["Alpha"] = $Settings["Alpha"]; }
224
+            if ( isset($Settings["BorderR"]) ) { $this->Data[$NodeID]["BorderR"] = $Settings["BorderR"]; }
225
+            if ( isset($Settings["BorderG"]) ) { $this->Data[$NodeID]["BorderG"] = $Settings["BorderG"]; }
226
+            if ( isset($Settings["BorderB"]) ) { $this->Data[$NodeID]["BorderB"] = $Settings["BorderB"]; }
227
+            if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$NodeID]["BorderAlpha"] = $Settings["BorderAlpha"]; }
228
+            if ( isset($Settings["Surrounding"]) ) { $this->Data[$NodeID]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
229
+            }
230
+        }
231
+        }
232
+        else
233
+        {
234
+        if ( isset($Settings["R"]) ) { $this->Data[$Nodes]["R"] = $Settings["R"]; }
235
+        if ( isset($Settings["G"]) ) { $this->Data[$Nodes]["G"] = $Settings["G"]; }
236
+        if ( isset($Settings["B"]) ) { $this->Data[$Nodes]["B"] = $Settings["B"]; }
237
+        if ( isset($Settings["Alpha"]) ) { $this->Data[$Nodes]["Alpha"] = $Settings["Alpha"]; }
238
+        if ( isset($Settings["BorderR"]) ) { $this->Data[$Nodes]["BorderR"] = $Settings["BorderR"]; }
239
+        if ( isset($Settings["BorderG"]) ) { $this->Data[$Nodes]["BorderG"] = $Settings["BorderG"]; }
240
+        if ( isset($Settings["BorderB"]) ) { $this->Data[$Nodes]["BorderB"] = $Settings["BorderB"]; }
241
+        if ( isset($Settings["BorderAlpha"]) ) { $this->Data[$Nodes]["BorderAlpha"] = $Settings["BorderAlpha"]; }
242
+        if ( isset($Settings["Surrounding"]) ) { $this->Data[$Nodes]["BorderR"] = $this->Data[$NodeID]["R"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderG"] = $this->Data[$NodeID]["G"] + $Settings["Surrounding"]; $this->Data[$NodeID]["BorderB"] = $this->Data[$NodeID]["B"] + $Settings["Surrounding"]; }
243
+        }
244 244
     }
245 245
 
246
-   /* Returns all the nodes details */
247
-   function dumpNodes()
246
+    /* Returns all the nodes details */
247
+    function dumpNodes()
248 248
     { return($this->Data); }
249 249
 
250
-   /* Check if a connection exists and create it if required */
251
-   function checkConnection($SourceID, $TargetID)
250
+    /* Check if a connection exists and create it if required */
251
+    function checkConnection($SourceID, $TargetID)
252 252
     {
253
-     if ( isset($this->Data[$SourceID]["Connections"]) )
254
-      {
255
-       foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
253
+        if ( isset($this->Data[$SourceID]["Connections"]) )
254
+        {
255
+        foreach ($this->Data[$SourceID]["Connections"] as $Key => $ConnectionID)
256 256
         { if ( $TargetID == $ConnectionID ) { return(TRUE); } }
257
-      }
258
-     $this->Data[$SourceID]["Connections"][] = $TargetID;
257
+        }
258
+        $this->Data[$SourceID]["Connections"][] = $TargetID;
259 259
     }
260
-   /* Get the median linked nodes position */
261
-   function getMedianOffset($Key,$X,$Y)
260
+    /* Get the median linked nodes position */
261
+    function getMedianOffset($Key,$X,$Y)
262 262
     {
263
-     $Cpt = 1;
264
-     if ( isset($this->Data[$Key]["Connections"]) )
265
-      {
266
-       foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
-        {
268
-         if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
-          {
270
-           $X = $X + $this->Data[$NodeID]["X"];
271
-           $Y = $Y + $this->Data[$NodeID]["Y"];
272
-           $Cpt++;
273
-          }
274
-        }
275
-      }
276
-     return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
263
+        $Cpt = 1;
264
+        if ( isset($this->Data[$Key]["Connections"]) )
265
+        {
266
+        foreach($this->Data[$Key]["Connections"] as $ID => $NodeID)
267
+        {
268
+            if ( isset($this->Data[$NodeID]["X"]) && isset($this->Data[$NodeID]["Y"]) )
269
+            {
270
+            $X = $X + $this->Data[$NodeID]["X"];
271
+            $Y = $Y + $this->Data[$NodeID]["Y"];
272
+            $Cpt++;
273
+            }
274
+        }
275
+        }
276
+        return(array("X"=>$X/$Cpt,"Y"=>$Y/$Cpt));
277 277
     }
278 278
 
279
-   /* Return the ID of the attached partner with the biggest weight */
280
-   function getBiggestPartner($Key)
279
+    /* Return the ID of the attached partner with the biggest weight */
280
+    function getBiggestPartner($Key)
281 281
     {
282
-     if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
282
+        if ( !isset($this->Data[$Key]["Connections"]) ) { return(""); }
283 283
 
284
-     $MaxWeight = 0; $Result = "";
285
-     foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
-      {
287
-       if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
284
+        $MaxWeight = 0; $Result = "";
285
+        foreach($this->Data[$Key]["Connections"] as $Key => $PeerID)
286
+        {
287
+        if ( $this->Data[$PeerID]["Weight"] > $MaxWeight )
288 288
         { $MaxWeight = $this->Data[$PeerID]["Weight"]; $Result = $PeerID; }
289
-      }
290
-     return($Result);
289
+        }
290
+        return($Result);
291 291
     }
292 292
 
293
-   /* Do the initial node positions computing pass */
294
-   function firstPass($Algorithm)
293
+    /* Do the initial node positions computing pass */
294
+    function firstPass($Algorithm)
295 295
     {
296
-     $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
-     $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
296
+        $CenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
297
+        $CenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
298 298
 
299
-     /* Check connections reciprocity */
300
-     foreach($this->Data as $Key => $Settings)
301
-      {
302
-       if ( isset($Settings["Connections"]) )
299
+        /* Check connections reciprocity */
300
+        foreach($this->Data as $Key => $Settings)
301
+        {
302
+        if ( isset($Settings["Connections"]) )
303 303
         {
304
-         foreach($Settings["Connections"] as $ID => $ConnectionID)
305
-          $this->checkConnection($ConnectionID,$Key);
304
+            foreach($Settings["Connections"] as $ID => $ConnectionID)
305
+            $this->checkConnection($ConnectionID,$Key);
306
+        }
306 307
         }
307
-      }
308 308
 
309
-     if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
309
+        if ( $this->AutoComputeFreeZone ) { $this->autoFreeZone(); }
310 310
 
311
-     /* Get the max number of connections */
312
-     $MaxConnections = 0;
313
-     foreach($this->Data as $Key => $Settings)
314
-      { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
311
+        /* Get the max number of connections */
312
+        $MaxConnections = 0;
313
+        foreach($this->Data as $Key => $Settings)
314
+        { if ( isset($Settings["Connections"]) ) { if ( $MaxConnections < count($Settings["Connections"] ) ) { $MaxConnections = count($Settings["Connections"]); } } }
315 315
 
316
-     if ( $Algorithm == ALGORITHM_WEIGHTED )
317
-      {
318
-       foreach($this->Data as $Key => $Settings)
316
+        if ( $Algorithm == ALGORITHM_WEIGHTED )
317
+        {
318
+        foreach($this->Data as $Key => $Settings)
319 319
         {
320
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
322
-          {
323
-           if ( isset($Settings["Connections"]) )
320
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
321
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
322
+            {
323
+            if ( isset($Settings["Connections"]) )
324 324
             { $Connections = count($Settings["Connections"]); }
325
-           else
325
+            else
326 326
             { $Connections = 0; }
327 327
 
328
-           $Ring  = $MaxConnections - $Connections;
329
-           $Angle = rand(0,360);
328
+            $Ring  = $MaxConnections - $Connections;
329
+            $Angle = rand(0,360);
330 330
            
331
-           $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
-           $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
-          }
331
+            $this->Data[$Key]["X"] = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
332
+            $this->Data[$Key]["Y"] = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
333
+            }
334 334
         }
335
-      }
336
-     elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
-      {
338
-       /* Put a weight on each nodes */
339
-       foreach($this->Data as $Key => $Settings)
335
+        }
336
+        elseif ( $Algorithm == ALGORITHM_CENTRAL )
337
+        {
338
+        /* Put a weight on each nodes */
339
+        foreach($this->Data as $Key => $Settings)
340 340
         {
341
-         if ( isset($Settings["Connections"]) )
342
-          $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
-         else
344
-          $this->Data[$Key]["Weight"] = 0;
341
+            if ( isset($Settings["Connections"]) )
342
+            $this->Data[$Key]["Weight"] = count($Settings["Connections"]);
343
+            else
344
+            $this->Data[$Key]["Weight"] = 0;
345 345
         }
346 346
 
347
-       $MaxConnections = $MaxConnections + 1;
348
-       for($i=$MaxConnections;$i>=0;$i--)
347
+        $MaxConnections = $MaxConnections + 1;
348
+        for($i=$MaxConnections;$i>=0;$i--)
349 349
         {
350
-         foreach($this->Data as $Key => $Settings)
351
-          {
352
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
350
+            foreach($this->Data as $Key => $Settings)
354 351
             {
355
-             if ( isset($Settings["Connections"]) )
356
-              { $Connections = count($Settings["Connections"]); }
357
-             else
358
-              { $Connections = 0; }
359
-
360
-             if ( $Connections == $i )
361
-              {
362
-               $BiggestPartner = $this->getBiggestPartner($Key);
363
-               if ( $BiggestPartner != "" )
352
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
353
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
354
+            {
355
+                if ( isset($Settings["Connections"]) )
356
+                { $Connections = count($Settings["Connections"]); }
357
+                else
358
+                { $Connections = 0; }
359
+
360
+                if ( $Connections == $i )
364 361
                 {
365
-                 $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
-                 $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
-                 $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
-                 $Done          = FALSE; $Tries = 0;
369
-                 while (!$Done && $Tries <= $Weight*2)
370
-                  {
371
-                   $Tries++;
372
-                   $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
-                   if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
362
+                $BiggestPartner = $this->getBiggestPartner($Key);
363
+                if ( $BiggestPartner != "" )
364
+                {
365
+                    $Ring          = $this->Data[$BiggestPartner]["FreeZone"];
366
+                    $Weight        = $this->Data[$BiggestPartner]["Weight"];
367
+                    $AngleDivision = 360 / $this->Data[$BiggestPartner]["Weight"];
368
+                    $Done          = FALSE; $Tries = 0;
369
+                    while (!$Done && $Tries <= $Weight*2)
370
+                    {
371
+                    $Tries++;
372
+                    $Angle = floor(rand(0,$Weight)*$AngleDivision);
373
+                    if ( !isset($this->Data[$BiggestPartner]["Angular"][$Angle]) || !isset($this->Data[$BiggestPartner]["Angular"]) )
374 374
                     {
375
-                     $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
-                     $Done = TRUE; 
375
+                        $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle;
376
+                        $Done = TRUE; 
377 377
                     }
378
-                  }
379
-                 if ( !$Done )
380
-                  { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
378
+                    }
379
+                    if ( !$Done )
380
+                    { $Angle = rand(0,360); $this->Data[$BiggestPartner]["Angular"][$Angle] = $Angle; }
381 381
 
382
-                 $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
-                 $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
382
+                    $X = cos(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["X"];
383
+                    $Y = sin(deg2rad($Angle)) * ($Ring) + $this->Data[$BiggestPartner]["Y"];
384 384
 
385
-                 $this->Data[$Key]["X"] = $X;
386
-                 $this->Data[$Key]["Y"] = $Y;
385
+                    $this->Data[$Key]["X"] = $X;
386
+                    $this->Data[$Key]["Y"] = $Y;
387
+                }
387 388
                 }
388
-              }
389 389
             }
390
-          }
391
-        }
392
-      }
393
-     elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
-      {
395
-       $MaxConnections = $MaxConnections + 1;
396
-       for($i=$MaxConnections;$i>=0;$i--)
397
-        {
398
-         foreach($this->Data as $Key => $Settings)
399
-          {
400
-           if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
-           if ( $Settings["Type"] == NODE_TYPE_FREE )
390
+            }
391
+        }
392
+        }
393
+        elseif ( $Algorithm == ALGORITHM_CIRCULAR )
394
+        {
395
+        $MaxConnections = $MaxConnections + 1;
396
+        for($i=$MaxConnections;$i>=0;$i--)
397
+        {
398
+            foreach($this->Data as $Key => $Settings)
399
+            {
400
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
401
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
402 402
             {
403
-             if ( isset($Settings["Connections"]) )
404
-              { $Connections = count($Settings["Connections"]); }
405
-             else
406
-              { $Connections = 0; }
403
+                if ( isset($Settings["Connections"]) )
404
+                { $Connections = count($Settings["Connections"]); }
405
+                else
406
+                { $Connections = 0; }
407 407
 
408
-             if ( $Connections == $i )
409
-              {
410
-               $Ring  = $MaxConnections - $Connections;
411
-               $Angle = rand(0,360);
408
+                if ( $Connections == $i )
409
+                {
410
+                $Ring  = $MaxConnections - $Connections;
411
+                $Angle = rand(0,360);
412 412
 
413
-               $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
-               $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
413
+                $X = cos(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterX;
414
+                $Y = sin(deg2rad($Angle)) * ($Ring*$this->RingSize) + $CenterY;
415 415
 
416
-               $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
416
+                $MedianOffset = $this->getMedianOffset($Key,$X,$Y);
417 417
 
418
-               $this->Data[$Key]["X"] = $MedianOffset["X"];
419
-               $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
-              }
418
+                $this->Data[$Key]["X"] = $MedianOffset["X"];
419
+                $this->Data[$Key]["Y"] = $MedianOffset["Y"];
420
+                }
421 421
             }
422
-          }
422
+            }
423
+        }
423 424
         }
424
-      }
425
-     elseif ( $Algorithm == ALGORITHM_RANDOM )
426
-      {
427
-       foreach($this->Data as $Key => $Settings)
425
+        elseif ( $Algorithm == ALGORITHM_RANDOM )
428 426
         {
429
-         if ( $Settings["Type"] == NODE_TYPE_FREE )
430
-          {
431
-           $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
-           $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
-          }
434
-         if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
427
+        foreach($this->Data as $Key => $Settings)
428
+        {
429
+            if ( $Settings["Type"] == NODE_TYPE_FREE )
430
+            {
431
+            $this->Data[$Key]["X"] = $CenterX + rand(-20,20);
432
+            $this->Data[$Key]["Y"] = $CenterY + rand(-20,20);
433
+            }
434
+            if ( $Settings["Type"] == NODE_TYPE_CENTRAL ) { $this->Data[$Key]["X"] = $CenterX; $this->Data[$Key]["Y"] = $CenterY; }
435
+        }
435 436
         }
436
-      }
437 437
     }
438 438
 
439
-   /* Compute one pass */
440
-   function doPass()
439
+    /* Compute one pass */
440
+    function doPass()
441 441
     {
442
-     /* Compute vectors */
443
-     foreach($this->Data as $Key => $Settings)
444
-      {
445
-       if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
442
+        /* Compute vectors */
443
+        foreach($this->Data as $Key => $Settings)
446 444
         {
447
-         unset($this->Data[$Key]["Vectors"]);
445
+        if ( $Settings["Type"] != NODE_TYPE_CENTRAL )
446
+        {
447
+            unset($this->Data[$Key]["Vectors"]);
448 448
 
449
-         $X1 = $Settings["X"];
450
-         $Y1 = $Settings["Y"];
449
+            $X1 = $Settings["X"];
450
+            $Y1 = $Settings["Y"];
451 451
 
452
-         /* Repulsion vectors */
453
-         foreach($this->Data as $Key2 => $Settings2)
454
-          {
455
-           if ( $Key != $Key2 )
452
+            /* Repulsion vectors */
453
+            foreach($this->Data as $Key2 => $Settings2)
454
+            {
455
+            if ( $Key != $Key2 )
456 456
             {
457
-             $X2 = $this->Data[$Key2]["X"];
458
-             $Y2 = $this->Data[$Key2]["Y"];
459
-             $FreeZone = $this->Data[$Key2]["FreeZone"];
460
-
461
-             $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
-             $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
-
464
-             /* Nodes too close, repulsion occurs */
465
-             if ( $Distance < $FreeZone )
466
-              {
467
-               $Force = log(pow(2,$FreeZone-$Distance));
468
-               if ( $Force > 1 )
457
+                $X2 = $this->Data[$Key2]["X"];
458
+                $Y2 = $this->Data[$Key2]["Y"];
459
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
460
+
461
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
462
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2) + 180;
463
+
464
+                /* Nodes too close, repulsion occurs */
465
+                if ( $Distance < $FreeZone )
466
+                {
467
+                $Force = log(pow(2,$FreeZone-$Distance));
468
+                if ( $Force > 1 )
469 469
                 { $this->Data[$Key]["Vectors"][] = array("Type"=>"R","Angle"=>$Angle % 360,"Force"=>$Force); }
470
-              }
470
+                }
471
+            }
471 472
             }
472
-          }
473 473
 
474
-         /* Attraction vectors */
475
-         if ( isset($Settings["Connections"]) )
476
-          {
477
-           foreach($Settings["Connections"] as $ID => $NodeID)
474
+            /* Attraction vectors */
475
+            if ( isset($Settings["Connections"]) )
478 476
             {
479
-             if ( isset($this->Data[$NodeID]) )
480
-              {
481
-               $X2 = $this->Data[$NodeID]["X"];
482
-               $Y2 = $this->Data[$NodeID]["Y"];
483
-               $FreeZone = $this->Data[$Key2]["FreeZone"];
477
+            foreach($Settings["Connections"] as $ID => $NodeID)
478
+            {
479
+                if ( isset($this->Data[$NodeID]) )
480
+                {
481
+                $X2 = $this->Data[$NodeID]["X"];
482
+                $Y2 = $this->Data[$NodeID]["Y"];
483
+                $FreeZone = $this->Data[$Key2]["FreeZone"];
484 484
 
485
-               $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
-               $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
485
+                $Distance = $this->getDistance($X1,$Y1,$X2,$Y2);
486
+                $Angle    = $this->getAngle($X1,$Y1,$X2,$Y2);
487 487
 
488
-               if ( $Distance > $FreeZone )
488
+                if ( $Distance > $FreeZone )
489 489
                 $Force = log(($Distance-$FreeZone)+1);
490
-               else
490
+                else
491 491
                 { $Force = log(($FreeZone-$Distance)+1); ($Angle = $Angle + 180); }
492 492
 
493
-               if ( $Force > 1 )
493
+                if ( $Force > 1 )
494 494
                 $this->Data[$Key]["Vectors"][] = array("Type"=>"A","Angle"=>$Angle % 360,"Force"=>$Force);
495
-              }
495
+                }
496
+            }
496 497
             }
497
-          }
498 498
         }
499
-      }
499
+        }
500 500
 
501
-     /* Move the nodes accoding to the vectors */
502
-     foreach($this->Data as $Key => $Settings)
503
-      {
504
-       $X = $Settings["X"];
505
-       $Y = $Settings["Y"];
501
+        /* Move the nodes accoding to the vectors */
502
+        foreach($this->Data as $Key => $Settings)
503
+        {
504
+        $X = $Settings["X"];
505
+        $Y = $Settings["Y"];
506 506
 
507
-       if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
507
+        if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
508 508
         {
509
-         foreach($Settings["Vectors"] as $ID => $Vector)
510
-          {
511
-           $Type  = $Vector["Type"];
512
-           $Force = $Vector["Force"];
513
-           $Angle = $Vector["Angle"];
514
-           $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
509
+            foreach($Settings["Vectors"] as $ID => $Vector)
510
+            {
511
+            $Type  = $Vector["Type"];
512
+            $Force = $Vector["Force"];
513
+            $Angle = $Vector["Angle"];
514
+            $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
515 515
 
516
-           $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
-           $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
-          }
516
+            $X = cos(deg2rad($Angle)) * $Force * $Factor + $X;
517
+            $Y = sin(deg2rad($Angle)) * $Force * $Factor + $Y;
518
+            }
519 519
         }
520 520
 
521
-       $this->Data[$Key]["X"] = $X;
522
-       $this->Data[$Key]["Y"] = $Y;
523
-      }
521
+        $this->Data[$Key]["X"] = $X;
522
+        $this->Data[$Key]["Y"] = $Y;
523
+        }
524 524
     }
525 525
 
526
-   function lastPass()
526
+    function lastPass()
527 527
     {
528
-     /* Put everything inside the graph area */
529
-     foreach($this->Data as $Key => $Settings)
530
-      {
531
-       $X = $Settings["X"];
532
-       $Y = $Settings["Y"];
533
-
534
-       if ( $X < $this->X1 ) { $X = $this->X1; }
535
-       if ( $X > $this->X2 ) { $X = $this->X2; }
536
-       if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
-       if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
-
539
-       $this->Data[$Key]["X"] = $X;
540
-       $this->Data[$Key]["Y"] = $Y;
541
-      }
542
-
543
-     /* Dump all links */
544
-     $Links = "";
545
-     foreach($this->Data as $Key => $Settings)
546
-      {
547
-       $X1 = $Settings["X"];
548
-       $Y1 = $Settings["Y"];
549
-
550
-       if ( isset($Settings["Connections"]) )
551
-        {
552
-         foreach ($Settings["Connections"] as $ID => $NodeID)
553
-          {
554
-           if ( isset($this->Data[$NodeID]) )
528
+        /* Put everything inside the graph area */
529
+        foreach($this->Data as $Key => $Settings)
530
+        {
531
+        $X = $Settings["X"];
532
+        $Y = $Settings["Y"];
533
+
534
+        if ( $X < $this->X1 ) { $X = $this->X1; }
535
+        if ( $X > $this->X2 ) { $X = $this->X2; }
536
+        if ( $Y < $this->Y1 ) { $Y = $this->Y1; }
537
+        if ( $Y > $this->Y2 ) { $Y = $this->Y2; }
538
+
539
+        $this->Data[$Key]["X"] = $X;
540
+        $this->Data[$Key]["Y"] = $Y;
541
+        }
542
+
543
+        /* Dump all links */
544
+        $Links = "";
545
+        foreach($this->Data as $Key => $Settings)
546
+        {
547
+        $X1 = $Settings["X"];
548
+        $Y1 = $Settings["Y"];
549
+
550
+        if ( isset($Settings["Connections"]) )
551
+        {
552
+            foreach ($Settings["Connections"] as $ID => $NodeID)
553
+            {
554
+            if ( isset($this->Data[$NodeID]) )
555 555
             {
556
-             $X2 = $this->Data[$NodeID]["X"];
557
-             $Y2 = $this->Data[$NodeID]["Y"];
556
+                $X2 = $this->Data[$NodeID]["X"];
557
+                $Y2 = $this->Data[$NodeID]["Y"];
558 558
 
559
-             $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
559
+                $Links[] = array("X1"=>$X1,"Y1"=>$Y1,"X2"=>$X2,"Y2"=>$Y2,"Source"=>$Settings["Name"],"Destination"=>$this->Data[$NodeID]["Name"]);
560 560
             }
561
-          }
561
+            }
562
+        }
562 563
         }
563
-      }
564 564
 
565
-     /* Check collisions */
566
-     $Conflicts = 0;
567
-     foreach($this->Data as $Key => $Settings)
568
-      {
569
-       $X1 = $Settings["X"];
570
-       $Y1 = $Settings["Y"];
565
+        /* Check collisions */
566
+        $Conflicts = 0;
567
+        foreach($this->Data as $Key => $Settings)
568
+        {
569
+        $X1 = $Settings["X"];
570
+        $Y1 = $Settings["Y"];
571 571
 
572
-       if ( isset($Settings["Connections"]) )
572
+        if ( isset($Settings["Connections"]) )
573 573
         {
574
-         foreach ($Settings["Connections"] as $ID => $NodeID)
575
-          {
576
-           if ( isset($this->Data[$NodeID]) )
574
+            foreach ($Settings["Connections"] as $ID => $NodeID)
575
+            {
576
+            if ( isset($this->Data[$NodeID]) )
577 577
             {
578
-             $X2 = $this->Data[$NodeID]["X"];
579
-             $Y2 = $this->Data[$NodeID]["Y"];
578
+                $X2 = $this->Data[$NodeID]["X"];
579
+                $Y2 = $this->Data[$NodeID]["Y"];
580 580
 
581
-             foreach($Links as $IDLinks => $Link)
582
-              {
583
-               $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
581
+                foreach($Links as $IDLinks => $Link)
582
+                {
583
+                $X3 = $Link["X1"]; $Y3 = $Link["Y1"]; $X4 = $Link["X2"]; $Y4 = $Link["Y2"];
584 584
 
585
-               if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
585
+                if ( !($X1 == $X3 && $X2 == $X4 && $Y1 == $Y3 && $Y2 == $Y4 ) )
586 586
                 {
587
-                 if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
-                  {
589
-                   if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
587
+                    if ( $this->intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4) )
588
+                    {
589
+                    if ( $Link["Source"] != $Settings["Name"] && $Link["Source"] != $this->Data[$NodeID]["Name"] && $Link["Destination"] != $Settings["Name"] && $Link["Destination"] != $this->Data[$NodeID]["Name"] )
590 590
                     { $Conflicts++; }
591
-                  }
591
+                    }
592
+                }
592 593
                 }
593
-              }
594 594
             }
595
-          }
595
+            }
596
+        }
596 597
         }
597
-      }
598
-     return($Conflicts/2);
598
+        return($Conflicts/2);
599 599
     }
600 600
 
601
-   /* Center the graph */
602
-   function center()
601
+    /* Center the graph */
602
+    function center()
603 603
     {
604
-     /* Determine the real center */
605
-     $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
-     $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
-
608
-     /* Get current boundaries */
609
-     $XMin = $this->X2; $XMax = $this->X1;
610
-     $YMin = $this->Y2; $YMax = $this->Y1;
611
-     foreach($this->Data as $Key => $Settings)
612
-      {
613
-       $X = $Settings["X"];
614
-       $Y = $Settings["Y"];
615
-
616
-       if ( $X < $XMin) { $XMin = $X; }
617
-       if ( $X > $XMax) { $XMax = $X; }
618
-       if ( $Y < $YMin) { $YMin = $Y; }
619
-       if ( $Y > $YMax) { $YMax = $Y; }
620
-      }
621
-     $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
-     $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
623
-
624
-     /* Compute the offset to apply */
625
-     $XOffset = $TargetCenterX - $CurrentCenterX;
626
-     $YOffset = $TargetCenterY - $CurrentCenterY;
627
-
628
-     /* Correct the points position */
629
-     foreach($this->Data as $Key => $Settings)
630
-      {
631
-       $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
-       $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
-      }
634
-    }
604
+        /* Determine the real center */
605
+        $TargetCenterX = ($this->X2 - $this->X1) / 2 + $this->X1;
606
+        $TargetCenterY = ($this->Y2 - $this->Y1) / 2 + $this->Y1;
607
+
608
+        /* Get current boundaries */
609
+        $XMin = $this->X2; $XMax = $this->X1;
610
+        $YMin = $this->Y2; $YMax = $this->Y1;
611
+        foreach($this->Data as $Key => $Settings)
612
+        {
613
+        $X = $Settings["X"];
614
+        $Y = $Settings["Y"];
635 615
 
636
-   /* Create the encoded string */
637
-   function drawSpring($Object,$Settings="")
638
-    {
639
-     $this->pChartObject = $Object;
616
+        if ( $X < $XMin) { $XMin = $X; }
617
+        if ( $X > $XMax) { $XMax = $X; }
618
+        if ( $Y < $YMin) { $YMin = $Y; }
619
+        if ( $Y > $YMax) { $YMax = $Y; }
620
+        }
621
+        $CurrentCenterX = ($XMax - $XMin) / 2 + $XMin;
622
+        $CurrentCenterY = ($YMax - $YMin) / 2 + $YMin;
640 623
 
641
-     $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
-     $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
-     $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
-     $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
-     $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
-     $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
-     $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
-     $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
-     $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
-     $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
624
+        /* Compute the offset to apply */
625
+        $XOffset = $TargetCenterX - $CurrentCenterX;
626
+        $YOffset = $TargetCenterY - $CurrentCenterY;
651 627
 
652
-     $FontSize		= $Object->FontSize;
653
-     $this->X1		= $Object->GraphAreaX1;
654
-     $this->Y1		= $Object->GraphAreaY1;
655
-     $this->X2		= $Object->GraphAreaX2;
656
-     $this->Y2		= $Object->GraphAreaY2;
628
+        /* Correct the points position */
629
+        foreach($this->Data as $Key => $Settings)
630
+        {
631
+        $this->Data[$Key]["X"] = $Settings["X"] + $XOffset;
632
+        $this->Data[$Key]["Y"] = $Settings["Y"] + $YOffset;
633
+        }
634
+    }
657 635
 
658
-     $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
-     while ($Conflicts != 0 && $Jobs < $Retries )
660
-      {
661
-       $Jobs++;
636
+    /* Create the encoded string */
637
+    function drawSpring($Object,$Settings="")
638
+    {
639
+        $this->pChartObject = $Object;
640
+
641
+        $Pass			= isset($Settings["Pass"]) ? $Settings["Pass"] : 50;
642
+        $Retries			= isset($Settings["Retry"]) ? $Settings["Retry"] : 10;
643
+        $this->MagneticForceA	= isset($Settings["MagneticForceA"]) ? $Settings["MagneticForceA"] : 1.5;
644
+        $this->MagneticForceR	= isset($Settings["MagneticForceR"]) ? $Settings["MagneticForceR"] : 2;
645
+        $this->RingSize		= isset($Settings["RingSize"]) ? $Settings["RingSize"] : 40;
646
+        $DrawVectors		= isset($Settings["DrawVectors"]) ? $Settings["DrawVectors"] : FALSE;
647
+        $DrawQuietZone		= isset($Settings["DrawQuietZone"]) ? $Settings["DrawQuietZone"] : FALSE;
648
+        $CenterGraph		= isset($Settings["CenterGraph"]) ? $Settings["CenterGraph"] : TRUE;
649
+        $TextPadding		= isset($Settings["TextPadding"]) ? $Settings["TextPadding"] : 4;
650
+        $Algorithm			= isset($Settings["Algorithm"]) ? $Settings["Algorithm"] : ALGORITHM_WEIGHTED;
651
+
652
+        $FontSize		= $Object->FontSize;
653
+        $this->X1		= $Object->GraphAreaX1;
654
+        $this->Y1		= $Object->GraphAreaY1;
655
+        $this->X2		= $Object->GraphAreaX2;
656
+        $this->Y2		= $Object->GraphAreaY2;
657
+
658
+        $Conflicts = 1; $Jobs = 0; $this->History["MinimumConflicts"] = -1;
659
+        while ($Conflicts != 0 && $Jobs < $Retries )
660
+        {
661
+        $Jobs++;
662 662
 
663
-       /* Compute the initial settings */
664
-       $this->firstPass($Algorithm);
663
+        /* Compute the initial settings */
664
+        $this->firstPass($Algorithm);
665 665
 
666
-       /* Apply the vectors */
667
-       if ( $Pass > 0 ) 
666
+        /* Apply the vectors */
667
+        if ( $Pass > 0 ) 
668 668
         {
669
-         for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
669
+            for ($i=0; $i<=$Pass; $i++) { $this->doPass(); }
670 670
         }
671 671
 
672
-       $Conflicts = $this->lastPass();
673
-       if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
672
+        $Conflicts = $this->lastPass();
673
+        if ( $this->History["MinimumConflicts"] == -1 || $Conflicts < $this->History["MinimumConflicts"] )
674 674
         { $this->History["MinimumConflicts"] = $Conflicts; $this->History["Result"] = $this->Data; }
675
-      }
675
+        }
676 676
 
677
-     $Conflicts  = $this->History["MinimumConflicts"];
678
-     $this->Data = $this->History["Result"];
677
+        $Conflicts  = $this->History["MinimumConflicts"];
678
+        $this->Data = $this->History["Result"];
679 679
 
680
-     if ( $CenterGraph ) { $this->center(); }
680
+        if ( $CenterGraph ) { $this->center(); }
681 681
 
682
-     /* Draw the connections */
683
-     $Drawn = "";
684
-     foreach($this->Data as $Key => $Settings)
685
-      {
686
-       $X	= $Settings["X"];
687
-       $Y	= $Settings["Y"];
682
+        /* Draw the connections */
683
+        $Drawn = "";
684
+        foreach($this->Data as $Key => $Settings)
685
+        {
686
+        $X	= $Settings["X"];
687
+        $Y	= $Settings["Y"];
688 688
 
689
-       if ( isset($Settings["Connections"]) )
689
+        if ( isset($Settings["Connections"]) )
690 690
         {
691
-         foreach ($Settings["Connections"] as $ID => $NodeID)
692
-          {
693
-           if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
-           if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
691
+            foreach ($Settings["Connections"] as $ID => $NodeID)
692
+            {
693
+            if ( !isset($Drawn[$Key]) )    { $Drawn[$Key] = ""; }
694
+            if ( !isset($Drawn[$NodeID]) ) { $Drawn[$NodeID] = ""; }
695 695
 
696
-           if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
696
+            if ( isset($this->Data[$NodeID]) && !isset($Drawn[$Key][$NodeID]) && !isset($Drawn[$NodeID][$Key]) )
697 697
             {
698
-             $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
698
+                $Color = array("R"=>$this->Default["LinkR"],"G"=>$this->Default["LinkG"],"B"=>$this->Default["LinkB"],"Alpha"=>$this->Default["Alpha"]);
699 699
 
700
-             if ( $this->Links != "" )
701
-              {
702
-               if ( isset($this->Links[$Key][$NodeID]["R"]) )
700
+                if ( $this->Links != "" )
701
+                {
702
+                if ( isset($this->Links[$Key][$NodeID]["R"]) )
703 703
                 { $Color = array("R"=>$this->Links[$Key][$NodeID]["R"],"G"=>$this->Links[$Key][$NodeID]["G"],"B"=>$this->Links[$Key][$NodeID]["B"],"Alpha"=>$this->Links[$Key][$NodeID]["Alpha"]); }
704 704
 
705
-               if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
-                 { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
-              }
705
+                if ( isset($this->Links[$Key][$NodeID]["Ticks"]) )
706
+                    { $Color["Ticks"] = $this->Links[$Key][$NodeID]["Ticks"]; }
707
+                }
708 708
 
709
-             $X2 = $this->Data[$NodeID]["X"];
710
-             $Y2 = $this->Data[$NodeID]["Y"];
711
-             $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
-             $Drawn[$Key][$NodeID] = TRUE;
709
+                $X2 = $this->Data[$NodeID]["X"];
710
+                $Y2 = $this->Data[$NodeID]["Y"];
711
+                $this->pChartObject->drawLine($X,$Y,$X2,$Y2,$Color);
712
+                $Drawn[$Key][$NodeID] = TRUE;
713 713
 
714
-             if ( isset($this->Links) && $this->Links != "" )
715
-              {
716
-               if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
714
+                if ( isset($this->Links) && $this->Links != "" )
715
+                {
716
+                if ( isset($this->Links[$Key][$NodeID]["Name"]) || isset($this->Links[$NodeID][$Key]["Name"]) )
717 717
                 {
718
-                 $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
-                 $TxtX  = ($X2 - $X)/2 + $X;
720
-                 $TxtY  = ($Y2 - $Y)/2 + $Y;
721
-
722
-                 if ( $X <= $X2 )
723
-                  $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
-                 else
725
-                  $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
-
727
-                 $Settings          = $Color;
728
-                 $Settings["Angle"] = $Angle;
729
-                 $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
-                 $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
718
+                    $Name  = isset($this->Links[$Key][$NodeID]["Name"]) ? $this->Links[$Key][$NodeID]["Name"] : $this->Links[$NodeID][$Key]["Name"];
719
+                    $TxtX  = ($X2 - $X)/2 + $X;
720
+                    $TxtY  = ($Y2 - $Y)/2 + $Y;
721
+
722
+                    if ( $X <= $X2 )
723
+                    $Angle = (360-$this->getAngle($X,$Y,$X2,$Y2)) % 360;
724
+                    else
725
+                    $Angle = (360-$this->getAngle($X2,$Y2,$X,$Y)) % 360;
726
+
727
+                    $Settings          = $Color;
728
+                    $Settings["Angle"] = $Angle;
729
+                    $Settings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE;
730
+                    $this->pChartObject->drawText($TxtX,$TxtY,$Name,$Settings);
731 731
                 }
732
-              }
732
+                }
733
+            }
733 734
             }
734
-          }
735 735
         }
736
-      }
736
+        }
737 737
 
738
-     /* Draw the quiet zones */
739
-     if ( $DrawQuietZone )
740
-      {
741
-       foreach($this->Data as $Key => $Settings)
738
+        /* Draw the quiet zones */
739
+        if ( $DrawQuietZone )
740
+        {
741
+        foreach($this->Data as $Key => $Settings)
742 742
         {
743
-         $X	 = $Settings["X"];
744
-         $Y	 = $Settings["Y"];
745
-         $FreeZone = $Settings["FreeZone"];
743
+            $X	 = $Settings["X"];
744
+            $Y	 = $Settings["Y"];
745
+            $FreeZone = $Settings["FreeZone"];
746 746
 
747
-         $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
747
+            $this->pChartObject->drawFilledCircle($X,$Y,$FreeZone,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>2));
748
+        }
748 749
         }
749
-      }
750 750
 
751 751
 
752
-     /* Draw the nodes */
753
-     foreach($this->Data as $Key => $Settings)
754
-      {
755
-       $X	 = $Settings["X"];
756
-       $Y	 = $Settings["Y"];
757
-       $Name	 = $Settings["Name"];
758
-       $FreeZone = $Settings["FreeZone"];
759
-       $Shape    = $Settings["Shape"];
760
-       $Size     = $Settings["Size"];
752
+        /* Draw the nodes */
753
+        foreach($this->Data as $Key => $Settings)
754
+        {
755
+        $X	 = $Settings["X"];
756
+        $Y	 = $Settings["Y"];
757
+        $Name	 = $Settings["Name"];
758
+        $FreeZone = $Settings["FreeZone"];
759
+        $Shape    = $Settings["Shape"];
760
+        $Size     = $Settings["Size"];
761 761
 
762
-       $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
762
+        $Color	 = array("R"=>$Settings["R"],"G"=>$Settings["G"],"B"=>$Settings["B"],"Alpha"=>$Settings["Alpha"],"BorderR"=>$Settings["BorderR"],"BorderG"=>$Settings["BorderG"],"BorderB"=>$Settings["BorderB"],"BorderApha"=>$Settings["BorderAlpha"]);
763 763
 
764
-       if ( $Shape == NODE_SHAPE_CIRCLE )
764
+        if ( $Shape == NODE_SHAPE_CIRCLE )
765 765
         {
766
-         $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
766
+            $this->pChartObject->drawFilledCircle($X,$Y,$Size,$Color);
767 767
         }
768
-       elseif ( $Shape == NODE_SHAPE_TRIANGLE )
768
+        elseif ( $Shape == NODE_SHAPE_TRIANGLE )
769 769
         {
770
-         $Points = "";
771
-         $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
-         $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
-         $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
-         $this->pChartObject->drawPolygon($Points,$Color);
770
+            $Points = "";
771
+            $Points[] = cos(deg2rad(270)) * $Size + $X; $Points[] = sin(deg2rad(270)) * $Size + $Y;
772
+            $Points[] = cos(deg2rad(45)) * $Size + $X;  $Points[] = sin(deg2rad(45)) * $Size + $Y;
773
+            $Points[] = cos(deg2rad(135)) * $Size + $X; $Points[] = sin(deg2rad(135)) * $Size + $Y;
774
+            $this->pChartObject->drawPolygon($Points,$Color);
775 775
         }
776
-       elseif ( $Shape == NODE_SHAPE_SQUARE )
776
+        elseif ( $Shape == NODE_SHAPE_SQUARE )
777 777
         {
778
-         $Offset = $Size/2; $Size = $Size / 2;
779
-         $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
778
+            $Offset = $Size/2; $Size = $Size / 2;
779
+            $this->pChartObject->drawFilledRectangle($X-$Offset,$Y-$Offset,$X+$Offset,$Y+$Offset,$Color);
780 780
         }
781 781
 
782
-       if ( $Name != "" )
782
+        if ( $Name != "" )
783 783
         {
784
-         $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
784
+            $LabelOptions = array("R"=>$this->Labels["R"],"G"=>$this->Labels["G"],"B"=>$this->Labels["B"],"Alpha"=>$this->Labels["Alpha"]);
785 785
 
786
-         if ( $this->Labels["Type"] == LABEL_LIGHT )
787
-          {
788
-           $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
-           $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
-          }
791
-         elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
-          {
793
-           $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
-           $LabelOptions["DrawBox"]       = TRUE;
795
-           $LabelOptions["BoxAlpha"]      = 50;
796
-           $LabelOptions["BorderOffset"]  = 4;
797
-           $LabelOptions["RoundedRadius"] = 3;
798
-           $LabelOptions["BoxRounded"]    = TRUE;
799
-           $LabelOptions["NoShadow"]      = TRUE;
800
-
801
-           $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
-          }
786
+            if ( $this->Labels["Type"] == LABEL_LIGHT )
787
+            {
788
+            $LabelOptions["Align"] = TEXT_ALIGN_BOTTOMLEFT;
789
+            $this->pChartObject->drawText($X,$Y,$Name,$LabelOptions);
790
+            }
791
+            elseif ( $this->Labels["Type"] == LABEL_CLASSIC )
792
+            {
793
+            $LabelOptions["Align"]         = TEXT_ALIGN_TOPMIDDLE;
794
+            $LabelOptions["DrawBox"]       = TRUE;
795
+            $LabelOptions["BoxAlpha"]      = 50;
796
+            $LabelOptions["BorderOffset"]  = 4;
797
+            $LabelOptions["RoundedRadius"] = 3;
798
+            $LabelOptions["BoxRounded"]    = TRUE;
799
+            $LabelOptions["NoShadow"]      = TRUE;
800
+
801
+            $this->pChartObject->drawText($X,$Y+$Size+$TextPadding,$Name,$LabelOptions);
802
+            }
803
+        }
803 804
         }
804
-      }
805 805
 
806
-     /* Draw the vectors */
807
-     if ( $DrawVectors )
808
-      {
809
-       foreach($this->Data as $Key => $Settings)
806
+        /* Draw the vectors */
807
+        if ( $DrawVectors )
810 808
         {
811
-         $X1 = $Settings["X"];
812
-         $Y1 = $Settings["Y"];
809
+        foreach($this->Data as $Key => $Settings)
810
+        {
811
+            $X1 = $Settings["X"];
812
+            $Y1 = $Settings["Y"];
813 813
 
814
-         if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
-          {
816
-           foreach($Settings["Vectors"] as $ID => $Vector)
814
+            if ( isset($Settings["Vectors"]) && $Settings["Type"] != NODE_TYPE_CENTRAL )
815
+            {
816
+            foreach($Settings["Vectors"] as $ID => $Vector)
817 817
             {
818
-             $Type  = $Vector["Type"];
819
-             $Force = $Vector["Force"];
820
-             $Angle = $Vector["Angle"];
821
-             $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
-             $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
818
+                $Type  = $Vector["Type"];
819
+                $Force = $Vector["Force"];
820
+                $Angle = $Vector["Angle"];
821
+                $Factor = $Type == "A" ? $this->MagneticForceA : $this->MagneticForceR;
822
+                $Color  = $Type == "A" ? array("FillR"=>255,"FillG"=>0,"FillB"=>0) : array("FillR"=>0,"FillG"=>255,"FillB"=>0);
823 823
 
824
-             $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
-             $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
824
+                $X2 = cos(deg2rad($Angle)) * $Force * $Factor + $X1;
825
+                $Y2 = sin(deg2rad($Angle)) * $Force * $Factor + $Y1;
826 826
 
827
-             $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
827
+                $this->pChartObject->drawArrow($X1,$Y1,$X2,$Y2,$Color);
828 828
             }
829
-          }
829
+            }
830
+        }
830 831
         }
831
-      }
832 832
 
833
-     return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
833
+        return(array("Pass"=>$Jobs,"Conflicts"=>$Conflicts));
834 834
     }
835 835
 
836
-   /* Return the distance between two points */
837
-   function getDistance($X1,$Y1,$X2,$Y2)
836
+    /* Return the distance between two points */
837
+    function getDistance($X1,$Y1,$X2,$Y2)
838 838
     { return (sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1))); }
839 839
 
840
-   /* Return the angle made by a line and the X axis */
841
-   function getAngle($X1,$Y1,$X2,$Y2)
840
+    /* Return the angle made by a line and the X axis */
841
+    function getAngle($X1,$Y1,$X2,$Y2)
842 842
     {
843
-     $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
-     if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
843
+        $Opposite = $Y2 - $Y1; $Adjacent = $X2 - $X1;$Angle = rad2deg(atan2($Opposite,$Adjacent));
844
+        if ($Angle > 0) { return($Angle); } else { return(360-abs($Angle)); }
845 845
     }
846 846
 
847
-   function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
847
+    function intersect($X1,$Y1,$X2,$Y2,$X3,$Y3,$X4,$Y4)
848 848
     {
849
-     $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
-     $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
849
+        $A = (($X3 * $Y4 - $X4 * $Y3) * ($X1 - $X2) - ($X1 * $Y2 - $X2 * $Y1) * ($X3 - $X4));
850
+        $B = (($Y1 - $Y2) * ($X3 - $X4) - ($Y3 - $Y4) * ($X1 - $X2));
851 851
 
852
-     if ( $B == 0 ) { return(FALSE); }
853
-     $Xi = $A / $B;
852
+        if ( $B == 0 ) { return(FALSE); }
853
+        $Xi = $A / $B;
854 854
 
855
-     $C = ($X1 - $X2);
856
-     if ( $C == 0 ) { return(FALSE); }
857
-     $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
855
+        $C = ($X1 - $X2);
856
+        if ( $C == 0 ) { return(FALSE); }
857
+        $Yi = $Xi * (($Y1 - $Y2)/$C) + (($X1 * $Y2 - $X2 * $Y1)/$C);
858 858
 
859
-     if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
-      {
861
-       if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
859
+        if ( $Xi >= min($X1,$X2) && $Xi >= min($X3,$X4) && $Xi <= max($X1,$X2) && $Xi <= max($X3,$X4))
860
+        {
861
+        if ( $Yi >= min($Y1,$Y2) && $Yi >= min($Y3,$Y4) && $Yi <= max($Y1,$Y2) && $Yi <= max($Y3,$Y4))
862 862
         { return(TRUE); }
863
-      }
863
+        }
864 864
 
865
-      return(FALSE);   
865
+        return(FALSE);   
866
+    }
866 867
     }
867
-  }
868 868
 ?>
869 869
\ No newline at end of file
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pDraw.class.php 1 patch
Indentation   +5013 added lines, -5013 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pDraw - class extension with drawing methods
4 4
 
5 5
      Version     : 2.1.3
@@ -13,6181 +13,6181 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- define("DIRECTION_VERTICAL"		, 690001);
17
- define("DIRECTION_HORIZONTAL"		, 690002);
18
-
19
- define("SCALE_POS_LEFTRIGHT"		, 690101);
20
- define("SCALE_POS_TOPBOTTOM"		, 690102);
21
-
22
- define("SCALE_MODE_FLOATING"		, 690201);
23
- define("SCALE_MODE_START0"		, 690202);
24
- define("SCALE_MODE_ADDALL"		, 690203);
25
- define("SCALE_MODE_ADDALL_START0"	, 690204);
26
- define("SCALE_MODE_MANUAL"		, 690205);
27
-
28
- define("SCALE_SKIP_NONE"		, 690301);
29
- define("SCALE_SKIP_SAME"		, 690302);
30
- define("SCALE_SKIP_NUMBERS"		, 690303);
31
-
32
- define("TEXT_ALIGN_TOPLEFT"		, 690401);
33
- define("TEXT_ALIGN_TOPMIDDLE"		, 690402);
34
- define("TEXT_ALIGN_TOPRIGHT"		, 690403);
35
- define("TEXT_ALIGN_MIDDLELEFT"		, 690404);
36
- define("TEXT_ALIGN_MIDDLEMIDDLE"	, 690405);
37
- define("TEXT_ALIGN_MIDDLERIGHT"	, 690406);
38
- define("TEXT_ALIGN_BOTTOMLEFT"		, 690407);
39
- define("TEXT_ALIGN_BOTTOMMIDDLE"	, 690408);
40
- define("TEXT_ALIGN_BOTTOMRIGHT"	, 690409);
41
-
42
- define("POSITION_TOP"                  , 690501);
43
- define("POSITION_BOTTOM"               , 690502);
44
-
45
- define("LABEL_POS_LEFT"		, 690601);
46
- define("LABEL_POS_CENTER"		, 690602);
47
- define("LABEL_POS_RIGHT"		, 690603);
48
- define("LABEL_POS_TOP"			, 690604);
49
- define("LABEL_POS_BOTTOM"		, 690605);
50
- define("LABEL_POS_INSIDE"		, 690606);
51
- define("LABEL_POS_OUTSIDE"		, 690607);
52
-
53
- define("ORIENTATION_HORIZONTAL"	, 690701);
54
- define("ORIENTATION_VERTICAL"		, 690702);
55
- define("ORIENTATION_AUTO"		, 690703);
56
-
57
- define("LEGEND_NOBORDER"		, 690800);
58
- define("LEGEND_BOX"			, 690801);
59
- define("LEGEND_ROUND"			, 690802);
60
-
61
- define("LEGEND_VERTICAL"		, 690901);
62
- define("LEGEND_HORIZONTAL"		, 690902);
63
-
64
- define("LEGEND_FAMILY_BOX"		, 691051);
65
- define("LEGEND_FAMILY_CIRCLE"		, 691052);
66
- define("LEGEND_FAMILY_LINE"		, 691053);
67
-
68
- define("DISPLAY_AUTO"			, 691001);
69
- define("DISPLAY_MANUAL"		, 691002);
70
-
71
- define("LABELING_ALL"			, 691011);
72
- define("LABELING_DIFFERENT"		, 691012);
73
-
74
- define("BOUND_MIN"			, 691021);
75
- define("BOUND_MAX"			, 691022);
76
- define("BOUND_BOTH"			, 691023);
77
-
78
- define("BOUND_LABEL_POS_TOP"		, 691031);
79
- define("BOUND_LABEL_POS_BOTTOM"	, 691032);
80
- define("BOUND_LABEL_POS_AUTO"		, 691033);
81
-
82
- define("CAPTION_LEFT_TOP"		, 691041);
83
- define("CAPTION_RIGHT_BOTTOM"		, 691042);
84
-
85
- define("GRADIENT_SIMPLE"		, 691051);
86
- define("GRADIENT_EFFECT_CAN"		, 691052);
87
-
88
- define("LABEL_TITLE_NOBACKGROUND"	, 691061);
89
- define("LABEL_TITLE_BACKGROUND"	, 691062);
90
-
91
- define("LABEL_POINT_NONE"		, 691071);
92
- define("LABEL_POINT_CIRCLE"		, 691072);
93
- define("LABEL_POINT_BOX"		, 691073);
94
-
95
- define("ZONE_NAME_ANGLE_AUTO"		, 691081);
96
-
97
- define("PI"		, 3.14159265);
98
- define("ALL"		, 69);
99
- define("NONE"		, 31);
100
- define("AUTO"		, 690000);
101
- define("OUT_OF_SIGHT"	, -10000000000000);
102
-
103
- class pDraw
104
-  {
105
-   /* Returns the number of drawable series */
106
-   function countDrawableSeries()
16
+    define("DIRECTION_VERTICAL"		, 690001);
17
+    define("DIRECTION_HORIZONTAL"		, 690002);
18
+
19
+    define("SCALE_POS_LEFTRIGHT"		, 690101);
20
+    define("SCALE_POS_TOPBOTTOM"		, 690102);
21
+
22
+    define("SCALE_MODE_FLOATING"		, 690201);
23
+    define("SCALE_MODE_START0"		, 690202);
24
+    define("SCALE_MODE_ADDALL"		, 690203);
25
+    define("SCALE_MODE_ADDALL_START0"	, 690204);
26
+    define("SCALE_MODE_MANUAL"		, 690205);
27
+
28
+    define("SCALE_SKIP_NONE"		, 690301);
29
+    define("SCALE_SKIP_SAME"		, 690302);
30
+    define("SCALE_SKIP_NUMBERS"		, 690303);
31
+
32
+    define("TEXT_ALIGN_TOPLEFT"		, 690401);
33
+    define("TEXT_ALIGN_TOPMIDDLE"		, 690402);
34
+    define("TEXT_ALIGN_TOPRIGHT"		, 690403);
35
+    define("TEXT_ALIGN_MIDDLELEFT"		, 690404);
36
+    define("TEXT_ALIGN_MIDDLEMIDDLE"	, 690405);
37
+    define("TEXT_ALIGN_MIDDLERIGHT"	, 690406);
38
+    define("TEXT_ALIGN_BOTTOMLEFT"		, 690407);
39
+    define("TEXT_ALIGN_BOTTOMMIDDLE"	, 690408);
40
+    define("TEXT_ALIGN_BOTTOMRIGHT"	, 690409);
41
+
42
+    define("POSITION_TOP"                  , 690501);
43
+    define("POSITION_BOTTOM"               , 690502);
44
+
45
+    define("LABEL_POS_LEFT"		, 690601);
46
+    define("LABEL_POS_CENTER"		, 690602);
47
+    define("LABEL_POS_RIGHT"		, 690603);
48
+    define("LABEL_POS_TOP"			, 690604);
49
+    define("LABEL_POS_BOTTOM"		, 690605);
50
+    define("LABEL_POS_INSIDE"		, 690606);
51
+    define("LABEL_POS_OUTSIDE"		, 690607);
52
+
53
+    define("ORIENTATION_HORIZONTAL"	, 690701);
54
+    define("ORIENTATION_VERTICAL"		, 690702);
55
+    define("ORIENTATION_AUTO"		, 690703);
56
+
57
+    define("LEGEND_NOBORDER"		, 690800);
58
+    define("LEGEND_BOX"			, 690801);
59
+    define("LEGEND_ROUND"			, 690802);
60
+
61
+    define("LEGEND_VERTICAL"		, 690901);
62
+    define("LEGEND_HORIZONTAL"		, 690902);
63
+
64
+    define("LEGEND_FAMILY_BOX"		, 691051);
65
+    define("LEGEND_FAMILY_CIRCLE"		, 691052);
66
+    define("LEGEND_FAMILY_LINE"		, 691053);
67
+
68
+    define("DISPLAY_AUTO"			, 691001);
69
+    define("DISPLAY_MANUAL"		, 691002);
70
+
71
+    define("LABELING_ALL"			, 691011);
72
+    define("LABELING_DIFFERENT"		, 691012);
73
+
74
+    define("BOUND_MIN"			, 691021);
75
+    define("BOUND_MAX"			, 691022);
76
+    define("BOUND_BOTH"			, 691023);
77
+
78
+    define("BOUND_LABEL_POS_TOP"		, 691031);
79
+    define("BOUND_LABEL_POS_BOTTOM"	, 691032);
80
+    define("BOUND_LABEL_POS_AUTO"		, 691033);
81
+
82
+    define("CAPTION_LEFT_TOP"		, 691041);
83
+    define("CAPTION_RIGHT_BOTTOM"		, 691042);
84
+
85
+    define("GRADIENT_SIMPLE"		, 691051);
86
+    define("GRADIENT_EFFECT_CAN"		, 691052);
87
+
88
+    define("LABEL_TITLE_NOBACKGROUND"	, 691061);
89
+    define("LABEL_TITLE_BACKGROUND"	, 691062);
90
+
91
+    define("LABEL_POINT_NONE"		, 691071);
92
+    define("LABEL_POINT_CIRCLE"		, 691072);
93
+    define("LABEL_POINT_BOX"		, 691073);
94
+
95
+    define("ZONE_NAME_ANGLE_AUTO"		, 691081);
96
+
97
+    define("PI"		, 3.14159265);
98
+    define("ALL"		, 69);
99
+    define("NONE"		, 31);
100
+    define("AUTO"		, 690000);
101
+    define("OUT_OF_SIGHT"	, -10000000000000);
102
+
103
+    class pDraw
104
+    {
105
+    /* Returns the number of drawable series */
106
+    function countDrawableSeries()
107 107
     {
108
-     $Results = 0;
109
-     $Data = $this->DataSet->getData();
108
+        $Results = 0;
109
+        $Data = $this->DataSet->getData();
110 110
 
111
-     foreach($Data["Series"] as $SerieName => $Serie)
112
-      { if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] ) { $Results++; } }
111
+        foreach($Data["Series"] as $SerieName => $Serie)
112
+        { if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] ) { $Results++; } }
113 113
 
114
-     return($Results);
114
+        return($Results);
115 115
     }
116 116
 
117
-   /* Fix box coordinates */
118
-   function fixBoxCoordinates($Xa,$Ya,$Xb,$Yb)
117
+    /* Fix box coordinates */
118
+    function fixBoxCoordinates($Xa,$Ya,$Xb,$Yb)
119 119
     {
120
-     $X1 = min($Xa,$Xb); $Y1 = min($Ya,$Yb);
121
-     $X2 = max($Xa,$Xb); $Y2 = max($Ya,$Yb);
120
+        $X1 = min($Xa,$Xb); $Y1 = min($Ya,$Yb);
121
+        $X2 = max($Xa,$Xb); $Y2 = max($Ya,$Yb);
122 122
 
123
-     return(array($X1,$Y1,$X2,$Y2));
123
+        return(array($X1,$Y1,$X2,$Y2));
124 124
     }
125 125
 
126
-   /* Draw a polygon */
127
-   function drawPolygon($Points,$Format="")
126
+    /* Draw a polygon */
127
+    function drawPolygon($Points,$Format="")
128 128
     {
129
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
130
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
131
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
132
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
133
-     $NoFill		= isset($Format["NoFill"]) ? $Format["NoFill"] : FALSE;
134
-     $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
135
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
136
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
137
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
138
-     $BorderAlpha 	= isset($Format["Alpha"]) ? $Format["Alpha"] : $Alpha / 2;
139
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
140
-     $SkipX		= isset($Format["SkipX"]) ? $Format["SkipX"] : OUT_OF_SIGHT;
141
-     $SkipY		= isset($Format["SkipY"]) ? $Format["SkipY"] : OUT_OF_SIGHT;
142
-
143
-     /* Calling the ImageFilledPolygon() function over the $Points array will round it */ 	
144
-     $Backup = $Points;
145
-
146
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
147
-
148
-     if ( $SkipX != OUT_OF_SIGHT ) { $SkipX = floor($SkipX); }
149
-     if ( $SkipY != OUT_OF_SIGHT ) { $SkipY = floor($SkipY); }
150
-
151
-     $RestoreShadow = $this->Shadow;
152
-     if ( !$NoFill )
153
-      {
154
-       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
155
-        {
156
-         $this->Shadow = FALSE;
157
-         for($i=0;$i<=count($Points)-1;$i=$i+2)
158
-          { $Shadow[] = $Points[$i] + $this->ShadowX; $Shadow[] = $Points[$i+1] + $this->ShadowY; }
159
-         $this->drawPolygon($Shadow,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"NoBorder"=>TRUE));
160
-        }
161
-
162
-       $FillColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
163
-
164
-       if ( count($Points) >= 6 )
129
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
130
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
131
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
132
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
133
+        $NoFill		= isset($Format["NoFill"]) ? $Format["NoFill"] : FALSE;
134
+        $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
135
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
136
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
137
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
138
+        $BorderAlpha 	= isset($Format["Alpha"]) ? $Format["Alpha"] : $Alpha / 2;
139
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
140
+        $SkipX		= isset($Format["SkipX"]) ? $Format["SkipX"] : OUT_OF_SIGHT;
141
+        $SkipY		= isset($Format["SkipY"]) ? $Format["SkipY"] : OUT_OF_SIGHT;
142
+
143
+        /* Calling the ImageFilledPolygon() function over the $Points array will round it */ 	
144
+        $Backup = $Points;
145
+
146
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
147
+
148
+        if ( $SkipX != OUT_OF_SIGHT ) { $SkipX = floor($SkipX); }
149
+        if ( $SkipY != OUT_OF_SIGHT ) { $SkipY = floor($SkipY); }
150
+
151
+        $RestoreShadow = $this->Shadow;
152
+        if ( !$NoFill )
153
+        {
154
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
155
+        {
156
+            $this->Shadow = FALSE;
157
+            for($i=0;$i<=count($Points)-1;$i=$i+2)
158
+            { $Shadow[] = $Points[$i] + $this->ShadowX; $Shadow[] = $Points[$i+1] + $this->ShadowY; }
159
+            $this->drawPolygon($Shadow,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"NoBorder"=>TRUE));
160
+        }
161
+
162
+        $FillColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
163
+
164
+        if ( count($Points) >= 6 )
165 165
         { ImageFilledPolygon($this->Picture,$Points,count($Points)/2,$FillColor); }
166
-      }
166
+        }
167 167
 
168
-     if ( !$NoBorder )
169
-      {
170
-       $Points = $Backup;
168
+        if ( !$NoBorder )
169
+        {
170
+        $Points = $Backup;
171 171
 
172
-       if ( $NoFill )
172
+        if ( $NoFill )
173 173
         $BorderSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
174
-       else
174
+        else
175 175
         $BorderSettings = array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha);
176 176
 
177
-       for($i=0;$i<=count($Points)-1;$i=$i+2)
177
+        for($i=0;$i<=count($Points)-1;$i=$i+2)
178 178
         {
179
-         if ( isset($Points[$i+2]) )
180
-          {
181
-           if ( !($Points[$i] == $Points[$i+2] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[$i+3] && $Points[$i+1] == $SkipY ) )
179
+            if ( isset($Points[$i+2]) )
180
+            {
181
+            if ( !($Points[$i] == $Points[$i+2] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[$i+3] && $Points[$i+1] == $SkipY ) )
182 182
             $this->drawLine($Points[$i],$Points[$i+1],$Points[$i+2],$Points[$i+3],$BorderSettings);
183
-          }
184
-         else
185
-          {
186
-           if ( !($Points[$i] == $Points[0] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[1] && $Points[$i+1] == $SkipY ) )
183
+            }
184
+            else
185
+            {
186
+            if ( !($Points[$i] == $Points[0] && $Points[$i] == $SkipX ) && !($Points[$i+1] == $Points[1] && $Points[$i+1] == $SkipY ) )
187 187
             $this->drawLine($Points[$i],$Points[$i+1],$Points[0],$Points[1],$BorderSettings);
188
-          }
188
+            }
189
+        }
189 190
         }
190
-      }
191 191
 
192
-     $this->Shadow = $RestoreShadow;
192
+        $this->Shadow = $RestoreShadow;
193 193
     }
194 194
 
195
-   /* Apply AALias correction to the rounded box boundaries */
196
-   function offsetCorrection($Value,$Mode)
195
+    /* Apply AALias correction to the rounded box boundaries */
196
+    function offsetCorrection($Value,$Mode)
197 197
     {
198
-     $Value = round($Value,1);
198
+        $Value = round($Value,1);
199 199
 
200
-     if ( $Value == 0 && $Mode == 1 ) { return(.9); }
201
-     if ( $Value == 0 ) { return(0); }
200
+        if ( $Value == 0 && $Mode == 1 ) { return(.9); }
201
+        if ( $Value == 0 ) { return(0); }
202 202
 
203
-     if ( $Mode == 1) 
204
-      { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.9); }; if ( $Value == .2 ) { return(.8); }; if ( $Value == .3 ) { return(.8); }; if ( $Value == .4 ) { return(.7); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.6); }; if ( $Value == .9 ) { return(.9); }; }
203
+        if ( $Mode == 1) 
204
+        { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.9); }; if ( $Value == .2 ) { return(.8); }; if ( $Value == .3 ) { return(.8); }; if ( $Value == .4 ) { return(.7); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.6); }; if ( $Value == .9 ) { return(.9); }; }
205 205
 
206
-     if ( $Mode == 2) 
207
-      { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.8); }; if ( $Value == .9 ) { return(.9); }; }
206
+        if ( $Mode == 2) 
207
+        { if ( $Value == 1 ) { return(.9); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.5); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.8); }; if ( $Value == .9 ) { return(.9); }; }
208 208
 
209
-     if ( $Mode == 3) 
210
-      { if ( $Value == 1 ) { return(.1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.9); }; if ( $Value == .6 ) { return(.6); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.4); }; if ( $Value == .9 ) { return(.5); }; }
209
+        if ( $Mode == 3) 
210
+        { if ( $Value == 1 ) { return(.1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.4); }; if ( $Value == .5 ) { return(.9); }; if ( $Value == .6 ) { return(.6); }; if ( $Value == .7 ) { return(.7); }; if ( $Value == .8 ) { return(.4); }; if ( $Value == .9 ) { return(.5); }; }
211 211
 
212
-     if ( $Mode == 4) 
213
-      { if ( $Value == 1 ) { return(-1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.1); }; if ( $Value == .5 ) { return(-.1); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.1); }; if ( $Value == .8 ) { return(.1); }; if ( $Value == .9 ) { return(.1); }; }
212
+        if ( $Mode == 4) 
213
+        { if ( $Value == 1 ) { return(-1); }; if ( $Value == .1 ) { return(.1); }; if ( $Value == .2 ) { return(.2); }; if ( $Value == .3 ) { return(.3); }; if ( $Value == .4 ) { return(.1); }; if ( $Value == .5 ) { return(-.1); }; if ( $Value == .6 ) { return(.8); }; if ( $Value == .7 ) { return(.1); }; if ( $Value == .8 ) { return(.1); }; if ( $Value == .9 ) { return(.1); }; }
214 214
     }
215 215
 
216
-   /* Draw a rectangle with rounded corners */
217
-   function drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
216
+    /* Draw a rectangle with rounded corners */
217
+    function drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
218 218
     {
219
-     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
220
-     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
221
-     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
222
-     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
223
-
224
-     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
225
-
226
-     if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1))/2); }
227
-     if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1))/2); }
228
-
229
-     $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
230
-
231
-     if ( $Radius <= 0 ) { $this->drawRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
232
-
233
-     if ( $this->Antialias )
234
-      {
235
-       $this->drawLine($X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
236
-       $this->drawLine($X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
237
-       $this->drawLine($X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
238
-       $this->drawLine($X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
239
-      }
240
-     else
241
-      {
242
-       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
243
-       imageline($this->Picture,$X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
244
-       imageline($this->Picture,$X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
245
-       imageline($this->Picture,$X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
246
-       imageline($this->Picture,$X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
247
-      }
248
-
249
-     $Step = 360 / (2 * PI * $Radius);
250
-     for($i=0;$i<=90;$i=$i+$Step)
251
-      {
252
-       $X = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
253
-       $Y = sin(($i+180)*PI/180) * $Radius + $Y1 + $Radius;
254
-       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
255
-
256
-       $X = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
257
-       $Y = sin(($i+90)*PI/180) * $Radius + $Y2 - $Radius;
258
-       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
259
-
260
-       $X = cos($i*PI/180) * $Radius + $X2 - $Radius;
261
-       $Y = sin($i*PI/180) * $Radius + $Y2 - $Radius;
262
-       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
263
-
264
-       $X = cos(($i+270)*PI/180) * $Radius + $X2 - $Radius;
265
-       $Y = sin(($i+270)*PI/180) * $Radius + $Y1 + $Radius;
266
-       $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
267
-      }
219
+        $R	    = isset($Format["R"]) ? $Format["R"] : 0;
220
+        $G	    = isset($Format["G"]) ? $Format["G"] : 0;
221
+        $B	    = isset($Format["B"]) ? $Format["B"] : 0;
222
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
223
+
224
+        list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
225
+
226
+        if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1))/2); }
227
+        if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1))/2); }
228
+
229
+        $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
230
+
231
+        if ( $Radius <= 0 ) { $this->drawRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
232
+
233
+        if ( $this->Antialias )
234
+        {
235
+        $this->drawLine($X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
236
+        $this->drawLine($X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
237
+        $this->drawLine($X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
238
+        $this->drawLine($X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
239
+        }
240
+        else
241
+        {
242
+        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
243
+        imageline($this->Picture,$X1+$Radius,$Y1,$X2-$Radius,$Y1,$Color);
244
+        imageline($this->Picture,$X2,$Y1+$Radius,$X2,$Y2-$Radius,$Color);
245
+        imageline($this->Picture,$X2-$Radius,$Y2,$X1+$Radius,$Y2,$Color);
246
+        imageline($this->Picture,$X1,$Y1+$Radius,$X1,$Y2-$Radius,$Color);
247
+        }
248
+
249
+        $Step = 360 / (2 * PI * $Radius);
250
+        for($i=0;$i<=90;$i=$i+$Step)
251
+        {
252
+        $X = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
253
+        $Y = sin(($i+180)*PI/180) * $Radius + $Y1 + $Radius;
254
+        $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
255
+
256
+        $X = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
257
+        $Y = sin(($i+90)*PI/180) * $Radius + $Y2 - $Radius;
258
+        $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
259
+
260
+        $X = cos($i*PI/180) * $Radius + $X2 - $Radius;
261
+        $Y = sin($i*PI/180) * $Radius + $Y2 - $Radius;
262
+        $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
263
+
264
+        $X = cos(($i+270)*PI/180) * $Radius + $X2 - $Radius;
265
+        $Y = sin(($i+270)*PI/180) * $Radius + $Y1 + $Radius;
266
+        $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
267
+        }
268 268
     }
269 269
 
270
-   /* Draw a rectangle with rounded corners */
271
-   function drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
270
+    /* Draw a rectangle with rounded corners */
271
+    function drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$Radius,$Format="")
272 272
     {
273
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
274
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
275
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
276
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
277
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
278
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
279
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
280
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
281
-
282
-     /* Temporary fix for AA issue */
283
-     $Y1 = floor($Y1); $Y2 = floor($Y2); $X1 = floor($X1); $X2 = floor($X2);
284
-
285
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
286
-     if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
287
-
288
-     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
289
-
290
-     if ( $X2 - $X1 < $Radius*2 ) { $Radius = floor((($X2-$X1))/4); }
291
-     if ( $Y2 - $Y1 < $Radius*2 ) { $Radius = floor((($Y2-$Y1))/4); }
292
-
293
-     $RestoreShadow = $this->Shadow;
294
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
295
-      {
296
-       $this->Shadow = FALSE;
297
-       $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
298
-      }
299
-
300
-     $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
301
-
302
-     if ( $Radius <= 0 ) { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
303
-
304
-     $YTop    = $Y1+$Radius;
305
-     $YBottom = $Y2-$Radius;
306
-
307
-     $Step = 360 / (2 * PI * $Radius);
308
-     $Positions = ""; $Radius--; $MinY = ""; $MaxY = "";
309
-     for($i=0;$i<=90;$i=$i+$Step)
310
-      {
311
-       $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
312
-       $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
313
-       $Yp  = floor(sin(($i+180)*PI/180) * $Radius + $YTop);
314
-       if ( $MinY == "" || $Yp > $MinY ) { $MinY = $Yp; }
315
-
316
-       if ( $Xp1 <= floor($X1) )  { $Xp1++; }
317
-       if ( $Xp2 >= floor($X2) )  { $Xp2--; }
318
-       $Xp1++;
319
-
320
-       if ( !isset($Positions[$Yp]) )
273
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
274
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
275
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
276
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
277
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
278
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
279
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
280
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
281
+
282
+        /* Temporary fix for AA issue */
283
+        $Y1 = floor($Y1); $Y2 = floor($Y2); $X1 = floor($X1); $X2 = floor($X2);
284
+
285
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
286
+        if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
287
+
288
+        list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
289
+
290
+        if ( $X2 - $X1 < $Radius*2 ) { $Radius = floor((($X2-$X1))/4); }
291
+        if ( $Y2 - $Y1 < $Radius*2 ) { $Radius = floor((($Y2-$Y1))/4); }
292
+
293
+        $RestoreShadow = $this->Shadow;
294
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
295
+        {
296
+        $this->Shadow = FALSE;
297
+        $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
298
+        }
299
+
300
+        $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE);
301
+
302
+        if ( $Radius <= 0 ) { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color); return(0); }
303
+
304
+        $YTop    = $Y1+$Radius;
305
+        $YBottom = $Y2-$Radius;
306
+
307
+        $Step = 360 / (2 * PI * $Radius);
308
+        $Positions = ""; $Radius--; $MinY = ""; $MaxY = "";
309
+        for($i=0;$i<=90;$i=$i+$Step)
310
+        {
311
+        $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
312
+        $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
313
+        $Yp  = floor(sin(($i+180)*PI/180) * $Radius + $YTop);
314
+        if ( $MinY == "" || $Yp > $MinY ) { $MinY = $Yp; }
315
+
316
+        if ( $Xp1 <= floor($X1) )  { $Xp1++; }
317
+        if ( $Xp2 >= floor($X2) )  { $Xp2--; }
318
+        $Xp1++;
319
+
320
+        if ( !isset($Positions[$Yp]) )
321 321
         { $Positions[$Yp]["X1"] = $Xp1; $Positions[$Yp]["X2"] = $Xp2; }
322
-       else
322
+        else
323 323
         { $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"]+$Xp1)/2; $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"]+$Xp2)/2; }
324 324
 
325
-       $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
326
-       $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
327
-       $Yp  = floor(sin(($i+90)*PI/180) * $Radius + $YBottom);
328
-       if ( $MaxY == "" || $Yp < $MaxY ) { $MaxY = $Yp; }
325
+        $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
326
+        $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
327
+        $Yp  = floor(sin(($i+90)*PI/180) * $Radius + $YBottom);
328
+        if ( $MaxY == "" || $Yp < $MaxY ) { $MaxY = $Yp; }
329 329
 
330
-       if ( $Xp1 <= floor($X1) ) { $Xp1++; }
331
-       if ( $Xp2 >= floor($X2) ) { $Xp2--; }
332
-       $Xp1++;
330
+        if ( $Xp1 <= floor($X1) ) { $Xp1++; }
331
+        if ( $Xp2 >= floor($X2) ) { $Xp2--; }
332
+        $Xp1++;
333 333
 
334
-       if ( !isset($Positions[$Yp]) )
334
+        if ( !isset($Positions[$Yp]) )
335 335
         { $Positions[$Yp]["X1"] = $Xp1; $Positions[$Yp]["X2"] = $Xp2; }
336
-       else
336
+        else
337 337
         { $Positions[$Yp]["X1"] = ($Positions[$Yp]["X1"]+$Xp1)/2; $Positions[$Yp]["X2"] = ($Positions[$Yp]["X2"]+$Xp2)/2; }
338
-      }
338
+        }
339 339
 
340
-     $ManualColor  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
341
-     foreach($Positions as $Yp => $Bounds)
342
-      {
343
-       $X1 = $Bounds["X1"]; $X1Dec = $this->getFirstDecimal($X1); if ( $X1Dec != 0 ) { $X1 = floor($X1)+1; }
344
-       $X2 = $Bounds["X2"]; $X2Dec = $this->getFirstDecimal($X2); if ( $X2Dec != 0 ) { $X2 = floor($X2)-1; }
345
-       imageline($this->Picture,$X1,$Yp,$X2,$Yp,$ManualColor);
346
-      }
347
-     $this->drawFilledRectangle($X1,$MinY+1,floor($X2),$MaxY-1,$Color);
340
+        $ManualColor  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
341
+        foreach($Positions as $Yp => $Bounds)
342
+        {
343
+        $X1 = $Bounds["X1"]; $X1Dec = $this->getFirstDecimal($X1); if ( $X1Dec != 0 ) { $X1 = floor($X1)+1; }
344
+        $X2 = $Bounds["X2"]; $X2Dec = $this->getFirstDecimal($X2); if ( $X2Dec != 0 ) { $X2 = floor($X2)-1; }
345
+        imageline($this->Picture,$X1,$Yp,$X2,$Yp,$ManualColor);
346
+        }
347
+        $this->drawFilledRectangle($X1,$MinY+1,floor($X2),$MaxY-1,$Color);
348 348
 
349
-     $Radius++;
350
-     $this->drawRoundedRectangle($X1,$Y1,$X2+1,$Y2-1,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
349
+        $Radius++;
350
+        $this->drawRoundedRectangle($X1,$Y1,$X2+1,$Y2-1,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
351 351
 
352
-     $this->Shadow = $RestoreShadow;
352
+        $this->Shadow = $RestoreShadow;
353 353
     }
354 354
 
355
-   /* Draw a rectangle with rounded corners */
356
-   function drawRoundedFilledRectangle_deprecated($X1,$Y1,$X2,$Y2,$Radius,$Format="")
355
+    /* Draw a rectangle with rounded corners */
356
+    function drawRoundedFilledRectangle_deprecated($X1,$Y1,$X2,$Y2,$Radius,$Format="")
357 357
     {
358
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
359
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
360
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
361
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
362
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
363
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
364
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
365
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
358
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
359
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
360
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
361
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
362
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
363
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
364
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
365
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
366 366
 
367
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
368
-     if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
367
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
368
+        if ( $BorderR == -1 ) { $BorderR = $R; $BorderG = $G; $BorderB = $B; }
369 369
 
370
-     list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
370
+        list($X1,$Y1,$X2,$Y2) = $this->fixBoxCoordinates($X1,$Y1,$X2,$Y2);
371 371
 
372
-     if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1)+2)/2); }
373
-     if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1)+2)/2); }
372
+        if ( $X2 - $X1 < $Radius ) { $Radius = floor((($X2-$X1)+2)/2); }
373
+        if ( $Y2 - $Y1 < $Radius ) { $Radius = floor((($Y2-$Y1)+2)/2); }
374 374
 
375
-     $RestoreShadow = $this->Shadow;
376
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
377
-      {
378
-       $this->Shadow = FALSE;
379
-       $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
380
-      }
375
+        $RestoreShadow = $this->Shadow;
376
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
377
+        {
378
+        $this->Shadow = FALSE;
379
+        $this->drawRoundedFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
380
+        }
381 381
 
382
-     if ( $this->getFirstDecimal($X2) >= 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
383
-     if ( $this->getFirstDecimal($X1) <= 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
382
+        if ( $this->getFirstDecimal($X2) >= 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
383
+        if ( $this->getFirstDecimal($X1) <= 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
384 384
 
385
-     if ( !$this->Antialias ) { $XOffset1 = 1; $XOffset2 = 1; }
385
+        if ( !$this->Antialias ) { $XOffset1 = 1; $XOffset2 = 1; }
386 386
 
387
-     $YTop    = floor($Y1+$Radius);
388
-     $YBottom = floor($Y2-$Radius);
387
+        $YTop    = floor($Y1+$Radius);
388
+        $YBottom = floor($Y2-$Radius);
389 389
 
390
-     $this->drawFilledRectangle($X1-$XOffset1,$YTop,$X2+$XOffset2,$YBottom,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE));
390
+        $this->drawFilledRectangle($X1-$XOffset1,$YTop,$X2+$XOffset2,$YBottom,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"NoBorder"=>TRUE));
391 391
 
392
-     $Step = 360 / (2 * PI * $Radius);
393
-     $Color  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
394
-     $Color2 = $this->allocateColor($this->Picture,255,0,0,$Alpha);
395
-     $Drawn = "";
392
+        $Step = 360 / (2 * PI * $Radius);
393
+        $Color  = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
394
+        $Color2 = $this->allocateColor($this->Picture,255,0,0,$Alpha);
395
+        $Drawn = "";
396 396
 
397
-     if ( $Alpha < 100 )  { $Drawn[$YTop] = FALSE; }
398
-     if ( $Alpha < 100 )  { $Drawn[$YBottom] = TRUE; }
397
+        if ( $Alpha < 100 )  { $Drawn[$YTop] = FALSE; }
398
+        if ( $Alpha < 100 )  { $Drawn[$YBottom] = TRUE; }
399 399
      
400
-     for($i=0;$i<=90;$i=$i+$Step)
401
-      {
402
-       $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
403
-       $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
404
-       $Yp  = sin(($i+180)*PI/180) * $Radius + $YTop;
400
+        for($i=0;$i<=90;$i=$i+$Step)
401
+        {
402
+        $Xp1 = cos(($i+180)*PI/180) * $Radius + $X1 + $Radius;
403
+        $Xp2 = cos(((90-$i)+270)*PI/180) * $Radius + $X2 - $Radius;
404
+        $Yp  = sin(($i+180)*PI/180) * $Radius + $YTop;
405 405
 
406
-       if ( $this->getFirstDecimal($Xp1) > 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
407
-       if ( $this->getFirstDecimal($Xp2) > 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
408
-       if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
406
+        if ( $this->getFirstDecimal($Xp1) > 5 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
407
+        if ( $this->getFirstDecimal($Xp2) > 5 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
408
+        if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
409 409
 
410
-       if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
410
+        if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
411 411
         imageline($this->Picture,$Xp1+$XOffset1,$Yp+$YOffset,$Xp2+$XOffset2,$Yp+$YOffset,$Color);
412 412
 
413
-       $Drawn[$Yp+$YOffset] = $Xp2;
413
+        $Drawn[$Yp+$YOffset] = $Xp2;
414 414
 
415
-       $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
416
-       $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
417
-       $Yp  = sin(($i+90)*PI/180) * $Radius + $YBottom;
415
+        $Xp1 = cos(($i+90)*PI/180) * $Radius + $X1 + $Radius;
416
+        $Xp2 = cos((90-$i)*PI/180) * $Radius + $X2 - $Radius;
417
+        $Yp  = sin(($i+90)*PI/180) * $Radius + $YBottom;
418 418
 
419
-       if ( $this->getFirstDecimal($Xp1) > 7 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
420
-       if ( $this->getFirstDecimal($Xp2) > 7 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
421
-       if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
419
+        if ( $this->getFirstDecimal($Xp1) > 7 )  { $XOffset1 = 1; } else { $XOffset1 = 0; }
420
+        if ( $this->getFirstDecimal($Xp2) > 7 )  { $XOffset2 = 1; } else { $XOffset2 = 0; }
421
+        if ( $this->getFirstDecimal($Yp) > 5 )  { $YOffset = 1; } else { $YOffset = 0; }
422 422
 
423
-       if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
423
+        if ( !isset($Drawn[$Yp+$YOffset]) || $Alpha == 100 )
424 424
         imageline($this->Picture,$Xp1+$XOffset1,$Yp+$YOffset,$Xp2+$XOffset2,$Yp+$YOffset,$Color);
425 425
 
426
-       $Drawn[$Yp+$YOffset] = $Xp2;
427
-      }
426
+        $Drawn[$Yp+$YOffset] = $Xp2;
427
+        }
428 428
 
429
-     $this->drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
429
+        $this->drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
430 430
 
431
-     $this->Shadow = $RestoreShadow;
431
+        $this->Shadow = $RestoreShadow;
432 432
     }
433 433
 
434
-   /* Draw a rectangle */
435
-   function drawRectangle($X1,$Y1,$X2,$Y2,$Format="")
434
+    /* Draw a rectangle */
435
+    function drawRectangle($X1,$Y1,$X2,$Y2,$Format="")
436 436
     {
437
-     $R		= isset($Format["R"]) ? $Format["R"] : 0;
438
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
439
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
440
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
441
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
442
-     $NoAngle	= isset($Format["NoAngle"]) ? $Format["NoAngle"] : FALSE;
443
-
444
-     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
445
-     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
446
-
447
-     if ( $this->Antialias )
448
-      {
449
-       if ( $NoAngle )
450
-        {
451
-         $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
452
-         $this->drawLine($X2,$Y1+1,$X2,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
453
-         $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
454
-         $this->drawLine($X1,$Y1+1,$X1,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
455
-        }
456
-       else
457
-        {
458
-         $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
459
-         $this->drawLine($X2,$Y1,$X2,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
460
-         $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
461
-         $this->drawLine($X1,$Y1,$X1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
462
-        }
463
-      }
464
-     else
465
-      {
466
-       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
467
-       imagerectangle($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
468
-      }
437
+        $R		= isset($Format["R"]) ? $Format["R"] : 0;
438
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
439
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
440
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
441
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
442
+        $NoAngle	= isset($Format["NoAngle"]) ? $Format["NoAngle"] : FALSE;
443
+
444
+        if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
445
+        if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
446
+
447
+        if ( $this->Antialias )
448
+        {
449
+        if ( $NoAngle )
450
+        {
451
+            $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
452
+            $this->drawLine($X2,$Y1+1,$X2,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
453
+            $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
454
+            $this->drawLine($X1,$Y1+1,$X1,$Y2-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
455
+        }
456
+        else
457
+        {
458
+            $this->drawLine($X1+1,$Y1,$X2-1,$Y1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
459
+            $this->drawLine($X2,$Y1,$X2,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
460
+            $this->drawLine($X2-1,$Y2,$X1+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
461
+            $this->drawLine($X1,$Y1,$X1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
462
+        }
463
+        }
464
+        else
465
+        {
466
+        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
467
+        imagerectangle($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
468
+        }
469 469
     }
470 470
 
471
-   /* Draw a filled rectangle */
472
-   function drawFilledRectangle($X1,$Y1,$X2,$Y2,$Format="")
471
+    /* Draw a filled rectangle */
472
+    function drawFilledRectangle($X1,$Y1,$X2,$Y2,$Format="")
473 473
     {
474
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
475
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
476
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
477
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
478
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
479
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
480
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
481
-     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
482
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
483
-     $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
484
-     $NoAngle		= isset($Format["NoAngle"]) ? $Format["NoAngle"] : NULL;
485
-     $Dash		= isset($Format["Dash"]) ? $Format["Dash"] : FALSE;
486
-     $DashStep		= isset($Format["DashStep"]) ? $Format["DashStep"] : 4;
487
-     $DashR		= isset($Format["DashR"]) ? $Format["DashR"] : 0;
488
-     $DashG		= isset($Format["DashG"]) ? $Format["DashG"] : 0;
489
-     $DashB		= isset($Format["DashB"]) ? $Format["DashB"] : 0;
490
-     $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
491
-
492
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
493
-
494
-     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
495
-     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
496
-
497
-     $RestoreShadow = $this->Shadow;
498
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
499
-      {
500
-       $this->Shadow = FALSE;
501
-       $this->drawFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
502
-      }
503
-
504
-     $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
505
-     if ( $NoAngle )
506
-      {
507
-       imagefilledrectangle($this->Picture,ceil($X1)+1,ceil($Y1),floor($X2)-1,floor($Y2),$Color);
508
-       imageline($this->Picture,ceil($X1),ceil($Y1)+1,ceil($X1),floor($Y2)-1,$Color);
509
-       imageline($this->Picture,floor($X2),ceil($Y1)+1,floor($X2),floor($Y2)-1,$Color);
510
-      }
511
-     else
512
-      imagefilledrectangle($this->Picture,ceil($X1),ceil($Y1),floor($X2),floor($Y2),$Color);
513
-
514
-     if ( $Dash )
515
-      {
516
-       if ( $BorderR != -1 ) { $iX1=$X1+1; $iY1=$Y1+1; $iX2=$X2-1; $iY2=$Y2-1; } else { $iX1=$X1; $iY1=$Y1; $iX2=$X2; $iY2=$Y2; }
517
-
518
-       $Color = $this->allocateColor($this->Picture,$DashR,$DashG,$DashB,$Alpha);
519
-       $Y=$iY1-$DashStep;
520
-       for($X=$iX1; $X<=$iX2+($iY2-$iY1); $X=$X+$DashStep)
521
-        {
522
-         $Y=$Y+$DashStep;
523
-         if ( $X > $iX2 ) { $Xa = $X-($X-$iX2); $Ya = $iY1+($X-$iX2); } else { $Xa = $X; $Ya = $iY1; }
524
-         if ( $Y > $iY2 ) { $Xb = $iX1+($Y-$iY2); $Yb = $Y-($Y-$iY2); } else { $Xb = $iX1; $Yb = $Y; }
525
-         imageline($this->Picture,$Xa,$Ya,$Xb,$Yb,$Color);
526
-        }
527
-      }
528
-
529
-     if ( $this->Antialias && !$NoBorder )
530
-      {
531
-       if ( $X1 < ceil($X1) )
532
-        {
533
-         $AlphaA = $Alpha * (ceil($X1) - $X1);
534
-         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
535
-         imageline($this->Picture,ceil($X1)-1,ceil($Y1),ceil($X1)-1,floor($Y2),$Color);
536
-        }
537
-
538
-       if ( $Y1 < ceil($Y1) )
539
-        {
540
-         $AlphaA = $Alpha * (ceil($Y1) - $Y1);
541
-         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
542
-         imageline($this->Picture,ceil($X1),ceil($Y1)-1,floor($X2),ceil($Y1)-1,$Color);
543
-        }
544
-
545
-       if ( $X2 > floor($X2) )
546
-        {
547
-         $AlphaA = $Alpha * (.5-($X2 - floor($X2)));
548
-         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
549
-         imageline($this->Picture,floor($X2)+1,ceil($Y1),floor($X2)+1,floor($Y2),$Color);
474
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
475
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
476
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
477
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
478
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
479
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
480
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
481
+        $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
482
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
483
+        $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
484
+        $NoAngle		= isset($Format["NoAngle"]) ? $Format["NoAngle"] : NULL;
485
+        $Dash		= isset($Format["Dash"]) ? $Format["Dash"] : FALSE;
486
+        $DashStep		= isset($Format["DashStep"]) ? $Format["DashStep"] : 4;
487
+        $DashR		= isset($Format["DashR"]) ? $Format["DashR"] : 0;
488
+        $DashG		= isset($Format["DashG"]) ? $Format["DashG"] : 0;
489
+        $DashB		= isset($Format["DashB"]) ? $Format["DashB"] : 0;
490
+        $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
491
+
492
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
493
+
494
+        if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
495
+        if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
496
+
497
+        $RestoreShadow = $this->Shadow;
498
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
499
+        {
500
+        $this->Shadow = FALSE;
501
+        $this->drawFilledRectangle($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
502
+        }
503
+
504
+        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
505
+        if ( $NoAngle )
506
+        {
507
+        imagefilledrectangle($this->Picture,ceil($X1)+1,ceil($Y1),floor($X2)-1,floor($Y2),$Color);
508
+        imageline($this->Picture,ceil($X1),ceil($Y1)+1,ceil($X1),floor($Y2)-1,$Color);
509
+        imageline($this->Picture,floor($X2),ceil($Y1)+1,floor($X2),floor($Y2)-1,$Color);
510
+        }
511
+        else
512
+        imagefilledrectangle($this->Picture,ceil($X1),ceil($Y1),floor($X2),floor($Y2),$Color);
513
+
514
+        if ( $Dash )
515
+        {
516
+        if ( $BorderR != -1 ) { $iX1=$X1+1; $iY1=$Y1+1; $iX2=$X2-1; $iY2=$Y2-1; } else { $iX1=$X1; $iY1=$Y1; $iX2=$X2; $iY2=$Y2; }
517
+
518
+        $Color = $this->allocateColor($this->Picture,$DashR,$DashG,$DashB,$Alpha);
519
+        $Y=$iY1-$DashStep;
520
+        for($X=$iX1; $X<=$iX2+($iY2-$iY1); $X=$X+$DashStep)
521
+        {
522
+            $Y=$Y+$DashStep;
523
+            if ( $X > $iX2 ) { $Xa = $X-($X-$iX2); $Ya = $iY1+($X-$iX2); } else { $Xa = $X; $Ya = $iY1; }
524
+            if ( $Y > $iY2 ) { $Xb = $iX1+($Y-$iY2); $Yb = $Y-($Y-$iY2); } else { $Xb = $iX1; $Yb = $Y; }
525
+            imageline($this->Picture,$Xa,$Ya,$Xb,$Yb,$Color);
526
+        }
527
+        }
528
+
529
+        if ( $this->Antialias && !$NoBorder )
530
+        {
531
+        if ( $X1 < ceil($X1) )
532
+        {
533
+            $AlphaA = $Alpha * (ceil($X1) - $X1);
534
+            $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
535
+            imageline($this->Picture,ceil($X1)-1,ceil($Y1),ceil($X1)-1,floor($Y2),$Color);
536
+        }
537
+
538
+        if ( $Y1 < ceil($Y1) )
539
+        {
540
+            $AlphaA = $Alpha * (ceil($Y1) - $Y1);
541
+            $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
542
+            imageline($this->Picture,ceil($X1),ceil($Y1)-1,floor($X2),ceil($Y1)-1,$Color);
543
+        }
544
+
545
+        if ( $X2 > floor($X2) )
546
+        {
547
+            $AlphaA = $Alpha * (.5-($X2 - floor($X2)));
548
+            $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
549
+            imageline($this->Picture,floor($X2)+1,ceil($Y1),floor($X2)+1,floor($Y2),$Color);
550 550
         } 
551 551
 
552
-       if ( $Y2 > floor($Y2) )
552
+        if ( $Y2 > floor($Y2) )
553 553
         {
554
-         $AlphaA = $Alpha * (.5-($Y2 - floor($Y2)));
555
-         $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
556
-         imageline($this->Picture,ceil($X1),floor($Y2)+1,floor($X2),floor($Y2)+1,$Color);
554
+            $AlphaA = $Alpha * (.5-($Y2 - floor($Y2)));
555
+            $Color = $this->allocateColor($this->Picture,$R,$G,$B,$AlphaA);
556
+            imageline($this->Picture,ceil($X1),floor($Y2)+1,floor($X2),floor($Y2)+1,$Color);
557
+        }
557 558
         }
558
-      }
559 559
 
560
-     if ( $BorderR != -1 )
561
-      $this->drawRectangle($X1,$Y1,$X2,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
560
+        if ( $BorderR != -1 )
561
+        $this->drawRectangle($X1,$Y1,$X2,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks,"NoAngle"=>$NoAngle));
562 562
 
563
-     $this->Shadow = $RestoreShadow;
563
+        $this->Shadow = $RestoreShadow;
564 564
     }
565 565
 
566
-   /* Draw a rectangular marker of the specified size */
567
-   function drawRectangleMarker($X,$Y,$Format="")
566
+    /* Draw a rectangular marker of the specified size */
567
+    function drawRectangleMarker($X,$Y,$Format="")
568 568
     {
569
-     $Size = isset($Format["Size"]) ? $Format["Size"] : 4;
569
+        $Size = isset($Format["Size"]) ? $Format["Size"] : 4;
570 570
 
571
-     $HalfSize = floor($Size/2);
572
-     $this->drawFilledRectangle($X-$HalfSize,$Y-$HalfSize,$X+$HalfSize,$Y+$HalfSize,$Format);
571
+        $HalfSize = floor($Size/2);
572
+        $this->drawFilledRectangle($X-$HalfSize,$Y-$HalfSize,$X+$HalfSize,$Y+$HalfSize,$Format);
573 573
     }
574 574
 
575
-   /* Drawn a spline based on the bezier function */
576
-   function drawSpline($Coordinates,$Format="")
575
+    /* Drawn a spline based on the bezier function */
576
+    function drawSpline($Coordinates,$Format="")
577 577
     {
578
-     $R		= isset($Format["R"]) ? $Format["R"] : 0;
579
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
580
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
581
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
582
-     $Force	= isset($Format["Force"]) ? $Format["Force"] : 30;
583
-     $Forces	= isset($Format["Forces"]) ? $Format["Forces"] : NULL;
584
-     $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
585
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
586
-     $PathOnly	= isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
587
-     $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
588
-
589
-     $Cpt = NULL; $Mode = NULL; $Result = "";
590
-     for($i=1;$i<=count($Coordinates)-1;$i++)
591
-      {
592
-       $X1 = $Coordinates[$i-1][0]; $Y1 = $Coordinates[$i-1][1];
593
-       $X2 = $Coordinates[$i][0];   $Y2 = $Coordinates[$i][1];
594
-
595
-       if ( $Forces != NULL ) { $Force = $Forces[$i]; }
596
-
597
-       /* First segment */
598
-       if ( $i == 1 )
578
+        $R		= isset($Format["R"]) ? $Format["R"] : 0;
579
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
580
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
581
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
582
+        $Force	= isset($Format["Force"]) ? $Format["Force"] : 30;
583
+        $Forces	= isset($Format["Forces"]) ? $Format["Forces"] : NULL;
584
+        $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
585
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
586
+        $PathOnly	= isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
587
+        $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
588
+
589
+        $Cpt = NULL; $Mode = NULL; $Result = "";
590
+        for($i=1;$i<=count($Coordinates)-1;$i++)
591
+        {
592
+        $X1 = $Coordinates[$i-1][0]; $Y1 = $Coordinates[$i-1][1];
593
+        $X2 = $Coordinates[$i][0];   $Y2 = $Coordinates[$i][1];
594
+
595
+        if ( $Forces != NULL ) { $Force = $Forces[$i]; }
596
+
597
+        /* First segment */
598
+        if ( $i == 1 )
599 599
         { $Xv1 = $X1; $Yv1 = $Y1; }
600
-       else
600
+        else
601 601
         {
602
-         $Angle1 = $this->getAngle($XLast,$YLast,$X1,$Y1);
603
-         $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
604
-         $XOff = cos($Angle2 * PI / 180) * $Force + $X1;
605
-         $YOff = sin($Angle2 * PI / 180) * $Force + $Y1;
602
+            $Angle1 = $this->getAngle($XLast,$YLast,$X1,$Y1);
603
+            $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
604
+            $XOff = cos($Angle2 * PI / 180) * $Force + $X1;
605
+            $YOff = sin($Angle2 * PI / 180) * $Force + $Y1;
606 606
 
607
-         $Xv1 = cos($Angle1 * PI / 180) * $Force + $XOff;
608
-         $Yv1 = sin($Angle1 * PI / 180) * $Force + $YOff;
607
+            $Xv1 = cos($Angle1 * PI / 180) * $Force + $XOff;
608
+            $Yv1 = sin($Angle1 * PI / 180) * $Force + $YOff;
609 609
         }
610 610
 
611
-       /* Last segment */
612
-       if ( $i == count($Coordinates)-1 )
611
+        /* Last segment */
612
+        if ( $i == count($Coordinates)-1 )
613 613
         { $Xv2 = $X2; $Yv2 = $Y2; }
614
-       else
614
+        else
615 615
         {
616
-         $Angle1 = $this->getAngle($X2,$Y2,$Coordinates[$i+1][0],$Coordinates[$i+1][1]);
617
-         $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
618
-         $XOff = cos(($Angle2+180) * PI / 180) * $Force + $X2;
619
-         $YOff = sin(($Angle2+180) * PI / 180) * $Force + $Y2;
616
+            $Angle1 = $this->getAngle($X2,$Y2,$Coordinates[$i+1][0],$Coordinates[$i+1][1]);
617
+            $Angle2 = $this->getAngle($X1,$Y1,$X2,$Y2);
618
+            $XOff = cos(($Angle2+180) * PI / 180) * $Force + $X2;
619
+            $YOff = sin(($Angle2+180) * PI / 180) * $Force + $Y2;
620 620
 
621
-         $Xv2 = cos(($Angle1+180) * PI / 180) * $Force + $XOff;
622
-         $Yv2 = sin(($Angle1+180) * PI / 180) * $Force + $YOff;
621
+            $Xv2 = cos(($Angle1+180) * PI / 180) * $Force + $XOff;
622
+            $Yv2 = sin(($Angle1+180) * PI / 180) * $Force + $YOff;
623 623
         }
624 624
 
625
-       $Path = $this->drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format);
626
-       if ($PathOnly) { $Result[] = $Path; }
625
+        $Path = $this->drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format);
626
+        if ($PathOnly) { $Result[] = $Path; }
627 627
 
628
-       $XLast = $X1; $YLast = $Y1;
629
-      }
628
+        $XLast = $X1; $YLast = $Y1;
629
+        }
630 630
 
631
-     return($Result);
631
+        return($Result);
632 632
     }
633 633
 
634
-   /* Draw a bezier curve with two controls points */
635
-   function drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format="")
634
+    /* Draw a bezier curve with two controls points */
635
+    function drawBezier($X1,$Y1,$X2,$Y2,$Xv1,$Yv1,$Xv2,$Yv2,$Format="")
636 636
     {
637
-     $R		= isset($Format["R"]) ? $Format["R"] : 0;
638
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
639
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
640
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
641
-     $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
642
-     $Segments	= isset($Format["Segments"]) ? $Format["Segments"] : NULL;
643
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
644
-     $NoDraw    = isset($Format["NoDraw"]) ? $Format["NoDraw"] : FALSE;
645
-     $PathOnly  = isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
646
-     $Weight    = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
647
-     $DrawArrow		= isset($Format["DrawArrow"]) ? $Format["DrawArrow"] : FALSE;
648
-     $ArrowSize		= isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 10;
649
-     $ArrowRatio	= isset($Format["ArrowRatio"]) ? $Format["ArrowRatio"] : .5;
650
-     $ArrowTwoHeads	= isset($Format["ArrowTwoHeads"]) ? $Format["ArrowTwoHeads"] : FALSE;
651
-
652
-     if ( $Segments == NULL )
653
-      {
654
-       $Length    = $this->getLength($X1,$Y1,$X2,$Y2);
655
-       $Precision = ($Length*125)/1000;
656
-      }
657
-     else
658
-      $Precision = $Segments;
637
+        $R		= isset($Format["R"]) ? $Format["R"] : 0;
638
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
639
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
640
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
641
+        $ShowC	= isset($Format["ShowControl"]) ? $Format["ShowControl"] : FALSE;
642
+        $Segments	= isset($Format["Segments"]) ? $Format["Segments"] : NULL;
643
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
644
+        $NoDraw    = isset($Format["NoDraw"]) ? $Format["NoDraw"] : FALSE;
645
+        $PathOnly  = isset($Format["PathOnly"]) ? $Format["PathOnly"] : FALSE;
646
+        $Weight    = isset($Format["Weight"]) ? $Format["Weight"] : NULL;
647
+        $DrawArrow		= isset($Format["DrawArrow"]) ? $Format["DrawArrow"] : FALSE;
648
+        $ArrowSize		= isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 10;
649
+        $ArrowRatio	= isset($Format["ArrowRatio"]) ? $Format["ArrowRatio"] : .5;
650
+        $ArrowTwoHeads	= isset($Format["ArrowTwoHeads"]) ? $Format["ArrowTwoHeads"] : FALSE;
651
+
652
+        if ( $Segments == NULL )
653
+        {
654
+        $Length    = $this->getLength($X1,$Y1,$X2,$Y2);
655
+        $Precision = ($Length*125)/1000;
656
+        }
657
+        else
658
+        $Precision = $Segments;
659 659
 
660
-     $P[0]["X"] = $X1;  $P[0]["Y"] = $Y1;
661
-     $P[1]["X"] = $Xv1; $P[1]["Y"] = $Yv1;
662
-     $P[2]["X"] = $Xv2; $P[2]["Y"] = $Yv2;
663
-     $P[3]["X"] = $X2;  $P[3]["Y"] = $Y2;
660
+        $P[0]["X"] = $X1;  $P[0]["Y"] = $Y1;
661
+        $P[1]["X"] = $Xv1; $P[1]["Y"] = $Yv1;
662
+        $P[2]["X"] = $Xv2; $P[2]["Y"] = $Yv2;
663
+        $P[3]["X"] = $X2;  $P[3]["Y"] = $Y2;
664 664
 
665
-     /* Compute the bezier points */
666
-     $Q = ""; $ID = 0; $Path = "";
667
-     for($i=0;$i<=$Precision;$i=$i+1)
668
-      {
669
-       $u = $i / $Precision;
665
+        /* Compute the bezier points */
666
+        $Q = ""; $ID = 0; $Path = "";
667
+        for($i=0;$i<=$Precision;$i=$i+1)
668
+        {
669
+        $u = $i / $Precision;
670 670
 
671
-       $C    = "";
672
-       $C[0] = (1 - $u) * (1 - $u) * (1 - $u);
673
-       $C[1] = ($u * 3) * (1 - $u) * (1 - $u);
674
-       $C[2] = 3 * $u * $u * (1 - $u);
675
-       $C[3] = $u * $u * $u;
671
+        $C    = "";
672
+        $C[0] = (1 - $u) * (1 - $u) * (1 - $u);
673
+        $C[1] = ($u * 3) * (1 - $u) * (1 - $u);
674
+        $C[2] = 3 * $u * $u * (1 - $u);
675
+        $C[3] = $u * $u * $u;
676 676
 
677
-       for($j=0;$j<=3;$j++)
677
+        for($j=0;$j<=3;$j++)
678 678
         {
679
-         if ( !isset($Q[$ID]) ) { $Q[$ID] = ""; }
680
-         if ( !isset($Q[$ID]["X"]) ) { $Q[$ID]["X"] = 0; }
681
-         if ( !isset($Q[$ID]["Y"]) ) { $Q[$ID]["Y"] = 0; }
679
+            if ( !isset($Q[$ID]) ) { $Q[$ID] = ""; }
680
+            if ( !isset($Q[$ID]["X"]) ) { $Q[$ID]["X"] = 0; }
681
+            if ( !isset($Q[$ID]["Y"]) ) { $Q[$ID]["Y"] = 0; }
682 682
 
683
-         $Q[$ID]["X"] = $Q[$ID]["X"] + $P[$j]["X"] * $C[$j];
684
-         $Q[$ID]["Y"] = $Q[$ID]["Y"] + $P[$j]["Y"] * $C[$j];
683
+            $Q[$ID]["X"] = $Q[$ID]["X"] + $P[$j]["X"] * $C[$j];
684
+            $Q[$ID]["Y"] = $Q[$ID]["Y"] + $P[$j]["Y"] * $C[$j];
685 685
         }
686
-       $ID++;
687
-      }        
688
-     $Q[$ID]["X"] = $X2; $Q[$ID]["Y"] = $Y2;
686
+        $ID++;
687
+        }        
688
+        $Q[$ID]["X"] = $X2; $Q[$ID]["Y"] = $Y2;
689 689
 
690
-     if ( !$NoDraw )
691
-      {
692
-       /* Display the control points */
693
-       if ( $ShowC && !$PathOnly )
690
+        if ( !$NoDraw )
691
+        {
692
+        /* Display the control points */
693
+        if ( $ShowC && !$PathOnly )
694 694
         {
695
-         $Xv1 = floor($Xv1); $Yv1 = floor($Yv1); $Xv2 = floor($Xv2); $Yv2 = floor($Yv2);
695
+            $Xv1 = floor($Xv1); $Yv1 = floor($Yv1); $Xv2 = floor($Xv2); $Yv2 = floor($Yv2);
696 696
 
697
-         $this->drawLine($X1,$Y1,$X2,$Y2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
697
+            $this->drawLine($X1,$Y1,$X2,$Y2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>30));
698 698
 
699
-         $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
700
-         $this->drawRectangleMarker($Xv1,$Yv1,$MyMarkerSettings);
701
-         $this->drawText($Xv1+4,$Yv1,"v1");
702
-         $MyMarkerSettings = array("R"=>0,"G"=>0,"B"=>255,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
703
-         $this->drawRectangleMarker($Xv2,$Yv2,$MyMarkerSettings);
704
-         $this->drawText($Xv2+4,$Yv2,"v2");
699
+            $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
700
+            $this->drawRectangleMarker($Xv1,$Yv1,$MyMarkerSettings);
701
+            $this->drawText($Xv1+4,$Yv1,"v1");
702
+            $MyMarkerSettings = array("R"=>0,"G"=>0,"B"=>255,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
703
+            $this->drawRectangleMarker($Xv2,$Yv2,$MyMarkerSettings);
704
+            $this->drawText($Xv2+4,$Yv2,"v2");
705 705
         }
706 706
 
707
-       /* Draw the bezier */
708
-       $LastX = NULL; $LastY = NULL; $Cpt = NULL; $Mode = NULL; $ArrowS = NULL;
709
-       foreach ($Q as $Key => $Point)
707
+        /* Draw the bezier */
708
+        $LastX = NULL; $LastY = NULL; $Cpt = NULL; $Mode = NULL; $ArrowS = NULL;
709
+        foreach ($Q as $Key => $Point)
710 710
         {
711
-         $X = $Point["X"]; $Y = $Point["Y"];
711
+            $X = $Point["X"]; $Y = $Point["Y"];
712 712
 
713
-         /* Get the first segment */
714
-         if ( $ArrowS == NULL && $LastX != NULL && $LastY != NULL )
715
-          { $ArrowS["X2"] = $LastX; $ArrowS["Y2"] = $LastY; $ArrowS["X1"] = $X; $ArrowS["Y1"] = $Y; }
713
+            /* Get the first segment */
714
+            if ( $ArrowS == NULL && $LastX != NULL && $LastY != NULL )
715
+            { $ArrowS["X2"] = $LastX; $ArrowS["Y2"] = $LastY; $ArrowS["X1"] = $X; $ArrowS["Y1"] = $Y; }
716 716
 
717
-         if ( $LastX != NULL && $LastY != NULL && !$PathOnly)
718
-          list($Cpt,$Mode) = $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Cpt"=>$Cpt,"Mode"=>$Mode,"Weight"=>$Weight));
717
+            if ( $LastX != NULL && $LastY != NULL && !$PathOnly)
718
+            list($Cpt,$Mode) = $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Cpt"=>$Cpt,"Mode"=>$Mode,"Weight"=>$Weight));
719 719
 
720
-         /* Get the last segment */
721
-         $ArrowE["X1"] = $LastX; $ArrowE["Y1"] = $LastY; $ArrowE["X2"] = $X; $ArrowE["Y2"] = $Y;
720
+            /* Get the last segment */
721
+            $ArrowE["X1"] = $LastX; $ArrowE["Y1"] = $LastY; $ArrowE["X2"] = $X; $ArrowE["Y2"] = $Y;
722 722
 
723
-         $LastX = $X; $LastY = $Y;
723
+            $LastX = $X; $LastY = $Y;
724 724
         }
725 725
 
726
-       if ( $DrawArrow && !$PathOnly )
726
+        if ( $DrawArrow && !$PathOnly )
727 727
         {
728
-         $ArrowSettings = array("FillR"=>$R,"FillG"=>$G,"FillB"=>$B,"Alpha"=>$Alpha,"Size"=>$ArrowSize,"Ratio"=>$ArrowRatio);
729
-         if ( $ArrowTwoHeads )
730
-          $this->drawArrow($ArrowS["X1"],$ArrowS["Y1"],$ArrowS["X2"],$ArrowS["Y2"],$ArrowSettings);
728
+            $ArrowSettings = array("FillR"=>$R,"FillG"=>$G,"FillB"=>$B,"Alpha"=>$Alpha,"Size"=>$ArrowSize,"Ratio"=>$ArrowRatio);
729
+            if ( $ArrowTwoHeads )
730
+            $this->drawArrow($ArrowS["X1"],$ArrowS["Y1"],$ArrowS["X2"],$ArrowS["Y2"],$ArrowSettings);
731 731
 
732
-         $this->drawArrow($ArrowE["X1"],$ArrowE["Y1"],$ArrowE["X2"],$ArrowE["Y2"],$ArrowSettings);
732
+            $this->drawArrow($ArrowE["X1"],$ArrowE["Y1"],$ArrowE["X2"],$ArrowE["Y2"],$ArrowSettings);
733 733
         }
734
-      }
735
-     return($Q);
734
+        }
735
+        return($Q);
736 736
     }
737 737
 
738
-   /* Draw a line between two points */
739
-   function drawLine($X1,$Y1,$X2,$Y2,$Format="")
738
+    /* Draw a line between two points */
739
+    function drawLine($X1,$Y1,$X2,$Y2,$Format="")
740 740
     {
741
-     $R		= isset($Format["R"]) ? $Format["R"] : 0;
742
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
743
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
744
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
745
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
746
-     $Cpt	= isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
747
-     $Mode	= isset($Format["Mode"]) ? $Format["Mode"] : 1;
748
-     $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
749
-     $Threshold	= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
750
-
751
-     if ( $this->Antialias == FALSE && $Ticks == NULL )
752
-      {
753
-       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
741
+        $R		= isset($Format["R"]) ? $Format["R"] : 0;
742
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
743
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
744
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
745
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
746
+        $Cpt	= isset($Format["Cpt"]) ? $Format["Cpt"] : 1;
747
+        $Mode	= isset($Format["Mode"]) ? $Format["Mode"] : 1;
748
+        $Weight	= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
749
+        $Threshold	= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
750
+
751
+        if ( $this->Antialias == FALSE && $Ticks == NULL )
754 752
         {
755
-         $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
756
-         imageline($this->Picture,$X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$ShadowColor);
753
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
754
+        {
755
+            $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
756
+            imageline($this->Picture,$X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,$ShadowColor);
757 757
         }
758 758
 
759
-       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
760
-       imageline($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
761
-       return(0);
762
-      }
759
+        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
760
+        imageline($this->Picture,$X1,$Y1,$X2,$Y2,$Color);
761
+        return(0);
762
+        }
763 763
 
764
-     $Distance = sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1));  
765
-     if ( $Distance == 0 ) { return(-1); }
764
+        $Distance = sqrt(($X2-$X1)*($X2-$X1)+($Y2-$Y1)*($Y2-$Y1));  
765
+        if ( $Distance == 0 ) { return(-1); }
766 766
 
767
-     /* Derivative algorithm for overweighted lines, re-route to polygons primitives */
768
-     if ( $Weight != NULL )
769
-      {
770
-       $Angle        = $this->getAngle($X1,$Y1,$X2,$Y2);
771
-       $PolySettings = array ("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderAlpha"=>$Alpha);
767
+        /* Derivative algorithm for overweighted lines, re-route to polygons primitives */
768
+        if ( $Weight != NULL )
769
+        {
770
+        $Angle        = $this->getAngle($X1,$Y1,$X2,$Y2);
771
+        $PolySettings = array ("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderAlpha"=>$Alpha);
772 772
 
773
-       if ( $Ticks == NULL )
773
+        if ( $Ticks == NULL )
774 774
         {
775
-         $Points   = ""; 
776
-         $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y1;
777
-         $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y1;
778
-         $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y2;
779
-         $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y2;
775
+            $Points   = ""; 
776
+            $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y1;
777
+            $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X1; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y1;
778
+            $Points[] = cos(deg2rad($Angle+90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Y2;
779
+            $Points[] = cos(deg2rad($Angle-90)) * $Weight + $X2; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Y2;
780 780
 
781
-         $this->drawPolygon($Points,$PolySettings);
781
+            $this->drawPolygon($Points,$PolySettings);
782 782
         }
783
-       else
783
+        else
784 784
         {
785
-         for($i=0;$i<=$Distance;$i=$i+$Ticks*2)
786
-          {
787
-           $Xa = (($X2-$X1)/$Distance) * $i + $X1; $Ya = (($Y2-$Y1)/$Distance) * $i + $Y1;
788
-           $Xb = (($X2-$X1)/$Distance) * ($i+$Ticks) + $X1; $Yb = (($Y2-$Y1)/$Distance) * ($i+$Ticks) + $Y1;
785
+            for($i=0;$i<=$Distance;$i=$i+$Ticks*2)
786
+            {
787
+            $Xa = (($X2-$X1)/$Distance) * $i + $X1; $Ya = (($Y2-$Y1)/$Distance) * $i + $Y1;
788
+            $Xb = (($X2-$X1)/$Distance) * ($i+$Ticks) + $X1; $Yb = (($Y2-$Y1)/$Distance) * ($i+$Ticks) + $Y1;
789 789
 
790
-           $Points   = ""; 
791
-           $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Ya;
792
-           $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Ya;
793
-           $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Yb;
794
-           $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle-90)) * $Weight 	+ $Yb;
790
+            $Points   = ""; 
791
+            $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle-90)) * $Weight + $Ya;
792
+            $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xa; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Ya;
793
+            $Points[] = cos(deg2rad($Angle+90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle+90)) * $Weight + $Yb;
794
+            $Points[] = cos(deg2rad($Angle-90)) * $Weight + $Xb; $Points[] = sin(deg2rad($Angle-90)) * $Weight 	+ $Yb;
795 795
 
796
-           $this->drawPolygon($Points,$PolySettings);
797
-          }
796
+            $this->drawPolygon($Points,$PolySettings);
797
+            }
798 798
         }
799 799
 
800
-       return(1);
801
-      }
800
+        return(1);
801
+        }
802 802
 
803
-     $XStep = ($X2-$X1) / $Distance;
804
-     $YStep = ($Y2-$Y1) / $Distance;
803
+        $XStep = ($X2-$X1) / $Distance;
804
+        $YStep = ($Y2-$Y1) / $Distance;
805 805
 
806
-     for($i=0;$i<=$Distance;$i++)
807
-      {
808
-       $X = $i * $XStep + $X1;
809
-       $Y = $i * $YStep + $Y1;
806
+        for($i=0;$i<=$Distance;$i++)
807
+        {
808
+        $X = $i * $XStep + $X1;
809
+        $Y = $i * $YStep + $Y1;
810 810
 
811
-       $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
811
+        $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
812 812
 
813
-       if ( $Threshold != NULL )
813
+        if ( $Threshold != NULL )
814 814
         {
815
-         foreach($Threshold as $Key => $Parameters)
816
-          {
817
-           if ( $Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"])
815
+            foreach($Threshold as $Key => $Parameters)
816
+            {
817
+            if ( $Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"])
818 818
             {
819
-             if ( isset($Parameters["R"]) ) { $RT = $Parameters["R"]; } else { $RT = 0; }
820
-             if ( isset($Parameters["G"]) ) { $GT = $Parameters["G"]; } else { $GT = 0; }
821
-             if ( isset($Parameters["B"]) ) { $BT = $Parameters["B"]; } else { $BT = 0; }
822
-             if ( isset($Parameters["Alpha"]) ) { $AlphaT = $Parameters["Alpha"]; } else { $AlphaT = 0; }
823
-             $Color = array("R"=>$RT,"G"=>$GT,"B"=>$BT,"Alpha"=>$AlphaT);
819
+                if ( isset($Parameters["R"]) ) { $RT = $Parameters["R"]; } else { $RT = 0; }
820
+                if ( isset($Parameters["G"]) ) { $GT = $Parameters["G"]; } else { $GT = 0; }
821
+                if ( isset($Parameters["B"]) ) { $BT = $Parameters["B"]; } else { $BT = 0; }
822
+                if ( isset($Parameters["Alpha"]) ) { $AlphaT = $Parameters["Alpha"]; } else { $AlphaT = 0; }
823
+                $Color = array("R"=>$RT,"G"=>$GT,"B"=>$BT,"Alpha"=>$AlphaT);
824
+            }
824 825
             }
825
-          }
826 826
         }
827 827
 
828
-       if ( $Ticks != NULL )
828
+        if ( $Ticks != NULL )
829 829
         {
830
-         if ( $Cpt % $Ticks == 0 )
831
-          { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
830
+            if ( $Cpt % $Ticks == 0 )
831
+            { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
832 832
 
833
-         if ( $Mode == 1 )
834
-          $this->drawAntialiasPixel($X,$Y,$Color);
833
+            if ( $Mode == 1 )
834
+            $this->drawAntialiasPixel($X,$Y,$Color);
835 835
 
836
-         $Cpt++;
836
+            $Cpt++;
837 837
         }
838
-       else
838
+        else
839 839
         $this->drawAntialiasPixel($X,$Y,$Color);
840
-      }
840
+        }
841 841
 
842
-     return(array($Cpt,$Mode));
842
+        return(array($Cpt,$Mode));
843 843
     }
844 844
 
845
-   /* Draw a circle */
846
-   function drawCircle($Xc,$Yc,$Height,$Width,$Format="")
845
+    /* Draw a circle */
846
+    function drawCircle($Xc,$Yc,$Height,$Width,$Format="")
847 847
     {
848
-     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
849
-     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
850
-     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
851
-     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
852
-     $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
848
+        $R	    = isset($Format["R"]) ? $Format["R"] : 0;
849
+        $G	    = isset($Format["G"]) ? $Format["G"] : 0;
850
+        $B	    = isset($Format["B"]) ? $Format["B"] : 0;
851
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
852
+        $Ticks = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
853 853
 
854
-     $Height	= abs($Height);
855
-     $Width	= abs($Width);
854
+        $Height	= abs($Height);
855
+        $Width	= abs($Width);
856 856
 
857
-     if ( $Height == 0 ) { $Height = 1; }
858
-     if ( $Width == 0 )  { $Width = 1; }
859
-     $Xc = floor($Xc); $Yc = floor($Yc);
857
+        if ( $Height == 0 ) { $Height = 1; }
858
+        if ( $Width == 0 )  { $Width = 1; }
859
+        $Xc = floor($Xc); $Yc = floor($Yc);
860 860
 
861
-     $RestoreShadow = $this->Shadow;
862
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
863
-      {
864
-       $this->Shadow = FALSE;
865
-       $this->drawCircle($Xc+$this->ShadowX,$Yc+$this->ShadowY,$Height,$Width,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
866
-      }
861
+        $RestoreShadow = $this->Shadow;
862
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
863
+        {
864
+        $this->Shadow = FALSE;
865
+        $this->drawCircle($Xc+$this->ShadowX,$Yc+$this->ShadowY,$Height,$Width,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
866
+        }
867 867
 
868
-     if ( $Width == 0 ) { $Width = $Height; }
869
-     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
870
-     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
871
-     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
868
+        if ( $Width == 0 ) { $Width = $Height; }
869
+        if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
870
+        if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
871
+        if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
872 872
 
873
-     $Step = 360 / (2 * PI * max($Width,$Height));
874
-     $Mode = 1; $Cpt = 1;
875
-     for($i=0;$i<=360;$i=$i+$Step)
876
-      {
877
-       $X = cos($i*PI/180) * $Height + $Xc;
878
-       $Y = sin($i*PI/180) * $Width + $Yc;
873
+        $Step = 360 / (2 * PI * max($Width,$Height));
874
+        $Mode = 1; $Cpt = 1;
875
+        for($i=0;$i<=360;$i=$i+$Step)
876
+        {
877
+        $X = cos($i*PI/180) * $Height + $Xc;
878
+        $Y = sin($i*PI/180) * $Width + $Yc;
879 879
 
880
-       if ( $Ticks != NULL )
880
+        if ( $Ticks != NULL )
881 881
         {
882
-         if ( $Cpt % $Ticks == 0 )
883
-          { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
882
+            if ( $Cpt % $Ticks == 0 )
883
+            { $Cpt = 0; if ( $Mode == 1 ) { $Mode = 0; } else { $Mode = 1; } }
884 884
 
885
-         if ( $Mode == 1 )
886
-          $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
885
+            if ( $Mode == 1 )
886
+            $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
887 887
 
888
-         $Cpt++;
888
+            $Cpt++;
889 889
         }
890
-       else
890
+        else
891 891
         $this->drawAntialiasPixel($X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
892 892
 
893
-      }
894
-     $this->Shadow = $RestoreShadow;
893
+        }
894
+        $this->Shadow = $RestoreShadow;
895 895
     }
896 896
 
897
-   /* Draw a filled circle */
898
-   function drawFilledCircle($X,$Y,$Radius,$Format="")
897
+    /* Draw a filled circle */
898
+    function drawFilledCircle($X,$Y,$Radius,$Format="")
899 899
     {
900
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
901
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
902
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
903
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
904
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
905
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
906
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
907
-     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
908
-     $Ticks     	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
909
-     $Surrounding 	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
910
-
911
-     if ( $Radius == 0 ) { $Radius = 1; }
912
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
913
-     $X = floor($X); $Y = floor($Y);
914
-
915
-     $Radius = abs($Radius);
916
-
917
-     $RestoreShadow = $this->Shadow;
918
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
919
-      {
920
-       $this->Shadow = FALSE;
921
-       $this->drawFilledCircle($X+$this->ShadowX,$Y+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
922
-      }
923
-
924
-     $this->Mask  = "";
925
-     $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
926
-     for ($i=0; $i<=$Radius*2; $i++)
927
-      {
928
-       $Slice  = sqrt($Radius * $Radius - ($Radius - $i) * ($Radius - $i));
929
-       $XPos   = floor($Slice);
930
-       $YPos   = $Y + $i - $Radius;
931
-       $AAlias = $Slice - floor($Slice);
932
-
933
-       $this->Mask[$X-$XPos][$YPos] = TRUE;
934
-       $this->Mask[$X+$XPos][$YPos] = TRUE;
935
-       imageline($this->Picture,$X-$XPos,$YPos,$X+$XPos,$YPos,$Color);
936
-      }
937
-     if ( $this->Antialias )
938
-      $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
939
-
940
-     $this->Mask = "";
941
-
942
-     if ( $BorderR != -1 )
943
-      $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks));
944
-
945
-     $this->Shadow	= $RestoreShadow;
900
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
901
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
902
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
903
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
904
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
905
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
906
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
907
+        $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha;
908
+        $Ticks     	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
909
+        $Surrounding 	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
910
+
911
+        if ( $Radius == 0 ) { $Radius = 1; }
912
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
913
+        $X = floor($X); $Y = floor($Y);
914
+
915
+        $Radius = abs($Radius);
916
+
917
+        $RestoreShadow = $this->Shadow;
918
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
919
+        {
920
+        $this->Shadow = FALSE;
921
+        $this->drawFilledCircle($X+$this->ShadowX,$Y+$this->ShadowY,$Radius,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Ticks"=>$Ticks));
922
+        }
923
+
924
+        $this->Mask  = "";
925
+        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
926
+        for ($i=0; $i<=$Radius*2; $i++)
927
+        {
928
+        $Slice  = sqrt($Radius * $Radius - ($Radius - $i) * ($Radius - $i));
929
+        $XPos   = floor($Slice);
930
+        $YPos   = $Y + $i - $Radius;
931
+        $AAlias = $Slice - floor($Slice);
932
+
933
+        $this->Mask[$X-$XPos][$YPos] = TRUE;
934
+        $this->Mask[$X+$XPos][$YPos] = TRUE;
935
+        imageline($this->Picture,$X-$XPos,$YPos,$X+$XPos,$YPos,$Color);
936
+        }
937
+        if ( $this->Antialias )
938
+        $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
939
+
940
+        $this->Mask = "";
941
+
942
+        if ( $BorderR != -1 )
943
+        $this->drawCircle($X,$Y,$Radius,$Radius,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$Ticks));
944
+
945
+        $this->Shadow	= $RestoreShadow;
946 946
     }
947 947
 
948
-   /* Write text */
949
-   function drawText($X,$Y,$Text,$Format="")
948
+    /* Write text */
949
+    function drawText($X,$Y,$Text,$Format="")
950 950
     {
951
-     $R			= isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
952
-     $G			= isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
953
-     $B			= isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
954
-     $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
955
-     $Align		= isset($Format["Align"]) ? $Format["Align"] : TEXT_ALIGN_BOTTOMLEFT;
956
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
957
-     $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
958
-     $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
959
-     $ShowOrigine	= isset($Format["ShowOrigine"]) ? $Format["ShowOrigine"] : FALSE;
960
-     $TOffset		= isset($Format["TOffset"]) ? $Format["TOffset"] : 2;
961
-     $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : FALSE;
962
-     $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : TRUE;
963
-     $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 6;
964
-     $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : FALSE;
965
-     $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 6;
966
-     $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 255;
967
-     $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 255;
968
-     $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 255;
969
-     $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
970
-     $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
971
-     $BoxBorderR	= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
972
-     $BoxBorderG	= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
973
-     $BoxBorderB	= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
974
-     $BoxBorderAlpha	= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
975
-     $NoShadow		= isset($Format["NoShadow"]) ? $Format["NoShadow"] : FALSE;
976
-
977
-     $Shadow = $this->Shadow;
978
-     if ( $NoShadow ) { $this->Shadow = FALSE; }
979
-
980
-     if ( $BoxSurrounding != "" ) { $BoxBorderR = $BoxR - $BoxSurrounding; $BoxBorderG = $BoxG - $BoxSurrounding; $BoxBorderB = $BoxB - $BoxSurrounding; $BoxBorderAlpha = $BoxAlpha; }
981
-
982
-     if ( $ShowOrigine )
983
-      {
984
-       $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
985
-       $this->drawRectangleMarker($X,$Y,$MyMarkerSettings);
986
-      }
987
-
988
-     $TxtPos = $this->getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text);
989
-
990
-     if ( $DrawBox && ($Angle == 0 || $Angle == 90 || $Angle == 180 || $Angle == 270))
991
-      {
992
-       $T[0]["X"]=0;$T[0]["Y"]=0;$T[1]["X"]=0;$T[1]["Y"]=0;$T[2]["X"]=0;$T[2]["Y"]=0;$T[3]["X"]=0;$T[3]["Y"]=0;
993
-       if ( $Angle == 0 ) { $T[0]["X"]=-$TOffset;$T[0]["Y"]=$TOffset;$T[1]["X"]=$TOffset;$T[1]["Y"]=$TOffset;$T[2]["X"]=$TOffset;$T[2]["Y"]=-$TOffset;$T[3]["X"]=-$TOffset;$T[3]["Y"]=-$TOffset; }
994
-
995
-       $X1 = min($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) - $BorderOffset + 3;
996
-       $Y1 = min($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) - $BorderOffset;
997
-       $X2 = max($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) + $BorderOffset + 3;
998
-       $Y2 = max($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) + $BorderOffset - 3;
999
-
1000
-       $X1 = $X1 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1001
-       $Y1 = $Y1 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1002
-       $X2 = $X2 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1003
-       $Y2 = $Y2 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1004
-
1005
-       $Settings = array("R"=>$BoxR,"G"=>$BoxG,"B"=>$BoxB,"Alpha"=>$BoxAlpha,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"BorderAlpha"=>$BoxBorderAlpha);
1006
-
1007
-       if ( $BoxRounded )
951
+        $R			= isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
952
+        $G			= isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
953
+        $B			= isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
954
+        $Angle		= isset($Format["Angle"]) ? $Format["Angle"] : 0;
955
+        $Align		= isset($Format["Align"]) ? $Format["Align"] : TEXT_ALIGN_BOTTOMLEFT;
956
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
957
+        $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
958
+        $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
959
+        $ShowOrigine	= isset($Format["ShowOrigine"]) ? $Format["ShowOrigine"] : FALSE;
960
+        $TOffset		= isset($Format["TOffset"]) ? $Format["TOffset"] : 2;
961
+        $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : FALSE;
962
+        $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : TRUE;
963
+        $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 6;
964
+        $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : FALSE;
965
+        $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 6;
966
+        $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 255;
967
+        $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 255;
968
+        $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 255;
969
+        $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
970
+        $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
971
+        $BoxBorderR	= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
972
+        $BoxBorderG	= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
973
+        $BoxBorderB	= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
974
+        $BoxBorderAlpha	= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 50;
975
+        $NoShadow		= isset($Format["NoShadow"]) ? $Format["NoShadow"] : FALSE;
976
+
977
+        $Shadow = $this->Shadow;
978
+        if ( $NoShadow ) { $this->Shadow = FALSE; }
979
+
980
+        if ( $BoxSurrounding != "" ) { $BoxBorderR = $BoxR - $BoxSurrounding; $BoxBorderG = $BoxG - $BoxSurrounding; $BoxBorderB = $BoxB - $BoxSurrounding; $BoxBorderAlpha = $BoxAlpha; }
981
+
982
+        if ( $ShowOrigine )
983
+        {
984
+        $MyMarkerSettings = array("R"=>255,"G"=>0,"B"=>0,"BorderR"=>255,"BorderB"=>255,"BorderG"=>255,"Size"=>4);
985
+        $this->drawRectangleMarker($X,$Y,$MyMarkerSettings);
986
+        }
987
+
988
+        $TxtPos = $this->getTextBox($X,$Y,$FontName,$FontSize,$Angle,$Text);
989
+
990
+        if ( $DrawBox && ($Angle == 0 || $Angle == 90 || $Angle == 180 || $Angle == 270))
991
+        {
992
+        $T[0]["X"]=0;$T[0]["Y"]=0;$T[1]["X"]=0;$T[1]["Y"]=0;$T[2]["X"]=0;$T[2]["Y"]=0;$T[3]["X"]=0;$T[3]["Y"]=0;
993
+        if ( $Angle == 0 ) { $T[0]["X"]=-$TOffset;$T[0]["Y"]=$TOffset;$T[1]["X"]=$TOffset;$T[1]["Y"]=$TOffset;$T[2]["X"]=$TOffset;$T[2]["Y"]=-$TOffset;$T[3]["X"]=-$TOffset;$T[3]["Y"]=-$TOffset; }
994
+
995
+        $X1 = min($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) - $BorderOffset + 3;
996
+        $Y1 = min($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) - $BorderOffset;
997
+        $X2 = max($TxtPos[0]["X"],$TxtPos[1]["X"],$TxtPos[2]["X"],$TxtPos[3]["X"]) + $BorderOffset + 3;
998
+        $Y2 = max($TxtPos[0]["Y"],$TxtPos[1]["Y"],$TxtPos[2]["Y"],$TxtPos[3]["Y"]) + $BorderOffset - 3;
999
+
1000
+        $X1 = $X1 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1001
+        $Y1 = $Y1 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1002
+        $X2 = $X2 - $TxtPos[$Align]["X"] + $X + $T[0]["X"];
1003
+        $Y2 = $Y2 - $TxtPos[$Align]["Y"] + $Y + $T[0]["Y"];
1004
+
1005
+        $Settings = array("R"=>$BoxR,"G"=>$BoxG,"B"=>$BoxB,"Alpha"=>$BoxAlpha,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"BorderAlpha"=>$BoxBorderAlpha);
1006
+
1007
+        if ( $BoxRounded )
1008 1008
         { $this->drawRoundedFilledRectangle($X1,$Y1,$X2,$Y2,$RoundedRadius,$Settings); }
1009
-       else
1009
+        else
1010 1010
         { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Settings); }
1011
-      }
1011
+        }
1012 1012
 
1013
-     $X = $X - $TxtPos[$Align]["X"] + $X;
1014
-     $Y = $Y - $TxtPos[$Align]["Y"] + $Y;
1013
+        $X = $X - $TxtPos[$Align]["X"] + $X;
1014
+        $Y = $Y - $TxtPos[$Align]["Y"] + $Y;
1015 1015
 
1016
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1017
-      {
1018
-       $C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1019
-       imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$Text);
1020
-      }
1016
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1017
+        {
1018
+        $C_ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1019
+        imagettftext($this->Picture,$FontSize,$Angle,$X+$this->ShadowX,$Y+$this->ShadowY,$C_ShadowColor,$FontName,$Text);
1020
+        }
1021 1021
 
1022
-     $C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha);
1023
-     imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$Text);
1022
+        $C_TextColor = $this->AllocateColor($this->Picture,$R,$G,$B,$Alpha);
1023
+        imagettftext($this->Picture,$FontSize,$Angle,$X,$Y,$C_TextColor,$FontName,$Text);
1024 1024
 
1025
-     $this->Shadow = $Shadow;
1025
+        $this->Shadow = $Shadow;
1026 1026
 
1027
-     return($TxtPos);
1027
+        return($TxtPos);
1028 1028
     }
1029 1029
 
1030
-   /* Draw a gradient within a defined area */
1031
-   function drawGradientArea($X1,$Y1,$X2,$Y2,$Direction,$Format="")
1030
+    /* Draw a gradient within a defined area */
1031
+    function drawGradientArea($X1,$Y1,$X2,$Y2,$Direction,$Format="")
1032 1032
     {
1033
-     $StartR	= isset($Format["StartR"]) ? $Format["StartR"] : 90;
1034
-     $StartG	= isset($Format["StartG"]) ? $Format["StartG"] : 90;
1035
-     $StartB	= isset($Format["StartB"]) ? $Format["StartB"] : 90;
1036
-     $EndR	= isset($Format["EndR"]) ? $Format["EndR"] : 0;
1037
-     $EndG	= isset($Format["EndG"]) ? $Format["EndG"] : 0;
1038
-     $EndB	= isset($Format["EndB"]) ? $Format["EndB"] : 0;
1039
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1040
-     $Levels	= isset($Format["Levels"]) ? $Format["Levels"] : NULL;
1041
-
1042
-     $Shadow = $this->Shadow;
1043
-     $this->Shadow = FALSE;
1044
-
1045
-     if ( $StartR == $EndR && $StartG == $EndG && $StartB == $EndB )
1046
-      {
1047
-       $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,array("R"=>$StartR,"G"=>$StartG,"B"=>$StartB,"Alpha"=>$Alpha));
1048
-       return(0);
1049
-      }
1050
-
1051
-     if ( $Levels != NULL )
1052
-      { $EndR=$StartR+$Levels; $EndG=$StartG+$Levels; $EndB=$StartB+$Levels; }
1053
-
1054
-     if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
1055
-     if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
1056
-
1057
-     if ( $Direction == DIRECTION_VERTICAL )   { $Width = abs($Y2-$Y1); }
1058
-     if ( $Direction == DIRECTION_HORIZONTAL ) { $Width = abs($X2-$X1); }
1059
-
1060
-     $Step     = max(abs($EndR-$StartR),abs($EndG-$StartG),abs($EndB-$StartB));
1061
-     $StepSize = $Width/$Step;
1062
-     $RStep    = ($EndR-$StartR)/$Step;
1063
-     $GStep    = ($EndG-$StartG)/$Step;
1064
-     $BStep    = ($EndB-$StartB)/$Step;
1065
-
1066
-     $R=$StartR;$G=$StartG;$B=$StartB;
1067
-     switch($Direction)
1068
-      {
1069
-       case DIRECTION_VERTICAL:
1033
+        $StartR	= isset($Format["StartR"]) ? $Format["StartR"] : 90;
1034
+        $StartG	= isset($Format["StartG"]) ? $Format["StartG"] : 90;
1035
+        $StartB	= isset($Format["StartB"]) ? $Format["StartB"] : 90;
1036
+        $EndR	= isset($Format["EndR"]) ? $Format["EndR"] : 0;
1037
+        $EndG	= isset($Format["EndG"]) ? $Format["EndG"] : 0;
1038
+        $EndB	= isset($Format["EndB"]) ? $Format["EndB"] : 0;
1039
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1040
+        $Levels	= isset($Format["Levels"]) ? $Format["Levels"] : NULL;
1041
+
1042
+        $Shadow = $this->Shadow;
1043
+        $this->Shadow = FALSE;
1044
+
1045
+        if ( $StartR == $EndR && $StartG == $EndG && $StartB == $EndB )
1046
+        {
1047
+        $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,array("R"=>$StartR,"G"=>$StartG,"B"=>$StartB,"Alpha"=>$Alpha));
1048
+        return(0);
1049
+        }
1050
+
1051
+        if ( $Levels != NULL )
1052
+        { $EndR=$StartR+$Levels; $EndG=$StartG+$Levels; $EndB=$StartB+$Levels; }
1053
+
1054
+        if ($X1 > $X2) { list($X1, $X2) = array($X2, $X1); }
1055
+        if ($Y1 > $Y2) { list($Y1, $Y2) = array($Y2, $Y1); }
1056
+
1057
+        if ( $Direction == DIRECTION_VERTICAL )   { $Width = abs($Y2-$Y1); }
1058
+        if ( $Direction == DIRECTION_HORIZONTAL ) { $Width = abs($X2-$X1); }
1059
+
1060
+        $Step     = max(abs($EndR-$StartR),abs($EndG-$StartG),abs($EndB-$StartB));
1061
+        $StepSize = $Width/$Step;
1062
+        $RStep    = ($EndR-$StartR)/$Step;
1063
+        $GStep    = ($EndG-$StartG)/$Step;
1064
+        $BStep    = ($EndB-$StartB)/$Step;
1065
+
1066
+        $R=$StartR;$G=$StartG;$B=$StartB;
1067
+        switch($Direction)
1068
+        {
1069
+        case DIRECTION_VERTICAL:
1070 1070
         $StartY = $Y1; $EndY = floor($Y2)+1; $LastY2 = $StartY;
1071 1071
         for($i=0;$i<=$Step;$i++)
1072
-         {
1073
-          $Y2 = floor($StartY + ($i * $StepSize));
1072
+            {
1073
+            $Y2 = floor($StartY + ($i * $StepSize));
1074 1074
 
1075
-          if ($Y2 > $EndY) { $Y2 = $EndY; }
1076
-          if (($Y1 != $Y2 && $Y1 < $Y2) || $Y2 == $EndY)
1077
-           {
1075
+            if ($Y2 > $EndY) { $Y2 = $EndY; }
1076
+            if (($Y1 != $Y2 && $Y1 < $Y2) || $Y2 == $EndY)
1077
+            {
1078 1078
             $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
1079 1079
             $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color);
1080 1080
             $LastY2 = max($LastY2,$Y2);
1081 1081
             $Y1 = $Y2+1;
1082
-           }
1083
-          $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep;
1084
-         }
1082
+            }
1083
+            $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep;
1084
+            }
1085 1085
         if ( $LastY2 < $EndY && isset($Color)) { for ($i=$LastY2+1;$i<=$EndY;$i++) { $this->drawLine($X1,$i,$X2,$i,$Color); } }
1086 1086
         break;
1087 1087
 
1088
-       case DIRECTION_HORIZONTAL:
1088
+        case DIRECTION_HORIZONTAL:
1089 1089
         $StartX = $X1; $EndX = $X2;
1090 1090
         for($i=0;$i<=$Step;$i++)
1091
-         {
1092
-          $X2 = floor($StartX + ($i * $StepSize));
1091
+            {
1092
+            $X2 = floor($StartX + ($i * $StepSize));
1093 1093
 
1094
-          if ($X2 > $EndX) { $X2 = $EndX; }
1095
-          if (($X1 != $X2 && $X1 < $X2) || $X2 == $EndX)
1096
-           {
1094
+            if ($X2 > $EndX) { $X2 = $EndX; }
1095
+            if (($X1 != $X2 && $X1 < $X2) || $X2 == $EndX)
1096
+            {
1097 1097
             $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
1098 1098
             $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$Color);
1099 1099
             $X1 = $X2+1;
1100
-           }
1101
-          $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep; 
1102
-         }
1100
+            }
1101
+            $R = $R + $RStep; $G = $G + $GStep; $B = $B + $BStep; 
1102
+            }
1103 1103
         if ( $X2 < $EndX && isset($Color)) { $this->drawFilledRectangle($X2,$Y1,$EndX,$Y2,$Color); }
1104 1104
         break;
1105
-      }
1105
+        }
1106 1106
 
1107
-     $this->Shadow = $Shadow;
1107
+        $this->Shadow = $Shadow;
1108 1108
 
1109 1109
     }
1110 1110
 
1111
-   /* Draw an aliased pixel */
1112
-   function drawAntialiasPixel($X,$Y,$Format="")
1111
+    /* Draw an aliased pixel */
1112
+    function drawAntialiasPixel($X,$Y,$Format="")
1113 1113
     {
1114
-     $R     = isset($Format["R"]) ? $Format["R"] : 0;
1115
-     $G     = isset($Format["G"]) ? $Format["G"] : 0;
1116
-     $B     = isset($Format["B"]) ? $Format["B"] : 0;
1117
-     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1114
+        $R     = isset($Format["R"]) ? $Format["R"] : 0;
1115
+        $G     = isset($Format["G"]) ? $Format["G"] : 0;
1116
+        $B     = isset($Format["B"]) ? $Format["B"] : 0;
1117
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1118 1118
 
1119
-     if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1120
-      return(-1);
1119
+        if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1120
+        return(-1);
1121 1121
 
1122
-     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1123
-     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1124
-     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1122
+        if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1123
+        if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1124
+        if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1125 1125
 
1126
-     if ( !$this->Antialias )
1127
-      {
1128
-       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1126
+        if ( !$this->Antialias )
1127
+        {
1128
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1129 1129
         {
1130
-         $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1131
-         imagesetpixel($this->Picture,$X+$this->ShadowX,$Y+$this->ShadowY,$ShadowColor);
1130
+            $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$this->Shadowa);
1131
+            imagesetpixel($this->Picture,$X+$this->ShadowX,$Y+$this->ShadowY,$ShadowColor);
1132 1132
         }
1133 1133
 
1134
-       $PlotColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
1135
-       imagesetpixel($this->Picture,$X,$Y,$PlotColor);
1134
+        $PlotColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
1135
+        imagesetpixel($this->Picture,$X,$Y,$PlotColor);
1136 1136
 
1137
-       return(0);
1138
-      }
1137
+        return(0);
1138
+        }
1139 1139
 
1140
-     $Plot = "";
1141
-     $Xi   = floor($X);
1142
-     $Yi   = floor($Y);
1140
+        $Plot = "";
1141
+        $Xi   = floor($X);
1142
+        $Yi   = floor($Y);
1143 1143
 
1144
-     if ( $Xi == $X && $Yi == $Y)
1145
-      {
1146
-       if ( $Alpha == 100 )
1144
+        if ( $Xi == $X && $Yi == $Y)
1145
+        {
1146
+        if ( $Alpha == 100 )
1147 1147
         $this->drawAlphaPixel($X,$Y,100,$R,$G,$B);
1148
-       else
1148
+        else
1149 1149
         $this->drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B);
1150
-      }
1151
-     else
1152
-      {
1153
-       $Alpha1 = (((1 - ($X - floor($X))) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1154
-       if ( $Alpha1 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi,$Alpha1,$R,$G,$B); }
1150
+        }
1151
+        else
1152
+        {
1153
+        $Alpha1 = (((1 - ($X - floor($X))) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1154
+        if ( $Alpha1 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi,$Alpha1,$R,$G,$B); }
1155 1155
 
1156
-       $Alpha2 = ((($X - floor($X)) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1157
-       if ( $Alpha2 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi,$Alpha2,$R,$G,$B); }
1156
+        $Alpha2 = ((($X - floor($X)) * (1 - ($Y - floor($Y))) * 100) / 100) * $Alpha;
1157
+        if ( $Alpha2 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi,$Alpha2,$R,$G,$B); }
1158 1158
 
1159
-       $Alpha3 = (((1 - ($X - floor($X))) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1160
-       if ( $Alpha3 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi+1,$Alpha3,$R,$G,$B); }
1159
+        $Alpha3 = (((1 - ($X - floor($X))) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1160
+        if ( $Alpha3 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi,$Yi+1,$Alpha3,$R,$G,$B); }
1161 1161
 
1162
-       $Alpha4 = ((($X - floor($X)) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1163
-       if ( $Alpha4 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi+1,$Alpha4,$R,$G,$B); }
1164
-      }
1162
+        $Alpha4 = ((($X - floor($X)) * ($Y - floor($Y)) * 100) / 100) * $Alpha;
1163
+        if ( $Alpha4 > $this->AntialiasQuality ) { $this->drawAlphaPixel($Xi+1,$Yi+1,$Alpha4,$R,$G,$B); }
1164
+        }
1165 1165
     }
1166 1166
 
1167
-   /* Draw a semi-transparent pixel */
1168
-   function drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)
1167
+    /* Draw a semi-transparent pixel */
1168
+    function drawAlphaPixel($X,$Y,$Alpha,$R,$G,$B)
1169 1169
     {
1170
-     if ( isset($this->Mask[$X])) { if ( isset($this->Mask[$X][$Y]) ) { return(0); } }
1170
+        if ( isset($this->Mask[$X])) { if ( isset($this->Mask[$X][$Y]) ) { return(0); } }
1171 1171
 
1172
-     if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1173
-      return(-1);
1172
+        if ( $X < 0 || $Y < 0 || $X >= $this->XSize || $Y >= $this->YSize )
1173
+        return(-1);
1174 1174
 
1175
-     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1176
-     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1177
-     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1175
+        if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1176
+        if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1177
+        if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1178 1178
 
1179
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1180
-      {
1181
-       $AlphaFactor = floor(($Alpha / 100) * $this->Shadowa);
1182
-       $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$AlphaFactor);
1183
-       imagesetpixel($this->Picture,$X+$this->ShadowX,$Y+$this->ShadowY,$ShadowColor);
1184
-      }
1179
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1180
+        {
1181
+        $AlphaFactor = floor(($Alpha / 100) * $this->Shadowa);
1182
+        $ShadowColor = $this->allocateColor($this->Picture,$this->ShadowR,$this->ShadowG,$this->ShadowB,$AlphaFactor);
1183
+        imagesetpixel($this->Picture,$X+$this->ShadowX,$Y+$this->ShadowY,$ShadowColor);
1184
+        }
1185 1185
 
1186
-     $C_Aliased = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
1187
-     imagesetpixel($this->Picture,$X,$Y,$C_Aliased);
1186
+        $C_Aliased = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
1187
+        imagesetpixel($this->Picture,$X,$Y,$C_Aliased);
1188 1188
     }
1189 1189
 
1190
-   /* Convert apha to base 10 */
1191
-   function convertAlpha($AlphaValue)
1190
+    /* Convert apha to base 10 */
1191
+    function convertAlpha($AlphaValue)
1192 1192
     { return((127/100)*(100-$AlphaValue)); }
1193 1193
 
1194
-   /* Allocate a color with transparency */
1195
-   function allocateColor($Picture,$R,$G,$B,$Alpha=100)
1194
+    /* Allocate a color with transparency */
1195
+    function allocateColor($Picture,$R,$G,$B,$Alpha=100)
1196 1196
     {
1197
-     if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1198
-     if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1199
-     if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1200
-     if ( $Alpha < 0 )  { $Alpha = 0; }
1201
-     if ( $Alpha > 100) { $Alpha = 100; }
1202
-
1203
-     $Alpha = $this->convertAlpha($Alpha);
1204
-     return(imagecolorallocatealpha($Picture,$R,$G,$B,$Alpha));
1197
+        if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
1198
+        if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
1199
+        if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
1200
+        if ( $Alpha < 0 )  { $Alpha = 0; }
1201
+        if ( $Alpha > 100) { $Alpha = 100; }
1202
+
1203
+        $Alpha = $this->convertAlpha($Alpha);
1204
+        return(imagecolorallocatealpha($Picture,$R,$G,$B,$Alpha));
1205 1205
     }
1206 1206
 
1207
-   /* Load a PNG file and draw it over the chart */
1208
-   function drawFromPNG($X,$Y,$FileName)
1207
+    /* Load a PNG file and draw it over the chart */
1208
+    function drawFromPNG($X,$Y,$FileName)
1209 1209
     { $this->drawFromPicture(1,$FileName,$X,$Y); }
1210 1210
 
1211
-   /* Load a GIF file and draw it over the chart */
1212
-   function drawFromGIF($X,$Y,$FileName)
1211
+    /* Load a GIF file and draw it over the chart */
1212
+    function drawFromGIF($X,$Y,$FileName)
1213 1213
     { $this->drawFromPicture(2,$FileName,$X,$Y); }
1214 1214
 
1215
-   /* Load a JPEG file and draw it over the chart */
1216
-   function drawFromJPG($X,$Y,$FileName)
1215
+    /* Load a JPEG file and draw it over the chart */
1216
+    function drawFromJPG($X,$Y,$FileName)
1217 1217
     { $this->drawFromPicture(3,$FileName,$X,$Y); }
1218 1218
 
1219
-   function getPicInfo($FileName)
1219
+    function getPicInfo($FileName)
1220 1220
     {
1221
-     $Infos  = getimagesize($FileName);
1222
-     $Width  = $Infos[0];
1223
-     $Height = $Infos[1];
1224
-     $Type   = $Infos["mime"];
1221
+        $Infos  = getimagesize($FileName);
1222
+        $Width  = $Infos[0];
1223
+        $Height = $Infos[1];
1224
+        $Type   = $Infos["mime"];
1225 1225
 
1226
-     if ( $Type == "image/png") { $Type = 1; }
1227
-     if ( $Type == "image/gif") { $Type = 2; }
1228
-     if ( $Type == "image/jpeg ") { $Type = 3; }
1226
+        if ( $Type == "image/png") { $Type = 1; }
1227
+        if ( $Type == "image/gif") { $Type = 2; }
1228
+        if ( $Type == "image/jpeg ") { $Type = 3; }
1229 1229
 
1230
-     return(array($Width,$Height,$Type));
1230
+        return(array($Width,$Height,$Type));
1231 1231
     }
1232 1232
 
1233
-   /* Generic loader function for external pictures */
1234
-   function drawFromPicture($PicType,$FileName,$X,$Y)
1233
+    /* Generic loader function for external pictures */
1234
+    function drawFromPicture($PicType,$FileName,$X,$Y)
1235 1235
     {
1236
-     if ( file_exists($FileName))
1237
-      {
1238
-       list($Width,$Height) = $this->getPicInfo($FileName);
1236
+        if ( file_exists($FileName))
1237
+        {
1238
+        list($Width,$Height) = $this->getPicInfo($FileName);
1239 1239
 
1240
-       if ( $PicType == 1 )
1240
+        if ( $PicType == 1 )
1241 1241
         { $Raster = imagecreatefrompng($FileName); }
1242
-       elseif ( $PicType == 2 )
1242
+        elseif ( $PicType == 2 )
1243 1243
         { $Raster = imagecreatefromgif($FileName); }
1244
-       elseif ( $PicType == 3 )
1244
+        elseif ( $PicType == 3 )
1245 1245
         { $Raster = imagecreatefromjpeg($FileName); }
1246
-       else
1246
+        else
1247 1247
         { return(0); }
1248 1248
 
1249 1249
 
1250
-       $RestoreShadow = $this->Shadow;
1251
-       if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1250
+        $RestoreShadow = $this->Shadow;
1251
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1252 1252
         {
1253
-         $this->Shadow = FALSE;
1254
-         if ( $PicType == 3 )
1255
-          $this->drawFilledRectangle($X+$this->ShadowX,$Y+$this->ShadowY,$X+$Width+$this->ShadowX,$Y+$Height+$this->ShadowY,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
1256
-         else
1257
-          {
1258
-           $TranparentID = imagecolortransparent($Raster);
1259
-           for ($Xc=0;$Xc<=$Width-1;$Xc++)
1253
+            $this->Shadow = FALSE;
1254
+            if ( $PicType == 3 )
1255
+            $this->drawFilledRectangle($X+$this->ShadowX,$Y+$this->ShadowY,$X+$Width+$this->ShadowX,$Y+$Height+$this->ShadowY,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
1256
+            else
1260 1257
             {
1261
-             for ($Yc=0;$Yc<=$Height-1;$Yc++)
1262
-              {
1263
-               $RGBa   = imagecolorat($Raster,$Xc,$Yc);
1264
-               $Values = imagecolorsforindex($Raster,$RGBa);
1265
-               if ( $Values["alpha"] < 120 )
1258
+            $TranparentID = imagecolortransparent($Raster);
1259
+            for ($Xc=0;$Xc<=$Width-1;$Xc++)
1260
+            {
1261
+                for ($Yc=0;$Yc<=$Height-1;$Yc++)
1262
+                {
1263
+                $RGBa   = imagecolorat($Raster,$Xc,$Yc);
1264
+                $Values = imagecolorsforindex($Raster,$RGBa);
1265
+                if ( $Values["alpha"] < 120 )
1266 1266
                 {
1267
-                 $AlphaFactor = floor(($this->Shadowa / 100) * ((100 / 127) * (127-$Values["alpha"])));
1268
-                 $this->drawAlphaPixel($X+$Xc+$this->ShadowX,$Y+$Yc+$this->ShadowY,$AlphaFactor,$this->ShadowR,$this->ShadowG,$this->ShadowB);
1267
+                    $AlphaFactor = floor(($this->Shadowa / 100) * ((100 / 127) * (127-$Values["alpha"])));
1268
+                    $this->drawAlphaPixel($X+$Xc+$this->ShadowX,$Y+$Yc+$this->ShadowY,$AlphaFactor,$this->ShadowR,$this->ShadowG,$this->ShadowB);
1269 1269
                 }
1270
-              }
1270
+                }
1271
+            }
1271 1272
             }
1272
-          }
1273 1273
         }
1274
-       $this->Shadow = $RestoreShadow;
1274
+        $this->Shadow = $RestoreShadow;
1275 1275
 
1276
-       imagecopy($this->Picture,$Raster,$X,$Y,0,0,$Width,$Height);
1277
-       imagedestroy($Raster);
1278
-      }
1276
+        imagecopy($this->Picture,$Raster,$X,$Y,0,0,$Width,$Height);
1277
+        imagedestroy($Raster);
1278
+        }
1279 1279
     }
1280 1280
 
1281
-   /* Draw an arrow */
1282
-   function drawArrow($X1,$Y1,$X2,$Y2,$Format="")
1281
+    /* Draw an arrow */
1282
+    function drawArrow($X1,$Y1,$X2,$Y2,$Format="")
1283 1283
     {
1284
-     $FillR	= isset($Format["FillR"]) ? $Format["FillR"] : 0;
1285
-     $FillG	= isset($Format["FillG"]) ? $Format["FillG"] : 0;
1286
-     $FillB	= isset($Format["FillB"]) ? $Format["FillB"] : 0;
1287
-     $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : $FillR;
1288
-     $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : $FillG;
1289
-     $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : $FillB;
1290
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1291
-     $Size	= isset($Format["Size"]) ? $Format["Size"] : 10;
1292
-     $Ratio	= isset($Format["Ratio"]) ? $Format["Ratio"] : .5;
1293
-     $TwoHeads	= isset($Format["TwoHeads"]) ? $Format["TwoHeads"] : FALSE;
1294
-     $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : FALSE;
1295
-
1296
-     /* Calculate the line angle */
1297
-     $Angle = $this->getAngle($X1,$Y1,$X2,$Y2);
1298
-
1299
-     /* Override Shadow support, this will be managed internally */
1300
-     $RestoreShadow = $this->Shadow;
1301
-     if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1302
-      {
1303
-       $this->Shadow = FALSE;
1304
-       $this->drawArrow($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,array("FillR"=>$this->ShadowR,"FillG"=>$this->ShadowG,"FillB"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Size"=>$Size,"Ratio"=>$Ratio,"TwoHeads"=>$TwoHeads,"Ticks"=>$Ticks));
1305
-      }
1306
-
1307
-     /* Draw the 1st Head */
1308
-     $TailX = cos(($Angle-180)*PI/180)*$Size+$X2;
1309
-     $TailY = sin(($Angle-180)*PI/180)*$Size+$Y2;
1310
-
1311
-     $Points	= "";
1312
-     $Points[]  = $X2; $Points[]  = $Y2;
1313
-     $Points[]	= cos(($Angle-90)*PI/180)*$Size*$Ratio+$TailX; $Points[] = sin(($Angle-90)*PI/180)*$Size*$Ratio+$TailY;
1314
-     $Points[]	= cos(($Angle-270)*PI/180)*$Size*$Ratio+$TailX; $Points[] = sin(($Angle-270)*PI/180)*$Size*$Ratio+$TailY;
1315
-     $Points[]  = $X2; $Points[]  = $Y2;
1316
-
1317
-     /* Visual correction */
1318
-     if ($Angle == 180 || $Angle == 360 ) { $Points[4] = $Points[2]; }
1319
-     if ($Angle == 90 || $Angle == 270 ) { $Points[5] = $Points[3]; }
1320
-
1321
-     $ArrowColor = $this->allocateColor($this->Picture,$FillR,$FillG,$FillB,$Alpha);
1322
-     ImageFilledPolygon($this->Picture,$Points,4,$ArrowColor);
1323
-
1324
-     $this->drawLine($Points[0],$Points[1],$Points[2],$Points[3],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1325
-     $this->drawLine($Points[2],$Points[3],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1326
-     $this->drawLine($Points[0],$Points[1],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1327
-
1328
-     /* Draw the second head */
1329
-     if ( $TwoHeads )
1330
-      {
1331
-       $Angle = $this->getAngle($X2,$Y2,$X1,$Y1);
1332
-
1333
-       $TailX2 = cos(($Angle-180)*PI/180)*$Size+$X1;
1334
-       $TailY2 = sin(($Angle-180)*PI/180)*$Size+$Y1;
1335
-
1336
-       $Points   = "";
1337
-       $Points[] = $X1; $Points[]  = $Y1;
1338
-       $Points[] = cos(($Angle-90)*PI/180)*$Size*$Ratio+$TailX2; $Points[] = sin(($Angle-90)*PI/180)*$Size*$Ratio+$TailY2;
1339
-       $Points[] = cos(($Angle-270)*PI/180)*$Size*$Ratio+$TailX2; $Points[] = sin(($Angle-270)*PI/180)*$Size*$Ratio+$TailY2;
1340
-       $Points[] = $X1; $Points[]  = $Y1;
1341
-
1342
-       /* Visual correction */
1343
-       if ($Angle == 180 || $Angle == 360 ) { $Points[4] = $Points[2]; }
1344
-       if ($Angle == 90 || $Angle == 270 ) { $Points[5] = $Points[3]; }
1345
-
1346
-       $ArrowColor = $this->allocateColor($this->Picture,$FillR,$FillG,$FillB,$Alpha);
1347
-       ImageFilledPolygon($this->Picture,$Points,4,$ArrowColor);
1348
-
1349
-       $this->drawLine($Points[0],$Points[1],$Points[2],$Points[3],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1350
-       $this->drawLine($Points[2],$Points[3],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1351
-       $this->drawLine($Points[0],$Points[1],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1352
-
1353
-       $this->drawLine($TailX,$TailY,$TailX2,$TailY2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1354
-      }
1355
-     else
1356
-      $this->drawLine($X1,$Y1,$TailX,$TailY,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1357
-
1358
-     /* Re-enable shadows */
1359
-     $this->Shadow = $RestoreShadow;
1284
+        $FillR	= isset($Format["FillR"]) ? $Format["FillR"] : 0;
1285
+        $FillG	= isset($Format["FillG"]) ? $Format["FillG"] : 0;
1286
+        $FillB	= isset($Format["FillB"]) ? $Format["FillB"] : 0;
1287
+        $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : $FillR;
1288
+        $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : $FillG;
1289
+        $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : $FillB;
1290
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1291
+        $Size	= isset($Format["Size"]) ? $Format["Size"] : 10;
1292
+        $Ratio	= isset($Format["Ratio"]) ? $Format["Ratio"] : .5;
1293
+        $TwoHeads	= isset($Format["TwoHeads"]) ? $Format["TwoHeads"] : FALSE;
1294
+        $Ticks	= isset($Format["Ticks"]) ? $Format["Ticks"] : FALSE;
1295
+
1296
+        /* Calculate the line angle */
1297
+        $Angle = $this->getAngle($X1,$Y1,$X2,$Y2);
1298
+
1299
+        /* Override Shadow support, this will be managed internally */
1300
+        $RestoreShadow = $this->Shadow;
1301
+        if ( $this->Shadow && $this->ShadowX != 0 && $this->ShadowY != 0 )
1302
+        {
1303
+        $this->Shadow = FALSE;
1304
+        $this->drawArrow($X1+$this->ShadowX,$Y1+$this->ShadowY,$X2+$this->ShadowX,$Y2+$this->ShadowY,array("FillR"=>$this->ShadowR,"FillG"=>$this->ShadowG,"FillB"=>$this->ShadowB,"Alpha"=>$this->Shadowa,"Size"=>$Size,"Ratio"=>$Ratio,"TwoHeads"=>$TwoHeads,"Ticks"=>$Ticks));
1305
+        }
1306
+
1307
+        /* Draw the 1st Head */
1308
+        $TailX = cos(($Angle-180)*PI/180)*$Size+$X2;
1309
+        $TailY = sin(($Angle-180)*PI/180)*$Size+$Y2;
1310
+
1311
+        $Points	= "";
1312
+        $Points[]  = $X2; $Points[]  = $Y2;
1313
+        $Points[]	= cos(($Angle-90)*PI/180)*$Size*$Ratio+$TailX; $Points[] = sin(($Angle-90)*PI/180)*$Size*$Ratio+$TailY;
1314
+        $Points[]	= cos(($Angle-270)*PI/180)*$Size*$Ratio+$TailX; $Points[] = sin(($Angle-270)*PI/180)*$Size*$Ratio+$TailY;
1315
+        $Points[]  = $X2; $Points[]  = $Y2;
1316
+
1317
+        /* Visual correction */
1318
+        if ($Angle == 180 || $Angle == 360 ) { $Points[4] = $Points[2]; }
1319
+        if ($Angle == 90 || $Angle == 270 ) { $Points[5] = $Points[3]; }
1320
+
1321
+        $ArrowColor = $this->allocateColor($this->Picture,$FillR,$FillG,$FillB,$Alpha);
1322
+        ImageFilledPolygon($this->Picture,$Points,4,$ArrowColor);
1323
+
1324
+        $this->drawLine($Points[0],$Points[1],$Points[2],$Points[3],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1325
+        $this->drawLine($Points[2],$Points[3],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1326
+        $this->drawLine($Points[0],$Points[1],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1327
+
1328
+        /* Draw the second head */
1329
+        if ( $TwoHeads )
1330
+        {
1331
+        $Angle = $this->getAngle($X2,$Y2,$X1,$Y1);
1332
+
1333
+        $TailX2 = cos(($Angle-180)*PI/180)*$Size+$X1;
1334
+        $TailY2 = sin(($Angle-180)*PI/180)*$Size+$Y1;
1335
+
1336
+        $Points   = "";
1337
+        $Points[] = $X1; $Points[]  = $Y1;
1338
+        $Points[] = cos(($Angle-90)*PI/180)*$Size*$Ratio+$TailX2; $Points[] = sin(($Angle-90)*PI/180)*$Size*$Ratio+$TailY2;
1339
+        $Points[] = cos(($Angle-270)*PI/180)*$Size*$Ratio+$TailX2; $Points[] = sin(($Angle-270)*PI/180)*$Size*$Ratio+$TailY2;
1340
+        $Points[] = $X1; $Points[]  = $Y1;
1341
+
1342
+        /* Visual correction */
1343
+        if ($Angle == 180 || $Angle == 360 ) { $Points[4] = $Points[2]; }
1344
+        if ($Angle == 90 || $Angle == 270 ) { $Points[5] = $Points[3]; }
1345
+
1346
+        $ArrowColor = $this->allocateColor($this->Picture,$FillR,$FillG,$FillB,$Alpha);
1347
+        ImageFilledPolygon($this->Picture,$Points,4,$ArrowColor);
1348
+
1349
+        $this->drawLine($Points[0],$Points[1],$Points[2],$Points[3],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1350
+        $this->drawLine($Points[2],$Points[3],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1351
+        $this->drawLine($Points[0],$Points[1],$Points[4],$Points[5],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1352
+
1353
+        $this->drawLine($TailX,$TailY,$TailX2,$TailY2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1354
+        }
1355
+        else
1356
+        $this->drawLine($X1,$Y1,$TailX,$TailY,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1357
+
1358
+        /* Re-enable shadows */
1359
+        $this->Shadow = $RestoreShadow;
1360 1360
     }
1361 1361
 
1362
-   /* Draw a label with associated arrow */
1363
-   function drawArrowLabel($X1,$Y1,$Text,$Format="")
1362
+    /* Draw a label with associated arrow */
1363
+    function drawArrowLabel($X1,$Y1,$Text,$Format="")
1364 1364
     {
1365
-     $FillR    = isset($Format["FillR"]) ? $Format["FillR"] : 0;
1366
-     $FillG    = isset($Format["FillG"]) ? $Format["FillG"] : 0;
1367
-     $FillB    = isset($Format["FillB"]) ? $Format["FillB"] : 0;
1368
-     $BorderR  = isset($Format["BorderR"]) ? $Format["BorderR"] : $FillR;
1369
-     $BorderG  = isset($Format["BorderG"]) ? $Format["BorderG"] : $FillG;
1370
-     $BorderB  = isset($Format["BorderB"]) ? $Format["BorderB"] : $FillB;
1371
-     $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1372
-     $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1373
-     $Alpha    = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1374
-     $Length   = isset($Format["Length"]) ? $Format["Length"] : 50;
1375
-     $Angle    = isset($Format["Angle"]) ? $Format["Angle"] : 315;
1376
-     $Size     = isset($Format["Size"]) ? $Format["Size"] : 10;
1377
-     $Position = isset($Format["Position"]) ? $Format["Position"] : POSITION_TOP;
1378
-     $RoundPos = isset($Format["RoundPos"]) ? $Format["RoundPos"] : FALSE;
1379
-     $Ticks    = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
1380
-
1381
-     $Angle = $Angle % 360;
1382
-
1383
-     $X2 = sin(($Angle+180)*PI/180)*$Length+$X1;
1384
-     $Y2 = cos(($Angle+180)*PI/180)*$Length+$Y1;
1385
-
1386
-     if ( $RoundPos && $Angle > 0 && $Angle < 180 ) { $Y2 = ceil($Y2); }
1387
-     if ( $RoundPos && $Angle > 180 ) { $Y2 = floor($Y2); }
1388
-
1389
-     $this->drawArrow($X2,$Y2,$X1,$Y1,$Format);
1390
-
1391
-     $Size	= imagettfbbox($FontSize,0,$FontName,$Text);
1392
-     $TxtWidth	= max(abs($Size[2]-$Size[0]),abs($Size[0]-$Size[6]));
1393
-     $TxtHeight	= max(abs($Size[1]-$Size[7]),abs($Size[3]-$Size[1]));
1394
-
1395
-     if ( $Angle > 0 && $Angle < 180 )
1396
-      {
1397
-       $this->drawLine($X2,$Y2,$X2-$TxtWidth,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1398
-       if ( $Position == POSITION_TOP )
1365
+        $FillR    = isset($Format["FillR"]) ? $Format["FillR"] : 0;
1366
+        $FillG    = isset($Format["FillG"]) ? $Format["FillG"] : 0;
1367
+        $FillB    = isset($Format["FillB"]) ? $Format["FillB"] : 0;
1368
+        $BorderR  = isset($Format["BorderR"]) ? $Format["BorderR"] : $FillR;
1369
+        $BorderG  = isset($Format["BorderG"]) ? $Format["BorderG"] : $FillG;
1370
+        $BorderB  = isset($Format["BorderB"]) ? $Format["BorderB"] : $FillB;
1371
+        $FontName = isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1372
+        $FontSize = isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1373
+        $Alpha    = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1374
+        $Length   = isset($Format["Length"]) ? $Format["Length"] : 50;
1375
+        $Angle    = isset($Format["Angle"]) ? $Format["Angle"] : 315;
1376
+        $Size     = isset($Format["Size"]) ? $Format["Size"] : 10;
1377
+        $Position = isset($Format["Position"]) ? $Format["Position"] : POSITION_TOP;
1378
+        $RoundPos = isset($Format["RoundPos"]) ? $Format["RoundPos"] : FALSE;
1379
+        $Ticks    = isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
1380
+
1381
+        $Angle = $Angle % 360;
1382
+
1383
+        $X2 = sin(($Angle+180)*PI/180)*$Length+$X1;
1384
+        $Y2 = cos(($Angle+180)*PI/180)*$Length+$Y1;
1385
+
1386
+        if ( $RoundPos && $Angle > 0 && $Angle < 180 ) { $Y2 = ceil($Y2); }
1387
+        if ( $RoundPos && $Angle > 180 ) { $Y2 = floor($Y2); }
1388
+
1389
+        $this->drawArrow($X2,$Y2,$X1,$Y1,$Format);
1390
+
1391
+        $Size	= imagettfbbox($FontSize,0,$FontName,$Text);
1392
+        $TxtWidth	= max(abs($Size[2]-$Size[0]),abs($Size[0]-$Size[6]));
1393
+        $TxtHeight	= max(abs($Size[1]-$Size[7]),abs($Size[3]-$Size[1]));
1394
+
1395
+        if ( $Angle > 0 && $Angle < 180 )
1396
+        {
1397
+        $this->drawLine($X2,$Y2,$X2-$TxtWidth,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1398
+        if ( $Position == POSITION_TOP )
1399 1399
         $this->drawText($X2,$Y2-2,$Text,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Align"=>TEXT_ALIGN_BOTTOMRIGHT));
1400
-       else
1400
+        else
1401 1401
         $this->drawText($X2,$Y2+4,$Text,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Align"=>TEXT_ALIGN_TOPRIGHT));
1402
-      }
1403
-     else
1404
-      {
1405
-       $this->drawLine($X2,$Y2,$X2+$TxtWidth,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1406
-       if ( $Position == POSITION_TOP )
1402
+        }
1403
+        else
1404
+        {
1405
+        $this->drawLine($X2,$Y2,$X2+$TxtWidth,$Y2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
1406
+        if ( $Position == POSITION_TOP )
1407 1407
         $this->drawText($X2,$Y2-2,$Text,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha));
1408
-       else
1408
+        else
1409 1409
         $this->drawText($X2,$Y2+4,$Text,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$Alpha,"Align"=>TEXT_ALIGN_TOPLEFT));
1410
-      }
1410
+        }
1411 1411
     }
1412 1412
 
1413
-   /* Draw a progress bar filled with specified % */
1414
-   function drawProgress($X,$Y,$Percent,$Format="")
1413
+    /* Draw a progress bar filled with specified % */
1414
+    function drawProgress($X,$Y,$Percent,$Format="")
1415 1415
     {
1416
-     if ( $Percent > 100 ) { $Percent = 100; }
1417
-     if ( $Percent < 0 ) { $Percent = 0; }
1418
-
1419
-     $Width	= isset($Format["Width"]) ? $Format["Width"] : 200;
1420
-     $Height	= isset($Format["Height"]) ? $Format["Height"] : 20;
1421
-     $Orientation = isset($Format["Orientation"]) ? $Format["Orientation"] : ORIENTATION_HORIZONTAL;
1422
-     $ShowLabel = isset($Format["ShowLabel"]) ? $Format["ShowLabel"] : FALSE;
1423
-     $LabelPos	= isset($Format["LabelPos"]) ? $Format["LabelPos"] : LABEL_POS_INSIDE;
1424
-     $Margin    = isset($Format["Margin"]) ? $Format["Margin"] : 10;
1425
-     $R		= isset($Format["R"]) ? $Format["R"] : 130;
1426
-     $G		= isset($Format["G"]) ? $Format["G"] : 130;
1427
-     $B		= isset($Format["B"]) ? $Format["B"] : 130;
1428
-     $RFade	= isset($Format["RFade"]) ? $Format["RFade"] : -1;
1429
-     $GFade	= isset($Format["GFade"]) ? $Format["GFade"] : -1;
1430
-     $BFade	= isset($Format["BFade"]) ? $Format["BFade"] : -1;
1431
-     $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
1432
-     $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
1433
-     $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
1434
-     $BoxBorderR = isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 0;
1435
-     $BoxBorderG = isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 0;
1436
-     $BoxBorderB = isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 0;
1437
-     $BoxBackR	= isset($Format["BoxBackR"]) ? $Format["BoxBackR"] : 255;
1438
-     $BoxBackG	= isset($Format["BoxBackG"]) ? $Format["BoxBackG"] : 255;
1439
-     $BoxBackB	= isset($Format["BoxBackB"]) ? $Format["BoxBackB"] : 255;
1440
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1441
-     $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
1442
-     $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : NULL;
1443
-     $NoAngle	= isset($Format["NoAngle"]) ? $Format["NoAngle"] : FALSE;
1444
-
1445
-     if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1446
-      {
1447
-       $RFade = (($RFade-$R)/100)*$Percent+$R;
1448
-       $GFade = (($GFade-$G)/100)*$Percent+$G;
1449
-       $BFade = (($BFade-$B)/100)*$Percent+$B;
1450
-      }
1451
-
1452
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
1453
-     if ( $BoxSurrounding != NULL ) { $BoxBorderR = $BoxBackR + $Surrounding; $BoxBorderG = $BoxBackG + $Surrounding; $BoxBorderB = $BoxBackB + $Surrounding; }
1454
-
1455
-     if ( $Orientation == ORIENTATION_VERTICAL )
1456
-      {
1457
-       $InnerHeight = (($Height-2)/100)*$Percent;
1458
-       $this->drawFilledRectangle($X,$Y,$X+$Width,$Y-$Height,array("R"=>$BoxBackR,"G"=>$BoxBackG,"B"=>$BoxBackB,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"NoAngle"=>$NoAngle));
1459
-
1460
-       $RestoreShadow = $this->Shadow; $this->Shadow  = FALSE;
1461
-       if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1462
-        {
1463
-         $GradientOptions = array("StartR"=>$RFade,"StartG"=>$GFade,"StartB"=>$BFade,"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
1464
-         $this->drawGradientArea($X+1,$Y-1,$X+$Width-1,$Y-$InnerHeight,DIRECTION_VERTICAL,$GradientOptions);
1465
-
1466
-         if ( $Surrounding )
1467
-          $this->drawRectangle($X+1,$Y-1,$X+$Width-1,$Y-$InnerHeight,array("R"=>255,"G"=>255,"B"=>255,"Alpha"=>$Surrounding));
1468
-        }
1469
-       else
1416
+        if ( $Percent > 100 ) { $Percent = 100; }
1417
+        if ( $Percent < 0 ) { $Percent = 0; }
1418
+
1419
+        $Width	= isset($Format["Width"]) ? $Format["Width"] : 200;
1420
+        $Height	= isset($Format["Height"]) ? $Format["Height"] : 20;
1421
+        $Orientation = isset($Format["Orientation"]) ? $Format["Orientation"] : ORIENTATION_HORIZONTAL;
1422
+        $ShowLabel = isset($Format["ShowLabel"]) ? $Format["ShowLabel"] : FALSE;
1423
+        $LabelPos	= isset($Format["LabelPos"]) ? $Format["LabelPos"] : LABEL_POS_INSIDE;
1424
+        $Margin    = isset($Format["Margin"]) ? $Format["Margin"] : 10;
1425
+        $R		= isset($Format["R"]) ? $Format["R"] : 130;
1426
+        $G		= isset($Format["G"]) ? $Format["G"] : 130;
1427
+        $B		= isset($Format["B"]) ? $Format["B"] : 130;
1428
+        $RFade	= isset($Format["RFade"]) ? $Format["RFade"] : -1;
1429
+        $GFade	= isset($Format["GFade"]) ? $Format["GFade"] : -1;
1430
+        $BFade	= isset($Format["BFade"]) ? $Format["BFade"] : -1;
1431
+        $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
1432
+        $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
1433
+        $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
1434
+        $BoxBorderR = isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 0;
1435
+        $BoxBorderG = isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 0;
1436
+        $BoxBorderB = isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 0;
1437
+        $BoxBackR	= isset($Format["BoxBackR"]) ? $Format["BoxBackR"] : 255;
1438
+        $BoxBackG	= isset($Format["BoxBackG"]) ? $Format["BoxBackG"] : 255;
1439
+        $BoxBackB	= isset($Format["BoxBackB"]) ? $Format["BoxBackB"] : 255;
1440
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1441
+        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
1442
+        $BoxSurrounding = isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : NULL;
1443
+        $NoAngle	= isset($Format["NoAngle"]) ? $Format["NoAngle"] : FALSE;
1444
+
1445
+        if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1446
+        {
1447
+        $RFade = (($RFade-$R)/100)*$Percent+$R;
1448
+        $GFade = (($GFade-$G)/100)*$Percent+$G;
1449
+        $BFade = (($BFade-$B)/100)*$Percent+$B;
1450
+        }
1451
+
1452
+        if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
1453
+        if ( $BoxSurrounding != NULL ) { $BoxBorderR = $BoxBackR + $Surrounding; $BoxBorderG = $BoxBackG + $Surrounding; $BoxBorderB = $BoxBackB + $Surrounding; }
1454
+
1455
+        if ( $Orientation == ORIENTATION_VERTICAL )
1456
+        {
1457
+        $InnerHeight = (($Height-2)/100)*$Percent;
1458
+        $this->drawFilledRectangle($X,$Y,$X+$Width,$Y-$Height,array("R"=>$BoxBackR,"G"=>$BoxBackG,"B"=>$BoxBackB,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"NoAngle"=>$NoAngle));
1459
+
1460
+        $RestoreShadow = $this->Shadow; $this->Shadow  = FALSE;
1461
+        if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1462
+        {
1463
+            $GradientOptions = array("StartR"=>$RFade,"StartG"=>$GFade,"StartB"=>$BFade,"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
1464
+            $this->drawGradientArea($X+1,$Y-1,$X+$Width-1,$Y-$InnerHeight,DIRECTION_VERTICAL,$GradientOptions);
1465
+
1466
+            if ( $Surrounding )
1467
+            $this->drawRectangle($X+1,$Y-1,$X+$Width-1,$Y-$InnerHeight,array("R"=>255,"G"=>255,"B"=>255,"Alpha"=>$Surrounding));
1468
+        }
1469
+        else
1470 1470
         $this->drawFilledRectangle($X+1,$Y-1,$X+$Width-1,$Y-$InnerHeight,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1471 1471
 
1472
-       $this->Shadow = $RestoreShadow;
1472
+        $this->Shadow = $RestoreShadow;
1473 1473
 
1474
-       if ( $ShowLabel && $LabelPos == LABEL_POS_BOTTOM )	{ $this->drawText($X+($Width/2),$Y+$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_TOPMIDDLE)); }
1475
-       if ( $ShowLabel && $LabelPos == LABEL_POS_TOP )		{ $this->drawText($X+($Width/2),$Y-$Height-$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
1476
-       if ( $ShowLabel && $LabelPos == LABEL_POS_INSIDE )	{ $this->drawText($X+($Width/2),$Y-$InnerHeight-$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT,"Angle"=>90)); }
1477
-       if ( $ShowLabel && $LabelPos == LABEL_POS_CENTER )	{ $this->drawText($X+($Width/2),$Y-($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"Angle"=>90)); }
1478
-      }
1479
-     else
1480
-      {
1481
-       if ( $Percent == 100 )
1474
+        if ( $ShowLabel && $LabelPos == LABEL_POS_BOTTOM )	{ $this->drawText($X+($Width/2),$Y+$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_TOPMIDDLE)); }
1475
+        if ( $ShowLabel && $LabelPos == LABEL_POS_TOP )		{ $this->drawText($X+($Width/2),$Y-$Height-$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
1476
+        if ( $ShowLabel && $LabelPos == LABEL_POS_INSIDE )	{ $this->drawText($X+($Width/2),$Y-$InnerHeight-$Margin,$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT,"Angle"=>90)); }
1477
+        if ( $ShowLabel && $LabelPos == LABEL_POS_CENTER )	{ $this->drawText($X+($Width/2),$Y-($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"Angle"=>90)); }
1478
+        }
1479
+        else
1480
+        {
1481
+        if ( $Percent == 100 )
1482 1482
         $InnerWidth = $Width-1;
1483
-       else
1483
+        else
1484 1484
         $InnerWidth = (($Width-2)/100)*$Percent;
1485 1485
 
1486
-       $this->drawFilledRectangle($X,$Y,$X+$Width,$Y+$Height,array("R"=>$BoxBackR,"G"=>$BoxBackG,"B"=>$BoxBackB,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"NoAngle"=>$NoAngle));
1486
+        $this->drawFilledRectangle($X,$Y,$X+$Width,$Y+$Height,array("R"=>$BoxBackR,"G"=>$BoxBackG,"B"=>$BoxBackB,"BorderR"=>$BoxBorderR,"BorderG"=>$BoxBorderG,"BorderB"=>$BoxBorderB,"NoAngle"=>$NoAngle));
1487 1487
 
1488
-       $RestoreShadow = $this->Shadow; $this->Shadow  = FALSE;
1489
-       if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1488
+        $RestoreShadow = $this->Shadow; $this->Shadow  = FALSE;
1489
+        if ( $RFade != -1 && $GFade != -1 && $BFade != -1 )
1490 1490
         {
1491
-         $GradientOptions = array("StartR"=>$R,"StartG"=>$G,"StartB"=>$B,"EndR"=>$RFade,"EndG"=>$GFade,"EndB"=>$BFade);
1492
-         $this->drawGradientArea($X+1,$Y+1,$X+$InnerWidth,$Y+$Height-1,DIRECTION_HORIZONTAL,$GradientOptions);
1491
+            $GradientOptions = array("StartR"=>$R,"StartG"=>$G,"StartB"=>$B,"EndR"=>$RFade,"EndG"=>$GFade,"EndB"=>$BFade);
1492
+            $this->drawGradientArea($X+1,$Y+1,$X+$InnerWidth,$Y+$Height-1,DIRECTION_HORIZONTAL,$GradientOptions);
1493 1493
 
1494
-         if ( $Surrounding )
1495
-          $this->drawRectangle($X+1,$Y+1,$X+$InnerWidth,$Y+$Height-1,array("R"=>255,"G"=>255,"B"=>255,"Alpha"=>$Surrounding));
1494
+            if ( $Surrounding )
1495
+            $this->drawRectangle($X+1,$Y+1,$X+$InnerWidth,$Y+$Height-1,array("R"=>255,"G"=>255,"B"=>255,"Alpha"=>$Surrounding));
1496 1496
         }
1497
-       else
1497
+        else
1498 1498
         $this->drawFilledRectangle($X+1,$Y+1,$X+$InnerWidth,$Y+$Height-1,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1499 1499
  
1500
-       $this->Shadow = $RestoreShadow;
1500
+        $this->Shadow = $RestoreShadow;
1501 1501
 
1502
-       if ( $ShowLabel && $LabelPos == LABEL_POS_LEFT )		{ $this->drawText($X-$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); }
1503
-       if ( $ShowLabel && $LabelPos == LABEL_POS_RIGHT )	{ $this->drawText($X+$Width+$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
1504
-       if ( $ShowLabel && $LabelPos == LABEL_POS_CENTER )	{ $this->drawText($X+($Width/2),$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE)); }
1505
-       if ( $ShowLabel && $LabelPos == LABEL_POS_INSIDE )	{ $this->drawText($X+$InnerWidth+$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
1506
-      }
1502
+        if ( $ShowLabel && $LabelPos == LABEL_POS_LEFT )		{ $this->drawText($X-$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLERIGHT)); }
1503
+        if ( $ShowLabel && $LabelPos == LABEL_POS_RIGHT )	{ $this->drawText($X+$Width+$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
1504
+        if ( $ShowLabel && $LabelPos == LABEL_POS_CENTER )	{ $this->drawText($X+($Width/2),$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLEMIDDLE)); }
1505
+        if ( $ShowLabel && $LabelPos == LABEL_POS_INSIDE )	{ $this->drawText($X+$InnerWidth+$Margin,$Y+($Height/2),$Percent."%",array("Align"=>TEXT_ALIGN_MIDDLELEFT)); }
1506
+        }
1507 1507
     }
1508 1508
 
1509
-   /* Get the legend box size */
1510
-   function getLegendSize($Format="")
1509
+    /* Get the legend box size */
1510
+    function getLegendSize($Format="")
1511 1511
     {
1512
-     $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1513
-     $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1514
-     $BoxSize		= isset($Format["BoxSize"]) ? $Format["BoxSize"] : 5;
1515
-     $Margin		= isset($Format["Margin"]) ? $Format["Margin"] : 5;
1516
-     $Style		= isset($Format["Style"]) ? $Format["Style"] : LEGEND_ROUND;
1517
-     $Mode		= isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;
1518
-     $BoxWidth		= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 5;
1519
-     $BoxHeight		= isset($Format["BoxHeight"]) ? $Format["BoxHeight"] : 5;
1520
-     $IconAreaWidth	= isset($Format["IconAreaWidth"]) ? $Format["IconAreaWidth"] : $BoxWidth;
1521
-     $IconAreaHeight	= isset($Format["IconAreaHeight"]) ? $Format["IconAreaHeight"] : $BoxHeight;
1522
-     $XSpacing		= isset($Format["XSpacing"]) ? $Format["XSpacing"] : 5;
1523
-
1524
-     $Data = $this->DataSet->getData();
1525
-
1526
-     foreach($Data["Series"] as $SerieName => $Serie)
1527
-      {
1528
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && isset($Serie["Picture"]))
1512
+        $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1513
+        $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1514
+        $BoxSize		= isset($Format["BoxSize"]) ? $Format["BoxSize"] : 5;
1515
+        $Margin		= isset($Format["Margin"]) ? $Format["Margin"] : 5;
1516
+        $Style		= isset($Format["Style"]) ? $Format["Style"] : LEGEND_ROUND;
1517
+        $Mode		= isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;
1518
+        $BoxWidth		= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 5;
1519
+        $BoxHeight		= isset($Format["BoxHeight"]) ? $Format["BoxHeight"] : 5;
1520
+        $IconAreaWidth	= isset($Format["IconAreaWidth"]) ? $Format["IconAreaWidth"] : $BoxWidth;
1521
+        $IconAreaHeight	= isset($Format["IconAreaHeight"]) ? $Format["IconAreaHeight"] : $BoxHeight;
1522
+        $XSpacing		= isset($Format["XSpacing"]) ? $Format["XSpacing"] : 5;
1523
+
1524
+        $Data = $this->DataSet->getData();
1525
+
1526
+        foreach($Data["Series"] as $SerieName => $Serie)
1529 1527
         {
1530
-         list($PicWidth,$PicHeight) = $this->getPicInfo($Serie["Picture"]);
1531
-         if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; }
1532
-         if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; }
1528
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && isset($Serie["Picture"]))
1529
+        {
1530
+            list($PicWidth,$PicHeight) = $this->getPicInfo($Serie["Picture"]);
1531
+            if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; }
1532
+            if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; }
1533
+        }
1533 1534
         }
1534
-      }
1535 1535
 
1536
-     $YStep = max($this->FontSize,$IconAreaHeight) + 5;
1537
-     $XStep = $IconAreaWidth + 5;
1538
-     $XStep = $XSpacing;
1536
+        $YStep = max($this->FontSize,$IconAreaHeight) + 5;
1537
+        $XStep = $IconAreaWidth + 5;
1538
+        $XStep = $XSpacing;
1539 1539
 
1540
-     $X=100; $Y=100;
1540
+        $X=100; $Y=100;
1541 1541
 
1542
-     $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X;
1543
-     foreach($Data["Series"] as $SerieName => $Serie)
1544
-      {
1545
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1542
+        $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X;
1543
+        foreach($Data["Series"] as $SerieName => $Serie)
1546 1544
         {
1547
-         if ( $Mode == LEGEND_VERTICAL )
1548
-          {
1549
-           $BoxArray = $this->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Serie["Description"]);
1545
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1546
+        {
1547
+            if ( $Mode == LEGEND_VERTICAL )
1548
+            {
1549
+            $BoxArray = $this->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Serie["Description"]);
1550 1550
 
1551
-           if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1552
-           if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1553
-           if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1551
+            if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1552
+            if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1553
+            if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1554 1554
 
1555
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1556
-           $vY = $vY + max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1557
-          }
1558
-         elseif ( $Mode == LEGEND_HORIZONTAL )
1559
-          {
1560
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1561
-           $Width = "";
1562
-           foreach($Lines as $Key => $Value)
1555
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1556
+            $vY = $vY + max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1557
+            }
1558
+            elseif ( $Mode == LEGEND_HORIZONTAL )
1559
+            {
1560
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1561
+            $Width = "";
1562
+            foreach($Lines as $Key => $Value)
1563 1563
             {
1564
-             $BoxArray = $this->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$FontName,$FontSize,0,$Value);
1564
+                $BoxArray = $this->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$FontName,$FontSize,0,$Value);
1565 1565
 
1566
-             if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1567
-             if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1568
-             if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1566
+                if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1567
+                if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1568
+                if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1569 1569
 
1570
-             $Width[] = $BoxArray[1]["X"];
1570
+                $Width[] = $BoxArray[1]["X"];
1571 1571
             }
1572 1572
 
1573
-           $vX=max($Width)+$XStep;
1574
-          }
1573
+            $vX=max($Width)+$XStep;
1574
+            }
1575
+        }
1575 1576
         }
1576
-      }
1577
-     $vY=$vY-$YStep; $vX=$vX-$XStep;
1577
+        $vY=$vY-$YStep; $vX=$vX-$XStep;
1578 1578
 
1579
-     $TopOffset  = $Y - $Boundaries["T"];
1580
-     if ( $Boundaries["B"]-($vY+$IconAreaHeight) < $TopOffset ) { $Boundaries["B"] = $vY+$IconAreaHeight+$TopOffset; }
1579
+        $TopOffset  = $Y - $Boundaries["T"];
1580
+        if ( $Boundaries["B"]-($vY+$IconAreaHeight) < $TopOffset ) { $Boundaries["B"] = $vY+$IconAreaHeight+$TopOffset; }
1581 1581
 
1582
-     $Width  = ($Boundaries["R"]+$Margin) - ($Boundaries["L"]-$Margin);
1583
-     $Height = ($Boundaries["B"]+$Margin) - ($Boundaries["T"]-$Margin);
1582
+        $Width  = ($Boundaries["R"]+$Margin) - ($Boundaries["L"]-$Margin);
1583
+        $Height = ($Boundaries["B"]+$Margin) - ($Boundaries["T"]-$Margin);
1584 1584
 
1585
-     return(array("Width"=>$Width,"Height"=>$Height));
1585
+        return(array("Width"=>$Width,"Height"=>$Height));
1586 1586
     }
1587 1587
 
1588
-   /* Draw the legend of the active series */
1589
-   function drawLegend($X,$Y,$Format="")
1588
+    /* Draw the legend of the active series */
1589
+    function drawLegend($X,$Y,$Format="")
1590 1590
     {
1591
-     $Family	= isset($Format["Family"]) ? $Format["Family"] : LEGEND_FAMILY_BOX;
1592
-     $FontName	= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1593
-     $FontSize	= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1594
-     $FontR	= isset($Format["FontR"]) ? $Format["FontR"] : $this->FontColorR;
1595
-     $FontG	= isset($Format["FontG"]) ? $Format["FontG"] : $this->FontColorG;
1596
-     $FontB	= isset($Format["FontB"]) ? $Format["FontB"] : $this->FontColorB;
1597
-     $BoxWidth	= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 5;
1598
-     $BoxHeight	= isset($Format["BoxHeight"]) ? $Format["BoxHeight"] : 5;
1599
-     $IconAreaWidth	= isset($Format["IconAreaWidth"]) ? $Format["IconAreaWidth"] : $BoxWidth;
1600
-     $IconAreaHeight	= isset($Format["IconAreaHeight"]) ? $Format["IconAreaHeight"] : $BoxHeight;
1601
-     $XSpacing	= isset($Format["XSpacing"]) ? $Format["XSpacing"] : 5;
1602
-     $Margin	= isset($Format["Margin"]) ? $Format["Margin"] : 5;
1603
-     $R		= isset($Format["R"]) ? $Format["R"] : 200;
1604
-     $G		= isset($Format["G"]) ? $Format["G"] : 200;
1605
-     $B		= isset($Format["B"]) ? $Format["B"] : 200;
1606
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1607
-     $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : 255;
1608
-     $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : 255;
1609
-     $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : 255;
1610
-     $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
1611
-     $Style	= isset($Format["Style"]) ? $Format["Style"] : LEGEND_ROUND;
1612
-     $Mode	= isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;
1613
-
1614
-     if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
1615
-
1616
-     $Data = $this->DataSet->getData();
1617
-
1618
-     foreach($Data["Series"] as $SerieName => $Serie)
1619
-      {
1620
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && isset($Serie["Picture"]))
1621
-        {
1622
-         list($PicWidth,$PicHeight) = $this->getPicInfo($Serie["Picture"]);
1623
-         if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; }
1624
-         if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; }
1625
-        }
1626
-      }
1627
-
1628
-     $YStep = max($this->FontSize,$IconAreaHeight) + 5;
1629
-     $XStep = $IconAreaWidth + 5;
1630
-     $XStep = $XSpacing;
1631
-
1632
-     $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X;
1633
-     foreach($Data["Series"] as $SerieName => $Serie)
1634
-      {
1635
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1636
-        {
1637
-         if ( $Mode == LEGEND_VERTICAL )
1638
-          {
1639
-           $BoxArray = $this->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Serie["Description"]);
1640
-
1641
-           if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1642
-           if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1643
-           if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1644
-
1645
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1646
-           $vY = $vY + max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1647
-          }
1648
-         elseif ( $Mode == LEGEND_HORIZONTAL )
1649
-          {
1650
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1651
-           $Width = "";
1652
-           foreach($Lines as $Key => $Value)
1653
-            {
1654
-             $BoxArray = $this->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$FontName,$FontSize,0,$Value);
1655
-
1656
-             if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1657
-             if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1658
-             if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1659
-
1660
-             $Width[] = $BoxArray[1]["X"];
1661
-            }
1662
-
1663
-           $vX=max($Width)+$XStep;
1664
-          }
1665
-        }
1666
-      }
1667
-     $vY=$vY-$YStep; $vX=$vX-$XStep;
1668
-
1669
-     $TopOffset  = $Y - $Boundaries["T"];
1670
-     if ( $Boundaries["B"]-($vY+$IconAreaHeight) < $TopOffset ) { $Boundaries["B"] = $vY+$IconAreaHeight+$TopOffset; }
1671
-
1672
-     if ( $Style == LEGEND_ROUND )
1673
-      $this->drawRoundedFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1674
-     elseif ( $Style == LEGEND_BOX )
1675
-      $this->drawFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1676
-
1677
-     $RestoreShadow = $this->Shadow; $this->Shadow = FALSE;
1678
-     foreach($Data["Series"] as $SerieName => $Serie)
1679
-      {
1680
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1681
-        {
1682
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"];
1683
-         $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
1684
-
1685
-         if ( isset($Serie["Picture"]) )
1686
-          {
1687
-           $Picture = $Serie["Picture"];
1688
-           list($PicWidth,$PicHeight) = $this->getPicInfo($Picture);
1689
-           $PicX = $X+$IconAreaWidth/2; $PicY = $Y+$IconAreaHeight/2; 
1690
-
1691
-           $this->drawFromPNG($PicX-$PicWidth/2,$PicY-$PicHeight/2,$Picture);
1692
-          }
1693
-         else
1694
-          {
1695
-           if ( $Family == LEGEND_FAMILY_BOX )
1591
+        $Family	= isset($Format["Family"]) ? $Format["Family"] : LEGEND_FAMILY_BOX;
1592
+        $FontName	= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
1593
+        $FontSize	= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
1594
+        $FontR	= isset($Format["FontR"]) ? $Format["FontR"] : $this->FontColorR;
1595
+        $FontG	= isset($Format["FontG"]) ? $Format["FontG"] : $this->FontColorG;
1596
+        $FontB	= isset($Format["FontB"]) ? $Format["FontB"] : $this->FontColorB;
1597
+        $BoxWidth	= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 5;
1598
+        $BoxHeight	= isset($Format["BoxHeight"]) ? $Format["BoxHeight"] : 5;
1599
+        $IconAreaWidth	= isset($Format["IconAreaWidth"]) ? $Format["IconAreaWidth"] : $BoxWidth;
1600
+        $IconAreaHeight	= isset($Format["IconAreaHeight"]) ? $Format["IconAreaHeight"] : $BoxHeight;
1601
+        $XSpacing	= isset($Format["XSpacing"]) ? $Format["XSpacing"] : 5;
1602
+        $Margin	= isset($Format["Margin"]) ? $Format["Margin"] : 5;
1603
+        $R		= isset($Format["R"]) ? $Format["R"] : 200;
1604
+        $G		= isset($Format["G"]) ? $Format["G"] : 200;
1605
+        $B		= isset($Format["B"]) ? $Format["B"] : 200;
1606
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
1607
+        $BorderR	= isset($Format["BorderR"]) ? $Format["BorderR"] : 255;
1608
+        $BorderG	= isset($Format["BorderG"]) ? $Format["BorderG"] : 255;
1609
+        $BorderB	= isset($Format["BorderB"]) ? $Format["BorderB"] : 255;
1610
+        $Surrounding = isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
1611
+        $Style	= isset($Format["Style"]) ? $Format["Style"] : LEGEND_ROUND;
1612
+        $Mode	= isset($Format["Mode"]) ? $Format["Mode"] : LEGEND_VERTICAL;
1613
+
1614
+        if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
1615
+
1616
+        $Data = $this->DataSet->getData();
1617
+
1618
+        foreach($Data["Series"] as $SerieName => $Serie)
1619
+        {
1620
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && isset($Serie["Picture"]))
1621
+        {
1622
+            list($PicWidth,$PicHeight) = $this->getPicInfo($Serie["Picture"]);
1623
+            if ( $IconAreaWidth < $PicWidth ) { $IconAreaWidth = $PicWidth; }
1624
+            if ( $IconAreaHeight < $PicHeight ) { $IconAreaHeight = $PicHeight; }
1625
+        }
1626
+        }
1627
+
1628
+        $YStep = max($this->FontSize,$IconAreaHeight) + 5;
1629
+        $XStep = $IconAreaWidth + 5;
1630
+        $XStep = $XSpacing;
1631
+
1632
+        $Boundaries = ""; $Boundaries["L"] = $X; $Boundaries["T"] = $Y; $Boundaries["R"] = 0; $Boundaries["B"] = 0; $vY = $Y; $vX = $X;
1633
+        foreach($Data["Series"] as $SerieName => $Serie)
1634
+        {
1635
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1636
+        {
1637
+            if ( $Mode == LEGEND_VERTICAL )
1696 1638
             {
1697
-             if ( $BoxWidth != $IconAreaWidth ) { $XOffset = floor(($IconAreaWidth-$BoxWidth)/2); } else { $XOffset = 0; }
1698
-             if ( $BoxHeight != $IconAreaHeight ) { $YOffset = floor(($IconAreaHeight-$BoxHeight)/2); } else { $YOffset = 0; }
1639
+            $BoxArray = $this->getTextBox($vX+$IconAreaWidth+4,$vY+$IconAreaHeight/2,$FontName,$FontSize,0,$Serie["Description"]);
1699 1640
 
1700
-             $this->drawFilledRectangle($X+1+$XOffset,$Y+1+$YOffset,$X+$BoxWidth+$XOffset+1,$Y+$BoxHeight+1+$YOffset,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
1701
-             $this->drawFilledRectangle($X+$XOffset,$Y+$YOffset,$X+$BoxWidth+$XOffset,$Y+$BoxHeight+$YOffset,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
1641
+            if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1642
+            if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1643
+            if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1644
+
1645
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1646
+            $vY = $vY + max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1702 1647
             }
1703
-           elseif ( $Family == LEGEND_FAMILY_CIRCLE )
1648
+            elseif ( $Mode == LEGEND_HORIZONTAL )
1704 1649
             {
1705
-             $this->drawFilledCircle($X+1+$IconAreaWidth/2,$Y+1+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
1706
-             $this->drawFilledCircle($X+$IconAreaWidth/2,$Y+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
1707
-            }
1708
-           elseif ( $Family == LEGEND_FAMILY_LINE )
1650
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1651
+            $Width = "";
1652
+            foreach($Lines as $Key => $Value)
1709 1653
             {
1710
-             $this->drawLine($X+1,$Y+1+$IconAreaHeight/2,$X+1+$IconAreaWidth,$Y+1+$IconAreaHeight/2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20,"Ticks"=>$Ticks,"Weight"=>$Weight));
1711
-             $this->drawLine($X,$Y+$IconAreaHeight/2,$X+$IconAreaWidth,$Y+$IconAreaHeight/2,array("R"=>$R,"G"=>$G,"B"=>$B,"Ticks"=>$Ticks,"Weight"=>$Weight));
1712
-            }
1713
-          }
1654
+                $BoxArray = $this->getTextBox($vX+$IconAreaWidth+6,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$FontName,$FontSize,0,$Value);
1714 1655
 
1715
-         if ( $Mode == LEGEND_VERTICAL )
1716
-          {
1717
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1718
-           foreach($Lines as $Key => $Value)
1719
-            $this->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontSize"=>$FontSize,"FontName"=>$FontName));
1656
+                if ( $Boundaries["T"] > $BoxArray[2]["Y"]+$IconAreaHeight/2 ) { $Boundaries["T"] = $BoxArray[2]["Y"]+$IconAreaHeight/2; }
1657
+                if ( $Boundaries["R"] < $BoxArray[1]["X"]+2 ) { $Boundaries["R"] = $BoxArray[1]["X"]+2; }
1658
+                if ( $Boundaries["B"] < $BoxArray[1]["Y"]+2+$IconAreaHeight/2 ) { $Boundaries["B"] = $BoxArray[1]["Y"]+2+$IconAreaHeight/2; }
1720 1659
 
1721
-           $Y=$Y+max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1722
-          }
1723
-         elseif ( $Mode == LEGEND_HORIZONTAL )
1724
-          {
1725
-           $Lines = preg_split("/\n/",$Serie["Description"]);
1726
-           $Width = "";
1727
-           foreach($Lines as $Key => $Value)
1728
-            {
1729
-             $BoxArray = $this->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontSize"=>$FontSize,"FontName"=>$FontName));
1730
-             $Width[] = $BoxArray[1]["X"];
1660
+                $Width[] = $BoxArray[1]["X"];
1661
+            }
1662
+
1663
+            $vX=max($Width)+$XStep;
1731 1664
             }
1732
-           $X=max($Width)+2+$XStep;
1733
-          }
1734 1665
         }
1735
-      }
1666
+        }
1667
+        $vY=$vY-$YStep; $vX=$vX-$XStep;
1736 1668
 
1669
+        $TopOffset  = $Y - $Boundaries["T"];
1670
+        if ( $Boundaries["B"]-($vY+$IconAreaHeight) < $TopOffset ) { $Boundaries["B"] = $vY+$IconAreaHeight+$TopOffset; }
1737 1671
 
1738
-     $this->Shadow = $RestoreShadow;
1739
-    }
1672
+        if ( $Style == LEGEND_ROUND )
1673
+        $this->drawRoundedFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1674
+        elseif ( $Style == LEGEND_BOX )
1675
+        $this->drawFilledRectangle($Boundaries["L"]-$Margin,$Boundaries["T"]-$Margin,$Boundaries["R"]+$Margin,$Boundaries["B"]+$Margin,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB));
1740 1676
 
1741
-   function drawScale($Format="")
1742
-    {
1743
-     $Pos		= isset($Format["Pos"]) ? $Format["Pos"] : SCALE_POS_LEFTRIGHT;
1744
-     $Floating		= isset($Format["Floating"]) ? $Format["Floating"] : FALSE;
1745
-     $Mode		= isset($Format["Mode"]) ? $Format["Mode"] : SCALE_MODE_FLOATING;
1746
-     $RemoveXAxis	= isset($Format["RemoveXAxis"]) ? $Format["RemoveXAxis"] : FALSE;
1747
-     $MinDivHeight	= isset($Format["MinDivHeight"]) ? $Format["MinDivHeight"] : 20;
1748
-     $Factors		= isset($Format["Factors"]) ? $Format["Factors"] : array(1,2,5);
1749
-     $ManualScale	= isset($Format["ManualScale"]) ? $Format["ManualScale"] : array("0"=>array("Min"=>-100,"Max"=>100));
1750
-     $XMargin		= isset($Format["XMargin"]) ? $Format["XMargin"] : AUTO;
1751
-     $YMargin		= isset($Format["YMargin"]) ? $Format["YMargin"] : 0;
1752
-     $ScaleSpacing	= isset($Format["ScaleSpacing"]) ? $Format["ScaleSpacing"] : 15;
1753
-     $InnerTickWidth	= isset($Format["InnerTickWidth"]) ? $Format["InnerTickWidth"] : 2;
1754
-     $OuterTickWidth	= isset($Format["OuterTickWidth"]) ? $Format["OuterTickWidth"] : 2;
1755
-     $DrawXLines	= isset($Format["DrawXLines"]) ? $Format["DrawXLines"] : TRUE;
1756
-     $DrawYLines	= isset($Format["DrawYLines"]) ? $Format["DrawYLines"] : ALL;
1757
-     $GridTicks		= isset($Format["GridTicks"]) ? $Format["GridTicks"] : 4;
1758
-     $GridR		= isset($Format["GridR"]) ? $Format["GridR"] : 255;
1759
-     $GridG		= isset($Format["GridG"]) ? $Format["GridG"] : 255;
1760
-     $GridB		= isset($Format["GridB"]) ? $Format["GridB"] : 255;
1761
-     $GridAlpha		= isset($Format["GridAlpha"]) ? $Format["GridAlpha"] : 40;
1762
-     $AxisRo		= isset($Format["AxisR"]) ? $Format["AxisR"] : 0;
1763
-     $AxisGo		= isset($Format["AxisG"]) ? $Format["AxisG"] : 0;
1764
-     $AxisBo		= isset($Format["AxisB"]) ? $Format["AxisB"] : 0;
1765
-     $AxisAlpha		= isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 100;
1766
-     $TickRo		= isset($Format["TickR"]) ? $Format["TickR"] : 0;
1767
-     $TickGo		= isset($Format["TickG"]) ? $Format["TickG"] : 0;
1768
-     $TickBo		= isset($Format["TickB"]) ? $Format["TickB"] : 0;
1769
-     $TickAlpha		= isset($Format["TickAlpha"]) ? $Format["TickAlpha"] : 100;
1770
-     $DrawSubTicks	= isset($Format["DrawSubTicks"]) ? $Format["DrawSubTicks"] : FALSE;
1771
-     $InnerSubTickWidth	= isset($Format["InnerSubTickWidth"]) ? $Format["InnerSubTickWidth"] : 0;
1772
-     $OuterSubTickWidth	= isset($Format["OuterSubTickWidth"]) ? $Format["OuterSubTickWidth"] : 2;
1773
-     $SubTickR		= isset($Format["SubTickR"]) ? $Format["SubTickR"] : 255;
1774
-     $SubTickG		= isset($Format["SubTickG"]) ? $Format["SubTickG"] : 0;
1775
-     $SubTickB		= isset($Format["SubTickB"]) ? $Format["SubTickB"] : 0;
1776
-     $SubTickAlpha	= isset($Format["SubTickAlpha"]) ? $Format["SubTickAlpha"] : 100;
1777
-     $AutoAxisLabels	= isset($Format["AutoAxisLabels"]) ? $Format["AutoAxisLabels"] : TRUE;
1778
-     $XReleasePercent	= isset($Format["XReleasePercent"]) ? $Format["XReleasePercent"] : 1;
1779
-     $DrawArrows	= isset($Format["DrawArrows"]) ? $Format["DrawArrows"] : FALSE;
1780
-     $ArrowSize         = isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 8;
1781
-     $CycleBackground	= isset($Format["CycleBackground"]) ? $Format["CycleBackground"] : FALSE;
1782
-     $BackgroundR1	= isset($Format["BackgroundR1"]) ? $Format["BackgroundR1"] : 255;
1783
-     $BackgroundG1	= isset($Format["BackgroundG1"]) ? $Format["BackgroundG1"] : 255;
1784
-     $BackgroundB1	= isset($Format["BackgroundB1"]) ? $Format["BackgroundB1"] : 255;
1785
-     $BackgroundAlpha1	= isset($Format["BackgroundAlpha1"]) ? $Format["BackgroundAlpha1"] : 20;
1786
-     $BackgroundR2	= isset($Format["BackgroundR2"]) ? $Format["BackgroundR2"] : 230;
1787
-     $BackgroundG2	= isset($Format["BackgroundG2"]) ? $Format["BackgroundG2"] : 230;
1788
-     $BackgroundB2	= isset($Format["BackgroundB2"]) ? $Format["BackgroundB2"] : 230;
1789
-     $BackgroundAlpha2	= isset($Format["BackgroundAlpha2"]) ? $Format["BackgroundAlpha2"] : 20;
1790
-     $LabelingMethod	= isset($Format["LabelingMethod"]) ? $Format["LabelingMethod"] : LABELING_ALL;
1791
-     $LabelSkip		= isset($Format["LabelSkip"]) ? $Format["LabelSkip"] : 0;
1792
-     $LabelRotation	= isset($Format["LabelRotation"]) ? $Format["LabelRotation"] : 0;
1793
-     $SkippedAxisTicks	= isset($Format["SkippedAxisTicks"]) ? $Format["SkippedAxisTicks"] : $GridTicks+2;
1794
-     $SkippedAxisR	= isset($Format["SkippedAxisR"]) ? $Format["SkippedAxisR"] : $GridR;
1795
-     $SkippedAxisG	= isset($Format["SkippedAxisG"]) ? $Format["SkippedAxisG"] : $GridG;
1796
-     $SkippedAxisB	= isset($Format["SkippedAxisB"]) ? $Format["SkippedAxisB"] : $GridB;
1797
-     $SkippedAxisAlpha	= isset($Format["SkippedAxisAlpha"]) ? $Format["SkippedAxisAlpha"] : $GridAlpha-30;
1798
-     $SkippedTickR	= isset($Format["SkippedTickR"]) ? $Format["SkippedTickR"] : $TickRo;
1799
-     $SkippedTickG	= isset($Format["SkippedTickG"]) ? $Format["SkippedTickG"] : $TickGo;
1800
-     $SkippedTickB	= isset($Format["SkippedTicksB"]) ? $Format["SkippedTickB"] : $TickBo;
1801
-     $SkippedTickAlpha	= isset($Format["SkippedTickAlpha"]) ? $Format["SkippedTickAlpha"] : $TickAlpha-80;
1802
-     $SkippedInnerTickWidth	= isset($Format["SkippedInnerTickWidth"]) ? $Format["SkippedInnerTickWidth"] : 0;
1803
-     $SkippedOuterTickWidth	= isset($Format["SkippedOuterTickWidth"]) ? $Format["SkippedOuterTickWidth"] : 2;
1804
-
1805
-     /* Floating scale require X & Y margins to be set manually */
1806
-     if ( $Floating && ( $XMargin == AUTO || $YMargin == 0 ) ) { $Floating = FALSE; }
1807
-
1808
-     /* Skip a NOTICE event in case of an empty array */
1809
-     if ( $DrawYLines == NONE || $DrawYLines == FALSE ) { $DrawYLines = array("zarma"=>"31"); }
1810
-
1811
-     /* Define the color for the skipped elements */
1812
-     $SkippedAxisColor = array("R"=>$SkippedAxisR,"G"=>$SkippedAxisG,"B"=>$SkippedAxisB,"Alpha"=>$SkippedAxisAlpha,"Ticks"=>$SkippedAxisTicks);
1813
-     $SkippedTickColor = array("R"=>$SkippedTickR,"G"=>$SkippedTickG,"B"=>$SkippedTickB,"Alpha"=>$SkippedTickAlpha);
1814
-
1815
-     $Data = $this->DataSet->getData();
1816
-     if ( isset($Data["Abscissa"]) ) { $Abscissa = $Data["Abscissa"]; } else { $Abscissa = NULL; }
1817
-
1818
-     /* Unset the abscissa axis, needed if we display multiple charts on the same picture */
1819
-     if ( $Abscissa != NULL )
1820
-      {
1821
-       foreach($Data["Axis"] as $AxisID => $Parameters)
1822
-        { if ($Parameters["Identity"] == AXIS_X) { unset($Data["Axis"][$AxisID]); } }
1823
-      }
1677
+        $RestoreShadow = $this->Shadow; $this->Shadow = FALSE;
1678
+        foreach($Data["Series"] as $SerieName => $Serie)
1679
+        {
1680
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
1681
+        {
1682
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"];
1683
+            $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
1824 1684
 
1825
-     /* Build the scale settings */
1826
-     $GotXAxis = FALSE;
1827
-     foreach($Data["Axis"] as $AxisID => $AxisParameter)
1828
-      {
1829
-       if ( $AxisParameter["Identity"] == AXIS_X ) { $GotXAxis = TRUE; }
1685
+            if ( isset($Serie["Picture"]) )
1686
+            {
1687
+            $Picture = $Serie["Picture"];
1688
+            list($PicWidth,$PicHeight) = $this->getPicInfo($Picture);
1689
+            $PicX = $X+$IconAreaWidth/2; $PicY = $Y+$IconAreaHeight/2; 
1830 1690
 
1831
-       if ( $Pos == SCALE_POS_LEFTRIGHT && $AxisParameter["Identity"] == AXIS_Y)
1832
-        { $Height = $this->GraphAreaY2-$this->GraphAreaY1 - $YMargin*2; }
1833
-       elseif ( $Pos == SCALE_POS_LEFTRIGHT && $AxisParameter["Identity"] == AXIS_X)
1834
-        { $Height = $this->GraphAreaX2-$this->GraphAreaX1; }
1835
-       elseif ( $Pos == SCALE_POS_TOPBOTTOM && $AxisParameter["Identity"] == AXIS_Y)
1836
-        { $Height = $this->GraphAreaX2-$this->GraphAreaX1 - $YMargin*2;; }
1837
-       else
1838
-        { $Height = $this->GraphAreaY2-$this->GraphAreaY1; }
1691
+            $this->drawFromPNG($PicX-$PicWidth/2,$PicY-$PicHeight/2,$Picture);
1692
+            }
1693
+            else
1694
+            {
1695
+            if ( $Family == LEGEND_FAMILY_BOX )
1696
+            {
1697
+                if ( $BoxWidth != $IconAreaWidth ) { $XOffset = floor(($IconAreaWidth-$BoxWidth)/2); } else { $XOffset = 0; }
1698
+                if ( $BoxHeight != $IconAreaHeight ) { $YOffset = floor(($IconAreaHeight-$BoxHeight)/2); } else { $YOffset = 0; }
1839 1699
 
1840
-       $AxisMin = ABSOLUTE_MAX; $AxisMax = OUT_OF_SIGHT;
1841
-       if ( $Mode == SCALE_MODE_FLOATING || $Mode == SCALE_MODE_START0 )
1842
-        {
1843
-         foreach($Data["Series"] as $SerieID => $SerieParameter)
1844
-          {
1845
-           if ( $SerieParameter["Axis"] == $AxisID && $Data["Series"][$SerieID]["isDrawable"] && $Data["Abscissa"] != $SerieID)
1700
+                $this->drawFilledRectangle($X+1+$XOffset,$Y+1+$YOffset,$X+$BoxWidth+$XOffset+1,$Y+$BoxHeight+1+$YOffset,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
1701
+                $this->drawFilledRectangle($X+$XOffset,$Y+$YOffset,$X+$BoxWidth+$XOffset,$Y+$BoxHeight+$YOffset,array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
1702
+            }
1703
+            elseif ( $Family == LEGEND_FAMILY_CIRCLE )
1846 1704
             {
1847
-             $AxisMax = max($AxisMax,$Data["Series"][$SerieID]["Max"]);
1848
-             $AxisMin = min($AxisMin,$Data["Series"][$SerieID]["Min"]);
1705
+                $this->drawFilledCircle($X+1+$IconAreaWidth/2,$Y+1+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20));
1706
+                $this->drawFilledCircle($X+$IconAreaWidth/2,$Y+$IconAreaHeight/2,min($IconAreaHeight/2,$IconAreaWidth/2),array("R"=>$R,"G"=>$G,"B"=>$B,"Surrounding"=>20));
1849 1707
             }
1850
-          }
1851
-         $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent;
1852
-
1853
-         $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin;
1854
-         if ( $Mode == SCALE_MODE_START0 ) { $Data["Axis"][$AxisID]["Min"] = 0; }
1708
+            elseif ( $Family == LEGEND_FAMILY_LINE )
1709
+            {
1710
+                $this->drawLine($X+1,$Y+1+$IconAreaHeight/2,$X+1+$IconAreaWidth,$Y+1+$IconAreaHeight/2,array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20,"Ticks"=>$Ticks,"Weight"=>$Weight));
1711
+                $this->drawLine($X,$Y+$IconAreaHeight/2,$X+$IconAreaWidth,$Y+$IconAreaHeight/2,array("R"=>$R,"G"=>$G,"B"=>$B,"Ticks"=>$Ticks,"Weight"=>$Weight));
1712
+            }
1713
+            }
1714
+
1715
+            if ( $Mode == LEGEND_VERTICAL )
1716
+            {
1717
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1718
+            foreach($Lines as $Key => $Value)
1719
+            $this->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontSize"=>$FontSize,"FontName"=>$FontName));
1720
+
1721
+            $Y=$Y+max($this->FontSize*count($Lines),$IconAreaHeight) + 5;
1722
+            }
1723
+            elseif ( $Mode == LEGEND_HORIZONTAL )
1724
+            {
1725
+            $Lines = preg_split("/\n/",$Serie["Description"]);
1726
+            $Width = "";
1727
+            foreach($Lines as $Key => $Value)
1728
+            {
1729
+                $BoxArray = $this->drawText($X+$IconAreaWidth+4,$Y+$IconAreaHeight/2+(($this->FontSize+3)*$Key),$Value,array("R"=>$FontR,"G"=>$FontG,"B"=>$FontB,"Align"=>TEXT_ALIGN_MIDDLELEFT,"FontSize"=>$FontSize,"FontName"=>$FontName));
1730
+                $Width[] = $BoxArray[1]["X"];
1731
+            }
1732
+            $X=max($Width)+2+$XStep;
1733
+            }
1734
+        }
1735
+        }
1736
+
1737
+
1738
+        $this->Shadow = $RestoreShadow;
1739
+    }
1740
+
1741
+    function drawScale($Format="")
1742
+    {
1743
+        $Pos		= isset($Format["Pos"]) ? $Format["Pos"] : SCALE_POS_LEFTRIGHT;
1744
+        $Floating		= isset($Format["Floating"]) ? $Format["Floating"] : FALSE;
1745
+        $Mode		= isset($Format["Mode"]) ? $Format["Mode"] : SCALE_MODE_FLOATING;
1746
+        $RemoveXAxis	= isset($Format["RemoveXAxis"]) ? $Format["RemoveXAxis"] : FALSE;
1747
+        $MinDivHeight	= isset($Format["MinDivHeight"]) ? $Format["MinDivHeight"] : 20;
1748
+        $Factors		= isset($Format["Factors"]) ? $Format["Factors"] : array(1,2,5);
1749
+        $ManualScale	= isset($Format["ManualScale"]) ? $Format["ManualScale"] : array("0"=>array("Min"=>-100,"Max"=>100));
1750
+        $XMargin		= isset($Format["XMargin"]) ? $Format["XMargin"] : AUTO;
1751
+        $YMargin		= isset($Format["YMargin"]) ? $Format["YMargin"] : 0;
1752
+        $ScaleSpacing	= isset($Format["ScaleSpacing"]) ? $Format["ScaleSpacing"] : 15;
1753
+        $InnerTickWidth	= isset($Format["InnerTickWidth"]) ? $Format["InnerTickWidth"] : 2;
1754
+        $OuterTickWidth	= isset($Format["OuterTickWidth"]) ? $Format["OuterTickWidth"] : 2;
1755
+        $DrawXLines	= isset($Format["DrawXLines"]) ? $Format["DrawXLines"] : TRUE;
1756
+        $DrawYLines	= isset($Format["DrawYLines"]) ? $Format["DrawYLines"] : ALL;
1757
+        $GridTicks		= isset($Format["GridTicks"]) ? $Format["GridTicks"] : 4;
1758
+        $GridR		= isset($Format["GridR"]) ? $Format["GridR"] : 255;
1759
+        $GridG		= isset($Format["GridG"]) ? $Format["GridG"] : 255;
1760
+        $GridB		= isset($Format["GridB"]) ? $Format["GridB"] : 255;
1761
+        $GridAlpha		= isset($Format["GridAlpha"]) ? $Format["GridAlpha"] : 40;
1762
+        $AxisRo		= isset($Format["AxisR"]) ? $Format["AxisR"] : 0;
1763
+        $AxisGo		= isset($Format["AxisG"]) ? $Format["AxisG"] : 0;
1764
+        $AxisBo		= isset($Format["AxisB"]) ? $Format["AxisB"] : 0;
1765
+        $AxisAlpha		= isset($Format["AxisAlpha"]) ? $Format["AxisAlpha"] : 100;
1766
+        $TickRo		= isset($Format["TickR"]) ? $Format["TickR"] : 0;
1767
+        $TickGo		= isset($Format["TickG"]) ? $Format["TickG"] : 0;
1768
+        $TickBo		= isset($Format["TickB"]) ? $Format["TickB"] : 0;
1769
+        $TickAlpha		= isset($Format["TickAlpha"]) ? $Format["TickAlpha"] : 100;
1770
+        $DrawSubTicks	= isset($Format["DrawSubTicks"]) ? $Format["DrawSubTicks"] : FALSE;
1771
+        $InnerSubTickWidth	= isset($Format["InnerSubTickWidth"]) ? $Format["InnerSubTickWidth"] : 0;
1772
+        $OuterSubTickWidth	= isset($Format["OuterSubTickWidth"]) ? $Format["OuterSubTickWidth"] : 2;
1773
+        $SubTickR		= isset($Format["SubTickR"]) ? $Format["SubTickR"] : 255;
1774
+        $SubTickG		= isset($Format["SubTickG"]) ? $Format["SubTickG"] : 0;
1775
+        $SubTickB		= isset($Format["SubTickB"]) ? $Format["SubTickB"] : 0;
1776
+        $SubTickAlpha	= isset($Format["SubTickAlpha"]) ? $Format["SubTickAlpha"] : 100;
1777
+        $AutoAxisLabels	= isset($Format["AutoAxisLabels"]) ? $Format["AutoAxisLabels"] : TRUE;
1778
+        $XReleasePercent	= isset($Format["XReleasePercent"]) ? $Format["XReleasePercent"] : 1;
1779
+        $DrawArrows	= isset($Format["DrawArrows"]) ? $Format["DrawArrows"] : FALSE;
1780
+        $ArrowSize         = isset($Format["ArrowSize"]) ? $Format["ArrowSize"] : 8;
1781
+        $CycleBackground	= isset($Format["CycleBackground"]) ? $Format["CycleBackground"] : FALSE;
1782
+        $BackgroundR1	= isset($Format["BackgroundR1"]) ? $Format["BackgroundR1"] : 255;
1783
+        $BackgroundG1	= isset($Format["BackgroundG1"]) ? $Format["BackgroundG1"] : 255;
1784
+        $BackgroundB1	= isset($Format["BackgroundB1"]) ? $Format["BackgroundB1"] : 255;
1785
+        $BackgroundAlpha1	= isset($Format["BackgroundAlpha1"]) ? $Format["BackgroundAlpha1"] : 20;
1786
+        $BackgroundR2	= isset($Format["BackgroundR2"]) ? $Format["BackgroundR2"] : 230;
1787
+        $BackgroundG2	= isset($Format["BackgroundG2"]) ? $Format["BackgroundG2"] : 230;
1788
+        $BackgroundB2	= isset($Format["BackgroundB2"]) ? $Format["BackgroundB2"] : 230;
1789
+        $BackgroundAlpha2	= isset($Format["BackgroundAlpha2"]) ? $Format["BackgroundAlpha2"] : 20;
1790
+        $LabelingMethod	= isset($Format["LabelingMethod"]) ? $Format["LabelingMethod"] : LABELING_ALL;
1791
+        $LabelSkip		= isset($Format["LabelSkip"]) ? $Format["LabelSkip"] : 0;
1792
+        $LabelRotation	= isset($Format["LabelRotation"]) ? $Format["LabelRotation"] : 0;
1793
+        $SkippedAxisTicks	= isset($Format["SkippedAxisTicks"]) ? $Format["SkippedAxisTicks"] : $GridTicks+2;
1794
+        $SkippedAxisR	= isset($Format["SkippedAxisR"]) ? $Format["SkippedAxisR"] : $GridR;
1795
+        $SkippedAxisG	= isset($Format["SkippedAxisG"]) ? $Format["SkippedAxisG"] : $GridG;
1796
+        $SkippedAxisB	= isset($Format["SkippedAxisB"]) ? $Format["SkippedAxisB"] : $GridB;
1797
+        $SkippedAxisAlpha	= isset($Format["SkippedAxisAlpha"]) ? $Format["SkippedAxisAlpha"] : $GridAlpha-30;
1798
+        $SkippedTickR	= isset($Format["SkippedTickR"]) ? $Format["SkippedTickR"] : $TickRo;
1799
+        $SkippedTickG	= isset($Format["SkippedTickG"]) ? $Format["SkippedTickG"] : $TickGo;
1800
+        $SkippedTickB	= isset($Format["SkippedTicksB"]) ? $Format["SkippedTickB"] : $TickBo;
1801
+        $SkippedTickAlpha	= isset($Format["SkippedTickAlpha"]) ? $Format["SkippedTickAlpha"] : $TickAlpha-80;
1802
+        $SkippedInnerTickWidth	= isset($Format["SkippedInnerTickWidth"]) ? $Format["SkippedInnerTickWidth"] : 0;
1803
+        $SkippedOuterTickWidth	= isset($Format["SkippedOuterTickWidth"]) ? $Format["SkippedOuterTickWidth"] : 2;
1804
+
1805
+        /* Floating scale require X & Y margins to be set manually */
1806
+        if ( $Floating && ( $XMargin == AUTO || $YMargin == 0 ) ) { $Floating = FALSE; }
1807
+
1808
+        /* Skip a NOTICE event in case of an empty array */
1809
+        if ( $DrawYLines == NONE || $DrawYLines == FALSE ) { $DrawYLines = array("zarma"=>"31"); }
1810
+
1811
+        /* Define the color for the skipped elements */
1812
+        $SkippedAxisColor = array("R"=>$SkippedAxisR,"G"=>$SkippedAxisG,"B"=>$SkippedAxisB,"Alpha"=>$SkippedAxisAlpha,"Ticks"=>$SkippedAxisTicks);
1813
+        $SkippedTickColor = array("R"=>$SkippedTickR,"G"=>$SkippedTickG,"B"=>$SkippedTickB,"Alpha"=>$SkippedTickAlpha);
1814
+
1815
+        $Data = $this->DataSet->getData();
1816
+        if ( isset($Data["Abscissa"]) ) { $Abscissa = $Data["Abscissa"]; } else { $Abscissa = NULL; }
1817
+
1818
+        /* Unset the abscissa axis, needed if we display multiple charts on the same picture */
1819
+        if ( $Abscissa != NULL )
1820
+        {
1821
+        foreach($Data["Axis"] as $AxisID => $Parameters)
1822
+        { if ($Parameters["Identity"] == AXIS_X) { unset($Data["Axis"][$AxisID]); } }
1823
+        }
1824
+
1825
+        /* Build the scale settings */
1826
+        $GotXAxis = FALSE;
1827
+        foreach($Data["Axis"] as $AxisID => $AxisParameter)
1828
+        {
1829
+        if ( $AxisParameter["Identity"] == AXIS_X ) { $GotXAxis = TRUE; }
1830
+
1831
+        if ( $Pos == SCALE_POS_LEFTRIGHT && $AxisParameter["Identity"] == AXIS_Y)
1832
+        { $Height = $this->GraphAreaY2-$this->GraphAreaY1 - $YMargin*2; }
1833
+        elseif ( $Pos == SCALE_POS_LEFTRIGHT && $AxisParameter["Identity"] == AXIS_X)
1834
+        { $Height = $this->GraphAreaX2-$this->GraphAreaX1; }
1835
+        elseif ( $Pos == SCALE_POS_TOPBOTTOM && $AxisParameter["Identity"] == AXIS_Y)
1836
+        { $Height = $this->GraphAreaX2-$this->GraphAreaX1 - $YMargin*2;; }
1837
+        else
1838
+        { $Height = $this->GraphAreaY2-$this->GraphAreaY1; }
1839
+
1840
+        $AxisMin = ABSOLUTE_MAX; $AxisMax = OUT_OF_SIGHT;
1841
+        if ( $Mode == SCALE_MODE_FLOATING || $Mode == SCALE_MODE_START0 )
1842
+        {
1843
+            foreach($Data["Series"] as $SerieID => $SerieParameter)
1844
+            {
1845
+            if ( $SerieParameter["Axis"] == $AxisID && $Data["Series"][$SerieID]["isDrawable"] && $Data["Abscissa"] != $SerieID)
1846
+            {
1847
+                $AxisMax = max($AxisMax,$Data["Series"][$SerieID]["Max"]);
1848
+                $AxisMin = min($AxisMin,$Data["Series"][$SerieID]["Min"]);
1849
+            }
1850
+            }
1851
+            $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent;
1852
+
1853
+            $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin;
1854
+            if ( $Mode == SCALE_MODE_START0 ) { $Data["Axis"][$AxisID]["Min"] = 0; }
1855 1855
         }
1856
-       elseif ( $Mode == SCALE_MODE_MANUAL )
1856
+        elseif ( $Mode == SCALE_MODE_MANUAL )
1857 1857
         {
1858
-         if ( isset($ManualScale[$AxisID]["Min"]) && isset($ManualScale[$AxisID]["Max"]) )
1859
-          {
1860
-           $Data["Axis"][$AxisID]["Min"] = $ManualScale[$AxisID]["Min"];
1861
-           $Data["Axis"][$AxisID]["Max"] = $ManualScale[$AxisID]["Max"];
1862
-          }
1863
-         else
1864
-          { echo "Manual scale boundaries not set."; exit(); }
1858
+            if ( isset($ManualScale[$AxisID]["Min"]) && isset($ManualScale[$AxisID]["Max"]) )
1859
+            {
1860
+            $Data["Axis"][$AxisID]["Min"] = $ManualScale[$AxisID]["Min"];
1861
+            $Data["Axis"][$AxisID]["Max"] = $ManualScale[$AxisID]["Max"];
1862
+            }
1863
+            else
1864
+            { echo "Manual scale boundaries not set."; exit(); }
1865 1865
         }
1866
-       elseif ( $Mode == SCALE_MODE_ADDALL || $Mode == SCALE_MODE_ADDALL_START0 )
1866
+        elseif ( $Mode == SCALE_MODE_ADDALL || $Mode == SCALE_MODE_ADDALL_START0 )
1867 1867
         {
1868
-         $Series = "";
1869
-         foreach($Data["Series"] as $SerieID => $SerieParameter)
1870
-          { if ( $SerieParameter["Axis"] == $AxisID && $SerieParameter["isDrawable"] && $Data["Abscissa"] != $SerieID ) { $Series[$SerieID] = count($Data["Series"][$SerieID]["Data"]); } }
1868
+            $Series = "";
1869
+            foreach($Data["Series"] as $SerieID => $SerieParameter)
1870
+            { if ( $SerieParameter["Axis"] == $AxisID && $SerieParameter["isDrawable"] && $Data["Abscissa"] != $SerieID ) { $Series[$SerieID] = count($Data["Series"][$SerieID]["Data"]); } }
1871 1871
 
1872
-         for ($ID=0;$ID<=max($Series)-1;$ID++)
1873
-          {
1874
-           $PointMin = 0; $PointMax = 0;
1875
-           foreach($Series as $SerieID => $ValuesCount )
1872
+            for ($ID=0;$ID<=max($Series)-1;$ID++)
1876 1873
             {
1877
-             if (isset($Data["Series"][$SerieID]["Data"][$ID]) && $Data["Series"][$SerieID]["Data"][$ID] != NULL )
1878
-              {
1879
-               $Value = $Data["Series"][$SerieID]["Data"][$ID];
1880
-               if ( $Value > 0 ) { $PointMax = $PointMax + $Value; } else { $PointMin = $PointMin + $Value; }
1881
-              }
1874
+            $PointMin = 0; $PointMax = 0;
1875
+            foreach($Series as $SerieID => $ValuesCount )
1876
+            {
1877
+                if (isset($Data["Series"][$SerieID]["Data"][$ID]) && $Data["Series"][$SerieID]["Data"][$ID] != NULL )
1878
+                {
1879
+                $Value = $Data["Series"][$SerieID]["Data"][$ID];
1880
+                if ( $Value > 0 ) { $PointMax = $PointMax + $Value; } else { $PointMin = $PointMin + $Value; }
1881
+                }
1882
+            }
1883
+            $AxisMax = max($AxisMax,$PointMax);
1884
+            $AxisMin = min($AxisMin,$PointMin);
1882 1885
             }
1883
-           $AxisMax = max($AxisMax,$PointMax);
1884
-           $AxisMin = min($AxisMin,$PointMin);
1885
-          }
1886
-         $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent;
1887
-         $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin;
1886
+            $AutoMargin = (($AxisMax-$AxisMin)/100)*$XReleasePercent;
1887
+            $Data["Axis"][$AxisID]["Min"] = $AxisMin-$AutoMargin; $Data["Axis"][$AxisID]["Max"] = $AxisMax+$AutoMargin;
1888 1888
         }
1889
-       $MaxDivs = floor($Height/$MinDivHeight);
1889
+        $MaxDivs = floor($Height/$MinDivHeight);
1890 1890
 
1891
-       if ( $Mode == SCALE_MODE_ADDALL_START0 ) { $Data["Axis"][$AxisID]["Min"] = 0; }
1891
+        if ( $Mode == SCALE_MODE_ADDALL_START0 ) { $Data["Axis"][$AxisID]["Min"] = 0; }
1892 1892
 
1893
-       $Scale   = $this->computeScale($Data["Axis"][$AxisID]["Min"],$Data["Axis"][$AxisID]["Max"],$MaxDivs,$Factors,$AxisID);
1893
+        $Scale   = $this->computeScale($Data["Axis"][$AxisID]["Min"],$Data["Axis"][$AxisID]["Max"],$MaxDivs,$Factors,$AxisID);
1894 1894
 
1895
-       $Data["Axis"][$AxisID]["Margin"]    = $AxisParameter["Identity"] == AXIS_X ? $XMargin : $YMargin;
1896
-       $Data["Axis"][$AxisID]["ScaleMin"]  = $Scale["XMin"];
1897
-       $Data["Axis"][$AxisID]["ScaleMax"]  = $Scale["XMax"];
1898
-       $Data["Axis"][$AxisID]["Rows"]      = $Scale["Rows"];
1899
-       $Data["Axis"][$AxisID]["RowHeight"] = $Scale["RowHeight"];
1895
+        $Data["Axis"][$AxisID]["Margin"]    = $AxisParameter["Identity"] == AXIS_X ? $XMargin : $YMargin;
1896
+        $Data["Axis"][$AxisID]["ScaleMin"]  = $Scale["XMin"];
1897
+        $Data["Axis"][$AxisID]["ScaleMax"]  = $Scale["XMax"];
1898
+        $Data["Axis"][$AxisID]["Rows"]      = $Scale["Rows"];
1899
+        $Data["Axis"][$AxisID]["RowHeight"] = $Scale["RowHeight"];
1900 1900
 
1901
-       if ( isset($Scale["Format"]) ) { $Data["Axis"][$AxisID]["Format"] = $Scale["Format"]; }
1901
+        if ( isset($Scale["Format"]) ) { $Data["Axis"][$AxisID]["Format"] = $Scale["Format"]; }
1902 1902
 
1903
-       if ( !isset($Data["Axis"][$AxisID]["Display"]) ) { $Data["Axis"][$AxisID]["Display"] = NULL; }
1904
-       if ( !isset($Data["Axis"][$AxisID]["Format"]) )  { $Data["Axis"][$AxisID]["Format"] = NULL; }
1905
-       if ( !isset($Data["Axis"][$AxisID]["Unit"]) )    { $Data["Axis"][$AxisID]["Unit"] = NULL; }
1906
-      }
1903
+        if ( !isset($Data["Axis"][$AxisID]["Display"]) ) { $Data["Axis"][$AxisID]["Display"] = NULL; }
1904
+        if ( !isset($Data["Axis"][$AxisID]["Format"]) )  { $Data["Axis"][$AxisID]["Format"] = NULL; }
1905
+        if ( !isset($Data["Axis"][$AxisID]["Unit"]) )    { $Data["Axis"][$AxisID]["Unit"] = NULL; }
1906
+        }
1907 1907
 
1908
-     /* Still no X axis */
1909
-     if ( $GotXAxis == FALSE )
1910
-      {
1911
-       if ( $Abscissa != NULL )
1908
+        /* Still no X axis */
1909
+        if ( $GotXAxis == FALSE )
1910
+        {
1911
+        if ( $Abscissa != NULL )
1912 1912
         {
1913
-         $Points = count($Data["Series"][$Abscissa]["Data"]);
1914
-         if ( $AutoAxisLabels )
1915
-          $AxisName = isset($Data["Series"][$Abscissa]["Description"]) ? $Data["Series"][$Abscissa]["Description"] : NULL;
1916
-         else
1917
-          $AxisName = NULL;
1913
+            $Points = count($Data["Series"][$Abscissa]["Data"]);
1914
+            if ( $AutoAxisLabels )
1915
+            $AxisName = isset($Data["Series"][$Abscissa]["Description"]) ? $Data["Series"][$Abscissa]["Description"] : NULL;
1916
+            else
1917
+            $AxisName = NULL;
1918 1918
         }
1919
-       else
1919
+        else
1920 1920
         {
1921
-         $Points = 0;
1922
-         $AxisName = isset($Data["XAxisName"]) ? $Data["XAxisName"] : NULL;
1923
-         foreach($Data["Series"] as $SerieID => $SerieParameter)
1924
-          { if ( $SerieParameter["isDrawable"] ) { $Points = max($Points,count($SerieParameter["Data"])); } }
1921
+            $Points = 0;
1922
+            $AxisName = isset($Data["XAxisName"]) ? $Data["XAxisName"] : NULL;
1923
+            foreach($Data["Series"] as $SerieID => $SerieParameter)
1924
+            { if ( $SerieParameter["isDrawable"] ) { $Points = max($Points,count($SerieParameter["Data"])); } }
1925 1925
         }
1926 1926
 
1927
-       $AxisID = count($Data["Axis"]);
1928
-       $Data["Axis"][$AxisID]["Identity"] = AXIS_X;
1929
-       if ( $Pos == SCALE_POS_LEFTRIGHT ) { $Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_BOTTOM; } else { $Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_LEFT; }
1930
-       if ( isset($Data["AbscissaName"]) ) { $Data["Axis"][$AxisID]["Name"] = $Data["AbscissaName"]; }
1931
-       if ( $XMargin == AUTO )
1927
+        $AxisID = count($Data["Axis"]);
1928
+        $Data["Axis"][$AxisID]["Identity"] = AXIS_X;
1929
+        if ( $Pos == SCALE_POS_LEFTRIGHT ) { $Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_BOTTOM; } else { $Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_LEFT; }
1930
+        if ( isset($Data["AbscissaName"]) ) { $Data["Axis"][$AxisID]["Name"] = $Data["AbscissaName"]; }
1931
+        if ( $XMargin == AUTO )
1932 1932
         {
1933
-         if ( $Pos == SCALE_POS_LEFTRIGHT )
1934
-          { $Height = $this->GraphAreaX2-$this->GraphAreaX1; }
1935
-         else
1936
-          { $Height = $this->GraphAreaY2-$this->GraphAreaY1; }
1937
-
1938
-         if ( $Points == 1 )
1939
-          $Data["Axis"][$AxisID]["Margin"] = $Height / 2;
1940
-         else
1941
-          $Data["Axis"][$AxisID]["Margin"] = ($Height/$Points) / 2;
1933
+            if ( $Pos == SCALE_POS_LEFTRIGHT )
1934
+            { $Height = $this->GraphAreaX2-$this->GraphAreaX1; }
1935
+            else
1936
+            { $Height = $this->GraphAreaY2-$this->GraphAreaY1; }
1937
+
1938
+            if ( $Points == 1 )
1939
+            $Data["Axis"][$AxisID]["Margin"] = $Height / 2;
1940
+            else
1941
+            $Data["Axis"][$AxisID]["Margin"] = ($Height/$Points) / 2;
1942 1942
         }
1943
-       else
1943
+        else
1944 1944
         { $Data["Axis"][$AxisID]["Margin"] = $XMargin; }
1945
-       $Data["Axis"][$AxisID]["Rows"] = $Points-1;
1946
-       if ( !isset($Data["Axis"][$AxisID]["Display"]) ) { $Data["Axis"][$AxisID]["Display"] = NULL; }
1947
-       if ( !isset($Data["Axis"][$AxisID]["Format"]) )  { $Data["Axis"][$AxisID]["Format"] = NULL; }
1948
-       if ( !isset($Data["Axis"][$AxisID]["Unit"]) )    { $Data["Axis"][$AxisID]["Unit"] = NULL; }
1949
-      }
1950
-
1951
-     /* Do we need to reverse the abscissa position? */
1952
-     if ( $Pos != SCALE_POS_LEFTRIGHT )
1953
-      {
1954
-       if ( $Data["AbsicssaPosition"] == AXIS_POSITION_BOTTOM )
1945
+        $Data["Axis"][$AxisID]["Rows"] = $Points-1;
1946
+        if ( !isset($Data["Axis"][$AxisID]["Display"]) ) { $Data["Axis"][$AxisID]["Display"] = NULL; }
1947
+        if ( !isset($Data["Axis"][$AxisID]["Format"]) )  { $Data["Axis"][$AxisID]["Format"] = NULL; }
1948
+        if ( !isset($Data["Axis"][$AxisID]["Unit"]) )    { $Data["Axis"][$AxisID]["Unit"] = NULL; }
1949
+        }
1950
+
1951
+        /* Do we need to reverse the abscissa position? */
1952
+        if ( $Pos != SCALE_POS_LEFTRIGHT )
1953
+        {
1954
+        if ( $Data["AbsicssaPosition"] == AXIS_POSITION_BOTTOM )
1955 1955
         { $Data["AbsicssaPosition"] = AXIS_POSITION_LEFT; }
1956
-       else
1956
+        else
1957 1957
         { $Data["AbsicssaPosition"] = AXIS_POSITION_RIGHT; }
1958
-      }
1959
-     $Data["Axis"][$AxisID]["Position"] = $Data["AbsicssaPosition"];
1958
+        }
1959
+        $Data["Axis"][$AxisID]["Position"] = $Data["AbsicssaPosition"];
1960 1960
 
1961
-     $this->DataSet->saveOrientation($Pos);
1962
-     $this->DataSet->saveAxisConfig($Data["Axis"]);
1963
-     $this->DataSet->saveYMargin($YMargin);
1961
+        $this->DataSet->saveOrientation($Pos);
1962
+        $this->DataSet->saveAxisConfig($Data["Axis"]);
1963
+        $this->DataSet->saveYMargin($YMargin);
1964 1964
 
1965
-     $FontColorRo = $this->FontColorR; $FontColorGo = $this->FontColorG; $FontColorBo = $this->FontColorB;
1965
+        $FontColorRo = $this->FontColorR; $FontColorGo = $this->FontColorG; $FontColorBo = $this->FontColorB;
1966 1966
 
1967
-     $AxisPos["L"] = $this->GraphAreaX1; $AxisPos["R"] = $this->GraphAreaX2; $AxisPos["T"] = $this->GraphAreaY1; $AxisPos["B"] = $this->GraphAreaY2;
1968
-     foreach($Data["Axis"] as $AxisID => $Parameters)
1969
-      {
1970
-       if ( isset($Parameters["Color"]) )
1967
+        $AxisPos["L"] = $this->GraphAreaX1; $AxisPos["R"] = $this->GraphAreaX2; $AxisPos["T"] = $this->GraphAreaY1; $AxisPos["B"] = $this->GraphAreaY2;
1968
+        foreach($Data["Axis"] as $AxisID => $Parameters)
1969
+        {
1970
+        if ( isset($Parameters["Color"]) )
1971 1971
         {
1972
-         $AxisR = $Parameters["Color"]["R"]; $AxisG = $Parameters["Color"]["G"]; $AxisB = $Parameters["Color"]["B"];
1973
-         $TickR = $Parameters["Color"]["R"]; $TickG = $Parameters["Color"]["G"]; $TickB = $Parameters["Color"]["B"];
1974
-         $this->setFontProperties(array("R"=>$Parameters["Color"]["R"],"G"=>$Parameters["Color"]["G"],"B"=>$Parameters["Color"]["B"]));
1972
+            $AxisR = $Parameters["Color"]["R"]; $AxisG = $Parameters["Color"]["G"]; $AxisB = $Parameters["Color"]["B"];
1973
+            $TickR = $Parameters["Color"]["R"]; $TickG = $Parameters["Color"]["G"]; $TickB = $Parameters["Color"]["B"];
1974
+            $this->setFontProperties(array("R"=>$Parameters["Color"]["R"],"G"=>$Parameters["Color"]["G"],"B"=>$Parameters["Color"]["B"]));
1975 1975
         }
1976
-       else
1976
+        else
1977 1977
         {
1978
-         $AxisR = $AxisRo; $AxisG = $AxisGo; $AxisB = $AxisBo;
1979
-         $TickR = $TickRo; $TickG = $TickGo; $TickB = $TickBo;
1980
-         $this->setFontProperties(array("R"=>$FontColorRo,"G"=>$FontColorGo,"B"=>$FontColorBo));
1978
+            $AxisR = $AxisRo; $AxisG = $AxisGo; $AxisB = $AxisBo;
1979
+            $TickR = $TickRo; $TickG = $TickGo; $TickB = $TickBo;
1980
+            $this->setFontProperties(array("R"=>$FontColorRo,"G"=>$FontColorGo,"B"=>$FontColorBo));
1981 1981
         }
1982 1982
 
1983
-       $LastValue = "w00t"; $ID = 1;
1984
-       if ( $Parameters["Identity"] == AXIS_X )
1983
+        $LastValue = "w00t"; $ID = 1;
1984
+        if ( $Parameters["Identity"] == AXIS_X )
1985 1985
         {
1986
-         if ( $Pos == SCALE_POS_LEFTRIGHT )
1987
-          {
1988
-           if ( $Parameters["Position"] == AXIS_POSITION_BOTTOM )
1986
+            if ( $Pos == SCALE_POS_LEFTRIGHT )
1989 1987
             {
1990
-             if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $YLabelOffset = 2; }
1991
-             if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $YLabelOffset = 5; }
1992
-             if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $YLabelOffset = 5; }
1993
-             if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $YLabelOffset = 2; }
1988
+            if ( $Parameters["Position"] == AXIS_POSITION_BOTTOM )
1989
+            {
1990
+                if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $YLabelOffset = 2; }
1991
+                if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $YLabelOffset = 5; }
1992
+                if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $YLabelOffset = 5; }
1993
+                if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $YLabelOffset = 2; }
1994 1994
 
1995
-             if ( !$RemoveXAxis )
1996
-              {
1997
-               if ( $Floating )
1995
+                if ( !$RemoveXAxis )
1996
+                {
1997
+                if ( $Floating )
1998 1998
                 { $FloatingOffset = $YMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
1999
-               else
1999
+                else
2000 2000
                 { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["B"],$this->GraphAreaX2,$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2001 2001
 
2002
-               if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["B"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2003
-              }
2002
+                if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["B"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2003
+                }
2004 2004
 
2005
-             $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2005
+                $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2006 2006
 
2007
-             if ($Parameters["Rows"] == 0 ) { $Step  = $Width; } else { $Step  = $Width / ($Parameters["Rows"]); }
2007
+                if ($Parameters["Rows"] == 0 ) { $Step  = $Width; } else { $Step  = $Width / ($Parameters["Rows"]); }
2008 2008
              
2009
-             $MaxBottom = $AxisPos["B"];
2010
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2011
-              {
2012
-               $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2013
-               $YPos  = $AxisPos["B"];
2009
+                $MaxBottom = $AxisPos["B"];
2010
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2011
+                {
2012
+                $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2013
+                $YPos  = $AxisPos["B"];
2014 2014
 
2015
-               if ( $Abscissa != NULL )
2015
+                if ( $Abscissa != NULL )
2016 2016
                 { if ( isset($Data["Series"][$Abscissa]["Data"][$i]) ) { $Value = $this->scaleFormat($Data["Series"][$Abscissa]["Data"][$i],$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]); } else { $Value = ""; } }
2017
-               else
2017
+                else
2018 2018
                 {
2019
-                 if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2020
-                  $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2021
-                 else
2022
-                  $Value = $i;
2019
+                    if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2020
+                    $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2021
+                    else
2022
+                    $Value = $i;
2023 2023
                 }
2024 2024
 
2025
-               $ID++; $Skipped = TRUE;
2026
-               if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2025
+                $ID++; $Skipped = TRUE;
2026
+                if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2027 2027
                 {
2028
-                 $Bounds    = $this->drawText($XPos,$YPos+$OuterTickWidth+$YLabelOffset,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2029
-                 $TxtBottom = $YPos+$OuterTickWidth+2+($Bounds[0]["Y"]-$Bounds[2]["Y"]);
2030
-                 $MaxBottom = max($MaxBottom,$TxtBottom);
2031
-                 $LastValue = $Value;
2032
-                 $Skipped   = FALSE;
2028
+                    $Bounds    = $this->drawText($XPos,$YPos+$OuterTickWidth+$YLabelOffset,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2029
+                    $TxtBottom = $YPos+$OuterTickWidth+2+($Bounds[0]["Y"]-$Bounds[2]["Y"]);
2030
+                    $MaxBottom = max($MaxBottom,$TxtBottom);
2031
+                    $LastValue = $Value;
2032
+                    $Skipped   = FALSE;
2033 2033
                 }
2034 2034
 
2035
-               if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2035
+                if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2036 2036
 
2037
-               if ( $Skipped )
2037
+                if ( $Skipped )
2038 2038
                 {
2039
-                 if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$SkippedAxisColor); }
2040
-                 if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos-$SkippedInnerTickWidth,$XPos,$YPos+$SkippedOuterTickWidth,$SkippedTickColor); }
2039
+                    if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$SkippedAxisColor); }
2040
+                    if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos-$SkippedInnerTickWidth,$XPos,$YPos+$SkippedOuterTickWidth,$SkippedTickColor); }
2041 2041
                 }
2042
-               else
2042
+                else
2043 2043
                 {
2044
-                 if ( $DrawXLines && ($XPos != $this->GraphAreaX1 && $XPos != $this->GraphAreaX2) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2045
-                 if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos-$InnerTickWidth,$XPos,$YPos+$OuterTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2044
+                    if ( $DrawXLines && ($XPos != $this->GraphAreaX1 && $XPos != $this->GraphAreaX2) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2045
+                    if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos-$InnerTickWidth,$XPos,$YPos+$OuterTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2046
+                }
2046 2047
                 }
2047
-              }
2048 2048
 
2049
-             if ( isset($Parameters["Name"]) && !$RemoveXAxis)
2050
-              {
2051
-               $YPos   = $MaxBottom+2;
2052
-               $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2053
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2054
-               $MaxBottom = $Bounds[0]["Y"];
2049
+                if ( isset($Parameters["Name"]) && !$RemoveXAxis)
2050
+                {
2051
+                $YPos   = $MaxBottom+2;
2052
+                $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2053
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2054
+                $MaxBottom = $Bounds[0]["Y"];
2055 2055
 
2056
-               $this->DataSet->Data["GraphArea"]["Y2"] = $MaxBottom + $this->FontSize;
2057
-              }
2056
+                $this->DataSet->Data["GraphArea"]["Y2"] = $MaxBottom + $this->FontSize;
2057
+                }
2058 2058
 
2059
-             $AxisPos["B"] = $MaxBottom + $ScaleSpacing;
2059
+                $AxisPos["B"] = $MaxBottom + $ScaleSpacing;
2060 2060
             }
2061
-           elseif ( $Parameters["Position"] == AXIS_POSITION_TOP )
2061
+            elseif ( $Parameters["Position"] == AXIS_POSITION_TOP )
2062 2062
             {
2063
-             if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $YLabelOffset = 2; }
2064
-             if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $YLabelOffset = 2; }
2065
-             if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $YLabelOffset = 5; }
2066
-             if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $YLabelOffset = 5; }
2063
+                if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_BOTTOMMIDDLE; $YLabelOffset = 2; }
2064
+                if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $YLabelOffset = 2; }
2065
+                if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_TOPMIDDLE; $YLabelOffset = 5; }
2066
+                if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $YLabelOffset = 5; }
2067 2067
 
2068
-             if ( !$RemoveXAxis )
2069
-              {
2070
-               if ( $Floating )
2068
+                if ( !$RemoveXAxis )
2069
+                {
2070
+                if ( $Floating )
2071 2071
                 { $FloatingOffset = $YMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2072
-               else
2072
+                else
2073 2073
                 { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["T"],$this->GraphAreaX2,$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2074 2074
 
2075
-               if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["T"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2076
-              }
2075
+                if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["T"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2076
+                }
2077 2077
 
2078
-             $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2078
+                $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2079 2079
 
2080
-             if ($Parameters["Rows"] == 0 ) { $Step  = $Width; } else { $Step  = $Width / $Parameters["Rows"]; }
2080
+                if ($Parameters["Rows"] == 0 ) { $Step  = $Width; } else { $Step  = $Width / $Parameters["Rows"]; }
2081 2081
              
2082
-             $MinTop = $AxisPos["T"];
2083
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2084
-              {
2085
-               $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2086
-               $YPos  = $AxisPos["T"];
2082
+                $MinTop = $AxisPos["T"];
2083
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2084
+                {
2085
+                $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2086
+                $YPos  = $AxisPos["T"];
2087 2087
 
2088
-               if ( $Abscissa != NULL )
2088
+                if ( $Abscissa != NULL )
2089 2089
                 { if ( isset($Data["Series"][$Abscissa]["Data"][$i]) ) { $Value = $this->scaleFormat($Data["Series"][$Abscissa]["Data"][$i],$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]); } else { $Value = ""; } }
2090
-               else
2090
+                else
2091 2091
                 {
2092
-                 if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2093
-                  $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2094
-                 else
2095
-                  $Value = $i;
2092
+                    if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2093
+                    $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2094
+                    else
2095
+                    $Value = $i;
2096 2096
                 }
2097 2097
 
2098
-               $ID++; $Skipped = TRUE;
2099
-               if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2098
+                $ID++; $Skipped = TRUE;
2099
+                if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2100 2100
                 {
2101
-                 $Bounds = $this->drawText($XPos,$YPos-$OuterTickWidth-$YLabelOffset,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2102
-                 $TxtBox = $YPos-$OuterTickWidth-2-($Bounds[0]["Y"]-$Bounds[2]["Y"]);
2103
-                 $MinTop = min($MinTop,$TxtBox);
2104
-                 $LastValue = $Value;
2105
-                 $Skipped   = FALSE;
2101
+                    $Bounds = $this->drawText($XPos,$YPos-$OuterTickWidth-$YLabelOffset,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2102
+                    $TxtBox = $YPos-$OuterTickWidth-2-($Bounds[0]["Y"]-$Bounds[2]["Y"]);
2103
+                    $MinTop = min($MinTop,$TxtBox);
2104
+                    $LastValue = $Value;
2105
+                    $Skipped   = FALSE;
2106 2106
                 }
2107 2107
 
2108
-               if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2108
+                if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2109 2109
 
2110
-               if ( $Skipped )
2110
+                if ( $Skipped )
2111 2111
                 {
2112
-                 if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$SkippedAxisColor); }
2113
-                 if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos+$SkippedInnerTickWidth,$XPos,$YPos-$SkippedOuterTickWidth,$SkippedTickColor); }
2112
+                    if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$SkippedAxisColor); }
2113
+                    if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos+$SkippedInnerTickWidth,$XPos,$YPos-$SkippedOuterTickWidth,$SkippedTickColor); }
2114 2114
                 }
2115
-               else
2115
+                else
2116 2116
                 {
2117
-                 if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2118
-                 if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos+$InnerTickWidth,$XPos,$YPos-$OuterTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2117
+                    if ( $DrawXLines ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2118
+                    if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos,$YPos+$InnerTickWidth,$XPos,$YPos-$OuterTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2119 2119
                 }
2120 2120
 
2121
-              }
2121
+                }
2122 2122
 
2123
-             if ( isset($Parameters["Name"]) && !$RemoveXAxis )
2124
-              {
2125
-               $YPos   = $MinTop-2;
2126
-               $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2127
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2128
-               $MinTop = $Bounds[2]["Y"];
2123
+                if ( isset($Parameters["Name"]) && !$RemoveXAxis )
2124
+                {
2125
+                $YPos   = $MinTop-2;
2126
+                $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2127
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2128
+                $MinTop = $Bounds[2]["Y"];
2129 2129
 
2130
-               $this->DataSet->Data["GraphArea"]["Y1"] = $MinTop;
2131
-              }
2130
+                $this->DataSet->Data["GraphArea"]["Y1"] = $MinTop;
2131
+                }
2132 2132
 
2133
-             $AxisPos["T"] = $MinTop - $ScaleSpacing;
2133
+                $AxisPos["T"] = $MinTop - $ScaleSpacing;
2134
+            }
2134 2135
             }
2135
-          }
2136
-         elseif ( $Pos == SCALE_POS_TOPBOTTOM )
2137
-          {
2138
-           if ( $Parameters["Position"] == AXIS_POSITION_LEFT )
2136
+            elseif ( $Pos == SCALE_POS_TOPBOTTOM )
2139 2137
             {
2140
-             if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = -2; }
2141
-             if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = -6; }
2142
-             if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = -2; }
2143
-             if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = -5; }
2138
+            if ( $Parameters["Position"] == AXIS_POSITION_LEFT )
2139
+            {
2140
+                if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = -2; }
2141
+                if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = -6; }
2142
+                if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = -2; }
2143
+                if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = -5; }
2144 2144
 
2145
-             if ( !$RemoveXAxis )
2146
-              {
2147
-               if ( $Floating )
2145
+                if ( !$RemoveXAxis )
2146
+                {
2147
+                if ( $Floating )
2148 2148
                 { $FloatingOffset = $YMargin; $this->drawLine($AxisPos["L"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2149
-               else
2149
+                else
2150 2150
                 { $FloatingOffset = 0; $this->drawLine($AxisPos["L"],$this->GraphAreaY1,$AxisPos["L"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2151 2151
 
2152
-               if ( $DrawArrows ) { $this->drawArrow($AxisPos["L"],$this->GraphAreaY2-$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY2+($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2153
-              }
2152
+                if ( $DrawArrows ) { $this->drawArrow($AxisPos["L"],$this->GraphAreaY2-$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY2+($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2153
+                }
2154 2154
 
2155
-             $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2155
+                $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2156 2156
 
2157
-             if ($Parameters["Rows"] == 0 ) { $Step  = $Height; } else { $Step   = $Height / $Parameters["Rows"]; }
2157
+                if ($Parameters["Rows"] == 0 ) { $Step  = $Height; } else { $Step   = $Height / $Parameters["Rows"]; }
2158 2158
 
2159
-             $MinLeft = $AxisPos["L"];
2160
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2161
-              {
2162
-               $YPos  = $this->GraphAreaY1 + $Parameters["Margin"] + $Step*$i;
2163
-               $XPos  = $AxisPos["L"];
2159
+                $MinLeft = $AxisPos["L"];
2160
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2161
+                {
2162
+                $YPos  = $this->GraphAreaY1 + $Parameters["Margin"] + $Step*$i;
2163
+                $XPos  = $AxisPos["L"];
2164 2164
 
2165
-               if ( $Abscissa != NULL )
2165
+                if ( $Abscissa != NULL )
2166 2166
                 { if ( isset($Data["Series"][$Abscissa]["Data"][$i]) ) { $Value = $this->scaleFormat($Data["Series"][$Abscissa]["Data"][$i],$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]); } else { $Value = ""; } }
2167
-               else
2167
+                else
2168 2168
                 {
2169
-                 if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2170
-                  $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2171
-                 else
2172
-                  $Value = $i;
2169
+                    if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2170
+                    $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2171
+                    else
2172
+                    $Value = $i;
2173 2173
                 }
2174 2174
 
2175
-               $ID++; $Skipped = TRUE;
2176
-               if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2175
+                $ID++; $Skipped = TRUE;
2176
+                if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2177 2177
                 {
2178
-                 $Bounds  = $this->drawText($XPos-$OuterTickWidth+$XLabelOffset,$YPos,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2179
-                 $TxtBox  = $XPos-$OuterTickWidth-2-($Bounds[1]["X"]-$Bounds[0]["X"]);
2180
-                 $MinLeft = min($MinLeft,$TxtBox);
2181
-                 $LastValue = $Value;
2182
-                 $Skipped   = FALSE;
2178
+                    $Bounds  = $this->drawText($XPos-$OuterTickWidth+$XLabelOffset,$YPos,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2179
+                    $TxtBox  = $XPos-$OuterTickWidth-2-($Bounds[1]["X"]-$Bounds[0]["X"]);
2180
+                    $MinLeft = min($MinLeft,$TxtBox);
2181
+                    $LastValue = $Value;
2182
+                    $Skipped   = FALSE;
2183 2183
                 }
2184 2184
 
2185
-               if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2185
+                if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2186 2186
 
2187
-               if ( $Skipped )
2187
+                if ( $Skipped )
2188 2188
                 {
2189
-                 if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,$SkippedAxisColor); }
2190
-                 if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos-$SkippedOuterTickWidth,$YPos,$XPos+$SkippedInnerTickWidth,$YPos,$SkippedTickColor); }
2189
+                    if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,$SkippedAxisColor); }
2190
+                    if ( ($SkippedInnerTickWidth !=0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos-$SkippedOuterTickWidth,$YPos,$XPos+$SkippedInnerTickWidth,$YPos,$SkippedTickColor); }
2191 2191
                 }
2192
-               else
2192
+                else
2193 2193
                 {
2194
-                 if ( $DrawXLines && ($YPos != $this->GraphAreaY1 && $YPos != $this->GraphAreaY2) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2195
-                 if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos-$OuterTickWidth,$YPos,$XPos+$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2194
+                    if ( $DrawXLines && ($YPos != $this->GraphAreaY1 && $YPos != $this->GraphAreaY2) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2195
+                    if ( ($InnerTickWidth !=0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos-$OuterTickWidth,$YPos,$XPos+$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2196 2196
                 }
2197 2197
 
2198
-              }
2199
-             if ( isset($Parameters["Name"]) && !$RemoveXAxis )
2200
-              {
2201
-               $XPos   = $MinLeft-2;
2202
-               $YPos   = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2203
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>90));
2204
-               $MinLeft = $Bounds[0]["X"];
2198
+                }
2199
+                if ( isset($Parameters["Name"]) && !$RemoveXAxis )
2200
+                {
2201
+                $XPos   = $MinLeft-2;
2202
+                $YPos   = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2203
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>90));
2204
+                $MinLeft = $Bounds[0]["X"];
2205 2205
 
2206
-               $this->DataSet->Data["GraphArea"]["X1"] = $MinLeft;
2207
-              }
2206
+                $this->DataSet->Data["GraphArea"]["X1"] = $MinLeft;
2207
+                }
2208 2208
 
2209
-             $AxisPos["L"] = $MinLeft - $ScaleSpacing;
2209
+                $AxisPos["L"] = $MinLeft - $ScaleSpacing;
2210 2210
             }
2211
-           elseif ( $Parameters["Position"] == AXIS_POSITION_RIGHT )
2211
+            elseif ( $Parameters["Position"] == AXIS_POSITION_RIGHT )
2212 2212
             {
2213
-             if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = 2; }
2214
-             if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = 6; }
2215
-             if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = 5; }
2216
-             if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = 7; }
2213
+                if ( $LabelRotation == 0 )					{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = 2; }
2214
+                if ( $LabelRotation > 0 && $LabelRotation < 190 )		{ $LabelAlign = TEXT_ALIGN_MIDDLELEFT; $XLabelOffset = 6; }
2215
+                if ( $LabelRotation == 180 )				{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = 5; }
2216
+                if ( $LabelRotation > 180 && $LabelRotation < 360 )	{ $LabelAlign = TEXT_ALIGN_MIDDLERIGHT; $XLabelOffset = 7; }
2217 2217
 
2218
-             if ( !$RemoveXAxis )
2219
-              {
2220
-               if ( $Floating )
2218
+                if ( !$RemoveXAxis )
2219
+                {
2220
+                if ( $Floating )
2221 2221
                 { $FloatingOffset = $YMargin; $this->drawLine($AxisPos["R"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2222
-               else
2222
+                else
2223 2223
                 { $FloatingOffset = 0; $this->drawLine($AxisPos["R"],$this->GraphAreaY1,$AxisPos["R"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2224 2224
 
2225
-               if ( $DrawArrows ) { $this->drawArrow($AxisPos["R"],$this->GraphAreaY2-$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY2+($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2226
-              }
2225
+                if ( $DrawArrows ) { $this->drawArrow($AxisPos["R"],$this->GraphAreaY2-$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY2+($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2226
+                }
2227 2227
 
2228
-             $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2228
+                $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2229 2229
 
2230
-             if ($Parameters["Rows"] == 0 ) { $Step  = $Height; } else { $Step   = $Height / $Parameters["Rows"]; }
2230
+                if ($Parameters["Rows"] == 0 ) { $Step  = $Height; } else { $Step   = $Height / $Parameters["Rows"]; }
2231 2231
              
2232
-             $MaxRight = $AxisPos["R"];
2233
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2234
-              {
2235
-               $YPos  = $this->GraphAreaY1 + $Parameters["Margin"] + $Step*$i;
2236
-               $XPos  = $AxisPos["R"];
2232
+                $MaxRight = $AxisPos["R"];
2233
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2234
+                {
2235
+                $YPos  = $this->GraphAreaY1 + $Parameters["Margin"] + $Step*$i;
2236
+                $XPos  = $AxisPos["R"];
2237 2237
 
2238
-               if ( $Abscissa != NULL )
2238
+                if ( $Abscissa != NULL )
2239 2239
                 { if ( isset($Data["Series"][$Abscissa]["Data"][$i]) ) { $Value = $this->scaleFormat($Data["Series"][$Abscissa]["Data"][$i],$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]); } else { $Value = ""; } }
2240
-               else
2240
+                else
2241 2241
                 {
2242
-                 if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2243
-                  $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2244
-                 else
2245
-                  $Value = $i;
2242
+                    if ( isset($Parameters["ScaleMin"]) && isset ($Parameters["RowHeight"]) )
2243
+                    $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Data["XAxisDisplay"],$Data["XAxisFormat"],$Data["XAxisUnit"]);
2244
+                    else
2245
+                    $Value = $i;
2246 2246
                 }
2247 2247
 
2248
-               $ID++; $Skipped = TRUE;
2249
-               if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2248
+                $ID++; $Skipped = TRUE;
2249
+                if ( $this->isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip) && !$RemoveXAxis)
2250 2250
                 {
2251
-                 $Bounds   = $this->drawText($XPos+$OuterTickWidth+$XLabelOffset,$YPos,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2252
-                 $TxtBox   = $XPos+$OuterTickWidth+2+($Bounds[1]["X"]-$Bounds[0]["X"]);
2253
-                 $MaxRight = max($MaxRight,$TxtBox);
2254
-                 $LastValue = $Value;
2255
-                 $Skipped   = FALSE;
2251
+                    $Bounds   = $this->drawText($XPos+$OuterTickWidth+$XLabelOffset,$YPos,$Value,array("Angle"=>$LabelRotation,"Align"=>$LabelAlign));
2252
+                    $TxtBox   = $XPos+$OuterTickWidth+2+($Bounds[1]["X"]-$Bounds[0]["X"]);
2253
+                    $MaxRight = max($MaxRight,$TxtBox);
2254
+                    $LastValue = $Value;
2255
+                    $Skipped   = FALSE;
2256 2256
                 }
2257 2257
 
2258
-               if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2258
+                if ( $RemoveXAxis ) { $Skipped   = FALSE; }
2259 2259
 
2260
-               if ( $Skipped )
2260
+                if ( $Skipped )
2261 2261
                 {
2262
-                 if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,$SkippedAxisColor); }
2263
-                 if ( ($SkippedInnerTickWidth != 0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos+$SkippedOuterTickWidth,$YPos,$XPos-$SkippedInnerTickWidth,$YPos,$SkippedTickColor); }
2262
+                    if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,$SkippedAxisColor); }
2263
+                    if ( ($SkippedInnerTickWidth != 0 || $SkippedOuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos+$SkippedOuterTickWidth,$YPos,$XPos-$SkippedInnerTickWidth,$YPos,$SkippedTickColor); }
2264 2264
                 }
2265
-               else
2265
+                else
2266 2266
                 {
2267
-                 if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2268
-                 if ( ($InnerTickWidth != 0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos+$OuterTickWidth,$YPos,$XPos-$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2267
+                    if ( $DrawXLines ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2268
+                    if ( ($InnerTickWidth != 0 || $OuterTickWidth != 0) && !$RemoveXAxis ) { $this->drawLine($XPos+$OuterTickWidth,$YPos,$XPos-$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha)); }
2269 2269
                 }
2270 2270
 
2271
-              }
2271
+                }
2272 2272
 
2273
-             if ( isset($Parameters["Name"]) && !$RemoveXAxis)
2274
-              {
2275
-               $XPos   = $MaxRight+4;
2276
-               $YPos   = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2277
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>270));
2278
-               $MaxRight = $Bounds[1]["X"];
2273
+                if ( isset($Parameters["Name"]) && !$RemoveXAxis)
2274
+                {
2275
+                $XPos   = $MaxRight+4;
2276
+                $YPos   = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2277
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>270));
2278
+                $MaxRight = $Bounds[1]["X"];
2279 2279
 
2280
-               $this->DataSet->Data["GraphArea"]["X2"] = $MaxRight + $this->FontSize;
2281
-              }
2280
+                $this->DataSet->Data["GraphArea"]["X2"] = $MaxRight + $this->FontSize;
2281
+                }
2282 2282
 
2283
-             $AxisPos["R"] = $MaxRight + $ScaleSpacing;
2283
+                $AxisPos["R"] = $MaxRight + $ScaleSpacing;
2284
+            }
2284 2285
             }
2285
-          }
2286 2286
         }
2287 2287
 
2288 2288
 
2289 2289
 
2290
-       if ( $Parameters["Identity"] == AXIS_Y )
2290
+        if ( $Parameters["Identity"] == AXIS_Y )
2291 2291
         {
2292
-         if ( $Pos == SCALE_POS_LEFTRIGHT )
2293
-          {
2294
-           if ( $Parameters["Position"] == AXIS_POSITION_LEFT )
2292
+            if ( $Pos == SCALE_POS_LEFTRIGHT )
2293
+            {
2294
+            if ( $Parameters["Position"] == AXIS_POSITION_LEFT )
2295 2295
             {
2296 2296
 
2297
-             if ( $Floating )
2298
-              { $FloatingOffset = $XMargin; $this->drawLine($AxisPos["L"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2299
-             else
2300
-              { $FloatingOffset = 0; $this->drawLine($AxisPos["L"],$this->GraphAreaY1,$AxisPos["L"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2297
+                if ( $Floating )
2298
+                { $FloatingOffset = $XMargin; $this->drawLine($AxisPos["L"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2299
+                else
2300
+                { $FloatingOffset = 0; $this->drawLine($AxisPos["L"],$this->GraphAreaY1,$AxisPos["L"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2301 2301
 
2302
-             if ( $DrawArrows ) { $this->drawArrow($AxisPos["L"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2302
+                if ( $DrawArrows ) { $this->drawArrow($AxisPos["L"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["L"],$this->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2303 2303
 
2304
-             $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2305
-             $Step   = $Height / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MinLeft = $AxisPos["L"];
2306
-             $LastY  = NULL;
2307
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2308
-              {
2309
-               $YPos  = $this->GraphAreaY2 - $Parameters["Margin"] - $Step*$i;
2310
-               $XPos  = $AxisPos["L"];
2311
-               $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2304
+                $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2305
+                $Step   = $Height / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MinLeft = $AxisPos["L"];
2306
+                $LastY  = NULL;
2307
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2308
+                {
2309
+                $YPos  = $this->GraphAreaY2 - $Parameters["Margin"] - $Step*$i;
2310
+                $XPos  = $AxisPos["L"];
2311
+                $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2312 2312
 
2313
-               if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2314
-               if ( $LastY != NULL && $CycleBackground && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($this->GraphAreaX1+$FloatingOffset,$LastY,$this->GraphAreaX2-$FloatingOffset,$YPos,$BGColor); }
2313
+                if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2314
+                if ( $LastY != NULL && $CycleBackground && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($this->GraphAreaX1+$FloatingOffset,$LastY,$this->GraphAreaX2-$FloatingOffset,$YPos,$BGColor); }
2315 2315
 
2316
-               if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2316
+                if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2317 2317
 
2318
-               if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2318
+                if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2319 2319
                 $this->drawLine($XPos-$OuterSubTickWidth,$YPos-$SubTicksSize,$XPos+$InnerSubTickWidth,$YPos-$SubTicksSize,array("R"=>$SubTickR,"G"=>$SubTickG,"B"=>$SubTickB,"Alpha"=>$SubTickAlpha));
2320 2320
 
2321
-               $this->drawLine($XPos-$OuterTickWidth,$YPos,$XPos+$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2322
-               $Bounds  = $this->drawText($XPos-$OuterTickWidth-2,$YPos,$Value,array("Align"=>TEXT_ALIGN_MIDDLERIGHT));
2323
-               $TxtLeft = $XPos-$OuterTickWidth-2-($Bounds[1]["X"]-$Bounds[0]["X"]);
2324
-               $MinLeft = min($MinLeft,$TxtLeft);
2321
+                $this->drawLine($XPos-$OuterTickWidth,$YPos,$XPos+$InnerTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2322
+                $Bounds  = $this->drawText($XPos-$OuterTickWidth-2,$YPos,$Value,array("Align"=>TEXT_ALIGN_MIDDLERIGHT));
2323
+                $TxtLeft = $XPos-$OuterTickWidth-2-($Bounds[1]["X"]-$Bounds[0]["X"]);
2324
+                $MinLeft = min($MinLeft,$TxtLeft);
2325 2325
 
2326
-               $LastY = $YPos;
2327
-              }
2326
+                $LastY = $YPos;
2327
+                }
2328 2328
 
2329
-             if ( isset($Parameters["Name"]) )
2330
-              {
2331
-               $XPos    = $MinLeft-2;
2332
-               $YPos    = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2333
-               $Bounds  = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>90));
2334
-               $MinLeft = $Bounds[2]["X"];
2329
+                if ( isset($Parameters["Name"]) )
2330
+                {
2331
+                $XPos    = $MinLeft-2;
2332
+                $YPos    = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2333
+                $Bounds  = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>90));
2334
+                $MinLeft = $Bounds[2]["X"];
2335 2335
 
2336
-               $this->DataSet->Data["GraphArea"]["X1"] = $MinLeft;
2337
-              }
2336
+                $this->DataSet->Data["GraphArea"]["X1"] = $MinLeft;
2337
+                }
2338 2338
 
2339
-             $AxisPos["L"] = $MinLeft - $ScaleSpacing;
2339
+                $AxisPos["L"] = $MinLeft - $ScaleSpacing;
2340 2340
             }
2341
-           elseif ( $Parameters["Position"] == AXIS_POSITION_RIGHT )
2341
+            elseif ( $Parameters["Position"] == AXIS_POSITION_RIGHT )
2342 2342
             {
2343
-             if ( $Floating )
2344
-              { $FloatingOffset = $XMargin; $this->drawLine($AxisPos["R"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2345
-             else
2346
-              { $FloatingOffset = 0; $this->drawLine($AxisPos["R"],$this->GraphAreaY1,$AxisPos["R"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2343
+                if ( $Floating )
2344
+                { $FloatingOffset = $XMargin; $this->drawLine($AxisPos["R"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY2-$Parameters["Margin"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2345
+                else
2346
+                { $FloatingOffset = 0; $this->drawLine($AxisPos["R"],$this->GraphAreaY1,$AxisPos["R"],$this->GraphAreaY2,array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2347 2347
 
2348
-             if ( $DrawArrows ) { $this->drawArrow($AxisPos["R"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2348
+                if ( $DrawArrows ) { $this->drawArrow($AxisPos["R"],$this->GraphAreaY1+$Parameters["Margin"],$AxisPos["R"],$this->GraphAreaY1-($ArrowSize*2),array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2349 2349
 
2350
-             $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2351
-             $Step   = $Height / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MaxLeft = $AxisPos["R"];
2352
-             $LastY  = NULL;
2353
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2354
-              {
2355
-               $YPos  = $this->GraphAreaY2 - $Parameters["Margin"] - $Step*$i;
2356
-               $XPos  = $AxisPos["R"];
2357
-               $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2350
+                $Height = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Parameters["Margin"]*2;
2351
+                $Step   = $Height / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MaxLeft = $AxisPos["R"];
2352
+                $LastY  = NULL;
2353
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2354
+                {
2355
+                $YPos  = $this->GraphAreaY2 - $Parameters["Margin"] - $Step*$i;
2356
+                $XPos  = $AxisPos["R"];
2357
+                $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2358 2358
 
2359
-               if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2360
-               if ( $LastY != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($this->GraphAreaX1+$FloatingOffset,$LastY,$this->GraphAreaX2-$FloatingOffset,$YPos,$BGColor); }
2359
+                if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2360
+                if ( $LastY != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($this->GraphAreaX1+$FloatingOffset,$LastY,$this->GraphAreaX2-$FloatingOffset,$YPos,$BGColor); }
2361 2361
 
2362
-               if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2362
+                if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($this->GraphAreaX1+$FloatingOffset,$YPos,$this->GraphAreaX2-$FloatingOffset,$YPos,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2363 2363
 
2364
-               if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2364
+                if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2365 2365
                 $this->drawLine($XPos-$OuterSubTickWidth,$YPos-$SubTicksSize,$XPos+$InnerSubTickWidth,$YPos-$SubTicksSize,array("R"=>$SubTickR,"G"=>$SubTickG,"B"=>$SubTickB,"Alpha"=>$SubTickAlpha));
2366 2366
 
2367
-               $this->drawLine($XPos-$InnerTickWidth,$YPos,$XPos+$OuterTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2368
-               $Bounds  = $this->drawText($XPos+$OuterTickWidth+2,$YPos,$Value,array("Align"=>TEXT_ALIGN_MIDDLELEFT));
2369
-               $TxtLeft = $XPos+$OuterTickWidth+2+($Bounds[1]["X"]-$Bounds[0]["X"]);
2370
-               $MaxLeft = max($MaxLeft,$TxtLeft);
2367
+                $this->drawLine($XPos-$InnerTickWidth,$YPos,$XPos+$OuterTickWidth,$YPos,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2368
+                $Bounds  = $this->drawText($XPos+$OuterTickWidth+2,$YPos,$Value,array("Align"=>TEXT_ALIGN_MIDDLELEFT));
2369
+                $TxtLeft = $XPos+$OuterTickWidth+2+($Bounds[1]["X"]-$Bounds[0]["X"]);
2370
+                $MaxLeft = max($MaxLeft,$TxtLeft);
2371 2371
 
2372
-               $LastY = $YPos;
2373
-              }
2372
+                $LastY = $YPos;
2373
+                }
2374 2374
 
2375
-             if ( isset($Parameters["Name"]) )
2376
-              {
2377
-               $XPos    = $MaxLeft+6;
2378
-               $YPos    = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2379
-               $Bounds  = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>270));
2380
-               $MaxLeft = $Bounds[2]["X"];
2375
+                if ( isset($Parameters["Name"]) )
2376
+                {
2377
+                $XPos    = $MaxLeft+6;
2378
+                $YPos    = $this->GraphAreaY1+($this->GraphAreaY2-$this->GraphAreaY1)/2;
2379
+                $Bounds  = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE,"Angle"=>270));
2380
+                $MaxLeft = $Bounds[2]["X"];
2381 2381
 
2382
-               $this->DataSet->Data["GraphArea"]["X2"] = $MaxLeft + $this->FontSize;
2383
-              }
2384
-             $AxisPos["R"] = $MaxLeft + $ScaleSpacing;
2382
+                $this->DataSet->Data["GraphArea"]["X2"] = $MaxLeft + $this->FontSize;
2383
+                }
2384
+                $AxisPos["R"] = $MaxLeft + $ScaleSpacing;
2385
+            }
2385 2386
             }
2386
-          }
2387
-         elseif ( $Pos == SCALE_POS_TOPBOTTOM )
2388
-          {
2389
-           if ( $Parameters["Position"] == AXIS_POSITION_TOP )
2387
+            elseif ( $Pos == SCALE_POS_TOPBOTTOM )
2390 2388
             {
2391
-             if ( $Floating )
2392
-              { $FloatingOffset = $XMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2393
-             else
2394
-              { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["T"],$this->GraphAreaX2,$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2389
+            if ( $Parameters["Position"] == AXIS_POSITION_TOP )
2390
+            {
2391
+                if ( $Floating )
2392
+                { $FloatingOffset = $XMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2393
+                else
2394
+                { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["T"],$this->GraphAreaX2,$AxisPos["T"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2395 2395
 
2396
-             if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["T"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2396
+                if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["T"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["T"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2397 2397
 
2398
-             $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2399
-             $Step   = $Width / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MinTop = $AxisPos["T"];
2400
-             $LastX  = NULL;
2401
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2402
-              {
2403
-               $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2404
-               $YPos  = $AxisPos["T"];
2405
-               $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2398
+                $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2399
+                $Step   = $Width / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MinTop = $AxisPos["T"];
2400
+                $LastX  = NULL;
2401
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2402
+                {
2403
+                $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2404
+                $YPos  = $AxisPos["T"];
2405
+                $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2406 2406
 
2407
-               if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2408
-               if ( $LastX != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($LastX,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$BGColor); }
2407
+                if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2408
+                if ( $LastX != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($LastX,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$BGColor); }
2409 2409
 
2410
-               if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2410
+                if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2411 2411
 
2412
-               if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2412
+                if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2413 2413
                 $this->drawLine($XPos+$SubTicksSize,$YPos-$OuterSubTickWidth,$XPos+$SubTicksSize,$YPos+$InnerSubTickWidth,array("R"=>$SubTickR,"G"=>$SubTickG,"B"=>$SubTickB,"Alpha"=>$SubTickAlpha));
2414 2414
 
2415
-               $this->drawLine($XPos,$YPos-$OuterTickWidth,$XPos,$YPos+$InnerTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2416
-               $Bounds    = $this->drawText($XPos,$YPos-$OuterTickWidth-2,$Value,array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2417
-               $TxtHeight = $YPos-$OuterTickWidth-2-($Bounds[1]["Y"]-$Bounds[2]["Y"]);
2418
-               $MinTop    = min($MinTop,$TxtHeight);
2415
+                $this->drawLine($XPos,$YPos-$OuterTickWidth,$XPos,$YPos+$InnerTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2416
+                $Bounds    = $this->drawText($XPos,$YPos-$OuterTickWidth-2,$Value,array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2417
+                $TxtHeight = $YPos-$OuterTickWidth-2-($Bounds[1]["Y"]-$Bounds[2]["Y"]);
2418
+                $MinTop    = min($MinTop,$TxtHeight);
2419 2419
 
2420
-               $LastX = $XPos;
2421
-              }
2420
+                $LastX = $XPos;
2421
+                }
2422 2422
 
2423
-             if ( isset($Parameters["Name"]) )
2424
-              {
2425
-               $YPos   = $MinTop-2;
2426
-               $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2427
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2428
-               $MinTop = $Bounds[2]["Y"];
2423
+                if ( isset($Parameters["Name"]) )
2424
+                {
2425
+                $YPos   = $MinTop-2;
2426
+                $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2427
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
2428
+                $MinTop = $Bounds[2]["Y"];
2429 2429
 
2430
-               $this->DataSet->Data["GraphArea"]["Y1"] = $MinTop;
2431
-              }
2430
+                $this->DataSet->Data["GraphArea"]["Y1"] = $MinTop;
2431
+                }
2432 2432
 
2433
-             $AxisPos["T"] = $MinTop - $ScaleSpacing;
2433
+                $AxisPos["T"] = $MinTop - $ScaleSpacing;
2434 2434
             }
2435
-           elseif ( $Parameters["Position"] == AXIS_POSITION_BOTTOM )
2435
+            elseif ( $Parameters["Position"] == AXIS_POSITION_BOTTOM )
2436 2436
             {
2437
-             if ( $Floating )
2438
-              { $FloatingOffset = $XMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2439
-             else
2440
-              { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["B"],$this->GraphAreaX2,$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2437
+                if ( $Floating )
2438
+                { $FloatingOffset = $XMargin; $this->drawLine($this->GraphAreaX1+$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2439
+                else
2440
+                { $FloatingOffset = 0; $this->drawLine($this->GraphAreaX1,$AxisPos["B"],$this->GraphAreaX2,$AxisPos["B"],array("R"=>$AxisR,"G"=>$AxisG,"B"=>$AxisB,"Alpha"=>$AxisAlpha)); }
2441 2441
 
2442
-             if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["B"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2442
+                if ( $DrawArrows ) { $this->drawArrow($this->GraphAreaX2-$Parameters["Margin"],$AxisPos["B"],$this->GraphAreaX2+($ArrowSize*2),$AxisPos["B"],array("FillR"=>$AxisR,"FillG"=>$AxisG,"FillB"=>$AxisB,"Size"=>$ArrowSize)); }
2443 2443
 
2444
-             $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2445
-             $Step   = $Width / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MaxBottom = $AxisPos["B"];
2446
-             $LastX  = NULL;
2447
-             for($i=0;$i<=$Parameters["Rows"];$i++)
2448
-              {
2449
-               $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2450
-               $YPos  = $AxisPos["B"];
2451
-               $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2444
+                $Width = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Parameters["Margin"]*2;
2445
+                $Step   = $Width / $Parameters["Rows"]; $SubTicksSize = $Step /2; $MaxBottom = $AxisPos["B"];
2446
+                $LastX  = NULL;
2447
+                for($i=0;$i<=$Parameters["Rows"];$i++)
2448
+                {
2449
+                $XPos  = $this->GraphAreaX1 + $Parameters["Margin"] + $Step*$i;
2450
+                $YPos  = $AxisPos["B"];
2451
+                $Value = $this->scaleFormat($Parameters["ScaleMin"] + $Parameters["RowHeight"]*$i,$Parameters["Display"],$Parameters["Format"],$Parameters["Unit"]);
2452 2452
 
2453
-               if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2454
-               if ( $LastX != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($LastX,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$BGColor); }
2453
+                if ( $i%2 == 1 ) { $BGColor = array("R"=>$BackgroundR1,"G"=>$BackgroundG1,"B"=>$BackgroundB1,"Alpha"=>$BackgroundAlpha1); } else { $BGColor = array("R"=>$BackgroundR2,"G"=>$BackgroundG2,"B"=>$BackgroundB2,"Alpha"=>$BackgroundAlpha2); }
2454
+                if ( $LastX != NULL && $CycleBackground  && ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) )) { $this->drawFilledRectangle($LastX,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,$BGColor); }
2455 2455
 
2456
-               if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2456
+                if ( $DrawYLines == ALL || in_array($AxisID,$DrawYLines) ) { $this->drawLine($XPos,$this->GraphAreaY1+$FloatingOffset,$XPos,$this->GraphAreaY2-$FloatingOffset,array("R"=>$GridR,"G"=>$GridG,"B"=>$GridB,"Alpha"=>$GridAlpha,"Ticks"=>$GridTicks)); }
2457 2457
 
2458
-               if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2458
+                if ( $DrawSubTicks && $i != $Parameters["Rows"] )
2459 2459
                 $this->drawLine($XPos+$SubTicksSize,$YPos-$OuterSubTickWidth,$XPos+$SubTicksSize,$YPos+$InnerSubTickWidth,array("R"=>$SubTickR,"G"=>$SubTickG,"B"=>$SubTickB,"Alpha"=>$SubTickAlpha));
2460 2460
 
2461
-               $this->drawLine($XPos,$YPos-$OuterTickWidth,$XPos,$YPos+$InnerTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2462
-               $Bounds    = $this->drawText($XPos,$YPos+$OuterTickWidth+2,$Value,array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2463
-               $TxtHeight = $YPos+$OuterTickWidth+2+($Bounds[1]["Y"]-$Bounds[2]["Y"]);
2464
-               $MaxBottom = max($MaxBottom,$TxtHeight);
2461
+                $this->drawLine($XPos,$YPos-$OuterTickWidth,$XPos,$YPos+$InnerTickWidth,array("R"=>$TickR,"G"=>$TickG,"B"=>$TickB,"Alpha"=>$TickAlpha));
2462
+                $Bounds    = $this->drawText($XPos,$YPos+$OuterTickWidth+2,$Value,array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2463
+                $TxtHeight = $YPos+$OuterTickWidth+2+($Bounds[1]["Y"]-$Bounds[2]["Y"]);
2464
+                $MaxBottom = max($MaxBottom,$TxtHeight);
2465 2465
 
2466
-               $LastX = $XPos;
2467
-              }
2466
+                $LastX = $XPos;
2467
+                }
2468 2468
 
2469
-             if ( isset($Parameters["Name"]) )
2470
-              {
2471
-               $YPos   = $MaxBottom+2;
2472
-               $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2473
-               $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2474
-               $MaxBottom = $Bounds[0]["Y"];
2469
+                if ( isset($Parameters["Name"]) )
2470
+                {
2471
+                $YPos   = $MaxBottom+2;
2472
+                $XPos   = $this->GraphAreaX1+($this->GraphAreaX2-$this->GraphAreaX1)/2;
2473
+                $Bounds = $this->drawText($XPos,$YPos,$Parameters["Name"],array("Align"=>TEXT_ALIGN_TOPMIDDLE));
2474
+                $MaxBottom = $Bounds[0]["Y"];
2475 2475
 
2476
-               $this->DataSet->Data["GraphArea"]["Y2"] = $MaxBottom + $this->FontSize;
2477
-              }
2476
+                $this->DataSet->Data["GraphArea"]["Y2"] = $MaxBottom + $this->FontSize;
2477
+                }
2478 2478
 
2479
-             $AxisPos["B"] = $MaxBottom + $ScaleSpacing;
2479
+                $AxisPos["B"] = $MaxBottom + $ScaleSpacing;
2480
+            }
2480 2481
             }
2481
-          }
2482 2482
         }
2483
-      }
2483
+        }
2484 2484
     }
2485 2485
 
2486
-   function isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip)
2486
+    function isValidLabel($Value,$LastValue,$LabelingMethod,$ID,$LabelSkip)
2487 2487
     {
2488
-     if ( $LabelingMethod == LABELING_DIFFERENT && $Value != $LastValue ) { return(TRUE); }
2489
-     if ( $LabelingMethod == LABELING_DIFFERENT && $Value == $LastValue ) { return(FALSE); }
2490
-     if ( $LabelingMethod == LABELING_ALL && $LabelSkip == 0 ) { return(TRUE); }
2491
-     if ( $LabelingMethod == LABELING_ALL && ($ID+$LabelSkip) % ($LabelSkip+1) != 1 ) { return(FALSE); }
2488
+        if ( $LabelingMethod == LABELING_DIFFERENT && $Value != $LastValue ) { return(TRUE); }
2489
+        if ( $LabelingMethod == LABELING_DIFFERENT && $Value == $LastValue ) { return(FALSE); }
2490
+        if ( $LabelingMethod == LABELING_ALL && $LabelSkip == 0 ) { return(TRUE); }
2491
+        if ( $LabelingMethod == LABELING_ALL && ($ID+$LabelSkip) % ($LabelSkip+1) != 1 ) { return(FALSE); }
2492 2492
 
2493
-     return(TRUE);
2493
+        return(TRUE);
2494 2494
     }
2495 2495
 
2496
-   /* Compute the scale, check for the best visual factors */
2497
-   function computeScale($XMin,$XMax,$MaxDivs,$Factors,$AxisID=0)
2496
+    /* Compute the scale, check for the best visual factors */
2497
+    function computeScale($XMin,$XMax,$MaxDivs,$Factors,$AxisID=0)
2498 2498
     {
2499
-     /* Compute each factors */
2500
-     $Results = "";
2501
-     foreach ($Factors as $Key => $Factor)
2502
-      $Results[$Factor] = $this->processScale($XMin,$XMax,$MaxDivs,array($Factor),$AxisID);
2503
-
2504
-     /* Remove scales that are creating to much decimals */
2505
-     $GoodScaleFactors = "";
2506
-     foreach ($Results as $Key => $Result)
2507
-      {
2508
-       $Decimals = preg_split("/\./",$Result["RowHeight"]);
2509
-       if ( (!isset($Decimals[1])) || (strlen($Decimals[1]) < 6) ) { $GoodScaleFactors[] = $Key; }
2510
-      }
2511
-
2512
-     /* Found no correct scale, shame,... returns the 1st one as default */
2513
-     if ( $GoodScaleFactors == "" ) { return($Results[$Factors[0]]); }
2514
-
2515
-     /* Find the factor that cause the maximum number of Rows */
2516
-     $MaxRows = 0; $BestFactor = 0;
2517
-     foreach($GoodScaleFactors as $Key => $Factor)
2518
-      { if ( $Results[$Factor]["Rows"] > $MaxRows ) { $MaxRows = $Results[$Factor]["Rows"]; $BestFactor = $Factor; } }
2519
-
2520
-     /* Return the best visual scale */
2521
-     return($Results[$BestFactor]);
2499
+        /* Compute each factors */
2500
+        $Results = "";
2501
+        foreach ($Factors as $Key => $Factor)
2502
+        $Results[$Factor] = $this->processScale($XMin,$XMax,$MaxDivs,array($Factor),$AxisID);
2503
+
2504
+        /* Remove scales that are creating to much decimals */
2505
+        $GoodScaleFactors = "";
2506
+        foreach ($Results as $Key => $Result)
2507
+        {
2508
+        $Decimals = preg_split("/\./",$Result["RowHeight"]);
2509
+        if ( (!isset($Decimals[1])) || (strlen($Decimals[1]) < 6) ) { $GoodScaleFactors[] = $Key; }
2510
+        }
2511
+
2512
+        /* Found no correct scale, shame,... returns the 1st one as default */
2513
+        if ( $GoodScaleFactors == "" ) { return($Results[$Factors[0]]); }
2514
+
2515
+        /* Find the factor that cause the maximum number of Rows */
2516
+        $MaxRows = 0; $BestFactor = 0;
2517
+        foreach($GoodScaleFactors as $Key => $Factor)
2518
+        { if ( $Results[$Factor]["Rows"] > $MaxRows ) { $MaxRows = $Results[$Factor]["Rows"]; $BestFactor = $Factor; } }
2519
+
2520
+        /* Return the best visual scale */
2521
+        return($Results[$BestFactor]);
2522 2522
     }
2523 2523
 
2524
-   /* Compute the best matching scale based on size & factors */
2525
-   function processScale($XMin,$XMax,$MaxDivs,$Factors,$AxisID)
2524
+    /* Compute the best matching scale based on size & factors */
2525
+    function processScale($XMin,$XMax,$MaxDivs,$Factors,$AxisID)
2526 2526
     {
2527
-     $ScaleHeight = abs(ceil($XMax)-floor($XMin));
2527
+        $ScaleHeight = abs(ceil($XMax)-floor($XMin));
2528 2528
 
2529
-     if ( isset($this->DataSet->Data["Axis"][$AxisID]["Format"]) )
2530
-      $Format = $this->DataSet->Data["Axis"][$AxisID]["Format"];
2531
-     else
2532
-      $Format = NULL;
2529
+        if ( isset($this->DataSet->Data["Axis"][$AxisID]["Format"]) )
2530
+        $Format = $this->DataSet->Data["Axis"][$AxisID]["Format"];
2531
+        else
2532
+        $Format = NULL;
2533 2533
 
2534
-     if ( isset($this->DataSet->Data["Axis"][$AxisID]["Display"]) )
2535
-      $Mode = $this->DataSet->Data["Axis"][$AxisID]["Display"];
2536
-     else
2537
-      $Mode = AXIS_FORMAT_DEFAULT;
2534
+        if ( isset($this->DataSet->Data["Axis"][$AxisID]["Display"]) )
2535
+        $Mode = $this->DataSet->Data["Axis"][$AxisID]["Display"];
2536
+        else
2537
+        $Mode = AXIS_FORMAT_DEFAULT;
2538 2538
 
2539
-     $Scale = "";
2540
-     if ( $XMin != $XMax )
2541
-      {
2542
-       $Found = FALSE; $Rescaled = FALSE; $Scaled10Factor = .0001; $Result = 0;
2543
-       while(!$Found)
2539
+        $Scale = "";
2540
+        if ( $XMin != $XMax )
2544 2541
         {
2545
-         foreach($Factors as $Key => $Factor)
2546
-          {
2547
-           if ( !$Found )
2542
+        $Found = FALSE; $Rescaled = FALSE; $Scaled10Factor = .0001; $Result = 0;
2543
+        while(!$Found)
2544
+        {
2545
+            foreach($Factors as $Key => $Factor)
2546
+            {
2547
+            if ( !$Found )
2548 2548
             {
2549
-             if ( !($this->modulo($XMin,$Factor*$Scaled10Factor) == 0) || ($XMin != floor($XMin))) { $XMinRescaled = floor($XMin/($Factor*$Scaled10Factor))*$Factor*$Scaled10Factor; } else { $XMinRescaled = $XMin; }
2550
-             if ( !($this->modulo($XMax,$Factor*$Scaled10Factor) == 0) || ($XMax != floor($XMax))) { $XMaxRescaled = floor($XMax/($Factor*$Scaled10Factor))*$Factor*$Scaled10Factor+($Factor*$Scaled10Factor); } else { $XMaxRescaled = $XMax; }
2551
-             $ScaleHeightRescaled = abs($XMaxRescaled-$XMinRescaled);
2549
+                if ( !($this->modulo($XMin,$Factor*$Scaled10Factor) == 0) || ($XMin != floor($XMin))) { $XMinRescaled = floor($XMin/($Factor*$Scaled10Factor))*$Factor*$Scaled10Factor; } else { $XMinRescaled = $XMin; }
2550
+                if ( !($this->modulo($XMax,$Factor*$Scaled10Factor) == 0) || ($XMax != floor($XMax))) { $XMaxRescaled = floor($XMax/($Factor*$Scaled10Factor))*$Factor*$Scaled10Factor+($Factor*$Scaled10Factor); } else { $XMaxRescaled = $XMax; }
2551
+                $ScaleHeightRescaled = abs($XMaxRescaled-$XMinRescaled);
2552 2552
 
2553
-             if ( !$Found && floor($ScaleHeightRescaled/($Factor*$Scaled10Factor)) <= $MaxDivs ) { $Found = TRUE; $Rescaled = TRUE; $Result = $Factor * $Scaled10Factor; }
2553
+                if ( !$Found && floor($ScaleHeightRescaled/($Factor*$Scaled10Factor)) <= $MaxDivs ) { $Found = TRUE; $Rescaled = TRUE; $Result = $Factor * $Scaled10Factor; }
2554 2554
             }
2555
-          }
2556
-         $Scaled10Factor = $Scaled10Factor * 10;
2555
+            }
2556
+            $Scaled10Factor = $Scaled10Factor * 10;
2557 2557
         }
2558 2558
 
2559
-       /* ReCall Min / Max / Height */
2560
-       if ( $Rescaled ) { $XMin = $XMinRescaled; $XMax = $XMaxRescaled; $ScaleHeight = $ScaleHeightRescaled; }
2559
+        /* ReCall Min / Max / Height */
2560
+        if ( $Rescaled ) { $XMin = $XMinRescaled; $XMax = $XMaxRescaled; $ScaleHeight = $ScaleHeightRescaled; }
2561 2561
 
2562
-       /* Compute rows size */
2563
-       $Rows      = floor($ScaleHeight / $Result); if ( $Rows == 0 ) { $Rows = 1; }
2564
-       $RowHeight = $ScaleHeight / $Rows;
2562
+        /* Compute rows size */
2563
+        $Rows      = floor($ScaleHeight / $Result); if ( $Rows == 0 ) { $Rows = 1; }
2564
+        $RowHeight = $ScaleHeight / $Rows;
2565 2565
 
2566
-       /* Return the results */
2567
-       $Scale["Rows"] = $Rows; $Scale["RowHeight"] = $RowHeight; $Scale["XMin"] = $XMin;  $Scale["XMax"] = $XMax;
2566
+        /* Return the results */
2567
+        $Scale["Rows"] = $Rows; $Scale["RowHeight"] = $RowHeight; $Scale["XMin"] = $XMin;  $Scale["XMax"] = $XMax;
2568 2568
 
2569
-       /* Compute the needed decimals for the metric view to avoid repetition of the same X Axis labels */
2570
-       if ( $Mode == AXIS_FORMAT_METRIC && $Format == NULL )
2569
+        /* Compute the needed decimals for the metric view to avoid repetition of the same X Axis labels */
2570
+        if ( $Mode == AXIS_FORMAT_METRIC && $Format == NULL )
2571 2571
         {
2572
-         $Done = FALSE; $GoodDecimals = 0;
2573
-         for($Decimals=0;$Decimals<=10;$Decimals++)
2574
-          {
2575
-           if ( !$Done )
2572
+            $Done = FALSE; $GoodDecimals = 0;
2573
+            for($Decimals=0;$Decimals<=10;$Decimals++)
2574
+            {
2575
+            if ( !$Done )
2576 2576
             {
2577
-             $LastLabel = "zob"; $ScaleOK = TRUE;
2578
-             for($i=0;$i<=$Rows;$i++)
2579
-              {
2580
-               $Value = $XMin + $i*$RowHeight;
2581
-               $Label = $this->scaleFormat($Value,AXIS_FORMAT_METRIC,$Decimals);
2577
+                $LastLabel = "zob"; $ScaleOK = TRUE;
2578
+                for($i=0;$i<=$Rows;$i++)
2579
+                {
2580
+                $Value = $XMin + $i*$RowHeight;
2581
+                $Label = $this->scaleFormat($Value,AXIS_FORMAT_METRIC,$Decimals);
2582 2582
 
2583
-               if ( $LastLabel == $Label ) { $ScaleOK = FALSE; }
2584
-               $LastLabel = $Label;
2585
-              }
2586
-             if ( $ScaleOK ) { $Done = TRUE; $GoodDecimals = $Decimals; }
2583
+                if ( $LastLabel == $Label ) { $ScaleOK = FALSE; }
2584
+                $LastLabel = $Label;
2585
+                }
2586
+                if ( $ScaleOK ) { $Done = TRUE; $GoodDecimals = $Decimals; }
2587
+            }
2587 2588
             }
2588
-          }
2589 2589
 
2590
-         $Scale["Format"] = $GoodDecimals;
2590
+            $Scale["Format"] = $GoodDecimals;
2591
+        }
2591 2592
         }
2592
-      }
2593
-     else
2594
-      {
2595
-       /* If all values are the same we keep a +1/-1 scale */
2596
-       $Rows = 2; $XMin = $XMax-1; $XMax = $XMax+1; $RowHeight = 1;
2593
+        else
2594
+        {
2595
+        /* If all values are the same we keep a +1/-1 scale */
2596
+        $Rows = 2; $XMin = $XMax-1; $XMax = $XMax+1; $RowHeight = 1;
2597 2597
 
2598
-       /* Return the results */
2599
-       $Scale["Rows"] = $Rows; $Scale["RowHeight"] = $RowHeight; $Scale["XMin"] = $XMin;  $Scale["XMax"] = $XMax;
2600
-      }
2598
+        /* Return the results */
2599
+        $Scale["Rows"] = $Rows; $Scale["RowHeight"] = $RowHeight; $Scale["XMin"] = $XMin;  $Scale["XMax"] = $XMax;
2600
+        }
2601 2601
 
2602
-     return($Scale);
2602
+        return($Scale);
2603 2603
     }
2604 2604
 
2605
-   function modulo($Value1,$Value2)
2605
+    function modulo($Value1,$Value2)
2606 2606
     {
2607
-     if (floor($Value2) == 0) { return(0); }
2608
-     if (floor($Value2) != 0) { return($Value1 % $Value2); }
2607
+        if (floor($Value2) == 0) { return(0); }
2608
+        if (floor($Value2) != 0) { return($Value1 % $Value2); }
2609 2609
 
2610
-     $MinValue = min($Value1,$Value2); $Factor = 10;
2611
-     while ( floor($MinValue*$Factor) == 0 )
2612
-      { $Factor = $Factor * 10; }
2610
+        $MinValue = min($Value1,$Value2); $Factor = 10;
2611
+        while ( floor($MinValue*$Factor) == 0 )
2612
+        { $Factor = $Factor * 10; }
2613 2613
 
2614
-     return(($Value1*$Factor) % ($Value2*$Factor));
2614
+        return(($Value1*$Factor) % ($Value2*$Factor));
2615 2615
     }
2616 2616
 
2617
-   /* Draw an X threshold */
2618
-   function drawXThreshold($Value,$Format="")
2617
+    /* Draw an X threshold */
2618
+    function drawXThreshold($Value,$Format="")
2619 2619
     {
2620
-     $R			= isset($Format["R"]) ? $Format["R"] : 255;
2621
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
2622
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
2623
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 50;
2624
-     $Weight		= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
2625
-     $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : 6;
2626
-     $Wide		= isset($Format["Wide"]) ? $Format["Wide"] : FALSE;
2627
-     $WideFactor	= isset($Format["WideFactor"]) ? $Format["WideFactor"] : 5;
2628
-     $WriteCaption	= isset($Format["WriteCaption"]) ? $Format["WriteCaption"] : FALSE;
2629
-     $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : NULL;
2630
-     $CaptionAlign	= isset($Format["CaptionAlign"]) ? $Format["CaptionAlign"] : CAPTION_LEFT_TOP;
2631
-     $CaptionOffset     = isset($Format["CaptionOffset"]) ? $Format["CaptionOffset"] : 5;
2632
-     $CaptionR		= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
2633
-     $CaptionG		= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
2634
-     $CaptionB		= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
2635
-     $CaptionAlpha	= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
2636
-     $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
2637
-     $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
2638
-     $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 3;
2639
-     $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
2640
-     $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
2641
-     $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
2642
-     $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
2643
-     $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
2644
-     $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 30;
2645
-     $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
2646
-     $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
2647
-     $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
2648
-     $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
2649
-     $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
2650
-     $ValueIsLabel	= isset($Format["ValueIsLabel"]) ? $Format["ValueIsLabel"] : FALSE;
2651
-
2652
-     $Data           = $this->DataSet->getData();
2653
-     $AbscissaMargin = $this->getAbscissaMargin($Data);
2654
-     $XScale         = $this->scaleGetXSettings();
2655
-
2656
-     if ( is_array($Value) ) { foreach ($Value as $Key => $ID) { $this->drawXThreshold($ID,$Format); } return(0); }
2657
-
2658
-     if ( $ValueIsLabel )
2659
-      {
2660
-       $Format["ValueIsLabel"] = FALSE;
2661
-       foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $SerieValue)
2620
+        $R			= isset($Format["R"]) ? $Format["R"] : 255;
2621
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
2622
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
2623
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 50;
2624
+        $Weight		= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
2625
+        $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : 6;
2626
+        $Wide		= isset($Format["Wide"]) ? $Format["Wide"] : FALSE;
2627
+        $WideFactor	= isset($Format["WideFactor"]) ? $Format["WideFactor"] : 5;
2628
+        $WriteCaption	= isset($Format["WriteCaption"]) ? $Format["WriteCaption"] : FALSE;
2629
+        $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : NULL;
2630
+        $CaptionAlign	= isset($Format["CaptionAlign"]) ? $Format["CaptionAlign"] : CAPTION_LEFT_TOP;
2631
+        $CaptionOffset     = isset($Format["CaptionOffset"]) ? $Format["CaptionOffset"] : 5;
2632
+        $CaptionR		= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
2633
+        $CaptionG		= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
2634
+        $CaptionB		= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
2635
+        $CaptionAlpha	= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
2636
+        $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
2637
+        $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
2638
+        $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 3;
2639
+        $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
2640
+        $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
2641
+        $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
2642
+        $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
2643
+        $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
2644
+        $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 30;
2645
+        $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
2646
+        $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
2647
+        $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
2648
+        $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
2649
+        $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
2650
+        $ValueIsLabel	= isset($Format["ValueIsLabel"]) ? $Format["ValueIsLabel"] : FALSE;
2651
+
2652
+        $Data           = $this->DataSet->getData();
2653
+        $AbscissaMargin = $this->getAbscissaMargin($Data);
2654
+        $XScale         = $this->scaleGetXSettings();
2655
+
2656
+        if ( is_array($Value) ) { foreach ($Value as $Key => $ID) { $this->drawXThreshold($ID,$Format); } return(0); }
2657
+
2658
+        if ( $ValueIsLabel )
2659
+        {
2660
+        $Format["ValueIsLabel"] = FALSE;
2661
+        foreach($Data["Series"][$Data["Abscissa"]]["Data"] as $Key => $SerieValue)
2662 2662
         { if ( $SerieValue == $Value ) { $this->drawXThreshold($Key,$Format); } }
2663 2663
 
2664
-       return(0);
2665
-      }
2664
+        return(0);
2665
+        }
2666 2666
 
2667
-     $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
2668
-                              "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
2669
-                              "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha,
2670
-                              "R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha);
2667
+        $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
2668
+                                "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
2669
+                                "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha,
2670
+                                "R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha);
2671 2671
 
2672
-     if ( $Caption == NULL )
2673
-      {
2674
-       if ( isset($Data["Abscissa"]) )
2672
+        if ( $Caption == NULL )
2675 2673
         {
2676
-         if ( isset($Data["Series"][$Data["Abscissa"]]["Data"][$Value]) )
2677
-          $Caption = $Data["Series"][$Data["Abscissa"]]["Data"][$Value];
2678
-         else
2679
-          $Caption = $Value;
2674
+        if ( isset($Data["Abscissa"]) )
2675
+        {
2676
+            if ( isset($Data["Series"][$Data["Abscissa"]]["Data"][$Value]) )
2677
+            $Caption = $Data["Series"][$Data["Abscissa"]]["Data"][$Value];
2678
+            else
2679
+            $Caption = $Value;
2680 2680
         }
2681
-       else
2681
+        else
2682 2682
         $Caption = $Value;
2683
-      }
2683
+        }
2684 2684
 
2685
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2686
-      {
2687
-       $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] *2 ) / $XScale[1];
2688
-       $XPos  = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value;
2689
-       $YPos1 = $this->GraphAreaY1 + $Data["YMargin"];
2690
-       $YPos2 = $this->GraphAreaY2 - $Data["YMargin"];
2685
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2686
+        {
2687
+        $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] *2 ) / $XScale[1];
2688
+        $XPos  = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value;
2689
+        $YPos1 = $this->GraphAreaY1 + $Data["YMargin"];
2690
+        $YPos2 = $this->GraphAreaY2 - $Data["YMargin"];
2691 2691
 
2692
-       if ( $XPos >= $this->GraphAreaX1 + $AbscissaMargin && $XPos <= $this->GraphAreaX2 - $AbscissaMargin )
2692
+        if ( $XPos >= $this->GraphAreaX1 + $AbscissaMargin && $XPos <= $this->GraphAreaX2 - $AbscissaMargin )
2693 2693
         {
2694
-         $this->drawLine($XPos,$YPos1,$XPos,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2694
+            $this->drawLine($XPos,$YPos1,$XPos,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2695 2695
 
2696
-         if ( $Wide )
2697
-          {
2698
-           $this->drawLine($XPos-1,$YPos1,$XPos-1,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2699
-           $this->drawLine($XPos+1,$YPos1,$XPos+1,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2700
-          }
2696
+            if ( $Wide )
2697
+            {
2698
+            $this->drawLine($XPos-1,$YPos1,$XPos-1,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2699
+            $this->drawLine($XPos+1,$YPos1,$XPos+1,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2700
+            }
2701 2701
 
2702
-         if ( $WriteCaption )
2703
-          {
2704
-           if ( $CaptionAlign == CAPTION_LEFT_TOP )
2702
+            if ( $WriteCaption )
2703
+            {
2704
+            if ( $CaptionAlign == CAPTION_LEFT_TOP )
2705 2705
             { $Y = $YPos1 + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE; }
2706
-           else 
2706
+            else 
2707 2707
             { $Y = $YPos2 - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; }
2708 2708
            
2709
-           $this->drawText($XPos,$Y,$Caption,$CaptionSettings);
2710
-          }
2709
+            $this->drawText($XPos,$Y,$Caption,$CaptionSettings);
2710
+            }
2711 2711
 
2712
-         return(array("X"=>$XPos));
2712
+            return(array("X"=>$XPos));
2713
+        }
2713 2714
         }
2714
-      }
2715
-     elseif( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2716
-      {
2717
-       $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] *2 ) / $XScale[1];
2718
-       $XPos  = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value;
2719
-       $YPos1 = $this->GraphAreaX1 + $Data["YMargin"];
2720
-       $YPos2 = $this->GraphAreaX2 - $Data["YMargin"];
2715
+        elseif( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2716
+        {
2717
+        $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] *2 ) / $XScale[1];
2718
+        $XPos  = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value;
2719
+        $YPos1 = $this->GraphAreaX1 + $Data["YMargin"];
2720
+        $YPos2 = $this->GraphAreaX2 - $Data["YMargin"];
2721 2721
 
2722
-       if ( $XPos >= $this->GraphAreaY1 + $AbscissaMargin && $XPos <= $this->GraphAreaY2 - $AbscissaMargin )
2722
+        if ( $XPos >= $this->GraphAreaY1 + $AbscissaMargin && $XPos <= $this->GraphAreaY2 - $AbscissaMargin )
2723 2723
         {
2724
-         $this->drawLine($YPos1,$XPos,$YPos2,$XPos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2724
+            $this->drawLine($YPos1,$XPos,$YPos2,$XPos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2725 2725
 
2726
-         if ( $Wide )
2727
-          {
2728
-           $this->drawLine($YPos1,$XPos-1,$YPos2,$XPos-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2729
-           $this->drawLine($YPos1,$XPos+1,$YPos2,$XPos+1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2730
-          }
2726
+            if ( $Wide )
2727
+            {
2728
+            $this->drawLine($YPos1,$XPos-1,$YPos2,$XPos-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2729
+            $this->drawLine($YPos1,$XPos+1,$YPos2,$XPos+1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2730
+            }
2731 2731
 
2732
-         if ( $WriteCaption )
2733
-          {
2734
-           if ( $CaptionAlign == CAPTION_LEFT_TOP )
2732
+            if ( $WriteCaption )
2733
+            {
2734
+            if ( $CaptionAlign == CAPTION_LEFT_TOP )
2735 2735
             { $Y = $YPos1 + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
2736
-           else 
2736
+            else 
2737 2737
             { $Y = $YPos2 - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
2738 2738
            
2739
-           $this->drawText($Y,$XPos,$Caption,$CaptionSettings);
2740
-          }
2739
+            $this->drawText($Y,$XPos,$Caption,$CaptionSettings);
2740
+            }
2741 2741
 
2742
-         return(array("X"=>$XPos));
2742
+            return(array("X"=>$XPos));
2743
+        }
2743 2744
         }
2744
-      }
2745 2745
     }
2746 2746
 
2747
-   /* Draw an X threshold area */
2748
-   function drawXThresholdArea($Value1,$Value2,$Format="")
2747
+    /* Draw an X threshold area */
2748
+    function drawXThresholdArea($Value1,$Value2,$Format="")
2749 2749
     {
2750
-     $R		= isset($Format["R"]) ? $Format["R"] : 255;
2751
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
2752
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
2753
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 20;
2754
-     $Border    = isset($Format["Border"]) ? $Format["Border"] : TRUE;
2755
-     $BorderR   = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
2756
-     $BorderG   = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
2757
-     $BorderB   = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
2758
-     $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha + 20;
2759
-     $BorderTicks = isset($Format["BorderTicks"]) ? $Format["BorderTicks"] : 2;
2760
-     $AreaName 	= isset($Format["AreaName"]) ? $Format["AreaName"] : NULL;
2761
-     $NameAngle	= isset($Format["NameAngle"]) ? $Format["NameAngle"] : ZONE_NAME_ANGLE_AUTO;
2762
-     $NameR	= isset($Format["NameR"]) ? $Format["NameR"] : 255;
2763
-     $NameG	= isset($Format["NameG"]) ? $Format["NameG"] : 255;
2764
-     $NameB	= isset($Format["NameB"]) ? $Format["NameB"] : 255;
2765
-     $NameAlpha	= isset($Format["NameAlpha"]) ? $Format["NameAlpha"] : 100;
2766
-     $DisableShadowOnArea = isset($Format["DisableShadowOnArea"]) ? $Format["DisableShadowOnArea"] : TRUE;
2767
-
2768
-     $RestoreShadow = $this->Shadow;
2769
-     if ( $DisableShadowOnArea && $this->Shadow ) { $this->Shadow = FALSE; }
2770
-
2771
-     if ($BorderAlpha >100) { $BorderAlpha = 100;}
2772
-
2773
-     $Data           = $this->DataSet->getData();
2774
-     $XScale         = $this->scaleGetXSettings();
2775
-     $AbscissaMargin = $this->getAbscissaMargin($Data);
2776
-
2777
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2778
-      {
2779
-       $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] *2 ) / $XScale[1];
2780
-       $XPos1 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value1;
2781
-       $XPos2 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value2;
2782
-       $YPos1 = $this->GraphAreaY1 + $Data["YMargin"];
2783
-       $YPos2 = $this->GraphAreaY2 - $Data["YMargin"];
2784
-
2785
-       if ( $XPos1 < $this->GraphAreaX1 + $XScale[0] ) { $XPos1 = $this->GraphAreaX1 + $XScale[0]; }
2786
-       if ( $XPos1 > $this->GraphAreaX2 - $XScale[0] ) { $XPos1 = $this->GraphAreaX2 - $XScale[0]; }
2787
-       if ( $XPos2 < $this->GraphAreaX1 + $XScale[0] ) { $XPos2 = $this->GraphAreaX1 + $XScale[0]; }
2788
-       if ( $XPos2 > $this->GraphAreaX2 - $XScale[0] ) { $XPos2 = $this->GraphAreaX2 - $XScale[0]; }
2789
-
2790
-       $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
2791
-
2792
-       if ( $Border )
2793
-        {
2794
-         $this->drawLine($XPos1,$YPos1,$XPos1,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2795
-         $this->drawLine($XPos2,$YPos1,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2796
-        }
2797
-
2798
-       if ( $AreaName != NULL )
2799
-        {
2800
-         $XPos = ($XPos2-$XPos1)/2 + $XPos1;
2801
-         $YPos = ($YPos2-$YPos1)/2 + $YPos1;
2802
-
2803
-         if ( $NameAngle == ZONE_NAME_ANGLE_AUTO )
2804
-          {
2805
-           $TxtPos   = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$AreaName);
2806
-           $TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"];
2807
-           if ( abs($XPos2 - $XPos1) > $TxtWidth ) { $NameAngle = 0; } else { $NameAngle = 90; }
2808
-          }
2809
-         $this->Shadow = $RestoreShadow;
2810
-         $this->drawText($XPos,$YPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>$NameAngle,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
2811
-         if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
2812
-        }
2813
-
2814
-       $this->Shadow = $RestoreShadow;
2815
-       return(array("X1"=>$XPos1,"X2"=>$XPos2));
2816
-      }
2817
-     elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2818
-      {
2819
-       $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] *2 ) / $XScale[1];
2820
-       $XPos1 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value1;
2821
-       $XPos2 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value2;
2822
-       $YPos1 = $this->GraphAreaX1 + $Data["YMargin"];
2823
-       $YPos2 = $this->GraphAreaX2 - $Data["YMargin"];
2824
-
2825
-       if ( $XPos1 < $this->GraphAreaY1 + $XScale[0] ) { $XPos1 = $this->GraphAreaY1 + $XScale[0]; }
2826
-       if ( $XPos1 > $this->GraphAreaY2 - $XScale[0] ) { $XPos1 = $this->GraphAreaY2 - $XScale[0]; }
2827
-       if ( $XPos2 < $this->GraphAreaY1 + $XScale[0] ) { $XPos2 = $this->GraphAreaY1 + $XScale[0]; }
2828
-       if ( $XPos2 > $this->GraphAreaY2 - $XScale[0] ) { $XPos2 = $this->GraphAreaY2 - $XScale[0]; }
2829
-
2830
-       $this->drawFilledRectangle($YPos1,$XPos1,$YPos2,$XPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
2831
-
2832
-       if ( $Border )
2833
-        {
2834
-         $this->drawLine($YPos1,$XPos1,$YPos2,$XPos1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2835
-         $this->drawLine($YPos1,$XPos2,$YPos2,$XPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2836
-        }
2837
-
2838
-       if ( $AreaName != NULL )
2839
-        {
2840
-         $XPos = ($XPos2-$XPos1)/2 + $XPos1;
2841
-         $YPos = ($YPos2-$YPos1)/2 + $YPos1;
2842
-
2843
-         $this->Shadow = $RestoreShadow;
2844
-         $this->drawText($YPos,$XPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>0,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
2845
-         if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
2846
-        }
2847
-
2848
-       $this->Shadow = $RestoreShadow;
2849
-       return(array("X1"=>$XPos1,"X2"=>$XPos2));
2850
-      }
2750
+        $R		= isset($Format["R"]) ? $Format["R"] : 255;
2751
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
2752
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
2753
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 20;
2754
+        $Border    = isset($Format["Border"]) ? $Format["Border"] : TRUE;
2755
+        $BorderR   = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
2756
+        $BorderG   = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
2757
+        $BorderB   = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
2758
+        $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha + 20;
2759
+        $BorderTicks = isset($Format["BorderTicks"]) ? $Format["BorderTicks"] : 2;
2760
+        $AreaName 	= isset($Format["AreaName"]) ? $Format["AreaName"] : NULL;
2761
+        $NameAngle	= isset($Format["NameAngle"]) ? $Format["NameAngle"] : ZONE_NAME_ANGLE_AUTO;
2762
+        $NameR	= isset($Format["NameR"]) ? $Format["NameR"] : 255;
2763
+        $NameG	= isset($Format["NameG"]) ? $Format["NameG"] : 255;
2764
+        $NameB	= isset($Format["NameB"]) ? $Format["NameB"] : 255;
2765
+        $NameAlpha	= isset($Format["NameAlpha"]) ? $Format["NameAlpha"] : 100;
2766
+        $DisableShadowOnArea = isset($Format["DisableShadowOnArea"]) ? $Format["DisableShadowOnArea"] : TRUE;
2767
+
2768
+        $RestoreShadow = $this->Shadow;
2769
+        if ( $DisableShadowOnArea && $this->Shadow ) { $this->Shadow = FALSE; }
2770
+
2771
+        if ($BorderAlpha >100) { $BorderAlpha = 100;}
2772
+
2773
+        $Data           = $this->DataSet->getData();
2774
+        $XScale         = $this->scaleGetXSettings();
2775
+        $AbscissaMargin = $this->getAbscissaMargin($Data);
2776
+
2777
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2778
+        {
2779
+        $XStep = (($this->GraphAreaX2 - $this->GraphAreaX1) - $XScale[0] *2 ) / $XScale[1];
2780
+        $XPos1 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value1;
2781
+        $XPos2 = $this->GraphAreaX1 + $XScale[0] + $XStep * $Value2;
2782
+        $YPos1 = $this->GraphAreaY1 + $Data["YMargin"];
2783
+        $YPos2 = $this->GraphAreaY2 - $Data["YMargin"];
2784
+
2785
+        if ( $XPos1 < $this->GraphAreaX1 + $XScale[0] ) { $XPos1 = $this->GraphAreaX1 + $XScale[0]; }
2786
+        if ( $XPos1 > $this->GraphAreaX2 - $XScale[0] ) { $XPos1 = $this->GraphAreaX2 - $XScale[0]; }
2787
+        if ( $XPos2 < $this->GraphAreaX1 + $XScale[0] ) { $XPos2 = $this->GraphAreaX1 + $XScale[0]; }
2788
+        if ( $XPos2 > $this->GraphAreaX2 - $XScale[0] ) { $XPos2 = $this->GraphAreaX2 - $XScale[0]; }
2789
+
2790
+        $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
2791
+
2792
+        if ( $Border )
2793
+        {
2794
+            $this->drawLine($XPos1,$YPos1,$XPos1,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2795
+            $this->drawLine($XPos2,$YPos1,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2796
+        }
2797
+
2798
+        if ( $AreaName != NULL )
2799
+        {
2800
+            $XPos = ($XPos2-$XPos1)/2 + $XPos1;
2801
+            $YPos = ($YPos2-$YPos1)/2 + $YPos1;
2802
+
2803
+            if ( $NameAngle == ZONE_NAME_ANGLE_AUTO )
2804
+            {
2805
+            $TxtPos   = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$AreaName);
2806
+            $TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"];
2807
+            if ( abs($XPos2 - $XPos1) > $TxtWidth ) { $NameAngle = 0; } else { $NameAngle = 90; }
2808
+            }
2809
+            $this->Shadow = $RestoreShadow;
2810
+            $this->drawText($XPos,$YPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>$NameAngle,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
2811
+            if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
2812
+        }
2813
+
2814
+        $this->Shadow = $RestoreShadow;
2815
+        return(array("X1"=>$XPos1,"X2"=>$XPos2));
2816
+        }
2817
+        elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2818
+        {
2819
+        $XStep = (($this->GraphAreaY2 - $this->GraphAreaY1) - $XScale[0] *2 ) / $XScale[1];
2820
+        $XPos1 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value1;
2821
+        $XPos2 = $this->GraphAreaY1 + $XScale[0] + $XStep * $Value2;
2822
+        $YPos1 = $this->GraphAreaX1 + $Data["YMargin"];
2823
+        $YPos2 = $this->GraphAreaX2 - $Data["YMargin"];
2824
+
2825
+        if ( $XPos1 < $this->GraphAreaY1 + $XScale[0] ) { $XPos1 = $this->GraphAreaY1 + $XScale[0]; }
2826
+        if ( $XPos1 > $this->GraphAreaY2 - $XScale[0] ) { $XPos1 = $this->GraphAreaY2 - $XScale[0]; }
2827
+        if ( $XPos2 < $this->GraphAreaY1 + $XScale[0] ) { $XPos2 = $this->GraphAreaY1 + $XScale[0]; }
2828
+        if ( $XPos2 > $this->GraphAreaY2 - $XScale[0] ) { $XPos2 = $this->GraphAreaY2 - $XScale[0]; }
2829
+
2830
+        $this->drawFilledRectangle($YPos1,$XPos1,$YPos2,$XPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
2831
+
2832
+        if ( $Border )
2833
+        {
2834
+            $this->drawLine($YPos1,$XPos1,$YPos2,$XPos1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2835
+            $this->drawLine($YPos1,$XPos2,$YPos2,$XPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
2836
+        }
2837
+
2838
+        if ( $AreaName != NULL )
2839
+        {
2840
+            $XPos = ($XPos2-$XPos1)/2 + $XPos1;
2841
+            $YPos = ($YPos2-$YPos1)/2 + $YPos1;
2842
+
2843
+            $this->Shadow = $RestoreShadow;
2844
+            $this->drawText($YPos,$XPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>0,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
2845
+            if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
2846
+        }
2847
+
2848
+        $this->Shadow = $RestoreShadow;
2849
+        return(array("X1"=>$XPos1,"X2"=>$XPos2));
2850
+        }
2851 2851
     }
2852 2852
 
2853
-   /* Draw an Y threshold with the computed scale */
2854
-   function drawThreshold($Value,$Format="")
2853
+    /* Draw an Y threshold with the computed scale */
2854
+    function drawThreshold($Value,$Format="")
2855 2855
     {
2856
-     $AxisID		= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
2857
-     $R			= isset($Format["R"]) ? $Format["R"] : 255;
2858
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
2859
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
2860
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 50;
2861
-     $Weight		= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
2862
-     $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : 6;
2863
-     $Wide		= isset($Format["Wide"]) ? $Format["Wide"] : FALSE;
2864
-     $WideFactor	= isset($Format["WideFactor"]) ? $Format["WideFactor"] : 5;
2865
-     $WriteCaption	= isset($Format["WriteCaption"]) ? $Format["WriteCaption"] : FALSE;
2866
-     $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : NULL;
2867
-     $CaptionAlign	= isset($Format["CaptionAlign"]) ? $Format["CaptionAlign"] : CAPTION_LEFT_TOP;
2868
-     $CaptionOffset     = isset($Format["CaptionOffset"]) ? $Format["CaptionOffset"] : 10;
2869
-     $CaptionR		= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
2870
-     $CaptionG		= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
2871
-     $CaptionB		= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
2872
-     $CaptionAlpha	= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
2873
-     $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
2874
-     $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
2875
-     $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 5;
2876
-     $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
2877
-     $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
2878
-     $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
2879
-     $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
2880
-     $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
2881
-     $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 20;
2882
-     $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
2883
-     $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
2884
-     $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
2885
-     $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
2886
-     $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
2887
-     $NoMargin		= isset($Format["NoMargin"]) ? $Format["NoMargin"] : FALSE;
2888
-
2889
-     if ( is_array($Value) ) { foreach ($Value as $Key => $ID) { $this->drawThreshold($ID,$Format); } return(0); }
2890
-
2891
-     $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
2892
-                              "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
2893
-                              "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha,
2894
-                              "R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha);
2895
-
2896
-     $Data           = $this->DataSet->getData();
2897
-     $AbscissaMargin = $this->getAbscissaMargin($Data);
2898
-
2899
-     if ( $NoMargin ) { $AbscissaMargin = 0; }
2900
-     if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
2901
-     if ( $Caption == NULL ) { $Caption = $Value; }
2902
-
2903
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2904
-      {
2905
-       $YPos = $this->scaleComputeY($Value,array("AxisID"=>$AxisID));
2906
-       if ( $YPos >= $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] && $YPos <= $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] )
2907
-        {
2908
-         $X1 = $this->GraphAreaX1 + $AbscissaMargin;
2909
-         $X2 = $this->GraphAreaX2 - $AbscissaMargin;
2910
-
2911
-         $this->drawLine($X1,$YPos,$X2,$YPos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2912
-
2913
-         if ( $Wide )
2914
-          {
2915
-           $this->drawLine($X1,$YPos-1,$X2,$YPos-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2916
-           $this->drawLine($X1,$YPos+1,$X2,$YPos+1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2917
-          }
2918
-
2919
-         if ( $WriteCaption )
2920
-          {
2921
-           if ( $CaptionAlign == CAPTION_LEFT_TOP )
2856
+        $AxisID		= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
2857
+        $R			= isset($Format["R"]) ? $Format["R"] : 255;
2858
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
2859
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
2860
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 50;
2861
+        $Weight		= isset($Format["Weight"]) ? $Format["Weight"] : NULL;
2862
+        $Ticks		= isset($Format["Ticks"]) ? $Format["Ticks"] : 6;
2863
+        $Wide		= isset($Format["Wide"]) ? $Format["Wide"] : FALSE;
2864
+        $WideFactor	= isset($Format["WideFactor"]) ? $Format["WideFactor"] : 5;
2865
+        $WriteCaption	= isset($Format["WriteCaption"]) ? $Format["WriteCaption"] : FALSE;
2866
+        $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : NULL;
2867
+        $CaptionAlign	= isset($Format["CaptionAlign"]) ? $Format["CaptionAlign"] : CAPTION_LEFT_TOP;
2868
+        $CaptionOffset     = isset($Format["CaptionOffset"]) ? $Format["CaptionOffset"] : 10;
2869
+        $CaptionR		= isset($Format["CaptionR"]) ? $Format["CaptionR"] : 255;
2870
+        $CaptionG		= isset($Format["CaptionG"]) ? $Format["CaptionG"] : 255;
2871
+        $CaptionB		= isset($Format["CaptionB"]) ? $Format["CaptionB"] : 255;
2872
+        $CaptionAlpha	= isset($Format["CaptionAlpha"]) ? $Format["CaptionAlpha"] : 100;
2873
+        $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
2874
+        $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
2875
+        $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 5;
2876
+        $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
2877
+        $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
2878
+        $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
2879
+        $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
2880
+        $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
2881
+        $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 20;
2882
+        $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
2883
+        $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
2884
+        $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
2885
+        $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
2886
+        $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
2887
+        $NoMargin		= isset($Format["NoMargin"]) ? $Format["NoMargin"] : FALSE;
2888
+
2889
+        if ( is_array($Value) ) { foreach ($Value as $Key => $ID) { $this->drawThreshold($ID,$Format); } return(0); }
2890
+
2891
+        $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
2892
+                                "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
2893
+                                "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha,
2894
+                                "R"=>$CaptionR,"G"=>$CaptionG,"B"=>$CaptionB,"Alpha"=>$CaptionAlpha);
2895
+
2896
+        $Data           = $this->DataSet->getData();
2897
+        $AbscissaMargin = $this->getAbscissaMargin($Data);
2898
+
2899
+        if ( $NoMargin ) { $AbscissaMargin = 0; }
2900
+        if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
2901
+        if ( $Caption == NULL ) { $Caption = $Value; }
2902
+
2903
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
2904
+        {
2905
+        $YPos = $this->scaleComputeY($Value,array("AxisID"=>$AxisID));
2906
+        if ( $YPos >= $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] && $YPos <= $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] )
2907
+        {
2908
+            $X1 = $this->GraphAreaX1 + $AbscissaMargin;
2909
+            $X2 = $this->GraphAreaX2 - $AbscissaMargin;
2910
+
2911
+            $this->drawLine($X1,$YPos,$X2,$YPos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2912
+
2913
+            if ( $Wide )
2914
+            {
2915
+            $this->drawLine($X1,$YPos-1,$X2,$YPos-1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2916
+            $this->drawLine($X1,$YPos+1,$X2,$YPos+1,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2917
+            }
2918
+
2919
+            if ( $WriteCaption )
2920
+            {
2921
+            if ( $CaptionAlign == CAPTION_LEFT_TOP )
2922 2922
             { $X = $X1 + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLELEFT; }
2923
-           else 
2923
+            else 
2924 2924
             { $X = $X2 - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_MIDDLERIGHT; }
2925 2925
            
2926
-           $this->drawText($X,$YPos,$Caption,$CaptionSettings);
2927
-          }
2926
+            $this->drawText($X,$YPos,$Caption,$CaptionSettings);
2927
+            }
2928 2928
         }
2929 2929
 
2930
-       return(array("Y"=>$YPos));
2931
-      }
2930
+        return(array("Y"=>$YPos));
2931
+        }
2932 2932
 
2933
-     if ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2934
-      {
2935
-       $XPos = $this->scaleComputeY($Value,array("AxisID"=>$AxisID));
2936
-       if ( $XPos >= $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] && $XPos <= $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] )
2933
+        if ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
2937 2934
         {
2938
-         $Y1 = $this->GraphAreaY1 + $AbscissaMargin;
2939
-         $Y2 = $this->GraphAreaY2 - $AbscissaMargin;
2935
+        $XPos = $this->scaleComputeY($Value,array("AxisID"=>$AxisID));
2936
+        if ( $XPos >= $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] && $XPos <= $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] )
2937
+        {
2938
+            $Y1 = $this->GraphAreaY1 + $AbscissaMargin;
2939
+            $Y2 = $this->GraphAreaY2 - $AbscissaMargin;
2940 2940
 
2941
-         $this->drawLine($XPos,$Y1,$XPos,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2941
+            $this->drawLine($XPos,$Y1,$XPos,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
2942 2942
 
2943
-         if ( $Wide )
2944
-          {
2945
-           $this->drawLine($XPos-1,$Y1,$XPos-1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2946
-           $this->drawLine($XPos+1,$Y1,$XPos+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2947
-          }
2943
+            if ( $Wide )
2944
+            {
2945
+            $this->drawLine($XPos-1,$Y1,$XPos-1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2946
+            $this->drawLine($XPos+1,$Y1,$XPos+1,$Y2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/$WideFactor,"Ticks"=>$Ticks));
2947
+            }
2948 2948
 
2949
-         if ( $WriteCaption )
2950
-          {
2951
-           if ( $CaptionAlign == CAPTION_LEFT_TOP )
2949
+            if ( $WriteCaption )
2950
+            {
2951
+            if ( $CaptionAlign == CAPTION_LEFT_TOP )
2952 2952
             { $Y = $Y1 + $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE; }
2953
-           else 
2953
+            else 
2954 2954
             { $Y = $Y2 - $CaptionOffset; $CaptionSettings["Align"] = TEXT_ALIGN_BOTTOMMIDDLE; }
2955 2955
 
2956
-           $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE;
2957
-           $this->drawText($XPos,$Y,$Caption,$CaptionSettings);
2958
-          }
2956
+            $CaptionSettings["Align"] = TEXT_ALIGN_TOPMIDDLE;
2957
+            $this->drawText($XPos,$Y,$Caption,$CaptionSettings);
2958
+            }
2959 2959
         }
2960 2960
 
2961
-       return(array("Y"=>$XPos));
2962
-      }
2961
+        return(array("Y"=>$XPos));
2962
+        }
2963 2963
     }
2964 2964
 
2965
-   /* Draw a threshold with the computed scale */
2966
-   function drawThresholdArea($Value1,$Value2,$Format="")
2965
+    /* Draw a threshold with the computed scale */
2966
+    function drawThresholdArea($Value1,$Value2,$Format="")
2967 2967
     {
2968
-     $AxisID	= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
2969
-     $R		= isset($Format["R"]) ? $Format["R"] : 255;
2970
-     $G		= isset($Format["G"]) ? $Format["G"] : 0;
2971
-     $B		= isset($Format["B"]) ? $Format["B"] : 0;
2972
-     $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 20;
2973
-     $Border    = isset($Format["Border"]) ? $Format["Border"] : TRUE;
2974
-     $BorderR   = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
2975
-     $BorderG   = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
2976
-     $BorderB   = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
2977
-     $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha + 20;
2978
-     $BorderTicks = isset($Format["BorderTicks"]) ? $Format["BorderTicks"] : 2;
2979
-     $AreaName 	= isset($Format["AreaName"]) ? $Format["AreaName"] : NULL;
2980
-     $NameAngle	= isset($Format["NameAngle"]) ? $Format["NameAngle"] : ZONE_NAME_ANGLE_AUTO;
2981
-     $NameR	= isset($Format["NameR"]) ? $Format["NameR"] : 255;
2982
-     $NameG	= isset($Format["NameG"]) ? $Format["NameG"] : 255;
2983
-     $NameB	= isset($Format["NameB"]) ? $Format["NameB"] : 255;
2984
-     $NameAlpha	= isset($Format["NameAlpha"]) ? $Format["NameAlpha"] : 100;
2985
-     $DisableShadowOnArea = isset($Format["DisableShadowOnArea"]) ? $Format["DisableShadowOnArea"] : TRUE;
2986
-     $NoMargin	= isset($Format["NoMargin"]) ? $Format["NoMargin"] : FALSE;
2987
-
2988
-     if ($Value1 > $Value2) { list($Value1, $Value2) = array($Value2, $Value1); }
2989
-
2990
-     $RestoreShadow = $this->Shadow;
2991
-     if ( $DisableShadowOnArea && $this->Shadow ) { $this->Shadow = FALSE; }
2992
-
2993
-     if ($BorderAlpha >100) { $BorderAlpha = 100;}
2994
-
2995
-     $Data           = $this->DataSet->getData();
2996
-     $AbscissaMargin = $this->getAbscissaMargin($Data);
2997
-
2998
-     if ( $NoMargin ) { $AbscissaMargin = 0; }
2999
-     if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
3000
-
3001
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3002
-      {
3003
-       $XPos1 = $this->GraphAreaX1 + $AbscissaMargin;
3004
-       $XPos2 = $this->GraphAreaX2 - $AbscissaMargin;
3005
-       $YPos1 = $this->scaleComputeY($Value1,array("AxisID"=>$AxisID));
3006
-       $YPos2 = $this->scaleComputeY($Value2,array("AxisID"=>$AxisID));
3007
-
3008
-       if ( $YPos1 < $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] ) { $YPos1 = $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"]; }
3009
-       if ( $YPos1 > $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] ) { $YPos1 = $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"]; }
3010
-       if ( $YPos2 < $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] ) { $YPos2 = $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"]; }
3011
-       if ( $YPos2 > $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] ) { $YPos2 = $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"]; }
3012
-
3013
-       $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
3014
-       if ( $Border )
3015
-        {
3016
-         $this->drawLine($XPos1,$YPos1,$XPos2,$YPos1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3017
-         $this->drawLine($XPos1,$YPos2,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3018
-        }
3019
-
3020
-       if ( $AreaName != NULL )
3021
-        {
3022
-         $XPos = ($XPos2-$XPos1)/2 + $XPos1;
3023
-         $YPos = ($YPos2-$YPos1)/2 + $YPos1;
3024
-         $this->Shadow = $RestoreShadow;
3025
-         $this->drawText($XPos,$YPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>0,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
3026
-         if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
3027
-        }
3028
-
3029
-       $this->Shadow = $RestoreShadow;
3030
-       return(array("Y1"=>$YPos1,"Y2"=>$YPos2));
3031
-      }
3032
-     elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
3033
-      {
3034
-       $YPos1 = $this->GraphAreaY1 + $AbscissaMargin;
3035
-       $YPos2 = $this->GraphAreaY2 - $AbscissaMargin;
3036
-       $XPos1 = $this->scaleComputeY($Value1,array("AxisID"=>$AxisID));
3037
-       $XPos2 = $this->scaleComputeY($Value2,array("AxisID"=>$AxisID));
3038
-
3039
-       if ( $XPos1 < $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] ) { $XPos1 = $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"]; }
3040
-       if ( $XPos1 > $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] ) { $XPos1 = $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"]; }
3041
-       if ( $XPos2 < $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] ) { $XPos2 = $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"]; }
3042
-       if ( $XPos2 > $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] ) { $XPos2 = $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"]; }
3043
-
3044
-       $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
3045
-       if ( $Border )
3046
-        {
3047
-         $this->drawLine($XPos1,$YPos1,$XPos1,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3048
-         $this->drawLine($XPos2,$YPos1,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3049
-        }
3050
-
3051
-       if ( $AreaName != NULL )
3052
-        {
3053
-         $XPos = ($YPos2-$YPos1)/2 + $YPos1;
3054
-         $YPos = ($XPos2-$XPos1)/2 + $XPos1;
3055
-
3056
-         if ( $NameAngle == ZONE_NAME_ANGLE_AUTO )
3057
-          {
3058
-           $TxtPos   = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$AreaName);
3059
-           $TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"];
3060
-           if ( abs($XPos2 - $XPos1) > $TxtWidth ) { $NameAngle = 0; } else { $NameAngle = 90; }
3061
-          }
3062
-         $this->Shadow = $RestoreShadow;
3063
-         $this->drawText($YPos,$XPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>$NameAngle,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
3064
-         if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
3065
-        }
3066
-
3067
-       $this->Shadow = $RestoreShadow;
3068
-       return(array("Y1"=>$XPos1,"Y2"=>$XPos2));
3069
-      }
2968
+        $AxisID	= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
2969
+        $R		= isset($Format["R"]) ? $Format["R"] : 255;
2970
+        $G		= isset($Format["G"]) ? $Format["G"] : 0;
2971
+        $B		= isset($Format["B"]) ? $Format["B"] : 0;
2972
+        $Alpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : 20;
2973
+        $Border    = isset($Format["Border"]) ? $Format["Border"] : TRUE;
2974
+        $BorderR   = isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
2975
+        $BorderG   = isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
2976
+        $BorderB   = isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
2977
+        $BorderAlpha = isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha + 20;
2978
+        $BorderTicks = isset($Format["BorderTicks"]) ? $Format["BorderTicks"] : 2;
2979
+        $AreaName 	= isset($Format["AreaName"]) ? $Format["AreaName"] : NULL;
2980
+        $NameAngle	= isset($Format["NameAngle"]) ? $Format["NameAngle"] : ZONE_NAME_ANGLE_AUTO;
2981
+        $NameR	= isset($Format["NameR"]) ? $Format["NameR"] : 255;
2982
+        $NameG	= isset($Format["NameG"]) ? $Format["NameG"] : 255;
2983
+        $NameB	= isset($Format["NameB"]) ? $Format["NameB"] : 255;
2984
+        $NameAlpha	= isset($Format["NameAlpha"]) ? $Format["NameAlpha"] : 100;
2985
+        $DisableShadowOnArea = isset($Format["DisableShadowOnArea"]) ? $Format["DisableShadowOnArea"] : TRUE;
2986
+        $NoMargin	= isset($Format["NoMargin"]) ? $Format["NoMargin"] : FALSE;
2987
+
2988
+        if ($Value1 > $Value2) { list($Value1, $Value2) = array($Value2, $Value1); }
2989
+
2990
+        $RestoreShadow = $this->Shadow;
2991
+        if ( $DisableShadowOnArea && $this->Shadow ) { $this->Shadow = FALSE; }
2992
+
2993
+        if ($BorderAlpha >100) { $BorderAlpha = 100;}
2994
+
2995
+        $Data           = $this->DataSet->getData();
2996
+        $AbscissaMargin = $this->getAbscissaMargin($Data);
2997
+
2998
+        if ( $NoMargin ) { $AbscissaMargin = 0; }
2999
+        if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
3000
+
3001
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3002
+        {
3003
+        $XPos1 = $this->GraphAreaX1 + $AbscissaMargin;
3004
+        $XPos2 = $this->GraphAreaX2 - $AbscissaMargin;
3005
+        $YPos1 = $this->scaleComputeY($Value1,array("AxisID"=>$AxisID));
3006
+        $YPos2 = $this->scaleComputeY($Value2,array("AxisID"=>$AxisID));
3007
+
3008
+        if ( $YPos1 < $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] ) { $YPos1 = $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"]; }
3009
+        if ( $YPos1 > $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] ) { $YPos1 = $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"]; }
3010
+        if ( $YPos2 < $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"] ) { $YPos2 = $this->GraphAreaY1+$Data["Axis"][$AxisID]["Margin"]; }
3011
+        if ( $YPos2 > $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"] ) { $YPos2 = $this->GraphAreaY2-$Data["Axis"][$AxisID]["Margin"]; }
3012
+
3013
+        $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
3014
+        if ( $Border )
3015
+        {
3016
+            $this->drawLine($XPos1,$YPos1,$XPos2,$YPos1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3017
+            $this->drawLine($XPos1,$YPos2,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3018
+        }
3019
+
3020
+        if ( $AreaName != NULL )
3021
+        {
3022
+            $XPos = ($XPos2-$XPos1)/2 + $XPos1;
3023
+            $YPos = ($YPos2-$YPos1)/2 + $YPos1;
3024
+            $this->Shadow = $RestoreShadow;
3025
+            $this->drawText($XPos,$YPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>0,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
3026
+            if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
3027
+        }
3028
+
3029
+        $this->Shadow = $RestoreShadow;
3030
+        return(array("Y1"=>$YPos1,"Y2"=>$YPos2));
3031
+        }
3032
+        elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
3033
+        {
3034
+        $YPos1 = $this->GraphAreaY1 + $AbscissaMargin;
3035
+        $YPos2 = $this->GraphAreaY2 - $AbscissaMargin;
3036
+        $XPos1 = $this->scaleComputeY($Value1,array("AxisID"=>$AxisID));
3037
+        $XPos2 = $this->scaleComputeY($Value2,array("AxisID"=>$AxisID));
3038
+
3039
+        if ( $XPos1 < $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] ) { $XPos1 = $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"]; }
3040
+        if ( $XPos1 > $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] ) { $XPos1 = $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"]; }
3041
+        if ( $XPos2 < $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"] ) { $XPos2 = $this->GraphAreaX1+$Data["Axis"][$AxisID]["Margin"]; }
3042
+        if ( $XPos2 > $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"] ) { $XPos2 = $this->GraphAreaX2-$Data["Axis"][$AxisID]["Margin"]; }
3043
+
3044
+        $this->drawFilledRectangle($XPos1,$YPos1,$XPos2,$YPos2,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
3045
+        if ( $Border )
3046
+        {
3047
+            $this->drawLine($XPos1,$YPos1,$XPos1,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3048
+            $this->drawLine($XPos2,$YPos1,$XPos2,$YPos2,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Ticks"=>$BorderTicks));
3049
+        }
3050
+
3051
+        if ( $AreaName != NULL )
3052
+        {
3053
+            $XPos = ($YPos2-$YPos1)/2 + $YPos1;
3054
+            $YPos = ($XPos2-$XPos1)/2 + $XPos1;
3055
+
3056
+            if ( $NameAngle == ZONE_NAME_ANGLE_AUTO )
3057
+            {
3058
+            $TxtPos   = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$AreaName);
3059
+            $TxtWidth = $TxtPos[1]["X"] - $TxtPos[0]["X"];
3060
+            if ( abs($XPos2 - $XPos1) > $TxtWidth ) { $NameAngle = 0; } else { $NameAngle = 90; }
3061
+            }
3062
+            $this->Shadow = $RestoreShadow;
3063
+            $this->drawText($YPos,$XPos,$AreaName,array("R"=>$NameR,"G"=>$NameG,"B"=>$NameB,"Alpha"=>$NameAlpha,"Angle"=>$NameAngle,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE));
3064
+            if ( $DisableShadowOnArea ) { $this->Shadow = FALSE; }
3065
+        }
3066
+
3067
+        $this->Shadow = $RestoreShadow;
3068
+        return(array("Y1"=>$XPos1,"Y2"=>$XPos2));
3069
+        }
3070 3070
     }
3071 3071
 
3072
-   function scaleGetXSettings()
3072
+    function scaleGetXSettings()
3073 3073
     {
3074
-     $Data = $this->DataSet->getData();
3075
-     foreach($Data["Axis"] as $AxisID => $Settings)
3076
-      {
3077
-       if ( $Settings["Identity"] == AXIS_X )
3074
+        $Data = $this->DataSet->getData();
3075
+        foreach($Data["Axis"] as $AxisID => $Settings)
3076
+        {
3077
+        if ( $Settings["Identity"] == AXIS_X )
3078 3078
         {
3079
-         $Rows = $Settings["Rows"];
3079
+            $Rows = $Settings["Rows"];
3080 3080
 
3081
-         return(array($Settings["Margin"],$Rows));
3081
+            return(array($Settings["Margin"],$Rows));
3082
+        }
3082 3083
         }
3083
-      }
3084 3084
     }
3085 3085
 
3086
-   function scaleComputeY($Values,$Option="",$ReturnOnly0Height=FALSE)
3086
+    function scaleComputeY($Values,$Option="",$ReturnOnly0Height=FALSE)
3087 3087
     {
3088
-     $AxisID	= isset($Option["AxisID"]) ? $Option["AxisID"] : 0;
3089
-     $SerieName	= isset($Option["SerieName"]) ? $Option["SerieName"] : NULL;
3088
+        $AxisID	= isset($Option["AxisID"]) ? $Option["AxisID"] : 0;
3089
+        $SerieName	= isset($Option["SerieName"]) ? $Option["SerieName"] : NULL;
3090 3090
 
3091
-     $Data = $this->DataSet->getData();
3092
-     if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
3091
+        $Data = $this->DataSet->getData();
3092
+        if ( !isset($Data["Axis"][$AxisID]) ) { return(-1); }
3093 3093
 
3094
-     if ( $SerieName != NULL ) { $AxisID = $Data["Series"][$SerieName]["Axis"]; }
3095
-     if ( !is_array($Values) ) { $tmp = $Values; $Values = ""; $Values[0] = $tmp; }
3094
+        if ( $SerieName != NULL ) { $AxisID = $Data["Series"][$SerieName]["Axis"]; }
3095
+        if ( !is_array($Values) ) { $tmp = $Values; $Values = ""; $Values[0] = $tmp; }
3096 3096
 
3097
-     $Result = "";
3098
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3099
-      {
3100
-       $Height      = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Data["Axis"][$AxisID]["Margin"]*2;
3101
-       $ScaleHeight = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"];
3102
-       $Step        = $Height / $ScaleHeight;
3097
+        $Result = "";
3098
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3099
+        {
3100
+        $Height      = ($this->GraphAreaY2 - $this->GraphAreaY1) - $Data["Axis"][$AxisID]["Margin"]*2;
3101
+        $ScaleHeight = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"];
3102
+        $Step        = $Height / $ScaleHeight;
3103 3103
 
3104
-       if ( $ReturnOnly0Height )
3104
+        if ( $ReturnOnly0Height )
3105 3105
         { foreach($Values as $Key => $Value) { if ( $Value == VOID ) { $Result[] = VOID; } else { $Result[] = $Step * $Value; } } }
3106
-       else
3106
+        else
3107 3107
         { foreach($Values as $Key => $Value) { if ( $Value == VOID ) { $Result[] = VOID; } else { $Result[] = $this->GraphAreaY2 - $Data["Axis"][$AxisID]["Margin"] - ($Step * ($Value-$Data["Axis"][$AxisID]["ScaleMin"])); } } }
3108
-      }
3109
-     else
3110
-      {
3111
-       $Width      = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Data["Axis"][$AxisID]["Margin"]*2;
3112
-       $ScaleWidth = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"];
3113
-       $Step       = $Width / $ScaleWidth;
3114
-
3115
-       if ( $ReturnOnly0Height )
3108
+        }
3109
+        else
3110
+        {
3111
+        $Width      = ($this->GraphAreaX2 - $this->GraphAreaX1) - $Data["Axis"][$AxisID]["Margin"]*2;
3112
+        $ScaleWidth = $Data["Axis"][$AxisID]["ScaleMax"] - $Data["Axis"][$AxisID]["ScaleMin"];
3113
+        $Step       = $Width / $ScaleWidth;
3114
+
3115
+        if ( $ReturnOnly0Height )
3116 3116
         { foreach($Values as $Key => $Value) { if ( $Value == VOID ) { $Result[] = VOID; } else { $Result[] = $Step * $Value; } } }
3117
-       else
3117
+        else
3118 3118
         { foreach($Values as $Key => $Value) { if ( $Value == VOID ) { $Result[] = VOID; } else { $Result[] = $this->GraphAreaX1 + $Data["Axis"][$AxisID]["Margin"] + ($Step * ($Value-$Data["Axis"][$AxisID]["ScaleMin"])); } } }
3119
-      }
3119
+        }
3120 3120
 
3121
-     if ( count($Result) == 1 )
3122
-      return($Result[0]);
3123
-     else
3124
-      return($Result);
3121
+        if ( count($Result) == 1 )
3122
+        return($Result[0]);
3123
+        else
3124
+        return($Result);
3125 3125
     }
3126 3126
 
3127
-   /* Format the axis values */
3128
-   function scaleFormat($Value,$Mode=NULL,$Format=NULL,$Unit=NULL)
3127
+    /* Format the axis values */
3128
+    function scaleFormat($Value,$Mode=NULL,$Format=NULL,$Unit=NULL)
3129 3129
     {
3130
-     if ( $Value == VOID ) { return(""); }
3130
+        if ( $Value == VOID ) { return(""); }
3131 3131
 
3132
-     if ( $Mode == AXIS_FORMAT_CUSTOM )
3133
-      { if ( function_exists($Format) ) { return(call_user_func($Format,$Value)); } }
3132
+        if ( $Mode == AXIS_FORMAT_CUSTOM )
3133
+        { if ( function_exists($Format) ) { return(call_user_func($Format,$Value)); } }
3134 3134
 
3135
-     if ( $Mode == AXIS_FORMAT_DATE )
3136
-      { if ( $Format == NULL ) { $Pattern = "d/m/Y"; } else { $Pattern = $Format; } return(date($Pattern,$Value)); }
3135
+        if ( $Mode == AXIS_FORMAT_DATE )
3136
+        { if ( $Format == NULL ) { $Pattern = "d/m/Y"; } else { $Pattern = $Format; } return(date($Pattern,$Value)); }
3137 3137
 
3138
-     if ( $Mode == AXIS_FORMAT_TIME )
3139
-      { if ( $Format == NULL ) { $Pattern = "H:i:s"; } else { $Pattern = $Format; } return(date($Pattern,$Value)); }
3138
+        if ( $Mode == AXIS_FORMAT_TIME )
3139
+        { if ( $Format == NULL ) { $Pattern = "H:i:s"; } else { $Pattern = $Format; } return(date($Pattern,$Value)); }
3140 3140
 
3141
-     if ( $Mode == AXIS_FORMAT_CURRENCY )
3142
-      { return($Format.number_format($Value,2)); }
3141
+        if ( $Mode == AXIS_FORMAT_CURRENCY )
3142
+        { return($Format.number_format($Value,2)); }
3143 3143
 
3144
-     if ( $Mode == AXIS_FORMAT_METRIC )
3145
-      {
3146
-       if (abs($Value) > 1000000000)
3144
+        if ( $Mode == AXIS_FORMAT_METRIC )
3145
+        {
3146
+        if (abs($Value) > 1000000000)
3147 3147
         return(round($Value/1000000000,$Format)."g".$Unit);
3148
-       if (abs($Value) > 1000000)
3148
+        if (abs($Value) > 1000000)
3149 3149
         return(round($Value/1000000,$Format)."m".$Unit);
3150
-       elseif (abs($Value) >= 1000)
3150
+        elseif (abs($Value) >= 1000)
3151 3151
         return(round($Value/1000,$Format)."k".$Unit);
3152 3152
        
3153
-      }
3154
-     return($Value.$Unit);
3153
+        }
3154
+        return($Value.$Unit);
3155 3155
     }
3156 3156
 
3157
-   /* Write Max value on a chart */
3158
-   function writeBounds($Type=BOUND_BOTH,$Format=NULL)
3157
+    /* Write Max value on a chart */
3158
+    function writeBounds($Type=BOUND_BOTH,$Format=NULL)
3159 3159
     {
3160
-     $MaxLabelTxt	= isset($Format["MaxLabelTxt"]) ? $Format["MaxLabelTxt"] : "max=";
3161
-     $MinLabelTxt	= isset($Format["MinLabelTxt"]) ? $Format["MinLabelTxt"] : "min=";
3162
-     $Decimals		= isset($Format["Decimals"]) ? $Format["Decimals"] : 1;
3163
-     $ExcludedSeries	= isset($Format["ExcludedSeries"]) ? $Format["ExcludedSeries"] : "";
3164
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 4;
3165
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3166
-     $MaxDisplayR	= isset($Format["MaxDisplayR"]) ? $Format["MaxDisplayR"] : 0;
3167
-     $MaxDisplayG	= isset($Format["MaxDisplayG"]) ? $Format["MaxDisplayG"] : 0;
3168
-     $MaxDisplayB	= isset($Format["MaxDisplayB"]) ? $Format["MaxDisplayB"] : 0;
3169
-     $MinDisplayR	= isset($Format["MinDisplayR"]) ? $Format["MinDisplayR"] : 255;
3170
-     $MinDisplayG	= isset($Format["MinDisplayG"]) ? $Format["MinDisplayG"] : 255;
3171
-     $MinDisplayB	= isset($Format["MinDisplayB"]) ? $Format["MinDisplayB"] : 255;
3172
-     $MinLabelPos	= isset($Format["MinLabelPos"]) ? $Format["MinLabelPos"] : BOUND_LABEL_POS_AUTO;
3173
-     $MaxLabelPos	= isset($Format["MaxLabelPos"]) ? $Format["MaxLabelPos"] : BOUND_LABEL_POS_AUTO;
3174
-     $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
3175
-     $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
3176
-     $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 5;
3177
-     $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
3178
-     $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
3179
-     $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
3180
-     $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
3181
-     $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
3182
-     $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 20;
3183
-     $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
3184
-     $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
3185
-     $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
3186
-     $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
3187
-     $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
3188
-
3189
-     $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
3190
-                              "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
3191
-                              "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha);
3192
-
3193
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3194
-
3195
-     $Data = $this->DataSet->getData();
3196
-     foreach($Data["Series"] as $SerieName => $Serie)
3197
-      {
3198
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && !isset($ExcludedSeries[$SerieName]))
3199
-        {
3200
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3201
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3202
-
3203
-         $MinValue = $this->DataSet->getMin($SerieName);
3204
-         $MaxValue = $this->DataSet->getMax($SerieName);
3205
-
3206
-         $MinPos = VOID; $MaxPos = VOID;
3207
-         foreach($Serie["Data"] as $Key => $Value)
3208
-          { 
3209
-           if ( $Value == $MinValue && $MinPos == VOID ) { $MinPos = $Key; }
3210
-           if ( $Value == $MaxValue ) { $MaxPos = $Key; }
3211
-          }
3212
-
3213
-         $AxisID	= $Serie["Axis"];
3214
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3215
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3216
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3217
-
3218
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3219
-
3220
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3221
-          {
3222
-           $XStep       = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs;
3223
-           $X           = $this->GraphAreaX1 + $XMargin;
3224
-           $SerieOffset = isset($Serie["XOffset"]) ? $Serie["XOffset"] : 0;
3225
-
3226
-           if ( $Type == BOUND_MAX || $Type == BOUND_BOTH )
3227
-            {
3228
-             if ( $MaxLabelPos == BOUND_LABEL_POS_TOP    || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue >= 0) ) { $YPos  = $PosArray[$MaxPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_BOTTOMMIDDLE; }
3229
-             if ( $MaxLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue < 0) ) { $YPos  = $PosArray[$MaxPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_TOPMIDDLE; }
3230
-
3231
-             $XPos  = $X + $MaxPos*$XStep + $SerieOffset;
3232
-             $Label = $MaxLabelTxt.$this->scaleFormat(round($MaxValue,$Decimals),$Mode,$Format,$Unit);
3233
-
3234
-             $TxtPos  = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$Label);
3235
-             $XOffset = 0; $YOffset = 0;
3236
-             if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = (($this->GraphAreaX1 - $TxtPos[0]["X"])/2); }
3237
-             if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -(($TxtPos[1]["X"] - $this->GraphAreaX2)/2); }
3238
-             if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $TxtPos[2]["Y"]; }
3239
-             if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -($TxtPos[0]["Y"] - $this->GraphAreaY2); }
3240
-
3241
-             $CaptionSettings["R"] = $MaxDisplayR; $CaptionSettings["G"] = $MaxDisplayG;
3242
-             $CaptionSettings["B"] = $MaxDisplayB; $CaptionSettings["Align"] = $Align;
3243
-
3244
-             $this->drawText($XPos+$XOffset,$YPos+$YOffset,$Label,$CaptionSettings);
3245
-            }
3246
-
3247
-           if ( $Type == BOUND_MIN || $Type == BOUND_BOTH )
3248
-            {
3249
-             if ( $MinLabelPos == BOUND_LABEL_POS_TOP    || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue >= 0) ) { $YPos  = $PosArray[$MinPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_BOTTOMMIDDLE; }
3250
-             if ( $MinLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue < 0) ) { $YPos  = $PosArray[$MinPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_TOPMIDDLE; }
3251
-
3252
-             $XPos  = $X + $MinPos*$XStep + $SerieOffset;
3253
-             $Label = $MinLabelTxt.$this->scaleFormat(round($MinValue,$Decimals),$Mode,$Format,$Unit);
3254
-
3255
-             $TxtPos  = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$Label);
3256
-             $XOffset = 0; $YOffset = 0;
3257
-             if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = (($this->GraphAreaX1 - $TxtPos[0]["X"])/2); }
3258
-             if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -(($TxtPos[1]["X"] - $this->GraphAreaX2)/2); }
3259
-             if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $TxtPos[2]["Y"]; }
3260
-             if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -($TxtPos[0]["Y"] - $this->GraphAreaY2); }
3261
-
3262
-             $CaptionSettings["R"] = $MinDisplayR; $CaptionSettings["G"] = $MinDisplayG;
3263
-             $CaptionSettings["B"] = $MinDisplayB; $CaptionSettings["Align"] = $Align;
3160
+        $MaxLabelTxt	= isset($Format["MaxLabelTxt"]) ? $Format["MaxLabelTxt"] : "max=";
3161
+        $MinLabelTxt	= isset($Format["MinLabelTxt"]) ? $Format["MinLabelTxt"] : "min=";
3162
+        $Decimals		= isset($Format["Decimals"]) ? $Format["Decimals"] : 1;
3163
+        $ExcludedSeries	= isset($Format["ExcludedSeries"]) ? $Format["ExcludedSeries"] : "";
3164
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 4;
3165
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3166
+        $MaxDisplayR	= isset($Format["MaxDisplayR"]) ? $Format["MaxDisplayR"] : 0;
3167
+        $MaxDisplayG	= isset($Format["MaxDisplayG"]) ? $Format["MaxDisplayG"] : 0;
3168
+        $MaxDisplayB	= isset($Format["MaxDisplayB"]) ? $Format["MaxDisplayB"] : 0;
3169
+        $MinDisplayR	= isset($Format["MinDisplayR"]) ? $Format["MinDisplayR"] : 255;
3170
+        $MinDisplayG	= isset($Format["MinDisplayG"]) ? $Format["MinDisplayG"] : 255;
3171
+        $MinDisplayB	= isset($Format["MinDisplayB"]) ? $Format["MinDisplayB"] : 255;
3172
+        $MinLabelPos	= isset($Format["MinLabelPos"]) ? $Format["MinLabelPos"] : BOUND_LABEL_POS_AUTO;
3173
+        $MaxLabelPos	= isset($Format["MaxLabelPos"]) ? $Format["MaxLabelPos"] : BOUND_LABEL_POS_AUTO;
3174
+        $DrawBox		= isset($Format["DrawBox"]) ? $Format["DrawBox"] : TRUE;
3175
+        $DrawBoxBorder	= isset($Format["DrawBoxBorder"]) ? $Format["DrawBoxBorder"] : FALSE;
3176
+        $BorderOffset	= isset($Format["BorderOffset"]) ? $Format["BorderOffset"] : 5;
3177
+        $BoxRounded	= isset($Format["BoxRounded"]) ? $Format["BoxRounded"] : TRUE;
3178
+        $RoundedRadius	= isset($Format["RoundedRadius"]) ? $Format["RoundedRadius"] : 3;
3179
+        $BoxR		= isset($Format["BoxR"]) ? $Format["BoxR"] : 0;
3180
+        $BoxG		= isset($Format["BoxG"]) ? $Format["BoxG"] : 0;
3181
+        $BoxB		= isset($Format["BoxB"]) ? $Format["BoxB"] : 0;
3182
+        $BoxAlpha		= isset($Format["BoxAlpha"]) ? $Format["BoxAlpha"] : 20;
3183
+        $BoxSurrounding	= isset($Format["BoxSurrounding"]) ? $Format["BoxSurrounding"] : "";
3184
+        $BoxBorderR	= isset($Format["BoxBorderR"]) ? $Format["BoxBorderR"] : 255;
3185
+        $BoxBorderG	= isset($Format["BoxBorderG"]) ? $Format["BoxBorderG"] : 255;
3186
+        $BoxBorderB	= isset($Format["BoxBorderB"]) ? $Format["BoxBorderB"] : 255;
3187
+        $BoxBorderAlpha	= isset($Format["BoxBorderAlpha"]) ? $Format["BoxBorderAlpha"] : 100;
3188
+
3189
+        $CaptionSettings = array("DrawBox"=>$DrawBox,"DrawBoxBorder"=>$DrawBoxBorder,"BorderOffset"=>$BorderOffset,"BoxRounded"=>$BoxRounded,"RoundedRadius"=>$RoundedRadius,
3190
+                                "BoxR"=>$BoxR,"BoxG"=>$BoxG,"BoxB"=>$BoxB,"BoxAlpha"=>$BoxAlpha,"BoxSurrounding"=>$BoxSurrounding,
3191
+                                "BoxBorderR"=>$BoxBorderR,"BoxBorderG"=>$BoxBorderG,"BoxBorderB"=>$BoxBorderB,"BoxBorderAlpha"=>$BoxBorderAlpha);
3192
+
3193
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3194
+
3195
+        $Data = $this->DataSet->getData();
3196
+        foreach($Data["Series"] as $SerieName => $Serie)
3197
+        {
3198
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] && !isset($ExcludedSeries[$SerieName]))
3199
+        {
3200
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3201
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3264 3202
 
3265
-             $this->drawText($XPos+$XOffset,$YPos-$DisplayOffset+$YOffset,$Label,$CaptionSettings);
3203
+            $MinValue = $this->DataSet->getMin($SerieName);
3204
+            $MaxValue = $this->DataSet->getMax($SerieName);
3205
+
3206
+            $MinPos = VOID; $MaxPos = VOID;
3207
+            foreach($Serie["Data"] as $Key => $Value)
3208
+            { 
3209
+            if ( $Value == $MinValue && $MinPos == VOID ) { $MinPos = $Key; }
3210
+            if ( $Value == $MaxValue ) { $MaxPos = $Key; }
3266 3211
             }
3267
-          }
3268
-         else
3269
-          {
3270
-           $XStep       = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs;
3271
-           $X           = $this->GraphAreaY1 + $XMargin;
3272
-           $SerieOffset = isset($Serie["XOffset"]) ? $Serie["XOffset"] : 0;
3273 3212
 
3274
-           if ( $Type == BOUND_MAX || $Type == BOUND_BOTH )
3213
+            $AxisID	= $Serie["Axis"];
3214
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3215
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3216
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3217
+
3218
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3219
+
3220
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3221
+            {
3222
+            $XStep       = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs;
3223
+            $X           = $this->GraphAreaX1 + $XMargin;
3224
+            $SerieOffset = isset($Serie["XOffset"]) ? $Serie["XOffset"] : 0;
3225
+
3226
+            if ( $Type == BOUND_MAX || $Type == BOUND_BOTH )
3275 3227
             {
3276
-             if ( $MaxLabelPos == BOUND_LABEL_POS_TOP    || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue >= 0) ) { $YPos  = $PosArray[$MaxPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLELEFT; }
3277
-             if ( $MaxLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue < 0) ) { $YPos  = $PosArray[$MaxPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLERIGHT; }
3228
+                if ( $MaxLabelPos == BOUND_LABEL_POS_TOP    || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue >= 0) ) { $YPos  = $PosArray[$MaxPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_BOTTOMMIDDLE; }
3229
+                if ( $MaxLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue < 0) ) { $YPos  = $PosArray[$MaxPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_TOPMIDDLE; }
3278 3230
 
3279
-             $XPos  = $X + $MaxPos*$XStep + $SerieOffset;
3280
-             $Label = $MaxLabelTxt.$this->scaleFormat($MaxValue,$Mode,$Format,$Unit);
3231
+                $XPos  = $X + $MaxPos*$XStep + $SerieOffset;
3232
+                $Label = $MaxLabelTxt.$this->scaleFormat(round($MaxValue,$Decimals),$Mode,$Format,$Unit);
3281 3233
 
3282
-             $TxtPos  = $this->getTextBox($YPos,$XPos,$this->FontName,$this->FontSize,0,$Label);
3283
-             $XOffset = 0; $YOffset = 0;
3284
-             if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $TxtPos[0]["X"]; }
3285
-             if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -($TxtPos[1]["X"] - $this->GraphAreaX2); }
3286
-             if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = ($this->GraphAreaY1 - $TxtPos[2]["Y"])/2; }
3287
-             if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -(($TxtPos[0]["Y"] - $this->GraphAreaY2)/2);}
3234
+                $TxtPos  = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$Label);
3235
+                $XOffset = 0; $YOffset = 0;
3236
+                if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = (($this->GraphAreaX1 - $TxtPos[0]["X"])/2); }
3237
+                if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -(($TxtPos[1]["X"] - $this->GraphAreaX2)/2); }
3238
+                if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $TxtPos[2]["Y"]; }
3239
+                if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -($TxtPos[0]["Y"] - $this->GraphAreaY2); }
3288 3240
 
3289
-             $CaptionSettings["R"] = $MaxDisplayR; $CaptionSettings["G"] = $MaxDisplayG;
3290
-             $CaptionSettings["B"] = $MaxDisplayB; $CaptionSettings["Align"] = $Align;
3241
+                $CaptionSettings["R"] = $MaxDisplayR; $CaptionSettings["G"] = $MaxDisplayG;
3242
+                $CaptionSettings["B"] = $MaxDisplayB; $CaptionSettings["Align"] = $Align;
3291 3243
 
3292
-             $this->drawText($YPos+$XOffset,$XPos+$YOffset,$Label,$CaptionSettings);
3244
+                $this->drawText($XPos+$XOffset,$YPos+$YOffset,$Label,$CaptionSettings);
3293 3245
             }
3294 3246
 
3295
-           if ( $Type == BOUND_MIN || $Type == BOUND_BOTH )
3247
+            if ( $Type == BOUND_MIN || $Type == BOUND_BOTH )
3296 3248
             {
3297
-             if ( $MinLabelPos == BOUND_LABEL_POS_TOP    || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue >= 0) ) { $YPos  = $PosArray[$MinPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLELEFT; }
3298
-             if ( $MinLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue < 0) ) { $YPos  = $PosArray[$MinPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLERIGHT; }
3249
+                if ( $MinLabelPos == BOUND_LABEL_POS_TOP    || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue >= 0) ) { $YPos  = $PosArray[$MinPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_BOTTOMMIDDLE; }
3250
+                if ( $MinLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue < 0) ) { $YPos  = $PosArray[$MinPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_TOPMIDDLE; }
3299 3251
 
3300
-             $XPos  = $X + $MinPos*$XStep + $SerieOffset;
3301
-             $Label = $MinLabelTxt.$this->scaleFormat($MinValue,$Mode,$Format,$Unit);
3252
+                $XPos  = $X + $MinPos*$XStep + $SerieOffset;
3253
+                $Label = $MinLabelTxt.$this->scaleFormat(round($MinValue,$Decimals),$Mode,$Format,$Unit);
3302 3254
 
3303
-             $TxtPos  = $this->getTextBox($YPos,$XPos,$this->FontName,$this->FontSize,0,$Label);
3304
-             $XOffset = 0; $YOffset = 0;
3305
-             if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $TxtPos[0]["X"]; }
3306
-             if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -($TxtPos[1]["X"] - $this->GraphAreaX2); }
3307
-             if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = ($this->GraphAreaY1 - $TxtPos[2]["Y"])/2; }
3308
-             if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -(($TxtPos[0]["Y"] - $this->GraphAreaY2)/2);}
3255
+                $TxtPos  = $this->getTextBox($XPos,$YPos,$this->FontName,$this->FontSize,0,$Label);
3256
+                $XOffset = 0; $YOffset = 0;
3257
+                if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = (($this->GraphAreaX1 - $TxtPos[0]["X"])/2); }
3258
+                if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -(($TxtPos[1]["X"] - $this->GraphAreaX2)/2); }
3259
+                if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $TxtPos[2]["Y"]; }
3260
+                if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -($TxtPos[0]["Y"] - $this->GraphAreaY2); }
3309 3261
 
3310
-             $CaptionSettings["R"] = $MinDisplayR; $CaptionSettings["G"] = $MinDisplayG;
3311
-             $CaptionSettings["B"] = $MinDisplayB; $CaptionSettings["Align"] = $Align;
3262
+                $CaptionSettings["R"] = $MinDisplayR; $CaptionSettings["G"] = $MinDisplayG;
3263
+                $CaptionSettings["B"] = $MinDisplayB; $CaptionSettings["Align"] = $Align;
3312 3264
 
3313
-             $this->drawText($YPos+$XOffset,$XPos+$YOffset,$Label,$CaptionSettings);
3265
+                $this->drawText($XPos+$XOffset,$YPos-$DisplayOffset+$YOffset,$Label,$CaptionSettings);
3314 3266
             }
3315
-          }
3316
-        }
3317
-      }
3318
-    }
3319
-
3320
-   /* Draw a plot chart */
3321
-   function drawPlotChart($Format=NULL)
3322
-    {
3323
-     $PlotSize		= isset($Format["PlotSize"]) ? $Format["PlotSize"] : NULL;
3324
-     $PlotBorder	= isset($Format["PlotBorder"]) ? $Format["PlotBorder"] : FALSE;
3325
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 50;
3326
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 50;
3327
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 50;
3328
-     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 30;
3329
-     $BorderSize	= isset($Format["BorderSize"]) ? $Format["BorderSize"] : 2;
3330
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
3331
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3332
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 4;
3333
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3334
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3335
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3336
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3337
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3338
-
3339
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3340
-
3341
-     $Data = $this->DataSet->getData();
3342
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3343
-
3344
-     foreach($Data["Series"] as $SerieName => $Serie)
3345
-      {
3346
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3347
-        {
3348
-         if ( isset($Serie["Weight"]) ) { $SerieWeight = $Serie["Weight"] + 2; } else { $SerieWeight = 2; }
3349
-         if ( $PlotSize != NULL ) { $SerieWeight = $PlotSize; }
3350
-
3351
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3352
-         if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
3353
-         if ( isset($Serie["Picture"]) )
3354
-          { $Picture = $Serie["Picture"]; list($PicWidth,$PicHeight,$PicType) = $this->getPicInfo($Picture); }
3355
-         else { $Picture = NULL; $PicOffset = 0; }
3356
-
3357
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3358
-
3359
-         $AxisID	= $Serie["Axis"];
3360
-         $Shape		= $Serie["Shape"];
3361
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3362
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3363
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3364
-
3365
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3366
-
3367
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3368
-
3369
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3370
-
3371
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3372
-          {
3373
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3374
-           if ( $Picture != NULL ) { $PicOffset = $PicHeight / 2; $SerieWeight = 0; }
3375
-           $X = $this->GraphAreaX1 + $XMargin;
3376
-
3377
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3378
-           foreach($PosArray as $Key => $Y)
3379
-            {
3380
-             if ( $DisplayValues ) 
3381
-              $this->drawText($X,$Y-$DisplayOffset-$SerieWeight-$BorderSize-$PicOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3382
-
3383
-             if ( $Y != VOID )
3384
-              {
3385
-               if ( $RecordImageMap ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$SerieWeight,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3386
-
3387
-               if ( $Picture != NULL )
3388
-                { $this->drawFromPicture($PicType,$Picture,$X-$PicWidth/2,$Y-$PicHeight/2); }
3389
-               else
3390
-                { $this->drawShape($X,$Y,$Shape,$SerieWeight,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha); }
3391
-              }
3392
-             $X = $X + $XStep;
3393 3267
             }
3394
-          }
3395
-         else
3396
-          {
3397
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3398
-           if ( $Picture != NULL ) { $PicOffset = $PicWidth / 2; $SerieWeight = 0; }
3399
-           $Y = $this->GraphAreaY1 + $XMargin;
3400
-
3401
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3402
-           foreach($PosArray as $Key => $X)
3268
+            else
3403 3269
             {
3404
-             if ( $DisplayValues ) 
3405
-              $this->drawText($X+$DisplayOffset+$SerieWeight+$BorderSize+$PicOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3406
-
3407
-             if ( $X != VOID )
3408
-              {
3409
-               if ( $RecordImageMap ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$SerieWeight,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3410
-
3411
-               if ( $Picture != NULL )
3412
-                { $this->drawFromPicture($PicType,$Picture,$X-$PicWidth/2,$Y-$PicHeight/2); }
3413
-               else
3414
-                { $this->drawShape($X,$Y,$Shape,$SerieWeight,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha); }
3415
-              }
3416
-             $Y = $Y + $YStep;
3417
-            }
3418
-          }
3419
-        }
3420
-      }
3421
-    }
3422
-
3423
-   /* Draw a spline chart */
3424
-   function drawSplineChart($Format=NULL)
3425
-    {
3426
-     $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : TRUE;
3427
-     $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3428
-     $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL; // 234
3429
-     $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL; // 55
3430
-     $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL; // 26
3431
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3432
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3433
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3434
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3435
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3436
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3437
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3438
-     $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3439
-
3440
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3441
-
3442
-     $Data = $this->DataSet->getData();
3443
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3444
-     foreach($Data["Series"] as $SerieName => $Serie)
3445
-      {
3446
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3447
-        {
3448
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3449
-
3450
-         if ( $BreakR == NULL )
3451
-          $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks);
3452
-         else
3453
-          $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3454
-
3455
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3456
-
3457
-         $AxisID	= $Serie["Axis"];
3458
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3459
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3460
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3461
-
3462
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3463
-
3464
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3465
-
3466
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3467
-
3468
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3469
-          {
3470
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3471
-           $X     = $this->GraphAreaX1 + $XMargin; $WayPoints = "";
3472
-           $Force = $XStep / 5;
3473
-
3474
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3475
-           $LastGoodY = NULL; $LastGoodX = NULL; $LastX = 1; $LastY = 1;
3476
-           foreach($PosArray as $Key => $Y)
3477
-            {
3478
-             if ( $DisplayValues ) 
3479
-              $this->drawText($X,$Y-$DisplayOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3480
-	
3481
-             if ( $RecordImageMap && $Y != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3270
+            $XStep       = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs;
3271
+            $X           = $this->GraphAreaY1 + $XMargin;
3272
+            $SerieOffset = isset($Serie["XOffset"]) ? $Serie["XOffset"] : 0;
3482 3273
 
3483
-             if ( $Y == VOID && $LastY != NULL )
3484
-              { $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); $WayPoints = ""; }
3274
+            if ( $Type == BOUND_MAX || $Type == BOUND_BOTH )
3275
+            {
3276
+                if ( $MaxLabelPos == BOUND_LABEL_POS_TOP    || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue >= 0) ) { $YPos  = $PosArray[$MaxPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLELEFT; }
3277
+                if ( $MaxLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MaxLabelPos ==  BOUND_LABEL_POS_AUTO && $MaxValue < 0) ) { $YPos  = $PosArray[$MaxPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLERIGHT; }
3485 3278
 
3486
-             if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3487
-              { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); }
3279
+                $XPos  = $X + $MaxPos*$XStep + $SerieOffset;
3280
+                $Label = $MaxLabelTxt.$this->scaleFormat($MaxValue,$Mode,$Format,$Unit);
3488 3281
 
3489
-             if ( $Y != VOID )
3490
-              $WayPoints[] = array($X,$Y);
3282
+                $TxtPos  = $this->getTextBox($YPos,$XPos,$this->FontName,$this->FontSize,0,$Label);
3283
+                $XOffset = 0; $YOffset = 0;
3284
+                if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $TxtPos[0]["X"]; }
3285
+                if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -($TxtPos[1]["X"] - $this->GraphAreaX2); }
3286
+                if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = ($this->GraphAreaY1 - $TxtPos[2]["Y"])/2; }
3287
+                if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -(($TxtPos[0]["Y"] - $this->GraphAreaY2)/2);}
3491 3288
 
3492
-             if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3493
-             if ( $Y == VOID ) { $Y = NULL; }
3289
+                $CaptionSettings["R"] = $MaxDisplayR; $CaptionSettings["G"] = $MaxDisplayG;
3290
+                $CaptionSettings["B"] = $MaxDisplayB; $CaptionSettings["Align"] = $Align;
3494 3291
 
3495
-             $LastX = $X; $LastY = $Y;
3496
-             $X = $X + $XStep;
3292
+                $this->drawText($YPos+$XOffset,$XPos+$YOffset,$Label,$CaptionSettings);
3497 3293
             }
3498
-           $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3499
-          }
3500
-         else
3501
-          {
3502
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3503
-           $Y     = $this->GraphAreaY1 + $XMargin; $WayPoints = "";
3504
-           $Force = $YStep / 5;
3505 3294
 
3506
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3507
-           $LastGoodY = NULL; $LastGoodX = NULL; $LastX = 1; $LastY = 1;
3508
-           foreach($PosArray as $Key => $X)
3295
+            if ( $Type == BOUND_MIN || $Type == BOUND_BOTH )
3509 3296
             {
3510
-             if ( $DisplayValues ) 
3511
-              $this->drawText($X+$DisplayOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3512
-
3513
-             if ( $RecordImageMap && $X != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3297
+                if ( $MinLabelPos == BOUND_LABEL_POS_TOP    || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue >= 0) ) { $YPos  = $PosArray[$MinPos] + $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLELEFT; }
3298
+                if ( $MinLabelPos == BOUND_LABEL_POS_BOTTOM || ( $MinLabelPos ==  BOUND_LABEL_POS_AUTO && $MinValue < 0) ) { $YPos  = $PosArray[$MinPos] - $DisplayOffset + 2; $Align = TEXT_ALIGN_MIDDLERIGHT; }
3514 3299
 
3515
-             if ( $X == VOID && $LastX != NULL )
3516
-              { $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); $WayPoints = ""; }
3300
+                $XPos  = $X + $MinPos*$XStep + $SerieOffset;
3301
+                $Label = $MinLabelTxt.$this->scaleFormat($MinValue,$Mode,$Format,$Unit);
3517 3302
 
3518
-             if ( $X != VOID && $LastX == NULL && $LastGoodX != NULL && !$BreakVoid )
3519
-              { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); }
3303
+                $TxtPos  = $this->getTextBox($YPos,$XPos,$this->FontName,$this->FontSize,0,$Label);
3304
+                $XOffset = 0; $YOffset = 0;
3305
+                if ( $TxtPos[0]["X"] < $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $TxtPos[0]["X"]; }
3306
+                if ( $TxtPos[1]["X"] > $this->GraphAreaX2 ) { $XOffset = -($TxtPos[1]["X"] - $this->GraphAreaX2); }
3307
+                if ( $TxtPos[2]["Y"] < $this->GraphAreaY1 ) { $YOffset = ($this->GraphAreaY1 - $TxtPos[2]["Y"])/2; }
3308
+                if ( $TxtPos[0]["Y"] > $this->GraphAreaY2 ) { $YOffset = -(($TxtPos[0]["Y"] - $this->GraphAreaY2)/2);}
3520 3309
 
3521
-             if ( $X != VOID )
3522
-              $WayPoints[] = array($X,$Y);
3310
+                $CaptionSettings["R"] = $MinDisplayR; $CaptionSettings["G"] = $MinDisplayG;
3311
+                $CaptionSettings["B"] = $MinDisplayB; $CaptionSettings["Align"] = $Align;
3523 3312
 
3524
-             if ( $X != VOID ) { $LastGoodX = $X; $LastGoodY = $Y; }
3525
-             if ( $X == VOID ) { $X = NULL; }
3526
-
3527
-             $LastX = $X; $LastY = $Y;
3528
-             $Y = $Y + $YStep;
3313
+                $this->drawText($YPos+$XOffset,$XPos+$YOffset,$Label,$CaptionSettings);
3314
+            }
3529 3315
             }
3530
-           $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3531
-          }
3532 3316
         }
3533
-      }
3317
+        }
3534 3318
     }
3535 3319
 
3536
-   /* Draw a filled spline chart */
3537
-   function drawFilledSplineChart($Format=NULL)
3320
+    /* Draw a plot chart */
3321
+    function drawPlotChart($Format=NULL)
3538 3322
     {
3539
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3540
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3541
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3542
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3543
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3544
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3545
-     $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
3546
-     $Threshold		= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
3547
-
3548
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3549
-
3550
-     $Data = $this->DataSet->getData();
3551
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3552
-     foreach($Data["Series"] as $SerieName => $Serie)
3553
-      {
3554
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3323
+        $PlotSize		= isset($Format["PlotSize"]) ? $Format["PlotSize"] : NULL;
3324
+        $PlotBorder	= isset($Format["PlotBorder"]) ? $Format["PlotBorder"] : FALSE;
3325
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 50;
3326
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 50;
3327
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 50;
3328
+        $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 30;
3329
+        $BorderSize	= isset($Format["BorderSize"]) ? $Format["BorderSize"] : 2;
3330
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
3331
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3332
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 4;
3333
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3334
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3335
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3336
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3337
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3338
+
3339
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3340
+
3341
+        $Data = $this->DataSet->getData();
3342
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3343
+
3344
+        foreach($Data["Series"] as $SerieName => $Serie)
3345
+        {
3346
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3555 3347
         {
3556
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3557
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3348
+            if ( isset($Serie["Weight"]) ) { $SerieWeight = $Serie["Weight"] + 2; } else { $SerieWeight = 2; }
3349
+            if ( $PlotSize != NULL ) { $SerieWeight = $PlotSize; }
3558 3350
 
3559
-         $AxisID	= $Serie["Axis"];
3560
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3561
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3562
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3351
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3352
+            if ( $Surrounding != NULL ) { $BorderR = $R + $Surrounding; $BorderG = $G + $Surrounding; $BorderB = $B + $Surrounding; }
3353
+            if ( isset($Serie["Picture"]) )
3354
+            { $Picture = $Serie["Picture"]; list($PicWidth,$PicHeight,$PicType) = $this->getPicInfo($Picture); }
3355
+            else { $Picture = NULL; $PicOffset = 0; }
3563 3356
 
3564
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3565
-         if ( $AroundZero ) { $YZero = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"])); }
3357
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3566 3358
 
3567
-         if ( $Threshold != NULL )
3568
-          {
3569
-           foreach($Threshold as $Key => $Params)
3570
-            {
3571
-             $Threshold[$Key]["MinX"] = $this->scaleComputeY($Params["Min"],array("AxisID"=>$Serie["Axis"]));
3572
-             $Threshold[$Key]["MaxX"] = $this->scaleComputeY($Params["Max"],array("AxisID"=>$Serie["Axis"]));
3573
-            }
3574
-          }
3359
+            $AxisID	= $Serie["Axis"];
3360
+            $Shape		= $Serie["Shape"];
3361
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3362
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3363
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3575 3364
 
3576
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3365
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3577 3366
 
3578
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3579
-          {
3580
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3581
-           $X     = $this->GraphAreaX1 + $XMargin; $WayPoints = "";
3582
-           $Force = $XStep / 5;
3367
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3583 3368
 
3584
-           if ( !$AroundZero ) { $YZero = $this->GraphAreaY2-1; }
3585
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
3586
-           if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
3369
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3587 3370
 
3588
-           $LastX = ""; $LastY = "";
3589
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3590
-           foreach($PosArray as $Key => $Y)
3371
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3591 3372
             {
3592
-             if ( $DisplayValues ) 
3593
-              $this->drawText($X,$Y-$DisplayOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3373
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3374
+            if ( $Picture != NULL ) { $PicOffset = $PicHeight / 2; $SerieWeight = 0; }
3375
+            $X = $this->GraphAreaX1 + $XMargin;
3594 3376
 
3595
-             if ( $Y == VOID )
3596
-              {
3597
-               $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3377
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3378
+            foreach($PosArray as $Key => $Y)
3379
+            {
3380
+                if ( $DisplayValues ) 
3381
+                $this->drawText($X,$Y-$DisplayOffset-$SerieWeight-$BorderSize-$PicOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3598 3382
 
3599
-               if ( $Area != "" )
3383
+                if ( $Y != VOID )
3600 3384
                 {
3601
-                 foreach ($Area as $key => $Points)
3602
-                  {
3603
-                   $Corners = ""; $Corners[] = $Area[$key][0]["X"]; $Corners[] = $YZero;
3604
-                   foreach($Points as $subKey => $Point)
3605
-                    {
3606
-                     if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3607
-                     $Corners[] = $Point["Y"]+1;
3608
-                    }
3609
-                   $Corners[] = $Points[$subKey]["X"]-1; $Corners[] = $YZero;
3385
+                if ( $RecordImageMap ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$SerieWeight,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3610 3386
 
3611
-                   $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3612
-                  }
3613
-                 $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3387
+                if ( $Picture != NULL )
3388
+                { $this->drawFromPicture($PicType,$Picture,$X-$PicWidth/2,$Y-$PicHeight/2); }
3389
+                else
3390
+                { $this->drawShape($X,$Y,$Shape,$SerieWeight,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha); }
3614 3391
                 }
3615
-
3616
-               $WayPoints = "";
3617
-              }
3618
-             else
3619
-              $WayPoints[] = array($X,$Y-.5); /* -.5 for AA visual fix */
3620
-
3621
-             $X = $X + $XStep;
3392
+                $X = $X + $XStep;
3622 3393
             }
3623
-           $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3624
-
3625
-           if ( $Area != "" )
3626
-            {
3627
-             foreach ($Area as $key => $Points)
3628
-              {
3629
-               $Corners = ""; $Corners[] = $Area[$key][0]["X"]; $Corners[] = $YZero;
3630
-               foreach($Points as $subKey => $Point)
3631
-                {
3632
-                 if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3633
-                 $Corners[] = $Point["Y"]+1;
3634
-                }
3635
-               $Corners[] = $Points[$subKey]["X"]-1; $Corners[] = $YZero;
3636
-
3637
-               $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3638
-              }
3639
-             $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3640 3394
             }
3641
-          }
3642
-         else
3643
-          {
3644
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3645
-           $Y     = $this->GraphAreaY1 + $XMargin; $WayPoints = "";
3646
-           $Force = $YStep / 5;
3647
-
3648
-           if ( !$AroundZero ) { $YZero = $this->GraphAreaX1+1; }
3649
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
3650
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
3651
-
3652
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3653
-           foreach($PosArray as $Key => $X)
3395
+            else
3654 3396
             {
3655
-             if ( $DisplayValues ) 
3656
-              $this->drawText($X+$DisplayOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3397
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3398
+            if ( $Picture != NULL ) { $PicOffset = $PicWidth / 2; $SerieWeight = 0; }
3399
+            $Y = $this->GraphAreaY1 + $XMargin;
3657 3400
 
3658
-             if ( $X == VOID )
3659
-              {
3660
-               $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3401
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3402
+            foreach($PosArray as $Key => $X)
3403
+            {
3404
+                if ( $DisplayValues ) 
3405
+                $this->drawText($X+$DisplayOffset+$SerieWeight+$BorderSize+$PicOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3661 3406
 
3662
-               if ( $Area != "" )
3407
+                if ( $X != VOID )
3663 3408
                 {
3664
-                 foreach ($Area as $key => $Points)
3665
-                  {
3666
-                   $Corners = ""; $Corners[] = $YZero; $Corners[] = $Area[$key][0]["Y"];
3667
-                   foreach($Points as $subKey => $Point)
3668
-                    {
3669
-                     if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3670
-                     $Corners[] = $Point["Y"];
3671
-                    }
3672
-                   $Corners[] = $YZero; $Corners[] = $Points[$subKey]["Y"]-1;
3409
+                if ( $RecordImageMap ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$SerieWeight,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3673 3410
 
3674
-                   $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3675
-                  }
3676
-                 $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3677
-                }
3411
+                if ( $Picture != NULL )
3412
+                { $this->drawFromPicture($PicType,$Picture,$X-$PicWidth/2,$Y-$PicHeight/2); }
3413
+                else
3414
+                { $this->drawShape($X,$Y,$Shape,$SerieWeight,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha); }
3415
+                }
3416
+                $Y = $Y + $YStep;
3417
+            }
3418
+            }
3419
+        }
3420
+        }
3421
+    }
3678 3422
 
3679
-               $WayPoints = "";
3680
-              }
3681
-             else
3682
-              $WayPoints[] = array($X,$Y);
3423
+    /* Draw a spline chart */
3424
+    function drawSplineChart($Format=NULL)
3425
+    {
3426
+        $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : TRUE;
3427
+        $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3428
+        $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL; // 234
3429
+        $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL; // 55
3430
+        $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL; // 26
3431
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3432
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3433
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3434
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3435
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3436
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3437
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3438
+        $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3439
+
3440
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3441
+
3442
+        $Data = $this->DataSet->getData();
3443
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3444
+        foreach($Data["Series"] as $SerieName => $Serie)
3445
+        {
3446
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3447
+        {
3448
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3683 3449
 
3684
-             $Y = $Y + $YStep;
3685
-            }
3686
-           $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3450
+            if ( $BreakR == NULL )
3451
+            $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks);
3452
+            else
3453
+            $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3454
+
3455
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3456
+
3457
+            $AxisID	= $Serie["Axis"];
3458
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3459
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3460
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3461
+
3462
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3687 3463
 
3688
-           if ( $Area != "" )
3464
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3465
+
3466
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3467
+
3468
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3689 3469
             {
3690
-             foreach ($Area as $key => $Points)
3691
-              {
3692
-               $Corners = ""; $Corners[] = $YZero; $Corners[] = $Area[$key][0]["Y"];
3693
-               foreach($Points as $subKey => $Point)
3694
-                {
3695
-                 if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3696
-                 $Corners[] = $Point["Y"];
3697
-                }
3698
-               $Corners[] = $YZero; $Corners[] = $Points[$subKey]["Y"]-1;
3470
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3471
+            $X     = $this->GraphAreaX1 + $XMargin; $WayPoints = "";
3472
+            $Force = $XStep / 5;
3699 3473
 
3700
-               $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3701
-              }
3702
-             $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3474
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3475
+            $LastGoodY = NULL; $LastGoodX = NULL; $LastX = 1; $LastY = 1;
3476
+            foreach($PosArray as $Key => $Y)
3477
+            {
3478
+                if ( $DisplayValues ) 
3479
+                $this->drawText($X,$Y-$DisplayOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3480
+	
3481
+                if ( $RecordImageMap && $Y != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3482
+
3483
+                if ( $Y == VOID && $LastY != NULL )
3484
+                { $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); $WayPoints = ""; }
3485
+
3486
+                if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3487
+                { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); }
3488
+
3489
+                if ( $Y != VOID )
3490
+                $WayPoints[] = array($X,$Y);
3491
+
3492
+                if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3493
+                if ( $Y == VOID ) { $Y = NULL; }
3494
+
3495
+                $LastX = $X; $LastY = $Y;
3496
+                $X = $X + $XStep;
3703 3497
             }
3498
+            $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3499
+            }
3500
+            else
3501
+            {
3502
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3503
+            $Y     = $this->GraphAreaY1 + $XMargin; $WayPoints = "";
3504
+            $Force = $YStep / 5;
3704 3505
 
3705
-          }
3506
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3507
+            $LastGoodY = NULL; $LastGoodX = NULL; $LastX = 1; $LastY = 1;
3508
+            foreach($PosArray as $Key => $X)
3509
+            {
3510
+                if ( $DisplayValues ) 
3511
+                $this->drawText($X+$DisplayOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3512
+
3513
+                if ( $RecordImageMap && $X != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3514
+
3515
+                if ( $X == VOID && $LastX != NULL )
3516
+                { $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight)); $WayPoints = ""; }
3517
+
3518
+                if ( $X != VOID && $LastX == NULL && $LastGoodX != NULL && !$BreakVoid )
3519
+                { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); }
3520
+
3521
+                if ( $X != VOID )
3522
+                $WayPoints[] = array($X,$Y);
3523
+
3524
+                if ( $X != VOID ) { $LastGoodX = $X; $LastGoodY = $Y; }
3525
+                if ( $X == VOID ) { $X = NULL; }
3526
+
3527
+                $LastX = $X; $LastY = $Y;
3528
+                $Y = $Y + $YStep;
3529
+            }
3530
+            $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3531
+            }
3532
+        }
3706 3533
         }
3707
-      }
3708 3534
     }
3709 3535
 
3710
-   /* Draw a line chart */
3711
-   function drawLineChart($Format=NULL)
3536
+    /* Draw a filled spline chart */
3537
+    function drawFilledSplineChart($Format=NULL)
3712 3538
     {
3713
-     $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : TRUE;
3714
-     $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3715
-     $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL;
3716
-     $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL;
3717
-     $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL;
3718
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3719
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3720
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3721
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3722
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3723
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3724
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3725
-     $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3726
-     $ForceColor	= isset($Format["ForceColor"]) ? $Format["ForceColor"] : FALSE;
3727
-     $ForceR		= isset($Format["ForceR"]) ? $Format["ForceR"] : 0;
3728
-     $ForceG		= isset($Format["ForceG"]) ? $Format["ForceG"] : 0;
3729
-     $ForceB		= isset($Format["ForceB"]) ? $Format["ForceB"] : 0;
3730
-     $ForceAlpha	= isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : 100;
3731
-
3732
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3733
-
3734
-     $Data = $this->DataSet->getData();
3735
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3736
-     foreach($Data["Series"] as $SerieName => $Serie)
3737
-      {
3738
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3539
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3540
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3541
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3542
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3543
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3544
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3545
+        $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
3546
+        $Threshold		= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
3547
+
3548
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3549
+
3550
+        $Data = $this->DataSet->getData();
3551
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3552
+        foreach($Data["Series"] as $SerieName => $Serie)
3739 3553
         {
3740
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3554
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3555
+        {
3556
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
3557
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3741 3558
 
3742
-         if ( $ForceColor )
3743
-          { $R = $ForceR; $G = $ForceG; $B = $ForceB; $Alpha = $ForceAlpha; }
3559
+            $AxisID	= $Serie["Axis"];
3560
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3561
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3562
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3744 3563
 
3745
-         if ( $BreakR == NULL )
3746
-          $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3747
-         else
3748
-          $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3564
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3565
+            if ( $AroundZero ) { $YZero = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"])); }
3749 3566
 
3750
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3567
+            if ( $Threshold != NULL )
3568
+            {
3569
+            foreach($Threshold as $Key => $Params)
3570
+            {
3571
+                $Threshold[$Key]["MinX"] = $this->scaleComputeY($Params["Min"],array("AxisID"=>$Serie["Axis"]));
3572
+                $Threshold[$Key]["MaxX"] = $this->scaleComputeY($Params["Max"],array("AxisID"=>$Serie["Axis"]));
3573
+            }
3574
+            }
3751 3575
 
3752
-         $AxisID	= $Serie["Axis"];
3753
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3754
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3755
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3576
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3756 3577
 
3757
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3578
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3579
+            {
3580
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3581
+            $X     = $this->GraphAreaX1 + $XMargin; $WayPoints = "";
3582
+            $Force = $XStep / 5;
3758 3583
 
3759
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3584
+            if ( !$AroundZero ) { $YZero = $this->GraphAreaY2-1; }
3585
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
3586
+            if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
3760 3587
 
3761
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3588
+            $LastX = ""; $LastY = "";
3589
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3590
+            foreach($PosArray as $Key => $Y)
3591
+            {
3592
+                if ( $DisplayValues ) 
3593
+                $this->drawText($X,$Y-$DisplayOffset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3762 3594
 
3763
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3764
-          {
3765
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3766
-           $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3595
+                if ( $Y == VOID )
3596
+                {
3597
+                $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3767 3598
 
3768
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3769
-           $LastGoodY = NULL; $LastGoodX = NULL;
3770
-           foreach($PosArray as $Key => $Y)
3771
-            {
3772
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3773
-              {
3774
-               if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
3775
-               $this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
3776
-              }
3599
+                if ( $Area != "" )
3600
+                {
3601
+                    foreach ($Area as $key => $Points)
3602
+                    {
3603
+                    $Corners = ""; $Corners[] = $Area[$key][0]["X"]; $Corners[] = $YZero;
3604
+                    foreach($Points as $subKey => $Point)
3605
+                    {
3606
+                        if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3607
+                        $Corners[] = $Point["Y"]+1;
3608
+                    }
3609
+                    $Corners[] = $Points[$subKey]["X"]-1; $Corners[] = $YZero;
3777 3610
 
3778
-             if ( $RecordImageMap && $Y != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3611
+                    $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3612
+                    }
3613
+                    $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3614
+                }
3779 3615
 
3780
-             if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
3781
-              $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3616
+                $WayPoints = "";
3617
+                }
3618
+                else
3619
+                $WayPoints[] = array($X,$Y-.5); /* -.5 for AA visual fix */
3782 3620
 
3783
-             if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3784
-              { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); $LastGoodY = NULL; }
3621
+                $X = $X + $XStep;
3622
+            }
3623
+            $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3785 3624
 
3786
-             if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3787
-             if ( $Y == VOID ) { $Y = NULL; }
3625
+            if ( $Area != "" )
3626
+            {
3627
+                foreach ($Area as $key => $Points)
3628
+                {
3629
+                $Corners = ""; $Corners[] = $Area[$key][0]["X"]; $Corners[] = $YZero;
3630
+                foreach($Points as $subKey => $Point)
3631
+                {
3632
+                    if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3633
+                    $Corners[] = $Point["Y"]+1;
3634
+                }
3635
+                $Corners[] = $Points[$subKey]["X"]-1; $Corners[] = $YZero;
3788 3636
 
3789
-             $LastX = $X; $LastY = $Y;
3790
-             $X = $X + $XStep;
3637
+                $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3638
+                }
3639
+                $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3640
+            }
3791 3641
             }
3792
-          }
3793
-         else
3794
-          {
3795
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3796
-           $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
3642
+            else
3643
+            {
3644
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3645
+            $Y     = $this->GraphAreaY1 + $XMargin; $WayPoints = "";
3646
+            $Force = $YStep / 5;
3647
+
3648
+            if ( !$AroundZero ) { $YZero = $this->GraphAreaX1+1; }
3649
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
3650
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
3797 3651
 
3798
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3799
-           $LastGoodY = NULL; $LastGoodX = NULL;
3800
-           foreach($PosArray as $Key => $X)
3652
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3653
+            foreach($PosArray as $Key => $X)
3801 3654
             {
3802
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3803
-              { $this->drawText($X+$DisplayOffset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
3655
+                if ( $DisplayValues ) 
3656
+                $this->drawText($X+$DisplayOffset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE));
3657
+
3658
+                if ( $X == VOID )
3659
+                {
3660
+                $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3661
+
3662
+                if ( $Area != "" )
3663
+                {
3664
+                    foreach ($Area as $key => $Points)
3665
+                    {
3666
+                    $Corners = ""; $Corners[] = $YZero; $Corners[] = $Area[$key][0]["Y"];
3667
+                    foreach($Points as $subKey => $Point)
3668
+                    {
3669
+                        if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3670
+                        $Corners[] = $Point["Y"];
3671
+                    }
3672
+                    $Corners[] = $YZero; $Corners[] = $Points[$subKey]["Y"]-1;
3673
+
3674
+                    $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3675
+                    }
3676
+                    $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3677
+                }
3804 3678
 
3805
-             if ( $RecordImageMap && $X != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3679
+                $WayPoints = "";
3680
+                }
3681
+                else
3682
+                $WayPoints[] = array($X,$Y);
3806 3683
 
3807
-             if ( $X != VOID && $LastX != NULL && $LastY != NULL )
3808
-              $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3684
+                $Y = $Y + $YStep;
3685
+            }
3686
+            $Area = $this->drawSpline($WayPoints,array("Force"=>$Force,"PathOnly"=>TRUE));
3809 3687
 
3810
-             if ( $X != VOID && $LastX == NULL && $LastGoodY != NULL && !$BreakVoid )
3811
-              { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); $LastGoodY = NULL; }
3688
+            if ( $Area != "" )
3689
+            {
3690
+                foreach ($Area as $key => $Points)
3691
+                {
3692
+                $Corners = ""; $Corners[] = $YZero; $Corners[] = $Area[$key][0]["Y"];
3693
+                foreach($Points as $subKey => $Point)
3694
+                {
3695
+                    if ( $subKey == count($Points)-1) { $Corners[] = $Point["X"]-1; } else { $Corners[] = $Point["X"]; }
3696
+                    $Corners[] = $Point["Y"];
3697
+                }
3698
+                $Corners[] = $YZero; $Corners[] = $Points[$subKey]["Y"]-1;
3812 3699
 
3813
-             if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3814
-             if ( $X == VOID ) { $X = NULL; }
3700
+                $this->drawPolygonChart($Corners,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha/2,"NoBorder"=>TRUE,"Threshold"=>$Threshold));
3701
+                }
3702
+                $this->drawSpline($WayPoints,array("Force"=>$Force,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks));
3703
+            }
3815 3704
 
3816
-             $LastX = $X; $LastY = $Y;
3817
-             $Y = $Y + $YStep;
3818 3705
             }
3819
-          }
3820 3706
         }
3821
-      }
3707
+        }
3822 3708
     }
3823 3709
 
3824
-   /* Draw a line chart */
3825
-   function drawZoneChart($SerieA,$SerieB,$Format=NULL)
3710
+    /* Draw a line chart */
3711
+    function drawLineChart($Format=NULL)
3826 3712
     {
3827
-     $AxisID	= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
3828
-     $LineR	= isset($Format["LineR"]) ? $Format["LineR"] : 150;
3829
-     $LineG	= isset($Format["LineG"]) ? $Format["LineG"] : 150;
3830
-     $LineB	= isset($Format["LineB"]) ? $Format["LineB"] : 150;
3831
-     $LineAlpha	= isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 50;
3832
-     $LineTicks	= isset($Format["LineTicks"]) ? $Format["LineTicks"] : 1;
3833
-     $AreaR	= isset($Format["AreaR"]) ? $Format["AreaR"] : 150;
3834
-     $AreaG	= isset($Format["AreaG"]) ? $Format["AreaG"] : 150;
3835
-     $AreaB	= isset($Format["AreaB"]) ? $Format["AreaB"] : 150;
3836
-     $AreaAlpha	= isset($Format["AreaAlpha"]) ? $Format["AreaAlpha"] : 5;
3713
+        $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : TRUE;
3714
+        $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3715
+        $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL;
3716
+        $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL;
3717
+        $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL;
3718
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
3719
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3720
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3721
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3722
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3723
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3724
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3725
+        $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3726
+        $ForceColor	= isset($Format["ForceColor"]) ? $Format["ForceColor"] : FALSE;
3727
+        $ForceR		= isset($Format["ForceR"]) ? $Format["ForceR"] : 0;
3728
+        $ForceG		= isset($Format["ForceG"]) ? $Format["ForceG"] : 0;
3729
+        $ForceB		= isset($Format["ForceB"]) ? $Format["ForceB"] : 0;
3730
+        $ForceAlpha	= isset($Format["ForceAlpha"]) ? $Format["ForceAlpha"] : 100;
3731
+
3732
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3733
+
3734
+        $Data = $this->DataSet->getData();
3735
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3736
+        foreach($Data["Series"] as $SerieName => $Serie)
3737
+        {
3738
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3739
+        {
3740
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3741
+
3742
+            if ( $ForceColor )
3743
+            { $R = $ForceR; $G = $ForceG; $B = $ForceB; $Alpha = $ForceAlpha; }
3744
+
3745
+            if ( $BreakR == NULL )
3746
+            $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3747
+            else
3748
+            $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3749
+
3750
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3837 3751
 
3838
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3752
+            $AxisID	= $Serie["Axis"];
3753
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3754
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3755
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3839 3756
 
3840
-     $Data	 = $this->DataSet->getData();
3841
-     if ( !isset($Data["Series"][$SerieA]["Data"]) || !isset($Data["Series"][$SerieB]["Data"]) ) { return(0); }
3842
-     $SerieAData = $Data["Series"][$SerieA]["Data"];
3843
-     $SerieBData = $Data["Series"][$SerieB]["Data"];
3757
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3844 3758
 
3845
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3759
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3846 3760
 
3847
-     $Mode	= $Data["Axis"][$AxisID]["Display"];
3848
-     $Format	= $Data["Axis"][$AxisID]["Format"];
3849
-     $Unit	= $Data["Axis"][$AxisID]["Unit"];
3761
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3850 3762
 
3851
-     $PosArrayA = $this->scaleComputeY($SerieAData,array("AxisID"=>$AxisID));
3852
-     $PosArrayB = $this->scaleComputeY($SerieBData,array("AxisID"=>$AxisID));
3853
-     if ( count($PosArrayA) != count($PosArrayB) ) { return(0); }
3763
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3764
+            {
3765
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3766
+            $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3767
+
3768
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3769
+            $LastGoodY = NULL; $LastGoodX = NULL;
3770
+            foreach($PosArray as $Key => $Y)
3771
+            {
3772
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3773
+                {
3774
+                if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
3775
+                $this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
3776
+                }
3777
+
3778
+                if ( $RecordImageMap && $Y != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3779
+
3780
+                if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
3781
+                $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3782
+
3783
+                if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3784
+                { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); $LastGoodY = NULL; }
3785
+
3786
+                if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3787
+                if ( $Y == VOID ) { $Y = NULL; }
3788
+
3789
+                $LastX = $X; $LastY = $Y;
3790
+                $X = $X + $XStep;
3791
+            }
3792
+            }
3793
+            else
3794
+            {
3795
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3796
+            $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
3797
+
3798
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3799
+            $LastGoodY = NULL; $LastGoodX = NULL;
3800
+            foreach($PosArray as $Key => $X)
3801
+            {
3802
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3803
+                { $this->drawText($X+$DisplayOffset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_BOTTOMMIDDLE)); }
3804
+
3805
+                if ( $RecordImageMap && $X != VOID ) { $this->addToImageMap("CIRCLE",floor($X).",".floor($Y).",".$ImageMapPlotSize,$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3806
+
3807
+                if ( $X != VOID && $LastX != NULL && $LastY != NULL )
3808
+                $this->drawLine($LastX,$LastY,$X,$Y,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight));
3809
+
3810
+                if ( $X != VOID && $LastX == NULL && $LastGoodY != NULL && !$BreakVoid )
3811
+                { $this->drawLine($LastGoodX,$LastGoodY,$X,$Y,$BreakSettings); $LastGoodY = NULL; }
3812
+
3813
+                if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
3814
+                if ( $X == VOID ) { $X = NULL; }
3815
+
3816
+                $LastX = $X; $LastY = $Y;
3817
+                $Y = $Y + $YStep;
3818
+            }
3819
+            }
3820
+        }
3821
+        }
3822
+    }
3854 3823
 
3855
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3856
-      {
3857
-       if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3858
-       $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3824
+    /* Draw a line chart */
3825
+    function drawZoneChart($SerieA,$SerieB,$Format=NULL)
3826
+    {
3827
+        $AxisID	= isset($Format["AxisID"]) ? $Format["AxisID"] : 0;
3828
+        $LineR	= isset($Format["LineR"]) ? $Format["LineR"] : 150;
3829
+        $LineG	= isset($Format["LineG"]) ? $Format["LineG"] : 150;
3830
+        $LineB	= isset($Format["LineB"]) ? $Format["LineB"] : 150;
3831
+        $LineAlpha	= isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 50;
3832
+        $LineTicks	= isset($Format["LineTicks"]) ? $Format["LineTicks"] : 1;
3833
+        $AreaR	= isset($Format["AreaR"]) ? $Format["AreaR"] : 150;
3834
+        $AreaG	= isset($Format["AreaG"]) ? $Format["AreaG"] : 150;
3835
+        $AreaB	= isset($Format["AreaB"]) ? $Format["AreaB"] : 150;
3836
+        $AreaAlpha	= isset($Format["AreaAlpha"]) ? $Format["AreaAlpha"] : 5;
3837
+
3838
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3839
+
3840
+        $Data	 = $this->DataSet->getData();
3841
+        if ( !isset($Data["Series"][$SerieA]["Data"]) || !isset($Data["Series"][$SerieB]["Data"]) ) { return(0); }
3842
+        $SerieAData = $Data["Series"][$SerieA]["Data"];
3843
+        $SerieBData = $Data["Series"][$SerieB]["Data"];
3844
+
3845
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3846
+
3847
+        $Mode	= $Data["Axis"][$AxisID]["Display"];
3848
+        $Format	= $Data["Axis"][$AxisID]["Format"];
3849
+        $Unit	= $Data["Axis"][$AxisID]["Unit"];
3850
+
3851
+        $PosArrayA = $this->scaleComputeY($SerieAData,array("AxisID"=>$AxisID));
3852
+        $PosArrayB = $this->scaleComputeY($SerieBData,array("AxisID"=>$AxisID));
3853
+        if ( count($PosArrayA) != count($PosArrayB) ) { return(0); }
3854
+
3855
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3856
+        {
3857
+        if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3858
+        $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3859 3859
 
3860
-       $LastX = NULL; $LastY1 = NULL; $LastY2 = NULL;
3861
-       $BoundsA = ""; $BoundsB = "";
3862
-       foreach($PosArrayA as $Key => $Y1)
3860
+        $LastX = NULL; $LastY1 = NULL; $LastY2 = NULL;
3861
+        $BoundsA = ""; $BoundsB = "";
3862
+        foreach($PosArrayA as $Key => $Y1)
3863 3863
         {
3864
-         $Y2 = $PosArrayB[$Key];
3864
+            $Y2 = $PosArrayB[$Key];
3865 3865
 
3866
-         $BoundsA[] = $X; $BoundsA[] = $Y1;
3867
-         $BoundsB[] = $X; $BoundsB[] = $Y2;
3866
+            $BoundsA[] = $X; $BoundsA[] = $Y1;
3867
+            $BoundsB[] = $X; $BoundsB[] = $Y2;
3868 3868
 
3869
-         $LastX = $X;
3870
-         $LastY1 = $Y1; $LastY2 = $Y2;
3869
+            $LastX = $X;
3870
+            $LastY1 = $Y1; $LastY2 = $Y2;
3871 3871
 
3872
-         $X = $X + $XStep;
3872
+            $X = $X + $XStep;
3873 3873
         }
3874
-       $Bounds = array_merge($BoundsA,$this->reversePlots($BoundsB));
3875
-       $this->drawPolygonChart($Bounds,array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"Alpha"=>$AreaAlpha));
3874
+        $Bounds = array_merge($BoundsA,$this->reversePlots($BoundsB));
3875
+        $this->drawPolygonChart($Bounds,array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"Alpha"=>$AreaAlpha));
3876 3876
 
3877
-       for($i=0;$i<=count($BoundsA)-4;$i=$i+2)
3877
+        for($i=0;$i<=count($BoundsA)-4;$i=$i+2)
3878 3878
         {
3879
-         $this->drawLine($BoundsA[$i],$BoundsA[$i+1],$BoundsA[$i+2],$BoundsA[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3880
-         $this->drawLine($BoundsB[$i],$BoundsB[$i+1],$BoundsB[$i+2],$BoundsB[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3879
+            $this->drawLine($BoundsA[$i],$BoundsA[$i+1],$BoundsA[$i+2],$BoundsA[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3880
+            $this->drawLine($BoundsB[$i],$BoundsB[$i+1],$BoundsB[$i+2],$BoundsB[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3881 3881
         }
3882
-      }
3883
-     else
3884
-      {
3885
-       if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3886
-       $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
3882
+        }
3883
+        else
3884
+        {
3885
+        if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
3886
+        $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
3887 3887
 
3888
-       $LastY = NULL; $LastX1 = NULL; $LastX2 = NULL;
3889
-       $BoundsA = ""; $BoundsB = "";
3890
-       foreach($PosArrayA as $Key => $X1)
3888
+        $LastY = NULL; $LastX1 = NULL; $LastX2 = NULL;
3889
+        $BoundsA = ""; $BoundsB = "";
3890
+        foreach($PosArrayA as $Key => $X1)
3891 3891
         {
3892
-         $X2 = $PosArrayB[$Key];
3892
+            $X2 = $PosArrayB[$Key];
3893 3893
 
3894
-         $BoundsA[] = $X1; $BoundsA[] = $Y;
3895
-         $BoundsB[] = $X2; $BoundsB[] = $Y;
3894
+            $BoundsA[] = $X1; $BoundsA[] = $Y;
3895
+            $BoundsB[] = $X2; $BoundsB[] = $Y;
3896 3896
 
3897
-         $LastY = $Y;
3898
-         $LastX1 = $X1; $LastX2 = $X2;
3897
+            $LastY = $Y;
3898
+            $LastX1 = $X1; $LastX2 = $X2;
3899 3899
 
3900
-         $Y = $Y + $YStep;
3900
+            $Y = $Y + $YStep;
3901 3901
         }
3902
-       $Bounds = array_merge($BoundsA,$this->reversePlots($BoundsB));
3903
-       $this->drawPolygonChart($Bounds,array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"Alpha"=>$AreaAlpha));
3902
+        $Bounds = array_merge($BoundsA,$this->reversePlots($BoundsB));
3903
+        $this->drawPolygonChart($Bounds,array("R"=>$AreaR,"G"=>$AreaG,"B"=>$AreaB,"Alpha"=>$AreaAlpha));
3904 3904
 
3905
-       for($i=0;$i<=count($BoundsA)-4;$i=$i+2)
3905
+        for($i=0;$i<=count($BoundsA)-4;$i=$i+2)
3906 3906
         {
3907
-         $this->drawLine($BoundsA[$i],$BoundsA[$i+1],$BoundsA[$i+2],$BoundsA[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3908
-         $this->drawLine($BoundsB[$i],$BoundsB[$i+1],$BoundsB[$i+2],$BoundsB[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3907
+            $this->drawLine($BoundsA[$i],$BoundsA[$i+1],$BoundsA[$i+2],$BoundsA[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3908
+            $this->drawLine($BoundsB[$i],$BoundsB[$i+1],$BoundsB[$i+2],$BoundsB[$i+3],array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha,"Ticks"=>$LineTicks));
3909
+        }
3909 3910
         }
3910
-      }
3911 3911
     }
3912 3912
 
3913
-   /* Draw a step chart */
3914
-   function drawStepChart($Format=NULL)
3913
+    /* Draw a step chart */
3914
+    function drawStepChart($Format=NULL)
3915 3915
     {
3916
-     $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : FALSE;
3917
-     $ReCenter		= isset($Format["ReCenter"]) ? $Format["ReCenter"] : TRUE;
3918
-     $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3919
-     $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL;
3920
-     $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL;
3921
-     $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL;
3922
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] :FALSE;
3923
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3924
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3925
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3926
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3927
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3928
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3929
-     $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3930
-
3931
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3932
-
3933
-     $Data = $this->DataSet->getData();
3934
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
3935
-     foreach($Data["Series"] as $SerieName => $Serie)
3936
-      {
3937
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3938
-        {
3939
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3940
-
3941
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3942
-
3943
-         if ( $BreakR == NULL )
3944
-          $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3945
-         else
3946
-          $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3947
-
3948
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3949
-
3950
-         $AxisID	= $Serie["Axis"];
3951
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
3952
-         $Format	= $Data["Axis"][$AxisID]["Format"];
3953
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
3954
-         $Color		= array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
3955
-
3956
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3957
-
3958
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3959
-
3960
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3961
-          {
3962
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3963
-           $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3964
-
3965
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3966
-           $LastGoodY = NULL; $LastGoodX = NULL; $Init = FALSE;
3967
-           foreach($PosArray as $Key => $Y)
3968
-            {
3969
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3970
-              {
3971
-               if ( $Y <= $LastY ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
3972
-               $this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
3973
-              }
3974
-
3975
-             if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
3976
-              {
3977
-               $this->drawLine($LastX,$LastY,$X,$LastY,$Color);
3978
-               $this->drawLine($X,$LastY,$X,$Y,$Color);
3979
-               if ( $ReCenter && $X+$XStep < $this->GraphAreaX2 - $XMargin )
3916
+        $BreakVoid		= isset($Format["BreakVoid"]) ? $Format["BreakVoid"] : FALSE;
3917
+        $ReCenter		= isset($Format["ReCenter"]) ? $Format["ReCenter"] : TRUE;
3918
+        $VoidTicks		= isset($Format["VoidTicks"]) ? $Format["VoidTicks"] : 4;
3919
+        $BreakR		= isset($Format["BreakR"]) ? $Format["BreakR"] : NULL;
3920
+        $BreakG		= isset($Format["BreakG"]) ? $Format["BreakG"] : NULL;
3921
+        $BreakB		= isset($Format["BreakB"]) ? $Format["BreakB"] : NULL;
3922
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] :FALSE;
3923
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
3924
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
3925
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
3926
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
3927
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
3928
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
3929
+        $ImageMapPlotSize  = isset($Format["ImageMapPlotSize"]) ? $Format["ImageMapPlotSize"] : 5;
3930
+
3931
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
3932
+
3933
+        $Data = $this->DataSet->getData();
3934
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
3935
+        foreach($Data["Series"] as $SerieName => $Serie)
3936
+        {
3937
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
3938
+        {
3939
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
3940
+
3941
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
3942
+
3943
+            if ( $BreakR == NULL )
3944
+            $BreakSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3945
+            else
3946
+            $BreakSettings = array("R"=>$BreakR,"G"=>$BreakG,"B"=>$BreakB,"Alpha"=>$Alpha,"Ticks"=>$VoidTicks,"Weight"=>$Weight);
3947
+
3948
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
3949
+
3950
+            $AxisID	= $Serie["Axis"];
3951
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
3952
+            $Format	= $Data["Axis"][$AxisID]["Format"];
3953
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
3954
+            $Color		= array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
3955
+
3956
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
3957
+
3958
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
3959
+
3960
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
3961
+            {
3962
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
3963
+            $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
3964
+
3965
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
3966
+            $LastGoodY = NULL; $LastGoodX = NULL; $Init = FALSE;
3967
+            foreach($PosArray as $Key => $Y)
3968
+            {
3969
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
3970
+                {
3971
+                if ( $Y <= $LastY ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
3972
+                $this->drawText($X,$Y-$Offset-$Weight,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
3973
+                }
3974
+
3975
+                if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
3976
+                {
3977
+                $this->drawLine($LastX,$LastY,$X,$LastY,$Color);
3978
+                $this->drawLine($X,$LastY,$X,$Y,$Color);
3979
+                if ( $ReCenter && $X+$XStep < $this->GraphAreaX2 - $XMargin )
3980 3980
                 {
3981
-                 $this->drawLine($X,$Y,$X+$XStep,$Y,$Color);
3982
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X-$ImageMapPlotSize).",".floor($Y-$ImageMapPlotSize).",".floor($X+$XStep+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3981
+                    $this->drawLine($X,$Y,$X+$XStep,$Y,$Color);
3982
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X-$ImageMapPlotSize).",".floor($Y-$ImageMapPlotSize).",".floor($X+$XStep+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3983 3983
                 }
3984
-               else
3984
+                else
3985 3985
                 { if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($LastY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); } }
3986
-              }
3986
+                }
3987 3987
 
3988
-             if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3989
-              { 
3990
-               if ( $ReCenter )
3988
+                if ( $Y != VOID && $LastY == NULL && $LastGoodY != NULL && !$BreakVoid )
3989
+                { 
3990
+                if ( $ReCenter )
3991 3991
                 {
3992
-                 $this->drawLine($LastGoodX+$XStep,$LastGoodY,$X,$LastGoodY,$BreakSettings);
3993
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX+$XStep-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($LastGoodY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3992
+                    $this->drawLine($LastGoodX+$XStep,$LastGoodY,$X,$LastGoodY,$BreakSettings);
3993
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX+$XStep-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($LastGoodY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3994 3994
                 }
3995
-               else
3995
+                else
3996 3996
                 {
3997
-                 $this->drawLine($LastGoodX,$LastGoodY,$X,$LastGoodY,$BreakSettings);
3998
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($LastGoodY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3997
+                    $this->drawLine($LastGoodX,$LastGoodY,$X,$LastGoodY,$BreakSettings);
3998
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($LastGoodY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
3999 3999
                 }
4000 4000
 
4001
-               $this->drawLine($X,$LastGoodY,$X,$Y,$BreakSettings);
4002
-               $LastGoodY = NULL;
4003
-              }
4004
-             elseif( !$BreakVoid && $LastGoodY == NULL && $Y != VOID )
4005
-              {
4006
-              $this->drawLine($this->GraphAreaX1 + $XMargin,$Y,$X,$Y,$BreakSettings);
4007
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($this->GraphAreaX1+$XMargin-$ImageMapPlotSize).",".floor($Y-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4008
-              }
4009
-
4010
-             if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4011
-             if ( $Y == VOID ) { $Y = NULL; }
4012
-
4013
-             if ( !$Init && $ReCenter ) { $X = $X - $XStep/2; $Init = TRUE; }
4014
-             $LastX = $X; $LastY = $Y;
4015
-             if ( $LastX < $this->GraphAreaX1 + $XMargin ) { $LastX = $this->GraphAreaX1 + $XMargin; }
4016
-             $X = $X + $XStep;
4017
-            }
4018
-           if ( $ReCenter )
4019
-            {
4020
-             $this->drawLine($LastX,$LastY,$this->GraphAreaX2 - $XMargin,$LastY,$Color);
4021
-             if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($this->GraphAreaX2-$XMargin+$ImageMapPlotSize).",".floor($LastY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4022
-            }
4023
-          }
4024
-         else
4025
-          {
4026
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4027
-           $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4028
-
4029
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4030
-           $LastGoodY = NULL; $LastGoodX = NULL; $Init = FALSE;
4031
-           foreach($PosArray as $Key => $X)
4032
-            {
4033
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
4034
-              {
4035
-               if ( $X >= $LastX ) { $Align = TEXT_ALIGN_MIDDLELEFT; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_MIDDLERIGHT; $Offset = -$DisplayOffset; }
4036
-               $this->drawText($X+$Offset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4037
-              }
4038
-
4039
-             if ( $X != VOID && $LastX != NULL && $LastY != NULL )
4040
-              {
4041
-               $this->drawLine($LastX,$LastY,$LastX,$Y,$Color);
4042
-               $this->drawLine($LastX,$Y,$X,$Y,$Color);
4043
-
4044
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($LastX+$XStep+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4045
-              }
4046
-
4047
-             if ( $X != VOID && $LastX == NULL && $LastGoodY != NULL && !$BreakVoid )
4048
-              {
4049
-               $this->drawLine($LastGoodX,$LastGoodY,$LastGoodX,$LastGoodY+$YStep,$Color);
4050
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($LastGoodX+$ImageMapPlotSize).",".floor($LastGoodY+$YStep+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4051
-
4052
-               $this->drawLine($LastGoodX,$LastGoodY+$YStep,$LastGoodX,$Y,$BreakSettings);
4053
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY+$YStep-$ImageMapPlotSize).",".floor($LastGoodX+$ImageMapPlotSize).",".floor($YStep+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4054
-
4055
-               $this->drawLine($LastGoodX,$Y,$X,$Y,$BreakSettings);
4056
-               $LastGoodY = NULL;
4057
-              }
4058
-             elseif ( $X != VOID && $LastGoodY == NULL && !$BreakVoid )
4059
-              {
4060
-               $this->drawLine($X,$this->GraphAreaY1 + $XMargin,$X,$Y,$BreakSettings);
4061
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X-$ImageMapPlotSize).",".floor($this->GraphAreaY1+$XMargin-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4062
-              }
4063
-
4064
-             if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4065
-             if ( $X == VOID ) { $X = NULL; }
4066
-
4067
-             if ( !$Init && $ReCenter ) { $Y = $Y - $YStep/2; $Init = TRUE; }
4068
-             $LastX = $X; $LastY = $Y;
4069
-             if ( $LastY < $this->GraphAreaY1 + $XMargin ) { $LastY = $this->GraphAreaY1 + $XMargin; }
4070
-             $Y = $Y + $YStep;
4071
-            }
4072
-           if ( $ReCenter )
4073
-            {
4074
-             $this->drawLine($LastX,$LastY,$LastX,$this->GraphAreaY2 - $XMargin,$Color);
4075
-             if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($LastX+$ImageMapPlotSize).",".floor($this->GraphAreaY2-$XMargin+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4076
-            }
4077
-          }
4078
-        }
4079
-      }
4080
-    }
4001
+                $this->drawLine($X,$LastGoodY,$X,$Y,$BreakSettings);
4002
+                $LastGoodY = NULL;
4003
+                }
4004
+                elseif( !$BreakVoid && $LastGoodY == NULL && $Y != VOID )
4005
+                {
4006
+                $this->drawLine($this->GraphAreaX1 + $XMargin,$Y,$X,$Y,$BreakSettings);
4007
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($this->GraphAreaX1+$XMargin-$ImageMapPlotSize).",".floor($Y-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4008
+                }
4081 4009
 
4082
-   /* Draw a step chart */
4083
-   function drawFilledStepChart($Format=NULL)
4084
-    {
4085
-     $ReCenter		= isset($Format["ReCenter"]) ? $Format["ReCenter"] : TRUE;
4086
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] :FALSE;
4087
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4088
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4089
-     $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : NULL;
4090
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4091
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4092
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4093
-     $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4010
+                if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4011
+                if ( $Y == VOID ) { $Y = NULL; }
4012
+
4013
+                if ( !$Init && $ReCenter ) { $X = $X - $XStep/2; $Init = TRUE; }
4014
+                $LastX = $X; $LastY = $Y;
4015
+                if ( $LastX < $this->GraphAreaX1 + $XMargin ) { $LastX = $this->GraphAreaX1 + $XMargin; }
4016
+                $X = $X + $XStep;
4017
+            }
4018
+            if ( $ReCenter )
4019
+            {
4020
+                $this->drawLine($LastX,$LastY,$this->GraphAreaX2 - $XMargin,$LastY,$Color);
4021
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($this->GraphAreaX2-$XMargin+$ImageMapPlotSize).",".floor($LastY+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4022
+            }
4023
+            }
4024
+            else
4025
+            {
4026
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4027
+            $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4028
+
4029
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4030
+            $LastGoodY = NULL; $LastGoodX = NULL; $Init = FALSE;
4031
+            foreach($PosArray as $Key => $X)
4032
+            {
4033
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
4034
+                {
4035
+                if ( $X >= $LastX ) { $Align = TEXT_ALIGN_MIDDLELEFT; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_MIDDLERIGHT; $Offset = -$DisplayOffset; }
4036
+                $this->drawText($X+$Offset+$Weight,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4037
+                }
4038
+
4039
+                if ( $X != VOID && $LastX != NULL && $LastY != NULL )
4040
+                {
4041
+                $this->drawLine($LastX,$LastY,$LastX,$Y,$Color);
4042
+                $this->drawLine($LastX,$Y,$X,$Y,$Color);
4094 4043
 
4095
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4044
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($LastX+$XStep+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4045
+                }
4046
+
4047
+                if ( $X != VOID && $LastX == NULL && $LastGoodY != NULL && !$BreakVoid )
4048
+                {
4049
+                $this->drawLine($LastGoodX,$LastGoodY,$LastGoodX,$LastGoodY+$YStep,$Color);
4050
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY-$ImageMapPlotSize).",".floor($LastGoodX+$ImageMapPlotSize).",".floor($LastGoodY+$YStep+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4096 4051
 
4097
-     $Data = $this->DataSet->getData();
4098
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
4099
-     foreach($Data["Series"] as $SerieName => $Serie)
4100
-      {
4101
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4052
+                $this->drawLine($LastGoodX,$LastGoodY+$YStep,$LastGoodX,$Y,$BreakSettings);
4053
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastGoodX-$ImageMapPlotSize).",".floor($LastGoodY+$YStep-$ImageMapPlotSize).",".floor($LastGoodX+$ImageMapPlotSize).",".floor($YStep+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4054
+
4055
+                $this->drawLine($LastGoodX,$Y,$X,$Y,$BreakSettings);
4056
+                $LastGoodY = NULL;
4057
+                }
4058
+                elseif ( $X != VOID && $LastGoodY == NULL && !$BreakVoid )
4059
+                {
4060
+                $this->drawLine($X,$this->GraphAreaY1 + $XMargin,$X,$Y,$BreakSettings);
4061
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X-$ImageMapPlotSize).",".floor($this->GraphAreaY1+$XMargin-$ImageMapPlotSize).",".floor($X+$ImageMapPlotSize).",".floor($Y+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4062
+                }
4063
+
4064
+                if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4065
+                if ( $X == VOID ) { $X = NULL; }
4066
+
4067
+                if ( !$Init && $ReCenter ) { $Y = $Y - $YStep/2; $Init = TRUE; }
4068
+                $LastX = $X; $LastY = $Y;
4069
+                if ( $LastY < $this->GraphAreaY1 + $XMargin ) { $LastY = $this->GraphAreaY1 + $XMargin; }
4070
+                $Y = $Y + $YStep;
4071
+            }
4072
+            if ( $ReCenter )
4073
+            {
4074
+                $this->drawLine($LastX,$LastY,$LastX,$this->GraphAreaY2 - $XMargin,$Color);
4075
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($LastX-$ImageMapPlotSize).",".floor($LastY-$ImageMapPlotSize).",".floor($LastX+$ImageMapPlotSize).",".floor($this->GraphAreaY2-$XMargin+$ImageMapPlotSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4076
+            }
4077
+            }
4078
+        }
4079
+        }
4080
+    }
4081
+
4082
+    /* Draw a step chart */
4083
+    function drawFilledStepChart($Format=NULL)
4084
+    {
4085
+        $ReCenter		= isset($Format["ReCenter"]) ? $Format["ReCenter"] : TRUE;
4086
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] :FALSE;
4087
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4088
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4089
+        $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : NULL;
4090
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4091
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4092
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4093
+        $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4094
+
4095
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4096
+
4097
+        $Data = $this->DataSet->getData();
4098
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
4099
+        foreach($Data["Series"] as $SerieName => $Serie)
4100
+        {
4101
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4102 4102
         {
4103
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
4103
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
4104 4104
 
4105
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4105
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4106 4106
 
4107
-         $AxisID	= $Serie["Axis"];
4108
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
4109
-         $Format	= $Data["Axis"][$AxisID]["Format"];
4110
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
4107
+            $AxisID	= $Serie["Axis"];
4108
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
4109
+            $Format	= $Data["Axis"][$AxisID]["Format"];
4110
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
4111 4111
 
4112
-         $Color		= array("R"=>$R,"G"=>$G,"B"=>$B);
4113
-         if ( $ForceTransparency != NULL ) { $Color["Alpha"] = $ForceTransparency; } else { $Color["Alpha"] = $Alpha; }
4112
+            $Color		= array("R"=>$R,"G"=>$G,"B"=>$B);
4113
+            if ( $ForceTransparency != NULL ) { $Color["Alpha"] = $ForceTransparency; } else { $Color["Alpha"] = $Alpha; }
4114 4114
 
4115
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4116
-         $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4115
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4116
+            $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4117 4117
 
4118
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4118
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4119 4119
 
4120
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4121
-          {
4122
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4123
-           if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4120
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4121
+            {
4122
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4123
+            if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4124 4124
 
4125
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4126
-           $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
4125
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4126
+            $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
4127 4127
 
4128
-           if ( !$AroundZero ) { $YZero = $this->GraphAreaY2-1; }
4128
+            if ( !$AroundZero ) { $YZero = $this->GraphAreaY2-1; }
4129 4129
 
4130
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4131
-           $LastGoodY = NULL; $LastGoodX = NULL; $Points = ""; $Init = FALSE;
4132
-           foreach($PosArray as $Key => $Y)
4130
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4131
+            $LastGoodY = NULL; $LastGoodX = NULL; $Points = ""; $Init = FALSE;
4132
+            foreach($PosArray as $Key => $Y)
4133 4133
             {
4134
-             if ( $Y == VOID && $LastX != NULL && $LastY != NULL && $Points !="" )
4135
-              {
4136
-               $Points[] = $LastX; $Points[] = $LastY;
4137
-               $Points[] = $X; $Points[] = $LastY;
4138
-               $Points[] = $X; $Points[] = $YZero;
4139
-               $this->drawPolygon($Points,$Color);
4140
-               $Points = "";
4141
-              }
4134
+                if ( $Y == VOID && $LastX != NULL && $LastY != NULL && $Points !="" )
4135
+                {
4136
+                $Points[] = $LastX; $Points[] = $LastY;
4137
+                $Points[] = $X; $Points[] = $LastY;
4138
+                $Points[] = $X; $Points[] = $YZero;
4139
+                $this->drawPolygon($Points,$Color);
4140
+                $Points = "";
4141
+                }
4142 4142
 
4143
-             if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
4144
-              {
4145
-               if ( $Points == "") { $Points[] = $LastX; $Points[] = $YZero; }
4146
-               $Points[] = $LastX; $Points[] = $LastY;
4147
-               $Points[] = $X; $Points[] = $LastY;
4148
-               $Points[] = $X; $Points[] = $Y;
4149
-              }
4143
+                if ( $Y != VOID && $LastX != NULL && $LastY != NULL )
4144
+                {
4145
+                if ( $Points == "") { $Points[] = $LastX; $Points[] = $YZero; }
4146
+                $Points[] = $LastX; $Points[] = $LastY;
4147
+                $Points[] = $X; $Points[] = $LastY;
4148
+                $Points[] = $X; $Points[] = $Y;
4149
+                }
4150 4150
 
4151
-             if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4152
-             if ( $Y == VOID ) { $Y = NULL; }
4151
+                if ( $Y != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4152
+                if ( $Y == VOID ) { $Y = NULL; }
4153 4153
 
4154
-             if ( !$Init && $ReCenter ) { $X = $X - $XStep/2; $Init = TRUE; }
4155
-             $LastX = $X; $LastY = $Y;
4156
-             if ( $LastX < $this->GraphAreaX1 + $XMargin ) { $LastX = $this->GraphAreaX1 + $XMargin; }
4157
-             $X = $X + $XStep;
4154
+                if ( !$Init && $ReCenter ) { $X = $X - $XStep/2; $Init = TRUE; }
4155
+                $LastX = $X; $LastY = $Y;
4156
+                if ( $LastX < $this->GraphAreaX1 + $XMargin ) { $LastX = $this->GraphAreaX1 + $XMargin; }
4157
+                $X = $X + $XStep;
4158 4158
             }
4159 4159
 
4160
-           if ( $ReCenter )
4160
+            if ( $ReCenter )
4161 4161
             {
4162
-             $Points[] = $LastX+$XStep/2; $Points[] = $LastY;
4163
-             $Points[] = $LastX+$XStep/2; $Points[] = $YZero;
4162
+                $Points[] = $LastX+$XStep/2; $Points[] = $LastY;
4163
+                $Points[] = $LastX+$XStep/2; $Points[] = $YZero;
4164 4164
             }
4165
-           else
4165
+            else
4166 4166
             { $Points[] = $LastX; $Points[] = $YZero; }
4167 4167
 
4168
-           $this->drawPolygon($Points,$Color);
4169
-          }
4170
-         else
4171
-          {
4172
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4173
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4168
+            $this->drawPolygon($Points,$Color);
4169
+            }
4170
+            else
4171
+            {
4172
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4173
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4174 4174
 
4175
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4176
-           $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4175
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4176
+            $Y = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4177 4177
 
4178
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4179
-           $LastGoodY = NULL; $LastGoodX = NULL; $Points = "";
4180
-           foreach($PosArray as $Key => $X)
4178
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4179
+            $LastGoodY = NULL; $LastGoodX = NULL; $Points = "";
4180
+            foreach($PosArray as $Key => $X)
4181 4181
             {
4182
-             if ( $X == VOID && $LastX != NULL && $LastY != NULL && $Points !="" )
4183
-              {
4184
-               $Points[] = $LastX; $Points[] = $LastY;
4185
-               $Points[] = $LastX; $Points[] = $Y;
4186
-               $Points[] = $YZero; $Points[] = $Y;
4187
-               $this->drawPolygon($Points,$Color);
4188
-               $Points = "";
4189
-              }
4182
+                if ( $X == VOID && $LastX != NULL && $LastY != NULL && $Points !="" )
4183
+                {
4184
+                $Points[] = $LastX; $Points[] = $LastY;
4185
+                $Points[] = $LastX; $Points[] = $Y;
4186
+                $Points[] = $YZero; $Points[] = $Y;
4187
+                $this->drawPolygon($Points,$Color);
4188
+                $Points = "";
4189
+                }
4190 4190
 
4191
-             if ( $X != VOID && $LastX != NULL && $LastY != NULL )
4192
-              {
4193
-               if ( $Points == "") { $Points[] = $YZero; $Points[] = $LastY; }
4194
-               $Points[] = $LastX; $Points[] = $LastY;
4195
-               $Points[] = $LastX; $Points[] = $Y;
4196
-               $Points[] = $X; $Points[] = $Y;
4197
-              }
4191
+                if ( $X != VOID && $LastX != NULL && $LastY != NULL )
4192
+                {
4193
+                if ( $Points == "") { $Points[] = $YZero; $Points[] = $LastY; }
4194
+                $Points[] = $LastX; $Points[] = $LastY;
4195
+                $Points[] = $LastX; $Points[] = $Y;
4196
+                $Points[] = $X; $Points[] = $Y;
4197
+                }
4198 4198
 
4199
-             if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4200
-             if ( $X == VOID ) { $X = NULL; }
4199
+                if ( $X != VOID ) { $LastGoodY = $Y; $LastGoodX = $X; }
4200
+                if ( $X == VOID ) { $X = NULL; }
4201 4201
 
4202
-             if ( $LastX == NULL && $ReCenter ) { $Y = $Y - $YStep/2; }
4203
-             $LastX = $X; $LastY = $Y;
4204
-             if ( $LastY < $this->GraphAreaY1 + $XMargin ) { $LastY = $this->GraphAreaY1 + $XMargin; }
4205
-             $Y = $Y + $YStep;
4202
+                if ( $LastX == NULL && $ReCenter ) { $Y = $Y - $YStep/2; }
4203
+                $LastX = $X; $LastY = $Y;
4204
+                if ( $LastY < $this->GraphAreaY1 + $XMargin ) { $LastY = $this->GraphAreaY1 + $XMargin; }
4205
+                $Y = $Y + $YStep;
4206 4206
             }
4207 4207
 
4208
-           if ( $ReCenter )
4208
+            if ( $ReCenter )
4209 4209
             {
4210
-             $Points[] = $LastX; $Points[] = $LastY+$YStep/2;
4211
-             $Points[] = $YZero; $Points[] = $LastY+$YStep/2;
4210
+                $Points[] = $LastX; $Points[] = $LastY+$YStep/2;
4211
+                $Points[] = $YZero; $Points[] = $LastY+$YStep/2;
4212 4212
             }
4213
-           else
4213
+            else
4214 4214
             { $Points[] = $YZero; $Points[] = $LastY; }
4215 4215
 
4216
-           $this->drawPolygon($Points,$Color);
4217
-          }
4216
+            $this->drawPolygon($Points,$Color);
4217
+            }
4218
+        }
4218 4219
         }
4219
-      }
4220 4220
     }
4221 4221
 
4222
-   /* Draw an area chart */
4223
-   function drawAreaChart($Format=NULL)
4222
+    /* Draw an area chart */
4223
+    function drawAreaChart($Format=NULL)
4224 4224
     {
4225
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4226
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4227
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4228
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4229
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4230
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4231
-     $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : 25;
4232
-     $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4233
-     $Threshold		= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
4234
-
4235
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4236
-
4237
-     $Data  = $this->DataSet->getData();
4238
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
4239
-
4240
-     foreach($Data["Series"] as $SerieName => $Serie)
4241
-      {
4242
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4225
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4226
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4227
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4228
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4229
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4230
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4231
+        $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : 25;
4232
+        $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4233
+        $Threshold		= isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
4234
+
4235
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4236
+
4237
+        $Data  = $this->DataSet->getData();
4238
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
4239
+
4240
+        foreach($Data["Series"] as $SerieName => $Serie)
4243 4241
         {
4244
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4245
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4242
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4243
+        {
4244
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4245
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4246 4246
 
4247
-         $AxisID	= $Serie["Axis"];
4248
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
4249
-         $Format	= $Data["Axis"][$AxisID]["Format"];
4250
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
4247
+            $AxisID	= $Serie["Axis"];
4248
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
4249
+            $Format	= $Data["Axis"][$AxisID]["Format"];
4250
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
4251 4251
 
4252
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4253
-         $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4252
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4253
+            $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4254 4254
 
4255
-         if ( $Threshold != NULL )
4256
-          {
4257
-           foreach($Threshold as $Key => $Params)
4255
+            if ( $Threshold != NULL )
4256
+            {
4257
+            foreach($Threshold as $Key => $Params)
4258 4258
             {
4259
-             $Threshold[$Key]["MinX"] = $this->scaleComputeY($Params["Min"],array("AxisID"=>$Serie["Axis"]));
4260
-             $Threshold[$Key]["MaxX"] = $this->scaleComputeY($Params["Max"],array("AxisID"=>$Serie["Axis"]));
4259
+                $Threshold[$Key]["MinX"] = $this->scaleComputeY($Params["Min"],array("AxisID"=>$Serie["Axis"]));
4260
+                $Threshold[$Key]["MaxX"] = $this->scaleComputeY($Params["Max"],array("AxisID"=>$Serie["Axis"]));
4261
+            }
4261 4262
             }
4262
-          }
4263 4263
 
4264
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4264
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4265 4265
 
4266
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4267
-          {
4268
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4266
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4267
+            {
4268
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4269 4269
 
4270
-           $Areas = ""; $AreaID = 0; 
4271
-           $Areas[$AreaID][] = $this->GraphAreaX1 + $XMargin;
4272
-           if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4270
+            $Areas = ""; $AreaID = 0; 
4271
+            $Areas[$AreaID][] = $this->GraphAreaX1 + $XMargin;
4272
+            if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4273 4273
 
4274
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4275
-           $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
4274
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4275
+            $X = $this->GraphAreaX1 + $XMargin; $LastX = NULL; $LastY = NULL;
4276 4276
 
4277
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4278
-           foreach($PosArray as $Key => $Y)
4277
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4278
+            foreach($PosArray as $Key => $Y)
4279 4279
             {
4280
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4281
-              {
4282
-               if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4283
-               $this->drawText($X,$Y-$Offset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4284
-              }
4280
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4281
+                {
4282
+                if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4283
+                $this->drawText($X,$Y-$Offset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4284
+                }
4285 4285
 
4286
-             if ( $Y == VOID && isset($Areas[$AreaID]) )
4287
-              {
4288
-               if($LastX == NULL)
4286
+                if ( $Y == VOID && isset($Areas[$AreaID]) )
4287
+                {
4288
+                if($LastX == NULL)
4289 4289
                 { $Areas[$AreaID][] = $X; }
4290
-               else
4290
+                else
4291 4291
                 { $Areas[$AreaID][] = $LastX; }
4292 4292
 
4293
-               if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4294
-               $AreaID++;
4295
-              }
4296
-             elseif ($Y != VOID)
4297
-              {
4298
-               if ( !isset($Areas[$AreaID]) )
4293
+                if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4294
+                $AreaID++;
4295
+                }
4296
+                elseif ($Y != VOID)
4297
+                {
4298
+                if ( !isset($Areas[$AreaID]) )
4299 4299
                 {
4300
-                 $Areas[$AreaID][] = $X;
4301
-                 if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4300
+                    $Areas[$AreaID][] = $X;
4301
+                    if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4302 4302
                 }
4303 4303
 
4304
-               $Areas[$AreaID][] = $X;
4305
-               $Areas[$AreaID][] = $Y;
4306
-              }
4304
+                $Areas[$AreaID][] = $X;
4305
+                $Areas[$AreaID][] = $Y;
4306
+                }
4307 4307
 
4308
-             $LastX = $X;
4309
-             $X = $X + $XStep;
4308
+                $LastX = $X;
4309
+                $X = $X + $XStep;
4310 4310
             }
4311
-           $Areas[$AreaID][] = $LastX;
4312
-           if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4311
+            $Areas[$AreaID][] = $LastX;
4312
+            if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaY2-1; }
4313 4313
 
4314
-           /* Handle shadows in the areas */
4315
-           if ( $this->Shadow )
4314
+            /* Handle shadows in the areas */
4315
+            if ( $this->Shadow )
4316 4316
             {
4317
-             $ShadowArea = "";
4318
-             foreach($Areas as $Key => $Points)
4319
-              {
4320
-               $ShadowArea[$Key] = "";
4321
-               foreach($Points as $Key2 => $Value)
4317
+                $ShadowArea = "";
4318
+                foreach($Areas as $Key => $Points)
4319
+                {
4320
+                $ShadowArea[$Key] = "";
4321
+                foreach($Points as $Key2 => $Value)
4322 4322
                 {
4323
-                 if ( $Key2 % 2 == 0 )
4324
-                  { $ShadowArea[$Key][] = $Value + $this->ShadowX; }
4325
-                 else
4326
-                  { $ShadowArea[$Key][] = $Value + $this->ShadowY; }
4323
+                    if ( $Key2 % 2 == 0 )
4324
+                    { $ShadowArea[$Key][] = $Value + $this->ShadowX; }
4325
+                    else
4326
+                    { $ShadowArea[$Key][] = $Value + $this->ShadowY; }
4327 4327
                 }
4328
-              }              
4328
+                }              
4329 4329
 
4330
-             foreach($ShadowArea as $Key => $Points)
4331
-              $this->drawPolygonChart($Points,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
4330
+                foreach($ShadowArea as $Key => $Points)
4331
+                $this->drawPolygonChart($Points,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
4332 4332
             }
4333 4333
 
4334
-           $Alpha = $ForceTransparency != NULL ? $ForceTransparency : $Alpha;
4335
-           $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Threshold"=>$Threshold);
4334
+            $Alpha = $ForceTransparency != NULL ? $ForceTransparency : $Alpha;
4335
+            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Threshold"=>$Threshold);
4336 4336
 
4337
-           foreach($Areas as $Key => $Points)
4337
+            foreach($Areas as $Key => $Points)
4338 4338
             $this->drawPolygonChart($Points,$Color);
4339
-          }
4340
-         else
4341
-          {
4342
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4343
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4339
+            }
4340
+            else
4341
+            {
4342
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4343
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4344 4344
 
4345
-           $Areas = ""; $AreaID = 0; 
4346
-           if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4347
-           $Areas[$AreaID][] = $this->GraphAreaY1 + $XMargin;
4345
+            $Areas = ""; $AreaID = 0; 
4346
+            if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4347
+            $Areas[$AreaID][] = $this->GraphAreaY1 + $XMargin;
4348 4348
 
4349
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4350
-           $Y     = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4349
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4350
+            $Y     = $this->GraphAreaY1 + $XMargin; $LastX = NULL; $LastY = NULL;
4351 4351
 
4352
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4353
-           foreach($PosArray as $Key => $X)
4352
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4353
+            foreach($PosArray as $Key => $X)
4354 4354
             {
4355
-             if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4356
-              {
4357
-               if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4358
-               $this->drawText($X+$Offset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4359
-              }
4355
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4356
+                {
4357
+                if ( $Serie["Data"][$Key] > 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4358
+                $this->drawText($X+$Offset,$Y,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("Angle"=>270,"R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align));
4359
+                }
4360 4360
 
4361
-             if ( $X == VOID && isset($Areas[$AreaID]) )
4362
-              {
4363
-               if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4361
+                if ( $X == VOID && isset($Areas[$AreaID]) )
4362
+                {
4363
+                if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4364 4364
 
4365
-               if($LastY == NULL)
4365
+                if($LastY == NULL)
4366 4366
                 { $Areas[$AreaID][] = $Y; }
4367
-               else
4367
+                else
4368 4368
                 { $Areas[$AreaID][] = $LastY; }
4369 4369
 
4370
-               $AreaID++;
4371
-              }
4372
-             elseif ($X != VOID)
4373
-              {
4374
-               if ( !isset($Areas[$AreaID]) )
4370
+                $AreaID++;
4371
+                }
4372
+                elseif ($X != VOID)
4373
+                {
4374
+                if ( !isset($Areas[$AreaID]) )
4375 4375
                 {
4376
-                 if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4377
-                 $Areas[$AreaID][] = $Y;
4376
+                    if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4377
+                    $Areas[$AreaID][] = $Y;
4378 4378
                 }
4379 4379
 
4380
-               $Areas[$AreaID][] = $X;
4381
-               $Areas[$AreaID][] = $Y;
4382
-              }
4380
+                $Areas[$AreaID][] = $X;
4381
+                $Areas[$AreaID][] = $Y;
4382
+                }
4383 4383
 
4384
-             $LastX = $X; $LastY = $Y;
4385
-             $Y = $Y + $YStep;
4384
+                $LastX = $X; $LastY = $Y;
4385
+                $Y = $Y + $YStep;
4386 4386
             }
4387
-           if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4388
-           $Areas[$AreaID][] = $LastY;
4387
+            if ( $AroundZero ) { $Areas[$AreaID][] = $YZero; } else { $Areas[$AreaID][] = $this->GraphAreaX1+1; }
4388
+            $Areas[$AreaID][] = $LastY;
4389 4389
 
4390
-           /* Handle shadows in the areas */
4391
-           if ( $this->Shadow )
4390
+            /* Handle shadows in the areas */
4391
+            if ( $this->Shadow )
4392 4392
             {
4393
-             $ShadowArea = "";
4394
-             foreach($Areas as $Key => $Points)
4395
-              {
4396
-               $ShadowArea[$Key] = "";
4397
-               foreach($Points as $Key2 => $Value)
4393
+                $ShadowArea = "";
4394
+                foreach($Areas as $Key => $Points)
4395
+                {
4396
+                $ShadowArea[$Key] = "";
4397
+                foreach($Points as $Key2 => $Value)
4398 4398
                 {
4399
-                 if ( $Key2 % 2 == 0 )
4400
-                  { $ShadowArea[$Key][] = $Value + $this->ShadowX; }
4401
-                 else
4402
-                  { $ShadowArea[$Key][] = $Value + $this->ShadowY; }
4399
+                    if ( $Key2 % 2 == 0 )
4400
+                    { $ShadowArea[$Key][] = $Value + $this->ShadowX; }
4401
+                    else
4402
+                    { $ShadowArea[$Key][] = $Value + $this->ShadowY; }
4403 4403
                 }
4404
-              }              
4404
+                }              
4405 4405
 
4406
-             foreach($ShadowArea as $Key => $Points)
4407
-              $this->drawPolygonChart($Points,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
4406
+                foreach($ShadowArea as $Key => $Points)
4407
+                $this->drawPolygonChart($Points,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
4408 4408
             }
4409 4409
 
4410
-           $Alpha = $ForceTransparency != NULL ? $ForceTransparency : $Alpha;
4411
-           $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Threshold"=>$Threshold);
4410
+            $Alpha = $ForceTransparency != NULL ? $ForceTransparency : $Alpha;
4411
+            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Threshold"=>$Threshold);
4412 4412
 
4413
-           foreach($Areas as $Key => $Points)
4413
+            foreach($Areas as $Key => $Points)
4414 4414
             $this->drawPolygonChart($Points,$Color);
4415
-          }
4415
+            }
4416
+        }
4416 4417
         }
4417
-      }
4418 4418
     }
4419 4419
 
4420 4420
 
4421
-   /* Draw a bar chart */
4422
-   function drawBarChart($Format=NULL)
4421
+    /* Draw a bar chart */
4422
+    function drawBarChart($Format=NULL)
4423 4423
     {
4424
-     $Floating0Serie	= isset($Format["Floating0Serie"]) ? $Format["Floating0Serie"] : NULL;
4425
-     $Floating0Value	= isset($Format["Floating0Value"]) ? $Format["Floating0Value"] : NULL;
4426
-     $Draw0Line		= isset($Format["Draw0Line"]) ? $Format["Draw0Line"] : FALSE;
4427
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4428
-     $DisplayOrientation = isset($Format["DisplayOrientation"]) ? $Format["DisplayOrientation"] : ORIENTATION_HORIZONTAL;
4429
-     $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4430
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4431
-     $DisplayFont	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontName;
4432
-     $DisplaySize	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontSize;
4433
-     $DisplayPos	= isset($Format["DisplayPos"]) ? $Format["DisplayPos"] : LABEL_POS_OUTSIDE;
4434
-     $DisplayShadow	= isset($Format["DisplayShadow"]) ? $Format["DisplayShadow"] : TRUE;
4435
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4436
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4437
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4438
-     $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4439
-     $Interleave	= isset($Format["Interleave"]) ? $Format["Interleave"] : .5;
4440
-     $Rounded		= isset($Format["Rounded"]) ? $Format["Rounded"] : FALSE;
4441
-     $RoundRadius	= isset($Format["RoundRadius"]) ? $Format["RoundRadius"] : 4;
4442
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
4443
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
4444
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
4445
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
4446
-     $Gradient		= isset($Format["Gradient"]) ? $Format["Gradient"] : FALSE;
4447
-     $GradientMode	= isset($Format["GradientMode"]) ? $Format["GradientMode"] : GRADIENT_SIMPLE;
4448
-     $GradientAlpha	= isset($Format["GradientAlpha"]) ? $Format["GradientAlpha"] : 20;
4449
-     $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
4450
-     $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
4451
-     $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
4452
-     $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 0;
4453
-     $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 0;
4454
-     $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 0;
4455
-     $TxtMargin		= isset($Format["TxtMargin"]) ? $Format["TxtMargin"] : 6;
4456
-     $OverrideColors	= isset($Format["OverrideColors"]) ? $Format["OverrideColors"] : NULL;
4457
-     $OverrideSurrounding = isset($Format["OverrideSurrounding"]) ? $Format["OverrideSurrounding"] : 30;
4458
-     $InnerSurrounding	= isset($Format["InnerSurrounding"]) ? $Format["InnerSurrounding"] : NULL;
4459
-     $InnerBorderR	= isset($Format["InnerBorderR"]) ? $Format["InnerBorderR"] : -1;
4460
-     $InnerBorderG	= isset($Format["InnerBorderG"]) ? $Format["InnerBorderG"] : -1;
4461
-     $InnerBorderB	= isset($Format["InnerBorderB"]) ? $Format["InnerBorderB"] : -1;
4462
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
4463
-
4464
-     $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4465
-
4466
-     $Data = $this->DataSet->getData();
4467
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
4468
-
4469
-     if ( $OverrideColors != NULL )
4470
-      {
4471
-       $OverrideColors = $this->validatePalette($OverrideColors,$OverrideSurrounding);
4472
-       $this->DataSet->saveExtendedData("Palette",$OverrideColors);
4473
-      }
4474
-
4475
-     $RestoreShadow = $this->Shadow;
4476
-
4477
-     $SeriesCount  = $this->countDrawableSeries();
4478
-     $CurrentSerie = 0;
4479
-     foreach($Data["Series"] as $SerieName => $Serie)
4480
-      {
4481
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4482
-        {
4483
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4484
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4485
-         if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
4486
-         if ( $InnerSurrounding != NULL ) { $InnerBorderR = $R+$InnerSurrounding; $InnerBorderG = $G+$InnerSurrounding; $InnerBorderB = $B+$InnerSurrounding; }
4487
-         if ( $InnerBorderR == -1 ) { $InnerColor = NULL; } else { $InnerColor = array("R"=>$InnerBorderR,"G"=>$InnerBorderG,"B"=>$InnerBorderB); }
4488
-         $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB);
4489
-
4490
-         $AxisID	= $Serie["Axis"];
4491
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
4492
-         $Format	= $Data["Axis"][$AxisID]["Format"];
4493
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
4494
-
4495
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
4496
-
4497
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4498
-
4499
-         if ( $Floating0Value != NULL )
4500
-          { $YZero = $this->scaleComputeY($Floating0Value,array("AxisID"=>$Serie["Axis"])); }
4501
-         else
4502
-          { $YZero = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"])); }
4503
-
4504
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4505
-          {
4506
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4507
-           if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4508
-
4509
-           if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4510
-           $X = $this->GraphAreaX1 + $XMargin;
4511
-
4512
-           if ( $AroundZero ) { $Y1 = $YZero; } else { $Y1 = $this->GraphAreaY2-1; }
4513
-           if ( $XDivs == 0 ) { $XSize = ($this->GraphAreaX2-$this->GraphAreaX1)/($SeriesCount+$Interleave); } else { $XSize   = ($XStep / ($SeriesCount+$Interleave) ); }
4514
-
4515
-           $XOffset = -($XSize*$SeriesCount)/2 + $CurrentSerie * $XSize;
4516
-           if ( $X + $XOffset <= $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $X + 1 ; }
4517
-
4518
-           $this->DataSet->Data["Series"][$SerieName]["XOffset"] = $XOffset + $XSize / 2;
4519
-
4520
-           if ( $Rounded || $BorderR != -1) { $XSpace = 1; } else { $XSpace = 0; }
4521
-
4522
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4523
-
4524
-           $ID = 0;
4525
-           foreach($PosArray as $Key => $Y2)
4526
-            {
4527
-             if ( $Floating0Serie != NULL )
4528
-              {
4529
-               if ( isset($Data["Series"][$Floating0Serie]["Data"][$Key]) )
4424
+        $Floating0Serie	= isset($Format["Floating0Serie"]) ? $Format["Floating0Serie"] : NULL;
4425
+        $Floating0Value	= isset($Format["Floating0Value"]) ? $Format["Floating0Value"] : NULL;
4426
+        $Draw0Line		= isset($Format["Draw0Line"]) ? $Format["Draw0Line"] : FALSE;
4427
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4428
+        $DisplayOrientation = isset($Format["DisplayOrientation"]) ? $Format["DisplayOrientation"] : ORIENTATION_HORIZONTAL;
4429
+        $DisplayOffset	= isset($Format["DisplayOffset"]) ? $Format["DisplayOffset"] : 2;
4430
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4431
+        $DisplayFont	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontName;
4432
+        $DisplaySize	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontSize;
4433
+        $DisplayPos	= isset($Format["DisplayPos"]) ? $Format["DisplayPos"] : LABEL_POS_OUTSIDE;
4434
+        $DisplayShadow	= isset($Format["DisplayShadow"]) ? $Format["DisplayShadow"] : TRUE;
4435
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4436
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4437
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4438
+        $AroundZero	= isset($Format["AroundZero"]) ? $Format["AroundZero"] : TRUE;
4439
+        $Interleave	= isset($Format["Interleave"]) ? $Format["Interleave"] : .5;
4440
+        $Rounded		= isset($Format["Rounded"]) ? $Format["Rounded"] : FALSE;
4441
+        $RoundRadius	= isset($Format["RoundRadius"]) ? $Format["RoundRadius"] : 4;
4442
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
4443
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
4444
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
4445
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
4446
+        $Gradient		= isset($Format["Gradient"]) ? $Format["Gradient"] : FALSE;
4447
+        $GradientMode	= isset($Format["GradientMode"]) ? $Format["GradientMode"] : GRADIENT_SIMPLE;
4448
+        $GradientAlpha	= isset($Format["GradientAlpha"]) ? $Format["GradientAlpha"] : 20;
4449
+        $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
4450
+        $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
4451
+        $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
4452
+        $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 0;
4453
+        $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 0;
4454
+        $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 0;
4455
+        $TxtMargin		= isset($Format["TxtMargin"]) ? $Format["TxtMargin"] : 6;
4456
+        $OverrideColors	= isset($Format["OverrideColors"]) ? $Format["OverrideColors"] : NULL;
4457
+        $OverrideSurrounding = isset($Format["OverrideSurrounding"]) ? $Format["OverrideSurrounding"] : 30;
4458
+        $InnerSurrounding	= isset($Format["InnerSurrounding"]) ? $Format["InnerSurrounding"] : NULL;
4459
+        $InnerBorderR	= isset($Format["InnerBorderR"]) ? $Format["InnerBorderR"] : -1;
4460
+        $InnerBorderG	= isset($Format["InnerBorderG"]) ? $Format["InnerBorderG"] : -1;
4461
+        $InnerBorderB	= isset($Format["InnerBorderB"]) ? $Format["InnerBorderB"] : -1;
4462
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
4463
+
4464
+        $this->LastChartLayout = CHART_LAST_LAYOUT_REGULAR;
4465
+
4466
+        $Data = $this->DataSet->getData();
4467
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
4468
+
4469
+        if ( $OverrideColors != NULL )
4470
+        {
4471
+        $OverrideColors = $this->validatePalette($OverrideColors,$OverrideSurrounding);
4472
+        $this->DataSet->saveExtendedData("Palette",$OverrideColors);
4473
+        }
4474
+
4475
+        $RestoreShadow = $this->Shadow;
4476
+
4477
+        $SeriesCount  = $this->countDrawableSeries();
4478
+        $CurrentSerie = 0;
4479
+        foreach($Data["Series"] as $SerieName => $Serie)
4480
+        {
4481
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4482
+        {
4483
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4484
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = $R; $DisplayG = $G; $DisplayB = $B; }
4485
+            if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
4486
+            if ( $InnerSurrounding != NULL ) { $InnerBorderR = $R+$InnerSurrounding; $InnerBorderG = $G+$InnerSurrounding; $InnerBorderB = $B+$InnerSurrounding; }
4487
+            if ( $InnerBorderR == -1 ) { $InnerColor = NULL; } else { $InnerColor = array("R"=>$InnerBorderR,"G"=>$InnerBorderG,"B"=>$InnerBorderB); }
4488
+            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB);
4489
+
4490
+            $AxisID	= $Serie["Axis"];
4491
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
4492
+            $Format	= $Data["Axis"][$AxisID]["Format"];
4493
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
4494
+
4495
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
4496
+
4497
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
4498
+
4499
+            if ( $Floating0Value != NULL )
4500
+            { $YZero = $this->scaleComputeY($Floating0Value,array("AxisID"=>$Serie["Axis"])); }
4501
+            else
4502
+            { $YZero = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"])); }
4503
+
4504
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4505
+            {
4506
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4507
+            if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4508
+
4509
+            if ( $XDivs == 0 ) { $XStep = 0; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4510
+            $X = $this->GraphAreaX1 + $XMargin;
4511
+
4512
+            if ( $AroundZero ) { $Y1 = $YZero; } else { $Y1 = $this->GraphAreaY2-1; }
4513
+            if ( $XDivs == 0 ) { $XSize = ($this->GraphAreaX2-$this->GraphAreaX1)/($SeriesCount+$Interleave); } else { $XSize   = ($XStep / ($SeriesCount+$Interleave) ); }
4514
+
4515
+            $XOffset = -($XSize*$SeriesCount)/2 + $CurrentSerie * $XSize;
4516
+            if ( $X + $XOffset <= $this->GraphAreaX1 ) { $XOffset = $this->GraphAreaX1 - $X + 1 ; }
4517
+
4518
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = $XOffset + $XSize / 2;
4519
+
4520
+            if ( $Rounded || $BorderR != -1) { $XSpace = 1; } else { $XSpace = 0; }
4521
+
4522
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4523
+
4524
+            $ID = 0;
4525
+            foreach($PosArray as $Key => $Y2)
4526
+            {
4527
+                if ( $Floating0Serie != NULL )
4528
+                {
4529
+                if ( isset($Data["Series"][$Floating0Serie]["Data"][$Key]) )
4530 4530
                 { $Value = $Data["Series"][$Floating0Serie]["Data"][$Key]; }
4531
-               else
4531
+                else
4532 4532
                 { $Value = 0; }
4533 4533
 
4534
-               $YZero = $this->scaleComputeY($Value,array("AxisID"=>$Serie["Axis"]));
4535
-               if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4536
-               if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4534
+                $YZero = $this->scaleComputeY($Value,array("AxisID"=>$Serie["Axis"]));
4535
+                if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4536
+                if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
4537 4537
 
4538
-               if ( $AroundZero ) { $Y1 = $YZero; } else { $Y1 = $this->GraphAreaY2-1; }
4539
-              }
4538
+                if ( $AroundZero ) { $Y1 = $YZero; } else { $Y1 = $this->GraphAreaY2-1; }
4539
+                }
4540 4540
 
4541
-             if ( $OverrideColors != NULL )
4542
-              { if ( isset($OverrideColors[$ID]) ) { $Color = array("R"=>$OverrideColors[$ID]["R"],"G"=>$OverrideColors[$ID]["G"],"B"=>$OverrideColors[$ID]["B"],"Alpha"=>$OverrideColors[$ID]["Alpha"],"BorderR"=>$OverrideColors[$ID]["BorderR"],"BorderG"=>$OverrideColors[$ID]["BorderG"],"BorderB"=>$OverrideColors[$ID]["BorderB"]); } else { $Color = $this->getRandomColor(); } }
4541
+                if ( $OverrideColors != NULL )
4542
+                { if ( isset($OverrideColors[$ID]) ) { $Color = array("R"=>$OverrideColors[$ID]["R"],"G"=>$OverrideColors[$ID]["G"],"B"=>$OverrideColors[$ID]["B"],"Alpha"=>$OverrideColors[$ID]["Alpha"],"BorderR"=>$OverrideColors[$ID]["BorderR"],"BorderG"=>$OverrideColors[$ID]["BorderG"],"BorderB"=>$OverrideColors[$ID]["BorderB"]); } else { $Color = $this->getRandomColor(); } }
4543 4543
 
4544
-             if ( $Y2 != VOID )
4545
-              {
4546
-               $BarHeight = $Y1 - $Y2;
4544
+                if ( $Y2 != VOID )
4545
+                {
4546
+                $BarHeight = $Y1 - $Y2;
4547 4547
 
4548
-               if ( $Serie["Data"][$Key] == 0 )
4548
+                if ( $Serie["Data"][$Key] == 0 )
4549 4549
                 {
4550
-                 $this->drawLine($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y1,$Color);
4551
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset+$XSpace).",".floor($Y1-1).",".floor($X+$XOffset+$XSize-$XSpace).",".floor($Y1+1),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4550
+                    $this->drawLine($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y1,$Color);
4551
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset+$XSpace).",".floor($Y1-1).",".floor($X+$XOffset+$XSize-$XSpace).",".floor($Y1+1),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4552 4552
                 }
4553
-               else
4553
+                else
4554 4554
                 {
4555
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset+$XSpace).",".floor($Y1).",".floor($X+$XOffset+$XSize-$XSpace).",".floor($Y2),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4555
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset+$XSpace).",".floor($Y1).",".floor($X+$XOffset+$XSize-$XSpace).",".floor($Y2),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4556 4556
 
4557
-                 if ( $Rounded )
4558
-                  $this->drawRoundedFilledRectangle($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,$RoundRadius,$Color);
4559
-                 else
4560
-                  {
4561
-                   $this->drawFilledRectangle($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,$Color);
4557
+                    if ( $Rounded )
4558
+                    $this->drawRoundedFilledRectangle($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,$RoundRadius,$Color);
4559
+                    else
4560
+                    {
4561
+                    $this->drawFilledRectangle($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,$Color);
4562 4562
 
4563
-                   if ( $InnerColor != NULL ) { $this->drawRectangle($X+$XOffset+$XSpace+1,min($Y1,$Y2)+1,$X+$XOffset+$XSize-$XSpace-1,max($Y1,$Y2)-1,$InnerColor); }
4563
+                    if ( $InnerColor != NULL ) { $this->drawRectangle($X+$XOffset+$XSpace+1,min($Y1,$Y2)+1,$X+$XOffset+$XSize-$XSpace-1,max($Y1,$Y2)-1,$InnerColor); }
4564 4564
 
4565
-                   if ( $Gradient )
4565
+                    if ( $Gradient )
4566 4566
                     {
4567
-                     $this->Shadow  = FALSE;
4567
+                        $this->Shadow  = FALSE;
4568 4568
 
4569
-                     if ( $GradientMode == GRADIENT_SIMPLE )
4570
-                      {
4571
-                       if ( $Serie["Data"][$Key] >= 0 )
4569
+                        if ( $GradientMode == GRADIENT_SIMPLE )
4570
+                        {
4571
+                        if ( $Serie["Data"][$Key] >= 0 )
4572 4572
                         $GradienColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4573
-                       else
4573
+                        else
4574 4574
                         $GradienColor = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4575 4575
 
4576
-                       $this->drawGradientArea($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,DIRECTION_VERTICAL,$GradienColor);
4577
-                      }
4578
-                     elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4579
-                      {
4580
-                       $GradienColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4581
-                       $GradienColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4582
-                       $XSpan = floor($XSize / 3);
4583
-
4584
-                       $this->drawGradientArea($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSpan-$XSpace,$Y2,DIRECTION_HORIZONTAL,$GradienColor1);
4585
-                       $this->drawGradientArea($X+$XOffset+$XSpan+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,DIRECTION_HORIZONTAL,$GradienColor2);
4586
-                      }
4587
-                     $this->Shadow = $RestoreShadow;
4576
+                        $this->drawGradientArea($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,DIRECTION_VERTICAL,$GradienColor);
4577
+                        }
4578
+                        elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4579
+                        {
4580
+                        $GradienColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4581
+                        $GradienColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4582
+                        $XSpan = floor($XSize / 3);
4583
+
4584
+                        $this->drawGradientArea($X+$XOffset+$XSpace,$Y1,$X+$XOffset+$XSpan-$XSpace,$Y2,DIRECTION_HORIZONTAL,$GradienColor1);
4585
+                        $this->drawGradientArea($X+$XOffset+$XSpan+$XSpace,$Y1,$X+$XOffset+$XSize-$XSpace,$Y2,DIRECTION_HORIZONTAL,$GradienColor2);
4586
+                        }
4587
+                        $this->Shadow = $RestoreShadow;
4588
+                    }
4588 4589
                     }
4589
-                  }
4590 4590
 
4591
-                 if ( $Draw0Line )
4592
-                  {
4593
-                   $Line0Color = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20);
4591
+                    if ( $Draw0Line )
4592
+                    {
4593
+                    $Line0Color = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20);
4594 4594
 
4595
-                   if ( abs($Y1 - $Y2) > 3 ) { $Line0Width = 3; } else { $Line0Width = 1; }
4596
-                   if ( $Y1 - $Y2 < 0 ) { $Line0Width = -$Line0Width; }
4595
+                    if ( abs($Y1 - $Y2) > 3 ) { $Line0Width = 3; } else { $Line0Width = 1; }
4596
+                    if ( $Y1 - $Y2 < 0 ) { $Line0Width = -$Line0Width; }
4597 4597
 
4598
-                   $this->drawFilledRectangle($X+$XOffset+$XSpace,floor($Y1),$X+$XOffset+$XSize-$XSpace,floor($Y1)-$Line0Width,$Line0Color);
4599
-                   $this->drawLine($X+$XOffset+$XSpace,floor($Y1),$X+$XOffset+$XSize-$XSpace,floor($Y1),$Line0Color);
4600
-                  }
4598
+                    $this->drawFilledRectangle($X+$XOffset+$XSpace,floor($Y1),$X+$XOffset+$XSize-$XSpace,floor($Y1)-$Line0Width,$Line0Color);
4599
+                    $this->drawLine($X+$XOffset+$XSpace,floor($Y1),$X+$XOffset+$XSize-$XSpace,floor($Y1),$Line0Color);
4600
+                    }
4601 4601
                 }
4602 4602
 
4603
-               if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4603
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID )
4604 4604
                 {
4605
-                 if ( $DisplayShadow ) { $this->Shadow = TRUE; }
4606
-
4607
-                 $Caption    = $this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit);
4608
-                 $TxtPos     = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,90,$Caption);
4609
-                 $TxtHeight  = $TxtPos[0]["Y"] - $TxtPos[1]["Y"] + $TxtMargin;
4610
-
4611
-                 if ( $DisplayPos == LABEL_POS_INSIDE && abs($TxtHeight) < abs($BarHeight) )
4612
-                  {
4613
-                   $CenterX = (($X+$XOffset+$XSize-$XSpace)-($X+$XOffset+$XSpace))/2 + $X+$XOffset+$XSpace;
4614
-                   $CenterY = ($Y2-$Y1)/2 + $Y1;
4615
-
4616
-                   $this->drawText($CenterX,$CenterY,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"Angle"=>90));
4617
-                  }
4618
-                 else
4619
-                  {
4620
-                   if ( $Serie["Data"][$Key] >= 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4621
-                   $this->drawText($X+$XOffset+$XSize/2,$Y2-$Offset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align,"FontSize"=>$DisplaySize));
4622
-                  }
4623
-
4624
-                 $this->Shadow = $RestoreShadow;
4605
+                    if ( $DisplayShadow ) { $this->Shadow = TRUE; }
4606
+
4607
+                    $Caption    = $this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit);
4608
+                    $TxtPos     = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,90,$Caption);
4609
+                    $TxtHeight  = $TxtPos[0]["Y"] - $TxtPos[1]["Y"] + $TxtMargin;
4610
+
4611
+                    if ( $DisplayPos == LABEL_POS_INSIDE && abs($TxtHeight) < abs($BarHeight) )
4612
+                    {
4613
+                    $CenterX = (($X+$XOffset+$XSize-$XSpace)-($X+$XOffset+$XSpace))/2 + $X+$XOffset+$XSpace;
4614
+                    $CenterY = ($Y2-$Y1)/2 + $Y1;
4615
+
4616
+                    $this->drawText($CenterX,$CenterY,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"Angle"=>90));
4617
+                    }
4618
+                    else
4619
+                    {
4620
+                    if ( $Serie["Data"][$Key] >= 0 ) { $Align = TEXT_ALIGN_BOTTOMMIDDLE; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_TOPMIDDLE; $Offset = -$DisplayOffset; }
4621
+                    $this->drawText($X+$XOffset+$XSize/2,$Y2-$Offset,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align,"FontSize"=>$DisplaySize));
4622
+                    }
4623
+
4624
+                    $this->Shadow = $RestoreShadow;
4625
+                }
4625 4626
                 }
4626
-              }
4627 4627
 
4628
-             $X = $X + $XStep;
4629
-             $ID++;
4628
+                $X = $X + $XStep;
4629
+                $ID++;
4630
+            }
4630 4631
             }
4631
-          }
4632
-         else
4633
-          {
4634
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4635
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4632
+            else
4633
+            {
4634
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4635
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4636 4636
 
4637
-           if ( $XDivs == 0 ) { $YStep = 0; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4637
+            if ( $XDivs == 0 ) { $YStep = 0; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4638 4638
            
4639
-           $Y = $this->GraphAreaY1 + $XMargin;
4639
+            $Y = $this->GraphAreaY1 + $XMargin;
4640 4640
 
4641
-           if ( $AroundZero ) { $X1 = $YZero; } else { $X1 = $this->GraphAreaX1+1; }
4642
-           if ( $XDivs == 0 ) { $YSize = ($this->GraphAreaY2-$this->GraphAreaY1)/($SeriesCount+$Interleave); } else { $YSize   = ($YStep / ($SeriesCount+$Interleave) ); }
4641
+            if ( $AroundZero ) { $X1 = $YZero; } else { $X1 = $this->GraphAreaX1+1; }
4642
+            if ( $XDivs == 0 ) { $YSize = ($this->GraphAreaY2-$this->GraphAreaY1)/($SeriesCount+$Interleave); } else { $YSize   = ($YStep / ($SeriesCount+$Interleave) ); }
4643 4643
            
4644
-           $YOffset = -($YSize*$SeriesCount)/2 + $CurrentSerie * $YSize;
4645
-           if ( $Y + $YOffset <= $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $Y + 1 ; }
4644
+            $YOffset = -($YSize*$SeriesCount)/2 + $CurrentSerie * $YSize;
4645
+            if ( $Y + $YOffset <= $this->GraphAreaY1 ) { $YOffset = $this->GraphAreaY1 - $Y + 1 ; }
4646 4646
 
4647
-           $this->DataSet->Data["Series"][$SerieName]["XOffset"] = $YOffset + $YSize / 2;
4647
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = $YOffset + $YSize / 2;
4648 4648
 
4649
-           if ( $Rounded || $BorderR != -1 ) { $YSpace = 1; } else { $YSpace = 0; }
4649
+            if ( $Rounded || $BorderR != -1 ) { $YSpace = 1; } else { $YSpace = 0; }
4650 4650
 
4651
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4651
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4652 4652
 
4653
-           $ID = 0 ;
4654
-           foreach($PosArray as $Key => $X2)
4653
+            $ID = 0 ;
4654
+            foreach($PosArray as $Key => $X2)
4655 4655
             {
4656
-             if ( $Floating0Serie != NULL )
4657
-              {
4658
-               if ( isset($Data["Series"][$Floating0Serie]["Data"][$Key]) )
4656
+                if ( $Floating0Serie != NULL )
4657
+                {
4658
+                if ( isset($Data["Series"][$Floating0Serie]["Data"][$Key]) )
4659 4659
                 $Value = $Data["Series"][$Floating0Serie]["Data"][$Key];
4660
-               else { $Value = 0; }
4660
+                else { $Value = 0; }
4661
+
4662
+                $YZero = $this->scaleComputeY($Value,array("AxisID"=>$Serie["Axis"]));
4663
+                if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4664
+                if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4665
+                if ( $AroundZero ) { $X1 = $YZero; } else { $X1 = $this->GraphAreaX1+1; }
4666
+                }
4667
+
4668
+                if ( $OverrideColors != NULL )
4669
+                { if ( isset($OverrideColors[$ID]) ) { $Color = array("R"=>$OverrideColors[$ID]["R"],"G"=>$OverrideColors[$ID]["G"],"B"=>$OverrideColors[$ID]["B"],"Alpha"=>$OverrideColors[$ID]["Alpha"],"BorderR"=>$OverrideColors[$ID]["BorderR"],"BorderG"=>$OverrideColors[$ID]["BorderG"],"BorderB"=>$OverrideColors[$ID]["BorderB"]); } else { $Color = $this->getRandomColor(); } }
4670
+
4671
+                if ( $X2 != VOID )
4672
+                {
4673
+                $BarWidth = $X2 - $X1;
4674
+
4675
+                if ( $Serie["Data"][$Key] == 0 )
4676
+                {
4677
+                    $this->drawLine($X1,$Y+$YOffset+$YSpace,$X1,$Y+$YOffset+$YSize-$YSpace,$Color);
4678
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1-1).",".floor($Y+$YOffset+$YSpace).",".floor($X1+1).",".floor($Y+$YOffset+$YSize-$YSpace),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4679
+                }
4680
+                else
4681
+                {
4682
+                    if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1).",".floor($Y+$YOffset+$YSpace).",".floor($X2).",".floor($Y+$YOffset+$YSize-$YSpace),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4683
+
4684
+                    if ( $Rounded )
4685
+                    $this->drawRoundedFilledRectangle($X1+1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,$RoundRadius,$Color);
4686
+                    else
4687
+                    {
4688
+                    $this->drawFilledRectangle($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,$Color);
4689
+
4690
+                    if ( $InnerColor != NULL ) { $this->drawRectangle(min($X1,$X2)+1,$Y+$YOffset+$YSpace+1,max($X1,$X2)-1,$Y+$YOffset+$YSize-$YSpace-1,$InnerColor); }
4691
+
4692
+                    if ( $Gradient )
4693
+                    {
4694
+                        $this->Shadow  = FALSE;
4695
+
4696
+                        if ( $GradientMode == GRADIENT_SIMPLE )
4697
+                        {
4698
+                        if ( $Serie["Data"][$Key] >= 0 )
4699
+                        $GradienColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4700
+                        else
4701
+                        $GradienColor = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4702
+
4703
+                        $this->drawGradientArea($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,DIRECTION_HORIZONTAL,$GradienColor);
4704
+                        }
4705
+                        elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4706
+                        {
4707
+                        $GradienColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4708
+                        $GradienColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4709
+                        $YSpan = floor($YSize / 3);
4710
+
4711
+                        $this->drawGradientArea($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSpan-$YSpace,DIRECTION_VERTICAL,$GradienColor1);
4712
+                        $this->drawGradientArea($X1,$Y+$YOffset+$YSpan,$X2,$Y+$YOffset+$YSize-$YSpace,DIRECTION_VERTICAL,$GradienColor2);
4713
+                        }
4714
+                        $this->Shadow = $RestoreShadow;
4715
+                    }
4716
+                    }
4717
+
4718
+                    if ( $Draw0Line )
4719
+                    {
4720
+                    $Line0Color = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20);
4721
+
4722
+                    if ( abs($X1 - $X2) > 3 ) { $Line0Width = 3; } else { $Line0Width = 1; }
4723
+                    if ( $X2 - $X1 < 0 ) { $Line0Width = -$Line0Width; }
4724
+
4725
+                    $this->drawFilledRectangle(floor($X1),$Y+$YOffset+$YSpace,floor($X1)+$Line0Width,$Y+$YOffset+$YSize-$YSpace,$Line0Color);
4726
+                    $this->drawLine(floor($X1),$Y+$YOffset+$YSpace,floor($X1),$Y+$YOffset+$YSize-$YSpace,$Line0Color);
4727
+                    }
4728
+                }
4729
+
4730
+                if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
4731
+                {
4732
+                    if ( $DisplayShadow ) { $this->Shadow = TRUE; }
4733
+
4734
+                    $Caption   = $this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit);
4735
+                    $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4736
+                    $TxtWidth  = $TxtPos[1]["X"] - $TxtPos[0]["X"] + $TxtMargin;
4737
+
4738
+                    if ( $DisplayPos == LABEL_POS_INSIDE && abs($TxtWidth) < abs($BarWidth) )
4739
+                    {
4740
+                    $CenterX = ($X2-$X1)/2 + $X1;
4741
+                    $CenterY = (($Y+$YOffset+$YSize-$YSpace)-($Y+$YOffset+$YSpace))/2 + ($Y+$YOffset+$YSpace);
4742
+
4743
+                    $this->drawText($CenterX,$CenterY,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize));
4744
+                    }
4745
+                    else
4746
+                    {
4747
+                    if ( $Serie["Data"][$Key] >= 0 ) { $Align = TEXT_ALIGN_MIDDLELEFT; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_MIDDLERIGHT; $Offset = -$DisplayOffset; }
4748
+                    $this->drawText($X2+$Offset,$Y+$YOffset+$YSize/2,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align,"FontSize"=>$DisplaySize));
4749
+                    }
4750
+
4751
+                    $this->Shadow = $RestoreShadow;
4752
+                }
4753
+                }
4754
+                $Y = $Y + $YStep;
4755
+                $ID++;
4756
+            }
4757
+            }
4758
+            $CurrentSerie++;
4759
+        }
4760
+        }
4761
+    }
4762
+
4763
+    /* Draw a bar chart */
4764
+    function drawStackedBarChart($Format=NULL)
4765
+    {
4766
+        $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4767
+        $DisplayOrientation = isset($Format["DisplayOrientation"]) ? $Format["DisplayOrientation"] : ORIENTATION_AUTO;
4768
+        $DisplayRound      = isset($Format["DisplayRound"]) ? $Format["DisplayRound"] : 0;
4769
+        $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4770
+        $DisplayFont	= isset($Format["DisplayFont"]) ? $Format["DisplayFont"] : $this->FontName;
4771
+        $DisplaySize	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontSize;
4772
+        $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4773
+        $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4774
+        $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4775
+        $Interleave	= isset($Format["Interleave"]) ? $Format["Interleave"] : .5;
4776
+        $Rounded		= isset($Format["Rounded"]) ? $Format["Rounded"] : FALSE;
4777
+        $RoundRadius	= isset($Format["RoundRadius"]) ? $Format["RoundRadius"] : 4;
4778
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
4779
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
4780
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
4781
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
4782
+        $Gradient		= isset($Format["Gradient"]) ? $Format["Gradient"] : FALSE;
4783
+        $GradientMode	= isset($Format["GradientMode"]) ? $Format["GradientMode"] : GRADIENT_SIMPLE;
4784
+        $GradientAlpha	= isset($Format["GradientAlpha"]) ? $Format["GradientAlpha"] : 20;
4785
+        $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
4786
+        $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
4787
+        $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
4788
+        $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 0;
4789
+        $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 0;
4790
+        $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 0;
4791
+        $InnerSurrounding	= isset($Format["InnerSurrounding"]) ? $Format["InnerSurrounding"] : NULL;
4792
+        $InnerBorderR	= isset($Format["InnerBorderR"]) ? $Format["InnerBorderR"] : -1;
4793
+        $InnerBorderG	= isset($Format["InnerBorderG"]) ? $Format["InnerBorderG"] : -1;
4794
+        $InnerBorderB	= isset($Format["InnerBorderB"]) ? $Format["InnerBorderB"] : -1;
4795
+        $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
4796
+        $FontFactor	= isset($Format["FontFactor"]) ? $Format["FontFactor"] : 8;
4797
+
4798
+        $this->LastChartLayout = CHART_LAST_LAYOUT_STACKED;
4799
+
4800
+        $Data = $this->DataSet->getData();
4801
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
4802
+
4803
+        $RestoreShadow = $this->Shadow;
4804
+
4805
+        $LastX = ""; $LastY = "";
4806
+        foreach($Data["Series"] as $SerieName => $Serie)
4807
+        {
4808
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4809
+        {
4810
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4811
+            if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = 255; $DisplayG = 255; $DisplayB = 255; }
4812
+            if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
4813
+            if ( $InnerSurrounding != NULL ) { $InnerBorderR = $R+$InnerSurrounding; $InnerBorderG = $G+$InnerSurrounding; $InnerBorderB = $B+$InnerSurrounding; }
4814
+            if ( $InnerBorderR == -1 ) { $InnerColor = NULL; } else { $InnerColor = array("R"=>$InnerBorderR,"G"=>$InnerBorderG,"B"=>$InnerBorderB); }
4661 4815
 
4662
-               $YZero = $this->scaleComputeY($Value,array("AxisID"=>$Serie["Axis"]));
4663
-               if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4664
-               if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4665
-               if ( $AroundZero ) { $X1 = $YZero; } else { $X1 = $this->GraphAreaX1+1; }
4666
-              }
4816
+            $AxisID	= $Serie["Axis"];
4817
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
4818
+            $Format	= $Data["Axis"][$AxisID]["Format"];
4819
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
4667 4820
 
4668
-             if ( $OverrideColors != NULL )
4669
-              { if ( isset($OverrideColors[$ID]) ) { $Color = array("R"=>$OverrideColors[$ID]["R"],"G"=>$OverrideColors[$ID]["G"],"B"=>$OverrideColors[$ID]["B"],"Alpha"=>$OverrideColors[$ID]["Alpha"],"BorderR"=>$OverrideColors[$ID]["BorderR"],"BorderG"=>$OverrideColors[$ID]["BorderG"],"BorderB"=>$OverrideColors[$ID]["BorderB"]); } else { $Color = $this->getRandomColor(); } }
4821
+            if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
4670 4822
 
4671
-             if ( $X2 != VOID )
4672
-              {
4673
-               $BarWidth = $X2 - $X1;
4823
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]),TRUE);
4824
+            $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4674 4825
 
4675
-               if ( $Serie["Data"][$Key] == 0 )
4676
-                {
4677
-                 $this->drawLine($X1,$Y+$YOffset+$YSpace,$X1,$Y+$YOffset+$YSize-$YSpace,$Color);
4678
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1-1).",".floor($Y+$YOffset+$YSpace).",".floor($X1+1).",".floor($Y+$YOffset+$YSize-$YSpace),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4679
-                }
4680
-               else
4681
-                {
4682
-                 if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1).",".floor($Y+$YOffset+$YSpace).",".floor($X2).",".floor($Y+$YOffset+$YSize-$YSpace),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4826
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4683 4827
 
4684
-                 if ( $Rounded )
4685
-                  $this->drawRoundedFilledRectangle($X1+1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,$RoundRadius,$Color);
4686
-                 else
4687
-                  {
4688
-                   $this->drawFilledRectangle($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,$Color);
4828
+            $Color = array("TransCorner"=>TRUE,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB);
4689 4829
 
4690
-                   if ( $InnerColor != NULL ) { $this->drawRectangle(min($X1,$X2)+1,$Y+$YOffset+$YSpace+1,max($X1,$X2)-1,$Y+$YOffset+$YSize-$YSpace-1,$InnerColor); }
4830
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4831
+            {
4832
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4833
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4691 4834
 
4692
-                   if ( $Gradient )
4693
-                    {
4694
-                     $this->Shadow  = FALSE;
4835
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4836
+            $X     = $this->GraphAreaX1 + $XMargin;
4695 4837
 
4696
-                     if ( $GradientMode == GRADIENT_SIMPLE )
4697
-                      {
4698
-                       if ( $Serie["Data"][$Key] >= 0 )
4699
-                        $GradienColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4700
-                       else
4701
-                        $GradienColor = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4838
+            $XSize   = ($XStep / (1+$Interleave) );
4839
+            $XOffset = -($XSize/2);
4702 4840
 
4703
-                       $this->drawGradientArea($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSize-$YSpace,DIRECTION_HORIZONTAL,$GradienColor);
4704
-                      }
4705
-                     elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4706
-                      {
4707
-                       $GradienColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4708
-                       $GradienColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4709
-                       $YSpan = floor($YSize / 3);
4710
-
4711
-                       $this->drawGradientArea($X1,$Y+$YOffset+$YSpace,$X2,$Y+$YOffset+$YSpan-$YSpace,DIRECTION_VERTICAL,$GradienColor1);
4712
-                       $this->drawGradientArea($X1,$Y+$YOffset+$YSpan,$X2,$Y+$YOffset+$YSize-$YSpace,DIRECTION_VERTICAL,$GradienColor2);
4713
-                      }
4714
-                     $this->Shadow = $RestoreShadow;
4715
-                    }
4716
-                  }
4841
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4842
+            foreach($PosArray as $Key => $Height)
4843
+            {
4844
+                if ( $Height != VOID && $Serie["Data"][$Key] != 0 )
4845
+                {
4846
+                if ( $Serie["Data"][$Key] > 0 ) { $Pos = "+"; } else { $Pos = "-"; }
4717 4847
 
4718
-                 if ( $Draw0Line )
4719
-                  {
4720
-                   $Line0Color = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>20);
4848
+                if ( !isset($LastY[$Key] ) ) { $LastY[$Key] = ""; }
4849
+                if ( !isset($LastY[$Key][$Pos] ) ) { $LastY[$Key][$Pos] = $YZero; }
4721 4850
 
4722
-                   if ( abs($X1 - $X2) > 3 ) { $Line0Width = 3; } else { $Line0Width = 1; }
4723
-                   if ( $X2 - $X1 < 0 ) { $Line0Width = -$Line0Width; }
4851
+                $Y1 = $LastY[$Key][$Pos];
4852
+                $Y2 = $Y1 - $Height;
4724 4853
 
4725
-                   $this->drawFilledRectangle(floor($X1),$Y+$YOffset+$YSpace,floor($X1)+$Line0Width,$Y+$YOffset+$YSize-$YSpace,$Line0Color);
4726
-                   $this->drawLine(floor($X1),$Y+$YOffset+$YSpace,floor($X1),$Y+$YOffset+$YSize-$YSpace,$Line0Color);
4727
-                  }
4728
-                }
4854
+                if ( ($Rounded || $BorderR != -1) && ($Pos == "+" && $Y1 != $YZero) ) { $YSpaceUp = 1; } else { $YSpaceUp = 0; }
4855
+                if ( ($Rounded || $BorderR != -1) && ($Pos == "-" && $Y1 != $YZero) ) { $YSpaceDown = 1; } else { $YSpaceDown = 0; }
4729 4856
 
4730
-               if ( $DisplayValues && $Serie["Data"][$Key] != VOID ) 
4731
-                {
4732
-                 if ( $DisplayShadow ) { $this->Shadow = TRUE; }
4733
-
4734
-                 $Caption   = $this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit);
4735
-                 $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4736
-                 $TxtWidth  = $TxtPos[1]["X"] - $TxtPos[0]["X"] + $TxtMargin;
4737
-
4738
-                 if ( $DisplayPos == LABEL_POS_INSIDE && abs($TxtWidth) < abs($BarWidth) )
4739
-                  {
4740
-                   $CenterX = ($X2-$X1)/2 + $X1;
4741
-                   $CenterY = (($Y+$YOffset+$YSize-$YSpace)-($Y+$YOffset+$YSpace))/2 + ($Y+$YOffset+$YSpace);
4742
-
4743
-                   $this->drawText($CenterX,$CenterY,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize));
4744
-                  }
4745
-                 else
4746
-                  {
4747
-                   if ( $Serie["Data"][$Key] >= 0 ) { $Align = TEXT_ALIGN_MIDDLELEFT; $Offset = $DisplayOffset; } else { $Align = TEXT_ALIGN_MIDDLERIGHT; $Offset = -$DisplayOffset; }
4748
-                   $this->drawText($X2+$Offset,$Y+$YOffset+$YSize/2,$Caption,array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>$Align,"FontSize"=>$DisplaySize));
4749
-                  }
4750
-
4751
-                 $this->Shadow = $RestoreShadow;
4752
-                }
4753
-              }
4754
-             $Y = $Y + $YStep;
4755
-             $ID++;
4756
-            }
4757
-          }
4758
-         $CurrentSerie++;
4759
-        }
4760
-      }
4761
-    }
4857
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset).",".floor($Y1-$YSpaceUp+$YSpaceDown).",".floor($X+$XOffset+$XSize).",".floor($Y2),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4762 4858
 
4763
-   /* Draw a bar chart */
4764
-   function drawStackedBarChart($Format=NULL)
4765
-    {
4766
-     $DisplayValues	= isset($Format["DisplayValues"]) ? $Format["DisplayValues"] : FALSE;
4767
-     $DisplayOrientation = isset($Format["DisplayOrientation"]) ? $Format["DisplayOrientation"] : ORIENTATION_AUTO;
4768
-     $DisplayRound      = isset($Format["DisplayRound"]) ? $Format["DisplayRound"] : 0;
4769
-     $DisplayColor	= isset($Format["DisplayColor"]) ? $Format["DisplayColor"] : DISPLAY_MANUAL;
4770
-     $DisplayFont	= isset($Format["DisplayFont"]) ? $Format["DisplayFont"] : $this->FontName;
4771
-     $DisplaySize	= isset($Format["DisplaySize"]) ? $Format["DisplaySize"] : $this->FontSize;
4772
-     $DisplayR		= isset($Format["DisplayR"]) ? $Format["DisplayR"] : 0;
4773
-     $DisplayG		= isset($Format["DisplayG"]) ? $Format["DisplayG"] : 0;
4774
-     $DisplayB		= isset($Format["DisplayB"]) ? $Format["DisplayB"] : 0;
4775
-     $Interleave	= isset($Format["Interleave"]) ? $Format["Interleave"] : .5;
4776
-     $Rounded		= isset($Format["Rounded"]) ? $Format["Rounded"] : FALSE;
4777
-     $RoundRadius	= isset($Format["RoundRadius"]) ? $Format["RoundRadius"] : 4;
4778
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
4779
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : -1;
4780
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : -1;
4781
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : -1;
4782
-     $Gradient		= isset($Format["Gradient"]) ? $Format["Gradient"] : FALSE;
4783
-     $GradientMode	= isset($Format["GradientMode"]) ? $Format["GradientMode"] : GRADIENT_SIMPLE;
4784
-     $GradientAlpha	= isset($Format["GradientAlpha"]) ? $Format["GradientAlpha"] : 20;
4785
-     $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
4786
-     $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
4787
-     $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
4788
-     $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 0;
4789
-     $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 0;
4790
-     $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 0;
4791
-     $InnerSurrounding	= isset($Format["InnerSurrounding"]) ? $Format["InnerSurrounding"] : NULL;
4792
-     $InnerBorderR	= isset($Format["InnerBorderR"]) ? $Format["InnerBorderR"] : -1;
4793
-     $InnerBorderG	= isset($Format["InnerBorderG"]) ? $Format["InnerBorderG"] : -1;
4794
-     $InnerBorderB	= isset($Format["InnerBorderB"]) ? $Format["InnerBorderB"] : -1;
4795
-     $RecordImageMap	= isset($Format["RecordImageMap"]) ? $Format["RecordImageMap"] : FALSE;
4796
-     $FontFactor	= isset($Format["FontFactor"]) ? $Format["FontFactor"] : 8;
4797
-
4798
-     $this->LastChartLayout = CHART_LAST_LAYOUT_STACKED;
4799
-
4800
-     $Data = $this->DataSet->getData();
4801
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
4802
-
4803
-     $RestoreShadow = $this->Shadow;
4804
-
4805
-     $LastX = ""; $LastY = "";
4806
-     foreach($Data["Series"] as $SerieName => $Serie)
4807
-      {
4808
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
4809
-        {
4810
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
4811
-         if ( $DisplayColor == DISPLAY_AUTO ) { $DisplayR = 255; $DisplayG = 255; $DisplayB = 255; }
4812
-         if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
4813
-         if ( $InnerSurrounding != NULL ) { $InnerBorderR = $R+$InnerSurrounding; $InnerBorderG = $G+$InnerSurrounding; $InnerBorderB = $B+$InnerSurrounding; }
4814
-         if ( $InnerBorderR == -1 ) { $InnerColor = NULL; } else { $InnerColor = array("R"=>$InnerBorderR,"G"=>$InnerBorderG,"B"=>$InnerBorderB); }
4815
-
4816
-         $AxisID	= $Serie["Axis"];
4817
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
4818
-         $Format	= $Data["Axis"][$AxisID]["Format"];
4819
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
4820
-
4821
-         if (isset($Serie["Description"])) { $SerieDescription = $Serie["Description"]; } else { $SerieDescription = $SerieName; }
4822
-
4823
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]),TRUE);
4824
-         $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
4825
-
4826
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
4827
-
4828
-         $Color = array("TransCorner"=>TRUE,"R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"BorderR"=>$BorderR,"BorderG"=>$BorderG,"BorderB"=>$BorderB);
4829
-
4830
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
4831
-          {
4832
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4833
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
4834
-
4835
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
4836
-           $X     = $this->GraphAreaX1 + $XMargin;
4837
-
4838
-           $XSize   = ($XStep / (1+$Interleave) );
4839
-           $XOffset = -($XSize/2);
4840
-
4841
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4842
-           foreach($PosArray as $Key => $Height)
4843
-            {
4844
-             if ( $Height != VOID && $Serie["Data"][$Key] != 0 )
4845
-              {
4846
-               if ( $Serie["Data"][$Key] > 0 ) { $Pos = "+"; } else { $Pos = "-"; }
4847
-
4848
-               if ( !isset($LastY[$Key] ) ) { $LastY[$Key] = ""; }
4849
-               if ( !isset($LastY[$Key][$Pos] ) ) { $LastY[$Key][$Pos] = $YZero; }
4850
-
4851
-               $Y1 = $LastY[$Key][$Pos];
4852
-               $Y2 = $Y1 - $Height;
4853
-
4854
-               if ( ($Rounded || $BorderR != -1) && ($Pos == "+" && $Y1 != $YZero) ) { $YSpaceUp = 1; } else { $YSpaceUp = 0; }
4855
-               if ( ($Rounded || $BorderR != -1) && ($Pos == "-" && $Y1 != $YZero) ) { $YSpaceDown = 1; } else { $YSpaceDown = 0; }
4856
-
4857
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X+$XOffset).",".floor($Y1-$YSpaceUp+$YSpaceDown).",".floor($X+$XOffset+$XSize).",".floor($Y2),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4858
-
4859
-               if ( $Rounded )
4859
+                if ( $Rounded )
4860 4860
                 $this->drawRoundedFilledRectangle($X+$XOffset,$Y1-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2,$RoundRadius,$Color);
4861
-               else
4861
+                else
4862 4862
                 {
4863
-                 $this->drawFilledRectangle($X+$XOffset,$Y1-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2,$Color);
4863
+                    $this->drawFilledRectangle($X+$XOffset,$Y1-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2,$Color);
4864 4864
 
4865
-                 if ( $InnerColor != NULL ) { $RestoreShadow = $this->Shadow; $this->Shadow = FALSE; $this->drawRectangle(min($X+$XOffset+1,$X+$XOffset+$XSize),min($Y1-$YSpaceUp+$YSpaceDown,$Y2)+1,max($X+$XOffset+1,$X+$XOffset+$XSize)-1,max($Y1-$YSpaceUp+$YSpaceDown,$Y2)-1,$InnerColor); $this->Shadow = $RestoreShadow;}
4865
+                    if ( $InnerColor != NULL ) { $RestoreShadow = $this->Shadow; $this->Shadow = FALSE; $this->drawRectangle(min($X+$XOffset+1,$X+$XOffset+$XSize),min($Y1-$YSpaceUp+$YSpaceDown,$Y2)+1,max($X+$XOffset+1,$X+$XOffset+$XSize)-1,max($Y1-$YSpaceUp+$YSpaceDown,$Y2)-1,$InnerColor); $this->Shadow = $RestoreShadow;}
4866 4866
 
4867
-                 if ( $Gradient )
4868
-                  {
4869
-                   $this->Shadow  = FALSE;
4867
+                    if ( $Gradient )
4868
+                    {
4869
+                    $this->Shadow  = FALSE;
4870 4870
 
4871
-                   if ( $GradientMode == GRADIENT_SIMPLE )
4871
+                    if ( $GradientMode == GRADIENT_SIMPLE )
4872 4872
                     {
4873
-                     $GradientColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4874
-                     $this->drawGradientArea($X+$XOffset,$Y1-1-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2+1,DIRECTION_VERTICAL,$GradientColor);
4873
+                        $GradientColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4874
+                        $this->drawGradientArea($X+$XOffset,$Y1-1-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2+1,DIRECTION_VERTICAL,$GradientColor);
4875 4875
                     }
4876
-                   elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4876
+                    elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4877 4877
                     {
4878
-                     $GradientColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4879
-                     $GradientColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4880
-                     $XSpan = floor($XSize / 3);
4878
+                        $GradientColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4879
+                        $GradientColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4880
+                        $XSpan = floor($XSize / 3);
4881 4881
 
4882
-                     $this->drawGradientArea($X+$XOffset-.5,$Y1-.5-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSpan,$Y2+.5,DIRECTION_HORIZONTAL,$GradientColor1);
4883
-                     $this->drawGradientArea($X+$XSpan+$XOffset-.5,$Y1-.5-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2+.5,DIRECTION_HORIZONTAL,$GradientColor2);
4882
+                        $this->drawGradientArea($X+$XOffset-.5,$Y1-.5-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSpan,$Y2+.5,DIRECTION_HORIZONTAL,$GradientColor1);
4883
+                        $this->drawGradientArea($X+$XSpan+$XOffset-.5,$Y1-.5-$YSpaceUp+$YSpaceDown,$X+$XOffset+$XSize,$Y2+.5,DIRECTION_HORIZONTAL,$GradientColor2);
4884
+                    }
4885
+                    $this->Shadow = $RestoreShadow;
4884 4886
                     }
4885
-                   $this->Shadow = $RestoreShadow;
4886
-                  }
4887 4887
                 }
4888 4888
 
4889
-               if ( $DisplayValues )
4889
+                if ( $DisplayValues )
4890 4890
                 {
4891
-                 $BarHeight = abs($Y2-$Y1)-2;
4892
-                 $BarWidth  = $XSize+($XOffset/2)-$FontFactor;
4891
+                    $BarHeight = abs($Y2-$Y1)-2;
4892
+                    $BarWidth  = $XSize+($XOffset/2)-$FontFactor;
4893 4893
 
4894
-                 $Caption   = $this->scaleFormat(round($Serie["Data"][$Key],$DisplayRound),$Mode,$Format,$Unit);
4895
-                 $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4896
-                 $TxtHeight = abs($TxtPos[2]["Y"] - $TxtPos[0]["Y"]);
4897
-                 $TxtWidth  = abs($TxtPos[1]["X"] - $TxtPos[0]["X"]);
4894
+                    $Caption   = $this->scaleFormat(round($Serie["Data"][$Key],$DisplayRound),$Mode,$Format,$Unit);
4895
+                    $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4896
+                    $TxtHeight = abs($TxtPos[2]["Y"] - $TxtPos[0]["Y"]);
4897
+                    $TxtWidth  = abs($TxtPos[1]["X"] - $TxtPos[0]["X"]);
4898 4898
 
4899
-                 $XCenter = ( ($X+$XOffset+$XSize) - ($X+$XOffset) ) / 2 + $X+$XOffset;
4900
-                 $YCenter = ( ($Y2) - ($Y1-$YSpaceUp+$YSpaceDown) ) / 2 + $Y1-$YSpaceUp+$YSpaceDown;
4899
+                    $XCenter = ( ($X+$XOffset+$XSize) - ($X+$XOffset) ) / 2 + $X+$XOffset;
4900
+                    $YCenter = ( ($Y2) - ($Y1-$YSpaceUp+$YSpaceDown) ) / 2 + $Y1-$YSpaceUp+$YSpaceDown;
4901 4901
 
4902
-                 $Done = FALSE;
4903
-                 if ( $DisplayOrientation == ORIENTATION_HORIZONTAL || $DisplayOrientation == ORIENTATION_AUTO )
4904
-                  {
4905
-                   if ( $TxtHeight < $BarHeight && $TxtWidth < $BarWidth  )
4902
+                    $Done = FALSE;
4903
+                    if ( $DisplayOrientation == ORIENTATION_HORIZONTAL || $DisplayOrientation == ORIENTATION_AUTO )
4906 4904
                     {
4907
-                     $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
4908
-                     $Done = TRUE;
4905
+                    if ( $TxtHeight < $BarHeight && $TxtWidth < $BarWidth  )
4906
+                    {
4907
+                        $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
4908
+                        $Done = TRUE;
4909
+                    }
4909 4910
                     }
4910
-                  }
4911 4911
 
4912
-                 if ( $DisplayOrientation == ORIENTATION_VERTICAL || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) )
4913
-                  {
4914
-                   if ( $TxtHeight < $BarWidth && $TxtWidth < $BarHeight  )
4912
+                    if ( $DisplayOrientation == ORIENTATION_VERTICAL || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) )
4913
+                    {
4914
+                    if ( $TxtHeight < $BarWidth && $TxtWidth < $BarHeight  )
4915 4915
                     $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Angle"=>90,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
4916
-                  }
4916
+                    }
4917 4917
                 }
4918 4918
 
4919
-               $LastY[$Key][$Pos] = $Y2;
4920
-              }
4919
+                $LastY[$Key][$Pos] = $Y2;
4920
+                }
4921 4921
 
4922
-             $X = $X + $XStep;
4922
+                $X = $X + $XStep;
4923
+            }
4923 4924
             }
4924
-          }
4925
-         else
4926
-          {
4927
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4928
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4925
+            else
4926
+            {
4927
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
4928
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
4929 4929
 
4930
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4931
-           $Y     = $this->GraphAreaY1 + $XMargin;
4930
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
4931
+            $Y     = $this->GraphAreaY1 + $XMargin;
4932 4932
 
4933
-           $YSize   = $YStep / (1+$Interleave);
4934
-           $YOffset = -($YSize/2);
4933
+            $YSize   = $YStep / (1+$Interleave);
4934
+            $YOffset = -($YSize/2);
4935 4935
 
4936
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4937
-           foreach($PosArray as $Key => $Width)
4936
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
4937
+            foreach($PosArray as $Key => $Width)
4938 4938
             {
4939
-             if ( $Width != VOID && $Serie["Data"][$Key] != 0 )
4940
-              {
4941
-               if ( $Serie["Data"][$Key] > 0 ) { $Pos = "+"; } else { $Pos = "-"; }
4939
+                if ( $Width != VOID && $Serie["Data"][$Key] != 0 )
4940
+                {
4941
+                if ( $Serie["Data"][$Key] > 0 ) { $Pos = "+"; } else { $Pos = "-"; }
4942 4942
 
4943
-               if ( !isset($LastX[$Key] ) ) { $LastX[$Key] = ""; }
4944
-               if ( !isset($LastX[$Key][$Pos] ) ) { $LastX[$Key][$Pos] = $YZero; }
4943
+                if ( !isset($LastX[$Key] ) ) { $LastX[$Key] = ""; }
4944
+                if ( !isset($LastX[$Key][$Pos] ) ) { $LastX[$Key][$Pos] = $YZero; }
4945 4945
 
4946
-               $X1 = $LastX[$Key][$Pos];
4947
-               $X2 = $X1 + $Width;
4946
+                $X1 = $LastX[$Key][$Pos];
4947
+                $X2 = $X1 + $Width;
4948 4948
 
4949
-               if ( ($Rounded || $BorderR != -1) && ($Pos == "+" && $X1 != $YZero) ) { $XSpaceLeft = 2; } else { $XSpaceLeft = 0; }
4950
-               if ( ($Rounded || $BorderR != -1) && ($Pos == "-" && $X1 != $YZero) ) { $XSpaceRight = 2; } else { $XSpaceRight = 0; }
4949
+                if ( ($Rounded || $BorderR != -1) && ($Pos == "+" && $X1 != $YZero) ) { $XSpaceLeft = 2; } else { $XSpaceLeft = 0; }
4950
+                if ( ($Rounded || $BorderR != -1) && ($Pos == "-" && $X1 != $YZero) ) { $XSpaceRight = 2; } else { $XSpaceRight = 0; }
4951 4951
 
4952
-               if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1+$XSpaceLeft).",".floor($Y+$YOffset).",".floor($X2-$XSpaceRight).",".floor($Y+$YOffset+$YSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4952
+                if ( $RecordImageMap ) { $this->addToImageMap("RECT",floor($X1+$XSpaceLeft).",".floor($Y+$YOffset).",".floor($X2-$XSpaceRight).",".floor($Y+$YOffset+$YSize),$this->toHTMLColor($R,$G,$B),$SerieDescription,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit)); }
4953 4953
 
4954
-               if ( $Rounded )
4954
+                if ( $Rounded )
4955 4955
                 $this->drawRoundedFilledRectangle($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSize,$RoundRadius,$Color);
4956
-               else
4956
+                else
4957 4957
                 {
4958
-                 $this->drawFilledRectangle($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSize,$Color);
4958
+                    $this->drawFilledRectangle($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSize,$Color);
4959 4959
 
4960
-                 if ( $InnerColor != NULL ) { $RestoreShadow = $this->Shadow; $this->Shadow = FALSE; $this->drawRectangle(min($X1+$XSpaceLeft,$X2-$XSpaceRight)+1,min($Y+$YOffset,$Y+$YOffset+$YSize)+1,max($X1+$XSpaceLeft,$X2-$XSpaceRight)-1,max($Y+$YOffset,$Y+$YOffset+$YSize)-1,$InnerColor); $this->Shadow = $RestoreShadow;}
4960
+                    if ( $InnerColor != NULL ) { $RestoreShadow = $this->Shadow; $this->Shadow = FALSE; $this->drawRectangle(min($X1+$XSpaceLeft,$X2-$XSpaceRight)+1,min($Y+$YOffset,$Y+$YOffset+$YSize)+1,max($X1+$XSpaceLeft,$X2-$XSpaceRight)-1,max($Y+$YOffset,$Y+$YOffset+$YSize)-1,$InnerColor); $this->Shadow = $RestoreShadow;}
4961 4961
 
4962
-                 if ( $Gradient )
4963
-                  {
4964
-                   $this->Shadow  = FALSE;
4962
+                    if ( $Gradient )
4963
+                    {
4964
+                    $this->Shadow  = FALSE;
4965 4965
 
4966
-                   if ( $GradientMode == GRADIENT_SIMPLE )
4966
+                    if ( $GradientMode == GRADIENT_SIMPLE )
4967 4967
                     {
4968
-                     $GradientColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4969
-                     $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSize,DIRECTION_HORIZONTAL,$GradientColor);
4968
+                        $GradientColor = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4969
+                        $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSize,DIRECTION_HORIZONTAL,$GradientColor);
4970 4970
                     }
4971
-                   elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4971
+                    elseif ( $GradientMode == GRADIENT_EFFECT_CAN )
4972 4972
                     {
4973
-                     $GradientColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4974
-                     $GradientColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4975
-                     $YSpan = floor($YSize / 3);
4973
+                        $GradientColor1 = array("StartR"=>$GradientEndR,"StartG"=>$GradientEndG,"StartB"=>$GradientEndB,"EndR"=>$GradientStartR,"EndG"=>$GradientStartG,"EndB"=>$GradientStartB,"Alpha"=>$GradientAlpha);
4974
+                        $GradientColor2 = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB,"Alpha"=>$GradientAlpha);
4975
+                        $YSpan = floor($YSize / 3);
4976 4976
 
4977
-                     $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSpan,DIRECTION_VERTICAL,$GradientColor1);
4978
-                     $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset+$YSpan,$X2-$XSpaceRight,$Y+$YOffset+$YSize,DIRECTION_VERTICAL,$GradientColor2);
4977
+                        $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset,$X2-$XSpaceRight,$Y+$YOffset+$YSpan,DIRECTION_VERTICAL,$GradientColor1);
4978
+                        $this->drawGradientArea($X1+$XSpaceLeft,$Y+$YOffset+$YSpan,$X2-$XSpaceRight,$Y+$YOffset+$YSize,DIRECTION_VERTICAL,$GradientColor2);
4979
+                    }
4980
+                    $this->Shadow = $RestoreShadow;
4979 4981
                     }
4980
-                   $this->Shadow = $RestoreShadow;
4981
-                  }
4982 4982
                 }
4983 4983
 
4984
-               if ( $DisplayValues )
4984
+                if ( $DisplayValues )
4985 4985
                 {
4986
-                 $BarWidth = abs($X2-$X1)-$FontFactor;
4987
-                 $BarHeight = $YSize+($YOffset/2)-$FontFactor/2;
4988
-                 $Caption   = $this->scaleFormat(round($Serie["Data"][$Key],$DisplayRound),$Mode,$Format,$Unit);
4989
-                 $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4990
-                 $TxtHeight = abs($TxtPos[2]["Y"] - $TxtPos[0]["Y"]);
4991
-                 $TxtWidth  = abs($TxtPos[1]["X"] - $TxtPos[0]["X"]);
4992
-
4993
-                 $XCenter  = ( $X2 - $X1 ) / 2 + $X1;
4994
-                 $YCenter  = ( ($Y+$YOffset+$YSize) - ($Y+$YOffset) ) / 2 + $Y+$YOffset;
4995
-
4996
-                 $Done = FALSE;
4997
-                 if ( $DisplayOrientation == ORIENTATION_HORIZONTAL || $DisplayOrientation == ORIENTATION_AUTO )
4998
-                  {
4999
-                   if ( $TxtHeight < $BarHeight && $TxtWidth < $BarWidth  )
4986
+                    $BarWidth = abs($X2-$X1)-$FontFactor;
4987
+                    $BarHeight = $YSize+($YOffset/2)-$FontFactor/2;
4988
+                    $Caption   = $this->scaleFormat(round($Serie["Data"][$Key],$DisplayRound),$Mode,$Format,$Unit);
4989
+                    $TxtPos    = $this->getTextBox(0,0,$DisplayFont,$DisplaySize,0,$Caption);
4990
+                    $TxtHeight = abs($TxtPos[2]["Y"] - $TxtPos[0]["Y"]);
4991
+                    $TxtWidth  = abs($TxtPos[1]["X"] - $TxtPos[0]["X"]);
4992
+
4993
+                    $XCenter  = ( $X2 - $X1 ) / 2 + $X1;
4994
+                    $YCenter  = ( ($Y+$YOffset+$YSize) - ($Y+$YOffset) ) / 2 + $Y+$YOffset;
4995
+
4996
+                    $Done = FALSE;
4997
+                    if ( $DisplayOrientation == ORIENTATION_HORIZONTAL || $DisplayOrientation == ORIENTATION_AUTO )
5000 4998
                     {
5001
-                     $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
5002
-                     $Done = TRUE;
4999
+                    if ( $TxtHeight < $BarHeight && $TxtWidth < $BarWidth  )
5000
+                    {
5001
+                        $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
5002
+                        $Done = TRUE;
5003
+                    }
5003 5004
                     }
5004
-                  }
5005 5005
 
5006
-                 if ( $DisplayOrientation == ORIENTATION_VERTICAL || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) )
5007
-                  {
5008
-                   if ( $TxtHeight < $BarWidth && $TxtWidth < $BarHeight  )
5006
+                    if ( $DisplayOrientation == ORIENTATION_VERTICAL || ( $DisplayOrientation == ORIENTATION_AUTO && !$Done) )
5007
+                    {
5008
+                    if ( $TxtHeight < $BarWidth && $TxtWidth < $BarHeight  )
5009 5009
                     $this->drawText($XCenter,$YCenter,$this->scaleFormat($Serie["Data"][$Key],$Mode,$Format,$Unit),array("R"=>$DisplayR,"G"=>$DisplayG,"B"=>$DisplayB,"Angle"=>90,"Align"=>TEXT_ALIGN_MIDDLEMIDDLE,"FontSize"=>$DisplaySize,"FontName"=>$DisplayFont));
5010
-                  }
5010
+                    }
5011 5011
                 }
5012 5012
 
5013
-               $LastX[$Key][$Pos] = $X2;
5014
-              }
5013
+                $LastX[$Key][$Pos] = $X2;
5014
+                }
5015 5015
 
5016
-             $Y = $Y + $YStep;
5016
+                $Y = $Y + $YStep;
5017
+            }
5017 5018
             }
5018
-          }
5019 5019
         }
5020
-      }
5020
+        }
5021 5021
     }
5022 5022
 
5023
-   /* Draw a stacked area chart */
5024
-   function drawStackedAreaChart($Format=NULL)
5023
+    /* Draw a stacked area chart */
5024
+    function drawStackedAreaChart($Format=NULL)
5025 5025
     {
5026
-     $DrawLine		= isset($Format["DrawLine"]) ? $Format["DrawLine"] : FALSE;
5027
-     $LineSurrounding	= isset($Format["LineSurrounding"]) ? $Format["LineSurrounding"] : NULL;
5028
-     $LineR		= isset($Format["LineR"]) ? $Format["LineR"] : VOID;
5029
-     $LineG		= isset($Format["LineG"]) ? $Format["LineG"] : VOID;
5030
-     $LineB		= isset($Format["LineB"]) ? $Format["LineB"] : VOID;
5031
-     $LineAlpha		= isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100;
5032
-     $DrawPlot		= isset($Format["DrawPlot"]) ? $Format["DrawPlot"] : FALSE;
5033
-     $PlotRadius	= isset($Format["PlotRadius"]) ? $Format["PlotRadius"] : 2;
5034
-     $PlotBorder	= isset($Format["PlotBorder"]) ? $Format["PlotBorder"] : 1;
5035
-     $PlotBorderSurrounding = isset($Format["PlotBorderSurrounding"]) ? $Format["PlotBorderSurrounding"] : NULL;
5036
-     $PlotBorderR	= isset($Format["PlotBorderR"]) ? $Format["PlotBorderR"] : 0;
5037
-     $PlotBorderG	= isset($Format["PlotBorderG"]) ? $Format["PlotBorderG"] : 0;
5038
-     $PlotBorderB	= isset($Format["PlotBorderB"]) ? $Format["PlotBorderB"] : 0;
5039
-     $PlotBorderAlpha	= isset($Format["PlotBorderAlpha"]) ? $Format["PlotBorderAlpha"] : 50;
5040
-     $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : NULL;
5041
-
5042
-     $this->LastChartLayout = CHART_LAST_LAYOUT_STACKED;
5043
-
5044
-     $Data = $this->DataSet->getData();
5045
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
5046
-
5047
-     $RestoreShadow = $this->Shadow;
5048
-     $this->Shadow  = FALSE;
5049
-
5050
-     /* Build the offset data series */
5051
-     $OffsetData    = "";
5052
-     $OverallOffset = "";
5053
-     $SerieOrder    = "";
5054
-     foreach($Data["Series"] as $SerieName => $Serie)
5055
-      {
5056
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5057
-        {
5058
-         $SerieOrder[] = $SerieName;
5059
-
5060
-         foreach($Serie["Data"] as $Key => $Value)
5061
-          {
5062
-           if ( $Value == VOID ) { $Value = 0; }
5063
-           if ($Value >= 0) { $Sign = "+"; } else { $Sign = "-"; }
5064
-           if ( !isset($OverallOffset[$Key]) || !isset($OverallOffset[$Key][$Sign]) ) { $OverallOffset[$Key][$Sign] = 0; }
5065
-
5066
-           if ( $Sign == "+" )
5026
+        $DrawLine		= isset($Format["DrawLine"]) ? $Format["DrawLine"] : FALSE;
5027
+        $LineSurrounding	= isset($Format["LineSurrounding"]) ? $Format["LineSurrounding"] : NULL;
5028
+        $LineR		= isset($Format["LineR"]) ? $Format["LineR"] : VOID;
5029
+        $LineG		= isset($Format["LineG"]) ? $Format["LineG"] : VOID;
5030
+        $LineB		= isset($Format["LineB"]) ? $Format["LineB"] : VOID;
5031
+        $LineAlpha		= isset($Format["LineAlpha"]) ? $Format["LineAlpha"] : 100;
5032
+        $DrawPlot		= isset($Format["DrawPlot"]) ? $Format["DrawPlot"] : FALSE;
5033
+        $PlotRadius	= isset($Format["PlotRadius"]) ? $Format["PlotRadius"] : 2;
5034
+        $PlotBorder	= isset($Format["PlotBorder"]) ? $Format["PlotBorder"] : 1;
5035
+        $PlotBorderSurrounding = isset($Format["PlotBorderSurrounding"]) ? $Format["PlotBorderSurrounding"] : NULL;
5036
+        $PlotBorderR	= isset($Format["PlotBorderR"]) ? $Format["PlotBorderR"] : 0;
5037
+        $PlotBorderG	= isset($Format["PlotBorderG"]) ? $Format["PlotBorderG"] : 0;
5038
+        $PlotBorderB	= isset($Format["PlotBorderB"]) ? $Format["PlotBorderB"] : 0;
5039
+        $PlotBorderAlpha	= isset($Format["PlotBorderAlpha"]) ? $Format["PlotBorderAlpha"] : 50;
5040
+        $ForceTransparency	= isset($Format["ForceTransparency"]) ? $Format["ForceTransparency"] : NULL;
5041
+
5042
+        $this->LastChartLayout = CHART_LAST_LAYOUT_STACKED;
5043
+
5044
+        $Data = $this->DataSet->getData();
5045
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
5046
+
5047
+        $RestoreShadow = $this->Shadow;
5048
+        $this->Shadow  = FALSE;
5049
+
5050
+        /* Build the offset data series */
5051
+        $OffsetData    = "";
5052
+        $OverallOffset = "";
5053
+        $SerieOrder    = "";
5054
+        foreach($Data["Series"] as $SerieName => $Serie)
5055
+        {
5056
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5057
+        {
5058
+            $SerieOrder[] = $SerieName;
5059
+
5060
+            foreach($Serie["Data"] as $Key => $Value)
5061
+            {
5062
+            if ( $Value == VOID ) { $Value = 0; }
5063
+            if ($Value >= 0) { $Sign = "+"; } else { $Sign = "-"; }
5064
+            if ( !isset($OverallOffset[$Key]) || !isset($OverallOffset[$Key][$Sign]) ) { $OverallOffset[$Key][$Sign] = 0; }
5065
+
5066
+            if ( $Sign == "+" )
5067 5067
             { $Data["Series"][$SerieName]["Data"][$Key] = $Value + $OverallOffset[$Key][$Sign]; }
5068
-           else
5068
+            else
5069 5069
             { $Data["Series"][$SerieName]["Data"][$Key] = $Value - $OverallOffset[$Key][$Sign]; }
5070 5070
 
5071
-           $OverallOffset[$Key][$Sign] = $OverallOffset[$Key][$Sign] + abs($Value);
5072
-          }
5071
+            $OverallOffset[$Key][$Sign] = $OverallOffset[$Key][$Sign] + abs($Value);
5072
+            }
5073 5073
         } 
5074
-      }
5075
-     $SerieOrder = array_reverse($SerieOrder);
5074
+        }
5075
+        $SerieOrder = array_reverse($SerieOrder);
5076 5076
 
5077
-     $LastX = ""; $LastY = "";
5078
-     foreach($SerieOrder as $Key => $SerieName)
5079
-      {
5080
-       $Serie = $Data["Series"][$SerieName];
5081
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5077
+        $LastX = ""; $LastY = "";
5078
+        foreach($SerieOrder as $Key => $SerieName)
5082 5079
         {
5083
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
5084
-         if ( $ForceTransparency != NULL ) { $Alpha = $ForceTransparency; }
5080
+        $Serie = $Data["Series"][$SerieName];
5081
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5082
+        {
5083
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"];
5084
+            if ( $ForceTransparency != NULL ) { $Alpha = $ForceTransparency; }
5085 5085
 
5086
-         $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
5086
+            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
5087 5087
 
5088
-         if ( $LineSurrounding != NULL )
5089
-          $LineColor = array("R"=>$R+$LineSurrounding,"G"=>$G+$LineSurrounding,"B"=>$B+$LineSurrounding,"Alpha"=>$Alpha);
5090
-         elseif ( $LineR != VOID )
5091
-          $LineColor = array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha);
5092
-         else
5093
-          $LineColor = $Color;
5088
+            if ( $LineSurrounding != NULL )
5089
+            $LineColor = array("R"=>$R+$LineSurrounding,"G"=>$G+$LineSurrounding,"B"=>$B+$LineSurrounding,"Alpha"=>$Alpha);
5090
+            elseif ( $LineR != VOID )
5091
+            $LineColor = array("R"=>$LineR,"G"=>$LineG,"B"=>$LineB,"Alpha"=>$LineAlpha);
5092
+            else
5093
+            $LineColor = $Color;
5094 5094
 
5095
-         if ( $PlotBorderSurrounding != NULL )
5096
-          $PlotBorderColor = array("R"=>$R+$PlotBorderSurrounding,"G"=>$G+$PlotBorderSurrounding,"B"=>$B+$PlotBorderSurrounding,"Alpha"=>$PlotBorderAlpha);
5097
-         else
5098
-          $PlotBorderColor = array("R"=>$PlotBorderR,"G"=>$PlotBorderG,"B"=>$PlotBorderB,"Alpha"=>$PlotBorderAlpha);
5095
+            if ( $PlotBorderSurrounding != NULL )
5096
+            $PlotBorderColor = array("R"=>$R+$PlotBorderSurrounding,"G"=>$G+$PlotBorderSurrounding,"B"=>$B+$PlotBorderSurrounding,"Alpha"=>$PlotBorderAlpha);
5097
+            else
5098
+            $PlotBorderColor = array("R"=>$PlotBorderR,"G"=>$PlotBorderG,"B"=>$PlotBorderB,"Alpha"=>$PlotBorderAlpha);
5099 5099
 
5100
-         $AxisID	= $Serie["Axis"];
5101
-         $Mode		= $Data["Axis"][$AxisID]["Display"];
5102
-         $Format	= $Data["Axis"][$AxisID]["Format"];
5103
-         $Unit		= $Data["Axis"][$AxisID]["Unit"];
5100
+            $AxisID	= $Serie["Axis"];
5101
+            $Mode		= $Data["Axis"][$AxisID]["Display"];
5102
+            $Format	= $Data["Axis"][$AxisID]["Format"];
5103
+            $Unit		= $Data["Axis"][$AxisID]["Unit"];
5104 5104
 
5105
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]),TRUE);
5106
-         $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
5105
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]),TRUE);
5106
+            $YZero    = $this->scaleComputeY(0,array("AxisID"=>$Serie["Axis"]));
5107 5107
 
5108
-         $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
5108
+            $this->DataSet->Data["Series"][$SerieName]["XOffset"] = 0;
5109 5109
 
5110
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5111
-          {
5112
-           if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
5113
-           if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
5110
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5111
+            {
5112
+            if ( $YZero < $this->GraphAreaY1+1 ) { $YZero = $this->GraphAreaY1+1; }
5113
+            if ( $YZero > $this->GraphAreaY2-1 ) { $YZero = $this->GraphAreaY2-1; }
5114 5114
 
5115
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5116
-           $X = $this->GraphAreaX1 + $XMargin;
5115
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5116
+            $X = $this->GraphAreaX1 + $XMargin;
5117 5117
 
5118
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5118
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5119 5119
 
5120
-           $Plots = ""; $Plots[] = $X; $Plots[] = $YZero;
5121
-           foreach($PosArray as $Key => $Height)
5120
+            $Plots = ""; $Plots[] = $X; $Plots[] = $YZero;
5121
+            foreach($PosArray as $Key => $Height)
5122 5122
             {
5123
-             if ( $Height != VOID ) { $Plots[] = $X; $Plots[] = $YZero-$Height; }
5124
-             $X = $X + $XStep;
5123
+                if ( $Height != VOID ) { $Plots[] = $X; $Plots[] = $YZero-$Height; }
5124
+                $X = $X + $XStep;
5125 5125
             }
5126
-           $Plots[] = $X-$XStep; $Plots[] = $YZero;
5126
+            $Plots[] = $X-$XStep; $Plots[] = $YZero;
5127 5127
 
5128
-           $this->drawPolygon($Plots,$Color);
5128
+            $this->drawPolygon($Plots,$Color);
5129 5129
 
5130
-           $this->Shadow = $RestoreShadow;
5131
-           if ( $DrawLine ) { for($i=2; $i<=count($Plots)-6; $i=$i+2) { $this->drawLine($Plots[$i],$Plots[$i+1],$Plots[$i+2],$Plots[$i+3],$LineColor); } }
5132
-           if ( $DrawPlot )
5130
+            $this->Shadow = $RestoreShadow;
5131
+            if ( $DrawLine ) { for($i=2; $i<=count($Plots)-6; $i=$i+2) { $this->drawLine($Plots[$i],$Plots[$i+1],$Plots[$i+2],$Plots[$i+3],$LineColor); } }
5132
+            if ( $DrawPlot )
5133 5133
             {
5134
-             for($i=2; $i<=count($Plots)-4; $i=$i+2)
5135
-              {
5136
-               if ( $PlotBorder != 0 )
5134
+                for($i=2; $i<=count($Plots)-4; $i=$i+2)
5135
+                {
5136
+                if ( $PlotBorder != 0 )
5137 5137
                 { $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius+$PlotBorder,$PlotBorderColor); }
5138 5138
 
5139
-               $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius,$Color);
5140
-              }
5139
+                $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius,$Color);
5140
+                }
5141
+            }
5142
+            $this->Shadow = FALSE;
5141 5143
             }
5142
-           $this->Shadow = FALSE;
5143
-          }
5144
-         elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
5145
-          {
5146
-           if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
5147
-           if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
5144
+            elseif ( $Data["Orientation"] == SCALE_POS_TOPBOTTOM )
5145
+            {
5146
+            if ( $YZero < $this->GraphAreaX1+1 ) { $YZero = $this->GraphAreaX1+1; }
5147
+            if ( $YZero > $this->GraphAreaX2-1 ) { $YZero = $this->GraphAreaX2-1; }
5148 5148
 
5149
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5150
-           $Y = $this->GraphAreaY1 + $XMargin;
5149
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5150
+            $Y = $this->GraphAreaY1 + $XMargin;
5151 5151
 
5152
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5152
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5153 5153
 
5154
-           $Plots = ""; $Plots[] = $YZero; $Plots[] = $Y;
5155
-           foreach($PosArray as $Key => $Height)
5154
+            $Plots = ""; $Plots[] = $YZero; $Plots[] = $Y;
5155
+            foreach($PosArray as $Key => $Height)
5156 5156
             {
5157
-             if ( $Height != VOID ) { $Plots[] = $YZero+$Height; $Plots[] = $Y; }
5158
-             $Y = $Y + $YStep;
5157
+                if ( $Height != VOID ) { $Plots[] = $YZero+$Height; $Plots[] = $Y; }
5158
+                $Y = $Y + $YStep;
5159 5159
             }
5160
-           $Plots[] = $YZero; $Plots[] = $Y-$YStep;
5160
+            $Plots[] = $YZero; $Plots[] = $Y-$YStep;
5161 5161
 
5162
-           $this->drawPolygon($Plots,$Color);
5162
+            $this->drawPolygon($Plots,$Color);
5163 5163
 
5164
-           $this->Shadow = $RestoreShadow;
5165
-           if ( $DrawLine ) { for($i=2; $i<=count($Plots)-6; $i=$i+2) { $this->drawLine($Plots[$i],$Plots[$i+1],$Plots[$i+2],$Plots[$i+3],$LineColor); } }
5166
-           if ( $DrawPlot )
5164
+            $this->Shadow = $RestoreShadow;
5165
+            if ( $DrawLine ) { for($i=2; $i<=count($Plots)-6; $i=$i+2) { $this->drawLine($Plots[$i],$Plots[$i+1],$Plots[$i+2],$Plots[$i+3],$LineColor); } }
5166
+            if ( $DrawPlot )
5167 5167
             {
5168
-             for($i=2; $i<=count($Plots)-4; $i=$i+2)
5169
-              {
5170
-               if ( $PlotBorder != 0 )
5168
+                for($i=2; $i<=count($Plots)-4; $i=$i+2)
5169
+                {
5170
+                if ( $PlotBorder != 0 )
5171 5171
                 { $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius+$PlotBorder,$PlotBorderColor); }
5172 5172
 
5173
-               $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius,$Color);
5174
-              }
5173
+                $this->drawFilledCircle($Plots[$i],$Plots[$i+1],$PlotRadius,$Color);
5174
+                }
5175
+            }
5176
+            $this->Shadow = FALSE;
5175 5177
             }
5176
-           $this->Shadow = FALSE;
5177
-          }
5178 5178
         }
5179
-      }
5180
-     $this->Shadow = $RestoreShadow;
5179
+        }
5180
+        $this->Shadow = $RestoreShadow;
5181 5181
     }
5182 5182
 
5183
-   /* Returns a random color */
5184
-   function getRandomColor($Alpha=100)
5183
+    /* Returns a random color */
5184
+    function getRandomColor($Alpha=100)
5185 5185
     { return(array("R"=>rand(0,255),"G"=>rand(0,255),"B"=>rand(0,255),"Alpha"=>$Alpha)); }
5186 5186
  
5187
-   /* Validate a palette */
5188
-   function validatePalette($Colors,$Surrounding=NULL)
5187
+    /* Validate a palette */
5188
+    function validatePalette($Colors,$Surrounding=NULL)
5189 5189
     {
5190
-     $Result = "";
5190
+        $Result = "";
5191 5191
 
5192
-     if ( !is_array($Colors) ) { return($this->getRandomColor()); }
5192
+        if ( !is_array($Colors) ) { return($this->getRandomColor()); }
5193 5193
 
5194
-     foreach($Colors as $Key => $Values)
5195
-      {
5196
-       if ( isset($Values["R"]) ) { $Result[$Key]["R"] = $Values["R"]; } else { $Result[$Key]["R"] = rand(0,255); }
5197
-       if ( isset($Values["G"]) ) { $Result[$Key]["G"] = $Values["G"]; } else { $Result[$Key]["G"] = rand(0,255); }
5198
-       if ( isset($Values["B"]) ) { $Result[$Key]["B"] = $Values["B"]; } else { $Result[$Key]["B"] = rand(0,255); }
5199
-       if ( isset($Values["Alpha"]) ) { $Result[$Key]["Alpha"] = $Values["Alpha"]; } else { $Result[$Key]["Alpha"] = 100; }
5194
+        foreach($Colors as $Key => $Values)
5195
+        {
5196
+        if ( isset($Values["R"]) ) { $Result[$Key]["R"] = $Values["R"]; } else { $Result[$Key]["R"] = rand(0,255); }
5197
+        if ( isset($Values["G"]) ) { $Result[$Key]["G"] = $Values["G"]; } else { $Result[$Key]["G"] = rand(0,255); }
5198
+        if ( isset($Values["B"]) ) { $Result[$Key]["B"] = $Values["B"]; } else { $Result[$Key]["B"] = rand(0,255); }
5199
+        if ( isset($Values["Alpha"]) ) { $Result[$Key]["Alpha"] = $Values["Alpha"]; } else { $Result[$Key]["Alpha"] = 100; }
5200 5200
 
5201
-       if ( $Surrounding != NULL )
5201
+        if ( $Surrounding != NULL )
5202 5202
         {
5203
-         $Result[$Key]["BorderR"] = $Result[$Key]["R"] + $Surrounding;
5204
-         $Result[$Key]["BorderG"] = $Result[$Key]["G"] + $Surrounding;
5205
-         $Result[$Key]["BorderB"] = $Result[$Key]["B"] + $Surrounding;
5203
+            $Result[$Key]["BorderR"] = $Result[$Key]["R"] + $Surrounding;
5204
+            $Result[$Key]["BorderG"] = $Result[$Key]["G"] + $Surrounding;
5205
+            $Result[$Key]["BorderB"] = $Result[$Key]["B"] + $Surrounding;
5206 5206
         }
5207
-       else
5207
+        else
5208 5208
         {
5209
-         if ( isset($Values["BorderR"]) )     { $Result[$Key]["BorderR"] = $Values["BorderR"]; } else { $Result[$Key]["BorderR"] = $Result[$Key]["R"]; }
5210
-         if ( isset($Values["BorderG"]) )     { $Result[$Key]["BorderG"] = $Values["BorderG"]; } else { $Result[$Key]["BorderG"] = $Result[$Key]["G"]; }
5211
-         if ( isset($Values["BorderB"]) )     { $Result[$Key]["BorderB"] = $Values["BorderB"]; } else { $Result[$Key]["BorderB"] = $Result[$Key]["B"]; }
5212
-         if ( isset($Values["BorderAlpha"]) ) { $Result[$Key]["BorderAlpha"] = $Values["BorderAlpha"]; } else { $Result[$Key]["BorderAlpha"] = $Result[$Key]["Alpha"]; }
5209
+            if ( isset($Values["BorderR"]) )     { $Result[$Key]["BorderR"] = $Values["BorderR"]; } else { $Result[$Key]["BorderR"] = $Result[$Key]["R"]; }
5210
+            if ( isset($Values["BorderG"]) )     { $Result[$Key]["BorderG"] = $Values["BorderG"]; } else { $Result[$Key]["BorderG"] = $Result[$Key]["G"]; }
5211
+            if ( isset($Values["BorderB"]) )     { $Result[$Key]["BorderB"] = $Values["BorderB"]; } else { $Result[$Key]["BorderB"] = $Result[$Key]["B"]; }
5212
+            if ( isset($Values["BorderAlpha"]) ) { $Result[$Key]["BorderAlpha"] = $Values["BorderAlpha"]; } else { $Result[$Key]["BorderAlpha"] = $Result[$Key]["Alpha"]; }
5213
+        }
5213 5214
         }
5214
-      }
5215 5215
 
5216
-     return($Result);
5216
+        return($Result);
5217 5217
     }
5218 5218
 
5219
-   /* Draw the derivative chart associated to the data series */
5220
-   function drawDerivative($Format=NULL)
5219
+    /* Draw the derivative chart associated to the data series */
5220
+    function drawDerivative($Format=NULL)
5221 5221
     {
5222
-     $Offset		= isset($Format["Offset"]) ? $Format["Offset"] : 10;
5223
-     $SerieSpacing	= isset($Format["SerieSpacing"]) ? $Format["SerieSpacing"] : 3;
5224
-     $DerivativeHeight	= isset($Format["DerivativeHeight"]) ? $Format["DerivativeHeight"] : 4;
5225
-     $ShadedSlopeBox	= isset($Format["ShadedSlopeBox"]) ? $Format["ShadedSlopeBox"] : FALSE;
5226
-     $DrawBackground	= isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : TRUE;
5227
-     $BackgroundR	= isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255;
5228
-     $BackgroundG	= isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255;
5229
-     $BackgroundB	= isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255;
5230
-     $BackgroundAlpha	= isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 20;
5231
-     $DrawBorder	= isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : TRUE;
5232
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
5233
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
5234
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
5235
-     $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 100;
5236
-     $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : TRUE;
5237
-     $CaptionHeight	= isset($Format["CaptionHeight"]) ? $Format["CaptionHeight"] : 10;
5238
-     $CaptionWidth	= isset($Format["CaptionWidth"]) ? $Format["CaptionWidth"] : 20;
5239
-     $CaptionMargin	= isset($Format["CaptionMargin"]) ? $Format["CaptionMargin"] : 4;
5240
-     $CaptionLine	= isset($Format["CaptionLine"]) ? $Format["CaptionLine"] : FALSE;
5241
-     $CaptionBox	= isset($Format["CaptionBox"]) ? $Format["CaptionBox"] : FALSE;
5242
-     $CaptionBorderR	= isset($Format["CaptionBorderR"]) ? $Format["CaptionBorderR"] : 0;
5243
-     $CaptionBorderG	= isset($Format["CaptionBorderG"]) ? $Format["CaptionBorderG"] : 0;
5244
-     $CaptionBorderB	= isset($Format["CaptionBorderB"]) ? $Format["CaptionBorderB"] : 0;
5245
-     $CaptionFillR	= isset($Format["CaptionFillR"]) ? $Format["CaptionFillR"] : 255;
5246
-     $CaptionFillG	= isset($Format["CaptionFillG"]) ? $Format["CaptionFillG"] : 255;
5247
-     $CaptionFillB	= isset($Format["CaptionFillB"]) ? $Format["CaptionFillB"] : 255;
5248
-     $CaptionFillAlpha	= isset($Format["CaptionFillAlpha"]) ? $Format["CaptionFillAlpha"] : 80;
5249
-     $PositiveSlopeStartR	= isset($Format["PositiveSlopeStartR"]) ? $Format["PositiveSlopeStartR"] : 184;
5250
-     $PositiveSlopeStartG	= isset($Format["PositiveSlopeStartG"]) ? $Format["PositiveSlopeStartG"] : 234;
5251
-     $PositiveSlopeStartB	= isset($Format["PositiveSlopeStartB"]) ? $Format["PositiveSlopeStartB"] : 88;
5252
-     $PositiveSlopeEndR		= isset($Format["PositiveSlopeStartR"]) ? $Format["PositiveSlopeStartR"] : 239;
5253
-     $PositiveSlopeEndG		= isset($Format["PositiveSlopeStartG"]) ? $Format["PositiveSlopeStartG"] : 31;
5254
-     $PositiveSlopeEndB		= isset($Format["PositiveSlopeStartB"]) ? $Format["PositiveSlopeStartB"] : 36;
5255
-     $NegativeSlopeStartR	= isset($Format["NegativeSlopeStartR"]) ? $Format["NegativeSlopeStartR"] : 184;
5256
-     $NegativeSlopeStartG	= isset($Format["NegativeSlopeStartG"]) ? $Format["NegativeSlopeStartG"] : 234;
5257
-     $NegativeSlopeStartB	= isset($Format["NegativeSlopeStartB"]) ? $Format["NegativeSlopeStartB"] : 88;
5258
-     $NegativeSlopeEndR		= isset($Format["NegativeSlopeStartR"]) ? $Format["NegativeSlopeStartR"] : 67;
5259
-     $NegativeSlopeEndG		= isset($Format["NegativeSlopeStartG"]) ? $Format["NegativeSlopeStartG"] : 124;
5260
-     $NegativeSlopeEndB		= isset($Format["NegativeSlopeStartB"]) ? $Format["NegativeSlopeStartB"] : 227;
5261
-
5262
-     $Data = $this->DataSet->getData();
5263
-
5264
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
5265
-
5266
-     if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5267
-      $YPos = $this->DataSet->Data["GraphArea"]["Y2"] + $Offset;
5268
-     else
5269
-      $XPos = $this->DataSet->Data["GraphArea"]["X2"] + $Offset;
5270
-
5271
-     foreach($Data["Series"] as $SerieName => $Serie)
5272
-      {
5273
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5274
-        {
5275
-         $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
5276
-
5277
-         $AxisID   = $Serie["Axis"];
5278
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
5279
-
5280
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5281
-          {
5282
-           if ( $Caption )
5283
-            {
5284
-             if ( $CaptionLine ) 
5285
-              {
5286
-               $StartX = floor($this->GraphAreaX1-$CaptionWidth+$XMargin-$CaptionMargin);
5287
-               $EndX   = floor($this->GraphAreaX1-$CaptionMargin+$XMargin);
5288
-
5289
-               $CaptionSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
5290
-               if ( $CaptionBox ) { $this->drawFilledRectangle($StartX,$YPos,$EndX,$YPos+$CaptionHeight,array("R"=>$CaptionFillR,"G"=>$CaptionFillG,"B"=>$CaptionFillB,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB,"Alpha"=>$CaptionFillAlpha)); }
5291
-               $this->drawLine($StartX+2,$YPos+($CaptionHeight/2),$EndX-2,$YPos+($CaptionHeight/2),$CaptionSettings);
5292
-              }
5293
-             else
5294
-              $this->drawFilledRectangle($this->GraphAreaX1-$CaptionWidth+$XMargin-$CaptionMargin,$YPos,$this->GraphAreaX1-$CaptionMargin+$XMargin,$YPos+$CaptionHeight,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB));
5295
-            }
5296
-
5297
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5298
-           $X = $this->GraphAreaX1 + $XMargin;
5299
-
5300
-           $TopY    = $YPos + ($CaptionHeight/2) - ($DerivativeHeight/2);
5301
-           $BottomY = $YPos + ($CaptionHeight/2) + ($DerivativeHeight/2);
5302
-
5303
-           $StartX  = floor($this->GraphAreaX1+$XMargin);
5304
-           $EndX    = floor($this->GraphAreaX2-$XMargin);
5305
-
5306
-           if ( $DrawBackground ) { $this->drawFilledRectangle($StartX-1,$TopY-1,$EndX+1,$BottomY+1,array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha)); }
5307
-           if ( $DrawBorder ) { $this->drawRectangle($StartX-1,$TopY-1,$EndX+1,$BottomY+1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5308
-
5309
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5310
-
5311
-           $RestoreShadow = $this->Shadow;
5312
-           $this->Shadow  = FALSE;
5313
-
5314
-           /* Determine the Max slope index */
5315
-           $LastX = NULL; $LastY = NULL; $MinSlope = 0; $MaxSlope = 1;
5316
-           foreach($PosArray as $Key => $Y)
5317
-            {
5318
-             if ( $Y != VOID && $LastX != NULL )
5319
-              { $Slope = ($LastY - $Y); if ( $Slope > $MaxSlope ) { $MaxSlope = $Slope; } if ( $Slope < $MinSlope ) { $MinSlope = $Slope; } }
5320
-
5321
-             if ( $Y == VOID )
5322
-              { $LastX = NULL; $LastY = NULL; }
5323
-             else
5324
-              { $LastX = $X; $LastY = $Y; }
5325
-            }
5326
-
5327
-           $LastX = NULL; $LastY = NULL; $LastColor = NULL;
5328
-           foreach($PosArray as $Key => $Y)
5329
-            {
5330
-             if ( $Y != VOID && $LastY != NULL )
5331
-              {
5332
-               $Slope = ($LastY - $Y);
5333
-
5334
-               if ( $Slope >= 0 )
5222
+        $Offset		= isset($Format["Offset"]) ? $Format["Offset"] : 10;
5223
+        $SerieSpacing	= isset($Format["SerieSpacing"]) ? $Format["SerieSpacing"] : 3;
5224
+        $DerivativeHeight	= isset($Format["DerivativeHeight"]) ? $Format["DerivativeHeight"] : 4;
5225
+        $ShadedSlopeBox	= isset($Format["ShadedSlopeBox"]) ? $Format["ShadedSlopeBox"] : FALSE;
5226
+        $DrawBackground	= isset($Format["DrawBackground"]) ? $Format["DrawBackground"] : TRUE;
5227
+        $BackgroundR	= isset($Format["BackgroundR"]) ? $Format["BackgroundR"] : 255;
5228
+        $BackgroundG	= isset($Format["BackgroundG"]) ? $Format["BackgroundG"] : 255;
5229
+        $BackgroundB	= isset($Format["BackgroundB"]) ? $Format["BackgroundB"] : 255;
5230
+        $BackgroundAlpha	= isset($Format["BackgroundAlpha"]) ? $Format["BackgroundAlpha"] : 20;
5231
+        $DrawBorder	= isset($Format["DrawBorder"]) ? $Format["DrawBorder"] : TRUE;
5232
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : 0;
5233
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : 0;
5234
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : 0;
5235
+        $BorderAlpha	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : 100;
5236
+        $Caption		= isset($Format["Caption"]) ? $Format["Caption"] : TRUE;
5237
+        $CaptionHeight	= isset($Format["CaptionHeight"]) ? $Format["CaptionHeight"] : 10;
5238
+        $CaptionWidth	= isset($Format["CaptionWidth"]) ? $Format["CaptionWidth"] : 20;
5239
+        $CaptionMargin	= isset($Format["CaptionMargin"]) ? $Format["CaptionMargin"] : 4;
5240
+        $CaptionLine	= isset($Format["CaptionLine"]) ? $Format["CaptionLine"] : FALSE;
5241
+        $CaptionBox	= isset($Format["CaptionBox"]) ? $Format["CaptionBox"] : FALSE;
5242
+        $CaptionBorderR	= isset($Format["CaptionBorderR"]) ? $Format["CaptionBorderR"] : 0;
5243
+        $CaptionBorderG	= isset($Format["CaptionBorderG"]) ? $Format["CaptionBorderG"] : 0;
5244
+        $CaptionBorderB	= isset($Format["CaptionBorderB"]) ? $Format["CaptionBorderB"] : 0;
5245
+        $CaptionFillR	= isset($Format["CaptionFillR"]) ? $Format["CaptionFillR"] : 255;
5246
+        $CaptionFillG	= isset($Format["CaptionFillG"]) ? $Format["CaptionFillG"] : 255;
5247
+        $CaptionFillB	= isset($Format["CaptionFillB"]) ? $Format["CaptionFillB"] : 255;
5248
+        $CaptionFillAlpha	= isset($Format["CaptionFillAlpha"]) ? $Format["CaptionFillAlpha"] : 80;
5249
+        $PositiveSlopeStartR	= isset($Format["PositiveSlopeStartR"]) ? $Format["PositiveSlopeStartR"] : 184;
5250
+        $PositiveSlopeStartG	= isset($Format["PositiveSlopeStartG"]) ? $Format["PositiveSlopeStartG"] : 234;
5251
+        $PositiveSlopeStartB	= isset($Format["PositiveSlopeStartB"]) ? $Format["PositiveSlopeStartB"] : 88;
5252
+        $PositiveSlopeEndR		= isset($Format["PositiveSlopeStartR"]) ? $Format["PositiveSlopeStartR"] : 239;
5253
+        $PositiveSlopeEndG		= isset($Format["PositiveSlopeStartG"]) ? $Format["PositiveSlopeStartG"] : 31;
5254
+        $PositiveSlopeEndB		= isset($Format["PositiveSlopeStartB"]) ? $Format["PositiveSlopeStartB"] : 36;
5255
+        $NegativeSlopeStartR	= isset($Format["NegativeSlopeStartR"]) ? $Format["NegativeSlopeStartR"] : 184;
5256
+        $NegativeSlopeStartG	= isset($Format["NegativeSlopeStartG"]) ? $Format["NegativeSlopeStartG"] : 234;
5257
+        $NegativeSlopeStartB	= isset($Format["NegativeSlopeStartB"]) ? $Format["NegativeSlopeStartB"] : 88;
5258
+        $NegativeSlopeEndR		= isset($Format["NegativeSlopeStartR"]) ? $Format["NegativeSlopeStartR"] : 67;
5259
+        $NegativeSlopeEndG		= isset($Format["NegativeSlopeStartG"]) ? $Format["NegativeSlopeStartG"] : 124;
5260
+        $NegativeSlopeEndB		= isset($Format["NegativeSlopeStartB"]) ? $Format["NegativeSlopeStartB"] : 227;
5261
+
5262
+        $Data = $this->DataSet->getData();
5263
+
5264
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
5265
+
5266
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5267
+        $YPos = $this->DataSet->Data["GraphArea"]["Y2"] + $Offset;
5268
+        else
5269
+        $XPos = $this->DataSet->Data["GraphArea"]["X2"] + $Offset;
5270
+
5271
+        foreach($Data["Series"] as $SerieName => $Serie)
5272
+        {
5273
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5274
+        {
5275
+            $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; $Alpha = $Serie["Color"]["Alpha"]; $Ticks = $Serie["Ticks"]; $Weight = $Serie["Weight"];
5276
+
5277
+            $AxisID   = $Serie["Axis"];
5278
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
5279
+
5280
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5281
+            {
5282
+            if ( $Caption )
5283
+            {
5284
+                if ( $CaptionLine ) 
5285
+                {
5286
+                $StartX = floor($this->GraphAreaX1-$CaptionWidth+$XMargin-$CaptionMargin);
5287
+                $EndX   = floor($this->GraphAreaX1-$CaptionMargin+$XMargin);
5288
+
5289
+                $CaptionSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
5290
+                if ( $CaptionBox ) { $this->drawFilledRectangle($StartX,$YPos,$EndX,$YPos+$CaptionHeight,array("R"=>$CaptionFillR,"G"=>$CaptionFillG,"B"=>$CaptionFillB,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB,"Alpha"=>$CaptionFillAlpha)); }
5291
+                $this->drawLine($StartX+2,$YPos+($CaptionHeight/2),$EndX-2,$YPos+($CaptionHeight/2),$CaptionSettings);
5292
+                }
5293
+                else
5294
+                $this->drawFilledRectangle($this->GraphAreaX1-$CaptionWidth+$XMargin-$CaptionMargin,$YPos,$this->GraphAreaX1-$CaptionMargin+$XMargin,$YPos+$CaptionHeight,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB));
5295
+            }
5296
+
5297
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5298
+            $X = $this->GraphAreaX1 + $XMargin;
5299
+
5300
+            $TopY    = $YPos + ($CaptionHeight/2) - ($DerivativeHeight/2);
5301
+            $BottomY = $YPos + ($CaptionHeight/2) + ($DerivativeHeight/2);
5302
+
5303
+            $StartX  = floor($this->GraphAreaX1+$XMargin);
5304
+            $EndX    = floor($this->GraphAreaX2-$XMargin);
5305
+
5306
+            if ( $DrawBackground ) { $this->drawFilledRectangle($StartX-1,$TopY-1,$EndX+1,$BottomY+1,array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha)); }
5307
+            if ( $DrawBorder ) { $this->drawRectangle($StartX-1,$TopY-1,$EndX+1,$BottomY+1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5308
+
5309
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5310
+
5311
+            $RestoreShadow = $this->Shadow;
5312
+            $this->Shadow  = FALSE;
5313
+
5314
+            /* Determine the Max slope index */
5315
+            $LastX = NULL; $LastY = NULL; $MinSlope = 0; $MaxSlope = 1;
5316
+            foreach($PosArray as $Key => $Y)
5317
+            {
5318
+                if ( $Y != VOID && $LastX != NULL )
5319
+                { $Slope = ($LastY - $Y); if ( $Slope > $MaxSlope ) { $MaxSlope = $Slope; } if ( $Slope < $MinSlope ) { $MinSlope = $Slope; } }
5320
+
5321
+                if ( $Y == VOID )
5322
+                { $LastX = NULL; $LastY = NULL; }
5323
+                else
5324
+                { $LastX = $X; $LastY = $Y; }
5325
+            }
5326
+
5327
+            $LastX = NULL; $LastY = NULL; $LastColor = NULL;
5328
+            foreach($PosArray as $Key => $Y)
5329
+            {
5330
+                if ( $Y != VOID && $LastY != NULL )
5331
+                {
5332
+                $Slope = ($LastY - $Y);
5333
+
5334
+                if ( $Slope >= 0 )
5335 5335
                 {
5336
-                 $SlopeIndex = (100 / $MaxSlope) * $Slope;
5337
-                 $R = (($PositiveSlopeEndR - $PositiveSlopeStartR)/100)*$SlopeIndex+$PositiveSlopeStartR;
5338
-                 $G = (($PositiveSlopeEndG - $PositiveSlopeStartG)/100)*$SlopeIndex+$PositiveSlopeStartG;
5339
-                 $B = (($PositiveSlopeEndB - $PositiveSlopeStartB)/100)*$SlopeIndex+$PositiveSlopeStartB;
5336
+                    $SlopeIndex = (100 / $MaxSlope) * $Slope;
5337
+                    $R = (($PositiveSlopeEndR - $PositiveSlopeStartR)/100)*$SlopeIndex+$PositiveSlopeStartR;
5338
+                    $G = (($PositiveSlopeEndG - $PositiveSlopeStartG)/100)*$SlopeIndex+$PositiveSlopeStartG;
5339
+                    $B = (($PositiveSlopeEndB - $PositiveSlopeStartB)/100)*$SlopeIndex+$PositiveSlopeStartB;
5340 5340
                 }
5341
-               elseif ( $Slope < 0 )
5341
+                elseif ( $Slope < 0 )
5342 5342
                 {
5343
-                 $SlopeIndex = (100 / abs($MinSlope)) * abs($Slope);
5344
-                 $R = (($NegativeSlopeEndR - $NegativeSlopeStartR)/100)*$SlopeIndex+$NegativeSlopeStartR;
5345
-                 $G = (($NegativeSlopeEndG - $NegativeSlopeStartG)/100)*$SlopeIndex+$NegativeSlopeStartG;
5346
-                 $B = (($NegativeSlopeEndB - $NegativeSlopeStartB)/100)*$SlopeIndex+$NegativeSlopeStartB;
5343
+                    $SlopeIndex = (100 / abs($MinSlope)) * abs($Slope);
5344
+                    $R = (($NegativeSlopeEndR - $NegativeSlopeStartR)/100)*$SlopeIndex+$NegativeSlopeStartR;
5345
+                    $G = (($NegativeSlopeEndG - $NegativeSlopeStartG)/100)*$SlopeIndex+$NegativeSlopeStartG;
5346
+                    $B = (($NegativeSlopeEndB - $NegativeSlopeStartB)/100)*$SlopeIndex+$NegativeSlopeStartB;
5347 5347
                 }
5348 5348
 
5349
-               $Color = array("R"=>$R,"G"=>$G,"B"=>$B);
5349
+                $Color = array("R"=>$R,"G"=>$G,"B"=>$B);
5350 5350
 
5351
-               if ( $ShadedSlopeBox && $LastColor != NULL ) // && $Slope != 0
5351
+                if ( $ShadedSlopeBox && $LastColor != NULL ) // && $Slope != 0
5352 5352
                 {
5353
-                 $GradientSettings = array("StartR"=>$LastColor["R"],"StartG"=>$LastColor["G"],"StartB"=>$LastColor["B"],"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
5354
-                 $this->drawGradientArea($LastX,$TopY,$X,$BottomY,DIRECTION_HORIZONTAL,$GradientSettings);
5353
+                    $GradientSettings = array("StartR"=>$LastColor["R"],"StartG"=>$LastColor["G"],"StartB"=>$LastColor["B"],"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
5354
+                    $this->drawGradientArea($LastX,$TopY,$X,$BottomY,DIRECTION_HORIZONTAL,$GradientSettings);
5355 5355
                 }
5356
-               elseif ( !$ShadedSlopeBox || $LastColor == NULL ) // || $Slope == 0
5356
+                elseif ( !$ShadedSlopeBox || $LastColor == NULL ) // || $Slope == 0
5357 5357
                 $this->drawFilledRectangle(floor($LastX),$TopY,floor($X),$BottomY,$Color);
5358 5358
 
5359
-               $LastColor = $Color;
5360
-              }
5359
+                $LastColor = $Color;
5360
+                }
5361 5361
 
5362
-             if ( $Y == VOID )
5363
-              { $LastY = NULL; }
5364
-             else
5365
-              { $LastX = $X; $LastY = $Y; }
5362
+                if ( $Y == VOID )
5363
+                { $LastY = NULL; }
5364
+                else
5365
+                { $LastX = $X; $LastY = $Y; }
5366 5366
 
5367
-             $X = $X + $XStep;
5367
+                $X = $X + $XStep;
5368 5368
             }
5369 5369
 
5370
-           $YPos = $YPos + $CaptionHeight + $SerieSpacing;
5371
-          }
5372
-         else
5373
-          {
5374
-           if ( $Caption )
5370
+            $YPos = $YPos + $CaptionHeight + $SerieSpacing;
5371
+            }
5372
+            else
5373
+            {
5374
+            if ( $Caption )
5375 5375
             {
5376
-             $StartY = floor($this->GraphAreaY1-$CaptionWidth+$XMargin-$CaptionMargin);
5377
-             $EndY   = floor($this->GraphAreaY1-$CaptionMargin+$XMargin);
5378
-             if ( $CaptionLine ) 
5379
-              {
5380
-               $CaptionSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
5381
-               if ( $CaptionBox ) { $this->drawFilledRectangle($XPos,$StartY,$XPos+$CaptionHeight,$EndY,array("R"=>$CaptionFillR,"G"=>$CaptionFillG,"B"=>$CaptionFillB,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB,"Alpha"=>$CaptionFillAlpha)); }
5382
-               $this->drawLine($XPos+($CaptionHeight/2),$StartY+2,$XPos+($CaptionHeight/2),$EndY-2,$CaptionSettings);
5383
-              }
5384
-             else
5385
-              $this->drawFilledRectangle($XPos,$StartY,$XPos+$CaptionHeight,$EndY,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB));
5376
+                $StartY = floor($this->GraphAreaY1-$CaptionWidth+$XMargin-$CaptionMargin);
5377
+                $EndY   = floor($this->GraphAreaY1-$CaptionMargin+$XMargin);
5378
+                if ( $CaptionLine ) 
5379
+                {
5380
+                $CaptionSettings = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks,"Weight"=>$Weight);
5381
+                if ( $CaptionBox ) { $this->drawFilledRectangle($XPos,$StartY,$XPos+$CaptionHeight,$EndY,array("R"=>$CaptionFillR,"G"=>$CaptionFillG,"B"=>$CaptionFillB,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB,"Alpha"=>$CaptionFillAlpha)); }
5382
+                $this->drawLine($XPos+($CaptionHeight/2),$StartY+2,$XPos+($CaptionHeight/2),$EndY-2,$CaptionSettings);
5383
+                }
5384
+                else
5385
+                $this->drawFilledRectangle($XPos,$StartY,$XPos+$CaptionHeight,$EndY,array("R"=>$R,"G"=>$G,"B"=>$B,"BorderR"=>$CaptionBorderR,"BorderG"=>$CaptionBorderG,"BorderB"=>$CaptionBorderB));
5386 5386
             }
5387 5387
 
5388 5388
 
5389
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5390
-           $Y = $this->GraphAreaY1 + $XMargin;
5389
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5390
+            $Y = $this->GraphAreaY1 + $XMargin;
5391 5391
 
5392
-           $TopX    = $XPos + ($CaptionHeight/2) - ($DerivativeHeight/2);
5393
-           $BottomX = $XPos + ($CaptionHeight/2) + ($DerivativeHeight/2);
5392
+            $TopX    = $XPos + ($CaptionHeight/2) - ($DerivativeHeight/2);
5393
+            $BottomX = $XPos + ($CaptionHeight/2) + ($DerivativeHeight/2);
5394 5394
 
5395
-           $StartY  = floor($this->GraphAreaY1+$XMargin);
5396
-           $EndY    = floor($this->GraphAreaY2-$XMargin);
5395
+            $StartY  = floor($this->GraphAreaY1+$XMargin);
5396
+            $EndY    = floor($this->GraphAreaY2-$XMargin);
5397 5397
 
5398
-           if ( $DrawBackground ) { $this->drawFilledRectangle($TopX-1,$StartY-1,$BottomX+1,$EndY+1,array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha)); }
5399
-           if ( $DrawBorder ) { $this->drawRectangle($TopX-1,$StartY-1,$BottomX+1,$EndY+1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5398
+            if ( $DrawBackground ) { $this->drawFilledRectangle($TopX-1,$StartY-1,$BottomX+1,$EndY+1,array("R"=>$BackgroundR,"G"=>$BackgroundG,"B"=>$BackgroundB,"Alpha"=>$BackgroundAlpha)); }
5399
+            if ( $DrawBorder ) { $this->drawRectangle($TopX-1,$StartY-1,$BottomX+1,$EndY+1,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5400 5400
 
5401
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5401
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5402 5402
 
5403
-           $RestoreShadow = $this->Shadow;
5404
-           $this->Shadow  = FALSE;
5403
+            $RestoreShadow = $this->Shadow;
5404
+            $this->Shadow  = FALSE;
5405 5405
 
5406
-           /* Determine the Max slope index */
5407
-           $LastX = NULL; $LastY = NULL; $MinSlope = 0; $MaxSlope = 1;
5408
-           foreach($PosArray as $Key => $X)
5406
+            /* Determine the Max slope index */
5407
+            $LastX = NULL; $LastY = NULL; $MinSlope = 0; $MaxSlope = 1;
5408
+            foreach($PosArray as $Key => $X)
5409 5409
             {
5410
-             if ( $X != VOID && $LastX != NULL )
5411
-              { $Slope = ($X - $LastX); if ( $Slope > $MaxSlope ) { $MaxSlope = $Slope; } if ( $Slope < $MinSlope ) { $MinSlope = $Slope; } }
5410
+                if ( $X != VOID && $LastX != NULL )
5411
+                { $Slope = ($X - $LastX); if ( $Slope > $MaxSlope ) { $MaxSlope = $Slope; } if ( $Slope < $MinSlope ) { $MinSlope = $Slope; } }
5412 5412
 
5413
-             if ( $X == VOID )
5414
-              { $LastX = NULL; }
5415
-             else
5416
-              { $LastX = $X; }
5413
+                if ( $X == VOID )
5414
+                { $LastX = NULL; }
5415
+                else
5416
+                { $LastX = $X; }
5417 5417
             }
5418 5418
 
5419
-           $LastX = NULL; $LastY = NULL; $LastColor = NULL;
5420
-           foreach($PosArray as $Key => $X)
5419
+            $LastX = NULL; $LastY = NULL; $LastColor = NULL;
5420
+            foreach($PosArray as $Key => $X)
5421 5421
             {
5422
-             if ( $X != VOID && $LastX != NULL )
5423
-              {
5424
-               $Slope = ($X - $LastX);
5422
+                if ( $X != VOID && $LastX != NULL )
5423
+                {
5424
+                $Slope = ($X - $LastX);
5425 5425
 
5426
-               if ( $Slope >= 0 )
5426
+                if ( $Slope >= 0 )
5427 5427
                 {
5428
-                 $SlopeIndex = (100 / $MaxSlope) * $Slope;
5429
-                 $R = (($PositiveSlopeEndR - $PositiveSlopeStartR)/100)*$SlopeIndex+$PositiveSlopeStartR;
5430
-                 $G = (($PositiveSlopeEndG - $PositiveSlopeStartG)/100)*$SlopeIndex+$PositiveSlopeStartG;
5431
-                 $B = (($PositiveSlopeEndB - $PositiveSlopeStartB)/100)*$SlopeIndex+$PositiveSlopeStartB;
5428
+                    $SlopeIndex = (100 / $MaxSlope) * $Slope;
5429
+                    $R = (($PositiveSlopeEndR - $PositiveSlopeStartR)/100)*$SlopeIndex+$PositiveSlopeStartR;
5430
+                    $G = (($PositiveSlopeEndG - $PositiveSlopeStartG)/100)*$SlopeIndex+$PositiveSlopeStartG;
5431
+                    $B = (($PositiveSlopeEndB - $PositiveSlopeStartB)/100)*$SlopeIndex+$PositiveSlopeStartB;
5432 5432
                 }
5433
-               elseif ( $Slope < 0 )
5433
+                elseif ( $Slope < 0 )
5434 5434
                 {
5435
-                 $SlopeIndex = (100 / abs($MinSlope)) * abs($Slope);
5436
-                 $R = (($NegativeSlopeEndR - $NegativeSlopeStartR)/100)*$SlopeIndex+$NegativeSlopeStartR;
5437
-                 $G = (($NegativeSlopeEndG - $NegativeSlopeStartG)/100)*$SlopeIndex+$NegativeSlopeStartG;
5438
-                 $B = (($NegativeSlopeEndB - $NegativeSlopeStartB)/100)*$SlopeIndex+$NegativeSlopeStartB;
5435
+                    $SlopeIndex = (100 / abs($MinSlope)) * abs($Slope);
5436
+                    $R = (($NegativeSlopeEndR - $NegativeSlopeStartR)/100)*$SlopeIndex+$NegativeSlopeStartR;
5437
+                    $G = (($NegativeSlopeEndG - $NegativeSlopeStartG)/100)*$SlopeIndex+$NegativeSlopeStartG;
5438
+                    $B = (($NegativeSlopeEndB - $NegativeSlopeStartB)/100)*$SlopeIndex+$NegativeSlopeStartB;
5439 5439
                 }
5440 5440
 
5441
-               $Color = array("R"=>$R,"G"=>$G,"B"=>$B);
5441
+                $Color = array("R"=>$R,"G"=>$G,"B"=>$B);
5442 5442
 
5443
-               if ( $ShadedSlopeBox && $LastColor != NULL )
5443
+                if ( $ShadedSlopeBox && $LastColor != NULL )
5444 5444
                 {
5445
-                 $GradientSettings = array("StartR"=>$LastColor["R"],"StartG"=>$LastColor["G"],"StartB"=>$LastColor["B"],"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
5445
+                    $GradientSettings = array("StartR"=>$LastColor["R"],"StartG"=>$LastColor["G"],"StartB"=>$LastColor["B"],"EndR"=>$R,"EndG"=>$G,"EndB"=>$B);
5446 5446
 
5447
-                 $this->drawGradientArea($TopX,$LastY,$BottomX,$Y,DIRECTION_VERTICAL,$GradientSettings);
5447
+                    $this->drawGradientArea($TopX,$LastY,$BottomX,$Y,DIRECTION_VERTICAL,$GradientSettings);
5448 5448
                 }
5449
-               elseif ( !$ShadedSlopeBox || $LastColor == NULL ) 
5449
+                elseif ( !$ShadedSlopeBox || $LastColor == NULL ) 
5450 5450
                 $this->drawFilledRectangle($TopX,floor($LastY),$BottomX,floor($Y),$Color);
5451 5451
 
5452
-               $LastColor = $Color;
5453
-              }
5452
+                $LastColor = $Color;
5453
+                }
5454 5454
 
5455
-             if ( $X == VOID )
5456
-              { $LastX = NULL; }
5457
-             else
5458
-              { $LastX = $X; $LastY = $Y; }
5455
+                if ( $X == VOID )
5456
+                { $LastX = NULL; }
5457
+                else
5458
+                { $LastX = $X; $LastY = $Y; }
5459 5459
 
5460
-             $Y = $Y + $XStep;
5460
+                $Y = $Y + $XStep;
5461 5461
             }
5462 5462
 
5463
-           $XPos = $XPos + $CaptionHeight + $SerieSpacing;
5464
-          }
5463
+            $XPos = $XPos + $CaptionHeight + $SerieSpacing;
5464
+            }
5465 5465
 
5466
-         $this->Shadow = $RestoreShadow;
5466
+            $this->Shadow = $RestoreShadow;
5467
+        }
5467 5468
         }
5468
-      }
5469 5469
     }
5470 5470
 
5471
-   /* Draw the line of best fit */
5472
-   function drawBestFit($Format="")
5471
+    /* Draw the line of best fit */
5472
+    function drawBestFit($Format="")
5473 5473
     {
5474
-     $OverrideTicks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
5475
-     $OverrideR		= isset($Format["R"]) ? $Format["R"] : VOID;
5476
-     $OverrideG		= isset($Format["G"]) ? $Format["G"] : VOID;
5477
-     $OverrideB		= isset($Format["B"]) ? $Format["B"] : VOID;
5478
-     $OverrideAlpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : VOID;
5479
-
5480
-     $Data = $this->DataSet->getData();
5481
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
5482
-
5483
-     foreach($Data["Series"] as $SerieName => $Serie)
5484
-      {
5485
-       if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5486
-        {
5487
-         if ( $OverrideR != VOID && $OverrideG != VOID && $OverrideB != VOID ) { $R = $OverrideR; $G = $OverrideG; $B = $OverrideB; } else { $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; }
5488
-         if ( $OverrideTicks == NULL ) { $Ticks = $Serie["Ticks"]; } else { $Ticks = $OverrideTicks; }
5489
-         if ( $OverrideAlpha == VOID ) { $Alpha = $Serie["Color"]["Alpha"]; } else { $Alpha = $OverrideAlpha; }
5490
-
5491
-         $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks);
5492
-
5493
-         $AxisID   = $Serie["Axis"];
5494
-         $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
5495
-
5496
-         if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5497
-          {
5498
-           if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5499
-           $X = $this->GraphAreaX1 + $XMargin;
5500
-
5501
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5502
-           $Sxy = 0; $Sx = 0; $Sy = 0; $Sxx = 0;
5503
-           foreach($PosArray as $Key => $Y)
5504
-            {
5505
-             if ( $Y != VOID )
5506
-              {
5507
-               $Sxy = $Sxy + $X*$Y;
5508
-               $Sx  = $Sx + $X;
5509
-               $Sy  = $Sy + $Y;
5510
-               $Sxx = $Sxx + $X*$X;
5511
-              }
5512
-
5513
-             $X = $X + $XStep;
5514
-            }
5515
-           $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray);
5516
-           $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx));
5517
-           $B = (($Sy)-($M*$Sx))/($n);
5518
-
5519
-           $X1 = $this->GraphAreaX1 + $XMargin;
5520
-           $Y1 = $M * $X1 + $B;
5521
-           $X2 = $this->GraphAreaX2 - $XMargin;
5522
-           $Y2 = $M * $X2 + $B;
5523
-
5524
-           if ( $Y1 < $this->GraphAreaY1 ) { $X1 = $X1 + ($this->GraphAreaY1-$Y1); $Y1 = $this->GraphAreaY1; }
5525
-           if ( $Y1 > $this->GraphAreaY2 ) { $X1 = $X1 + ($Y1-$this->GraphAreaY2); $Y1 = $this->GraphAreaY2; }
5526
-           if ( $Y2 < $this->GraphAreaY1 ) { $X2 = $X2 - ($this->GraphAreaY1-$Y2); $Y2 = $this->GraphAreaY1; }
5527
-           if ( $Y2 > $this->GraphAreaY2 ) { $X2 = $X2 - ($Y2-$this->GraphAreaY2); $Y2 = $this->GraphAreaY2; }
5528
-
5529
-           $this->drawLine($X1,$Y1,$X2,$Y2,$Color);
5530
-          }
5531
-         else
5532
-          {
5533
-           if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5534
-           $Y = $this->GraphAreaY1 + $XMargin;
5535
-
5536
-           if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5537
-           $Sxy = 0; $Sx = 0; $Sy = 0; $Sxx = 0;
5538
-           foreach($PosArray as $Key => $X)
5539
-            {
5540
-             if ( $X != VOID )
5541
-              {
5542
-               $Sxy = $Sxy + $X*$Y;
5543
-               $Sx  = $Sx + $Y;
5544
-               $Sy  = $Sy + $X;
5545
-               $Sxx = $Sxx + $Y*$Y;
5546
-              }
5547
-
5548
-             $Y = $Y + $YStep;
5549
-            }
5550
-           $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray);
5551
-           $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx));
5552
-           $B = (($Sy)-($M*$Sx))/($n);
5553
-
5554
-           $Y1 = $this->GraphAreaY1 + $XMargin;
5555
-           $X1 = $M * $Y1 + $B;
5556
-           $Y2 = $this->GraphAreaY2 - $XMargin;
5557
-           $X2 = $M * $Y2 + $B;
5558
-
5559
-           if ( $X1 < $this->GraphAreaX1 ) { $Y1 = $Y1 + ($this->GraphAreaX1-$X1); $X1 = $this->GraphAreaX1; }
5560
-           if ( $X1 > $this->GraphAreaX2 ) { $Y1 = $Y1 + ($X1-$this->GraphAreaX2); $X1 = $this->GraphAreaX2; }
5561
-           if ( $X2 < $this->GraphAreaX1 ) { $Y2 = $Y2 - ($this->GraphAreaY1-$X2); $X2 = $this->GraphAreaX1; }
5562
-           if ( $X2 > $this->GraphAreaX2 ) { $Y2 = $Y2 - ($X2-$this->GraphAreaX2); $X2 = $this->GraphAreaX2; }
5563
-
5564
-           $this->drawLine($X1,$Y1,$X2,$Y2,$Color);
5565
-          }
5566
-        }
5567
-      }
5474
+        $OverrideTicks	= isset($Format["Ticks"]) ? $Format["Ticks"] : NULL;
5475
+        $OverrideR		= isset($Format["R"]) ? $Format["R"] : VOID;
5476
+        $OverrideG		= isset($Format["G"]) ? $Format["G"] : VOID;
5477
+        $OverrideB		= isset($Format["B"]) ? $Format["B"] : VOID;
5478
+        $OverrideAlpha	= isset($Format["Alpha"]) ? $Format["Alpha"] : VOID;
5479
+
5480
+        $Data = $this->DataSet->getData();
5481
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
5482
+
5483
+        foreach($Data["Series"] as $SerieName => $Serie)
5484
+        {
5485
+        if ( $Serie["isDrawable"] == TRUE && $SerieName != $Data["Abscissa"] )
5486
+        {
5487
+            if ( $OverrideR != VOID && $OverrideG != VOID && $OverrideB != VOID ) { $R = $OverrideR; $G = $OverrideG; $B = $OverrideB; } else { $R = $Serie["Color"]["R"]; $G = $Serie["Color"]["G"]; $B = $Serie["Color"]["B"]; }
5488
+            if ( $OverrideTicks == NULL ) { $Ticks = $Serie["Ticks"]; } else { $Ticks = $OverrideTicks; }
5489
+            if ( $OverrideAlpha == VOID ) { $Alpha = $Serie["Color"]["Alpha"]; } else { $Alpha = $OverrideAlpha; }
5490
+
5491
+            $Color = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha,"Ticks"=>$Ticks);
5492
+
5493
+            $AxisID   = $Serie["Axis"];
5494
+            $PosArray = $this->scaleComputeY($Serie["Data"],array("AxisID"=>$Serie["Axis"]));
5495
+
5496
+            if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5497
+            {
5498
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5499
+            $X = $this->GraphAreaX1 + $XMargin;
5500
+
5501
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5502
+            $Sxy = 0; $Sx = 0; $Sy = 0; $Sxx = 0;
5503
+            foreach($PosArray as $Key => $Y)
5504
+            {
5505
+                if ( $Y != VOID )
5506
+                {
5507
+                $Sxy = $Sxy + $X*$Y;
5508
+                $Sx  = $Sx + $X;
5509
+                $Sy  = $Sy + $Y;
5510
+                $Sxx = $Sxx + $X*$X;
5511
+                }
5512
+
5513
+                $X = $X + $XStep;
5514
+            }
5515
+            $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray);
5516
+            $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx));
5517
+            $B = (($Sy)-($M*$Sx))/($n);
5518
+
5519
+            $X1 = $this->GraphAreaX1 + $XMargin;
5520
+            $Y1 = $M * $X1 + $B;
5521
+            $X2 = $this->GraphAreaX2 - $XMargin;
5522
+            $Y2 = $M * $X2 + $B;
5523
+
5524
+            if ( $Y1 < $this->GraphAreaY1 ) { $X1 = $X1 + ($this->GraphAreaY1-$Y1); $Y1 = $this->GraphAreaY1; }
5525
+            if ( $Y1 > $this->GraphAreaY2 ) { $X1 = $X1 + ($Y1-$this->GraphAreaY2); $Y1 = $this->GraphAreaY2; }
5526
+            if ( $Y2 < $this->GraphAreaY1 ) { $X2 = $X2 - ($this->GraphAreaY1-$Y2); $Y2 = $this->GraphAreaY1; }
5527
+            if ( $Y2 > $this->GraphAreaY2 ) { $X2 = $X2 - ($Y2-$this->GraphAreaY2); $Y2 = $this->GraphAreaY2; }
5528
+
5529
+            $this->drawLine($X1,$Y1,$X2,$Y2,$Color);
5530
+            }
5531
+            else
5532
+            {
5533
+            if ( $XDivs == 0 ) { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $YStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5534
+            $Y = $this->GraphAreaY1 + $XMargin;
5535
+
5536
+            if ( !is_array($PosArray) ) { $Value = $PosArray; $PosArray = ""; $PosArray[0] = $Value; }
5537
+            $Sxy = 0; $Sx = 0; $Sy = 0; $Sxx = 0;
5538
+            foreach($PosArray as $Key => $X)
5539
+            {
5540
+                if ( $X != VOID )
5541
+                {
5542
+                $Sxy = $Sxy + $X*$Y;
5543
+                $Sx  = $Sx + $Y;
5544
+                $Sy  = $Sy + $X;
5545
+                $Sxx = $Sxx + $Y*$Y;
5546
+                }
5547
+
5548
+                $Y = $Y + $YStep;
5549
+            }
5550
+            $n = count($this->DataSet->stripVOID($PosArray)); //$n = count($PosArray);
5551
+            $M = (($n*$Sxy)-($Sx*$Sy)) / (($n*$Sxx)-($Sx*$Sx));
5552
+            $B = (($Sy)-($M*$Sx))/($n);
5553
+
5554
+            $Y1 = $this->GraphAreaY1 + $XMargin;
5555
+            $X1 = $M * $Y1 + $B;
5556
+            $Y2 = $this->GraphAreaY2 - $XMargin;
5557
+            $X2 = $M * $Y2 + $B;
5558
+
5559
+            if ( $X1 < $this->GraphAreaX1 ) { $Y1 = $Y1 + ($this->GraphAreaX1-$X1); $X1 = $this->GraphAreaX1; }
5560
+            if ( $X1 > $this->GraphAreaX2 ) { $Y1 = $Y1 + ($X1-$this->GraphAreaX2); $X1 = $this->GraphAreaX2; }
5561
+            if ( $X2 < $this->GraphAreaX1 ) { $Y2 = $Y2 - ($this->GraphAreaY1-$X2); $X2 = $this->GraphAreaX1; }
5562
+            if ( $X2 > $this->GraphAreaX2 ) { $Y2 = $Y2 - ($X2-$this->GraphAreaX2); $X2 = $this->GraphAreaX2; }
5563
+
5564
+            $this->drawLine($X1,$Y1,$X2,$Y2,$Color);
5565
+            }
5566
+        }
5567
+        }
5568 5568
     }
5569 5569
 
5570
-   /* Write labels */
5571
-   function writeLabel($SeriesName,$Indexes,$Format="")
5570
+    /* Write labels */
5571
+    function writeLabel($SeriesName,$Indexes,$Format="")
5572 5572
     {
5573
-     $OverrideTitle	= isset($Format["OverrideTitle"]) ? $Format["OverrideTitle"] : NULL;
5574
-     $ForceLabels	= isset($Format["ForceLabels"]) ? $Format["ForceLabels"] : NULL;
5575
-     $DrawPoint		= isset($Format["DrawPoint"]) ? $Format["DrawPoint"] : LABEL_POINT_BOX;
5576
-     $DrawVerticalLine	= isset($Format["DrawVerticalLine"]) ? $Format["DrawVerticalLine"] : FALSE;
5577
-     $VerticalLineR	= isset($Format["VerticalLineR"]) ? $Format["VerticalLineR"] : 0;
5578
-     $VerticalLineG	= isset($Format["VerticalLineG"]) ? $Format["VerticalLineG"] : 0;
5579
-     $VerticalLineB	= isset($Format["VerticalLineB"]) ? $Format["VerticalLineB"] : 0;
5580
-     $VerticalLineAlpha	= isset($Format["VerticalLineAlpha"]) ? $Format["VerticalLineAlpha"] : 40;
5581
-     $VerticalLineTicks	= isset($Format["VerticalLineTicks"]) ? $Format["VerticalLineTicks"] : 2;
5582
-
5583
-     $Data = $this->DataSet->getData();
5584
-     list($XMargin,$XDivs) = $this->scaleGetXSettings();
5585
-
5586
-     if ( !is_array($Indexes) )    { $Index = $Indexes; $Indexes = ""; $Indexes[] = $Index; }
5587
-     if ( !is_array($SeriesName) ) { $SerieName = $SeriesName; $SeriesName = ""; $SeriesName[] = $SerieName; }
5588
-     if ( $ForceLabels != NULL && !is_array($ForceLabels) ) { $ForceLabel = $ForceLabels; $ForceLabels = ""; $ForceLabels[] = $ForceLabel; }
5589
-
5590
-     foreach ($Indexes as $Key => $Index)
5591
-      {
5592
-       $Series = "";
5593
-
5594
-       if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5595
-        {
5596
-         if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5597
-         $X = $this->GraphAreaX1 + $XMargin + $Index * $XStep;
5598
-
5599
-         if ( $DrawVerticalLine ) { $this->drawLine($X,$this->GraphAreaY1+$Data["YMargin"],$X,$this->GraphAreaY2-$Data["YMargin"],array("R"=>$VerticalLineR,"G"=>$VerticalLineG,"B"=>$VerticalLineB,"Alpha"=>$VerticalLineAlpha,"Ticks"=>$VerticalLineTicks)); }
5600
-
5601
-         $MinY = $this->GraphAreaY2;
5602
-         foreach ($SeriesName as $iKey => $SerieName)
5603
-          {
5604
-           if ( isset($Data["Series"][$SerieName]["Data"][$Index]) )
5605
-            {
5606
-             $AxisID      = $Data["Series"][$SerieName]["Axis"];
5607
-
5608
-             if ( $OverrideTitle != NULL)
5609
-              $Description = $OverrideTitle;
5610
-             elseif ( count($SeriesName) == 1 )
5611
-              {
5612
-               if ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5573
+        $OverrideTitle	= isset($Format["OverrideTitle"]) ? $Format["OverrideTitle"] : NULL;
5574
+        $ForceLabels	= isset($Format["ForceLabels"]) ? $Format["ForceLabels"] : NULL;
5575
+        $DrawPoint		= isset($Format["DrawPoint"]) ? $Format["DrawPoint"] : LABEL_POINT_BOX;
5576
+        $DrawVerticalLine	= isset($Format["DrawVerticalLine"]) ? $Format["DrawVerticalLine"] : FALSE;
5577
+        $VerticalLineR	= isset($Format["VerticalLineR"]) ? $Format["VerticalLineR"] : 0;
5578
+        $VerticalLineG	= isset($Format["VerticalLineG"]) ? $Format["VerticalLineG"] : 0;
5579
+        $VerticalLineB	= isset($Format["VerticalLineB"]) ? $Format["VerticalLineB"] : 0;
5580
+        $VerticalLineAlpha	= isset($Format["VerticalLineAlpha"]) ? $Format["VerticalLineAlpha"] : 40;
5581
+        $VerticalLineTicks	= isset($Format["VerticalLineTicks"]) ? $Format["VerticalLineTicks"] : 2;
5582
+
5583
+        $Data = $this->DataSet->getData();
5584
+        list($XMargin,$XDivs) = $this->scaleGetXSettings();
5585
+
5586
+        if ( !is_array($Indexes) )    { $Index = $Indexes; $Indexes = ""; $Indexes[] = $Index; }
5587
+        if ( !is_array($SeriesName) ) { $SerieName = $SeriesName; $SeriesName = ""; $SeriesName[] = $SerieName; }
5588
+        if ( $ForceLabels != NULL && !is_array($ForceLabels) ) { $ForceLabel = $ForceLabels; $ForceLabels = ""; $ForceLabels[] = $ForceLabel; }
5589
+
5590
+        foreach ($Indexes as $Key => $Index)
5591
+        {
5592
+        $Series = "";
5593
+
5594
+        if ( $Data["Orientation"] == SCALE_POS_LEFTRIGHT )
5595
+        {
5596
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1)/4; } else { $XStep = ($this->GraphAreaX2-$this->GraphAreaX1-$XMargin*2)/$XDivs; }
5597
+            $X = $this->GraphAreaX1 + $XMargin + $Index * $XStep;
5598
+
5599
+            if ( $DrawVerticalLine ) { $this->drawLine($X,$this->GraphAreaY1+$Data["YMargin"],$X,$this->GraphAreaY2-$Data["YMargin"],array("R"=>$VerticalLineR,"G"=>$VerticalLineG,"B"=>$VerticalLineB,"Alpha"=>$VerticalLineAlpha,"Ticks"=>$VerticalLineTicks)); }
5600
+
5601
+            $MinY = $this->GraphAreaY2;
5602
+            foreach ($SeriesName as $iKey => $SerieName)
5603
+            {
5604
+            if ( isset($Data["Series"][$SerieName]["Data"][$Index]) )
5605
+            {
5606
+                $AxisID      = $Data["Series"][$SerieName]["Axis"];
5607
+
5608
+                if ( $OverrideTitle != NULL)
5609
+                $Description = $OverrideTitle;
5610
+                elseif ( count($SeriesName) == 1 )
5611
+                {
5612
+                if ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5613 5613
                 $Description = $Data["Series"][$SerieName]["Description"]." - ".$Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5614
-               else
5614
+                else
5615 5615
                 $Description = $Data["Series"][$SerieName]["Description"];
5616
-              }
5617
-             elseif ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5618
-              $Description = $Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5619
-
5620
-             $AxisMode     = $Data["Axis"][$AxisID]["Display"];
5621
-             $AxisFormat   = $Data["Axis"][$AxisID]["Format"];
5622
-             $AxisUnit     = $Data["Axis"][$AxisID]["Unit"];
5623
-
5624
-             $Serie = "";
5625
-             $Serie["R"] = $Data["Series"][$SerieName]["Color"]["R"];
5626
-             $Serie["G"] = $Data["Series"][$SerieName]["Color"]["G"];
5627
-             $Serie["B"] = $Data["Series"][$SerieName]["Color"]["B"];
5628
-             $Serie["Alpha"] = $Data["Series"][$SerieName]["Color"]["Alpha"];
5629
-
5630
-             if ( count($SeriesName) == 1 && isset($Data["Series"][$SerieName]["XOffset"]) )
5631
-              $SerieOffset = $Data["Series"][$SerieName]["XOffset"];
5632
-             else
5633
-              $SerieOffset = 0;
5634
-
5635
-             $Value = $Data["Series"][$SerieName]["Data"][$Index];
5636
-             if ( $Value == VOID ) { $Value = "NaN"; }
5637
-
5638
-             if ( $ForceLabels != NULL )
5639
-              $Caption = isset($ForceLabels[$Key]) ? $ForceLabels[$Key] : "Not set";
5640
-             else
5641
-              $Caption = $this->scaleFormat($Value,$AxisMode,$AxisFormat,$AxisUnit);
5642
-
5643
-             if ( $this->LastChartLayout == CHART_LAST_LAYOUT_STACKED )
5644
-              {
5645
-               if ( $Value >=0 ) { $LookFor = "+"; } else { $LookFor = "-"; }
5646
-
5647
-               $Value = 0; $Done = FALSE;
5648
-               foreach($Data["Series"] as $Name => $SerieLookup)
5616
+                }
5617
+                elseif ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5618
+                $Description = $Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5619
+
5620
+                $AxisMode     = $Data["Axis"][$AxisID]["Display"];
5621
+                $AxisFormat   = $Data["Axis"][$AxisID]["Format"];
5622
+                $AxisUnit     = $Data["Axis"][$AxisID]["Unit"];
5623
+
5624
+                $Serie = "";
5625
+                $Serie["R"] = $Data["Series"][$SerieName]["Color"]["R"];
5626
+                $Serie["G"] = $Data["Series"][$SerieName]["Color"]["G"];
5627
+                $Serie["B"] = $Data["Series"][$SerieName]["Color"]["B"];
5628
+                $Serie["Alpha"] = $Data["Series"][$SerieName]["Color"]["Alpha"];
5629
+
5630
+                if ( count($SeriesName) == 1 && isset($Data["Series"][$SerieName]["XOffset"]) )
5631
+                $SerieOffset = $Data["Series"][$SerieName]["XOffset"];
5632
+                else
5633
+                $SerieOffset = 0;
5634
+
5635
+                $Value = $Data["Series"][$SerieName]["Data"][$Index];
5636
+                if ( $Value == VOID ) { $Value = "NaN"; }
5637
+
5638
+                if ( $ForceLabels != NULL )
5639
+                $Caption = isset($ForceLabels[$Key]) ? $ForceLabels[$Key] : "Not set";
5640
+                else
5641
+                $Caption = $this->scaleFormat($Value,$AxisMode,$AxisFormat,$AxisUnit);
5642
+
5643
+                if ( $this->LastChartLayout == CHART_LAST_LAYOUT_STACKED )
5644
+                {
5645
+                if ( $Value >=0 ) { $LookFor = "+"; } else { $LookFor = "-"; }
5646
+
5647
+                $Value = 0; $Done = FALSE;
5648
+                foreach($Data["Series"] as $Name => $SerieLookup)
5649 5649
                 {
5650
-                 if ( $SerieLookup["isDrawable"] == TRUE && $Name != $Data["Abscissa"] && !$Done )
5651
-                  {
5652
-                   if ( isset($Data["Series"][$Name]["Data"][$Index]) && $Data["Series"][$Name]["Data"][$Index] != VOID )
5650
+                    if ( $SerieLookup["isDrawable"] == TRUE && $Name != $Data["Abscissa"] && !$Done )
5651
+                    {
5652
+                    if ( isset($Data["Series"][$Name]["Data"][$Index]) && $Data["Series"][$Name]["Data"][$Index] != VOID )
5653 5653
                     {
5654
-                     if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+" ) { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; }
5655
-                     if ($Data["Series"][$Name]["Data"][$Index] < 0 && $LookFor == "-" )  { $Value = $Value - $Data["Series"][$Name]["Data"][$Index]; }
5656
-                     if ($Name == $SerieName ) { $Done = TRUE; }
5654
+                        if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+" ) { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; }
5655
+                        if ($Data["Series"][$Name]["Data"][$Index] < 0 && $LookFor == "-" )  { $Value = $Value - $Data["Series"][$Name]["Data"][$Index]; }
5656
+                        if ($Name == $SerieName ) { $Done = TRUE; }
5657 5657
                     }
5658
-                  }
5658
+                    }
5659
+                }
5659 5660
                 }
5660
-              }
5661 5661
 
5662
-             $X = floor($this->GraphAreaX1 + $XMargin + $Index * $XStep + $SerieOffset);
5663
-             $Y = floor($this->scaleComputeY($Value,array("AxisID"=>$AxisID)));
5662
+                $X = floor($this->GraphAreaX1 + $XMargin + $Index * $XStep + $SerieOffset);
5663
+                $Y = floor($this->scaleComputeY($Value,array("AxisID"=>$AxisID)));
5664 5664
 
5665
-             if ($Y < $MinY) { $MinY = $Y; }
5665
+                if ($Y < $MinY) { $MinY = $Y; }
5666 5666
 
5667
-             if ( $DrawPoint == LABEL_POINT_CIRCLE )
5668
-              $this->drawFilledCircle($X,$Y,3,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5669
-             elseif ( $DrawPoint == LABEL_POINT_BOX )
5670
-              $this->drawFilledRectangle($X-2,$Y-2,$X+2,$Y+2,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5667
+                if ( $DrawPoint == LABEL_POINT_CIRCLE )
5668
+                $this->drawFilledCircle($X,$Y,3,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5669
+                elseif ( $DrawPoint == LABEL_POINT_BOX )
5670
+                $this->drawFilledRectangle($X-2,$Y-2,$X+2,$Y+2,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5671 5671
 
5672
-             $Series[] = array("Format"=>$Serie,"Caption"=>$Caption);
5672
+                $Series[] = array("Format"=>$Serie,"Caption"=>$Caption);
5673 5673
             }
5674
-          }
5675
-         $this->drawLabelBox($X,$MinY-3,$Description,$Series,$Format);
5674
+            }
5675
+            $this->drawLabelBox($X,$MinY-3,$Description,$Series,$Format);
5676 5676
 
5677 5677
         }
5678
-       else
5678
+        else
5679 5679
         {
5680
-         if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5681
-         $Y = $this->GraphAreaY1 + $XMargin + $Index * $XStep;
5680
+            if ( $XDivs == 0 ) { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1)/4; } else { $XStep = ($this->GraphAreaY2-$this->GraphAreaY1-$XMargin*2)/$XDivs; }
5681
+            $Y = $this->GraphAreaY1 + $XMargin + $Index * $XStep;
5682 5682
 
5683
-         if ( $DrawVerticalLine ) { $this->drawLine($this->GraphAreaX1+$Data["YMargin"],$Y,$this->GraphAreaX2-$Data["YMargin"],$Y,array("R"=>$VerticalLineR,"G"=>$VerticalLineG,"B"=>$VerticalLineB,"Alpha"=>$VerticalLineAlpha,"Ticks"=>$VerticalLineTicks)); }
5683
+            if ( $DrawVerticalLine ) { $this->drawLine($this->GraphAreaX1+$Data["YMargin"],$Y,$this->GraphAreaX2-$Data["YMargin"],$Y,array("R"=>$VerticalLineR,"G"=>$VerticalLineG,"B"=>$VerticalLineB,"Alpha"=>$VerticalLineAlpha,"Ticks"=>$VerticalLineTicks)); }
5684 5684
 
5685
-         $MinX = $this->GraphAreaX2;
5686
-         foreach ($SeriesName as $Key => $SerieName)
5687
-          {
5688
-           if ( isset($Data["Series"][$SerieName]["Data"][$Index]) )
5685
+            $MinX = $this->GraphAreaX2;
5686
+            foreach ($SeriesName as $Key => $SerieName)
5687
+            {
5688
+            if ( isset($Data["Series"][$SerieName]["Data"][$Index]) )
5689 5689
             {
5690
-             $AxisID      = $Data["Series"][$SerieName]["Axis"];
5690
+                $AxisID      = $Data["Series"][$SerieName]["Axis"];
5691 5691
 
5692
-             if ( $OverrideTitle != NULL)
5693
-              $Description = $OverrideTitle;
5694
-             elseif ( count($SeriesName) == 1 )
5695
-              {
5696
-               if ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5692
+                if ( $OverrideTitle != NULL)
5693
+                $Description = $OverrideTitle;
5694
+                elseif ( count($SeriesName) == 1 )
5695
+                {
5696
+                if ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5697 5697
                 $Description = $Data["Series"][$SerieName]["Description"]." - ".$Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5698
-               else
5698
+                else
5699 5699
                 $Description = $Data["Series"][$SerieName]["Description"];
5700
-              }
5701
-             elseif ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5702
-              $Description = $Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5703
-
5704
-             $AxisMode     = $Data["Axis"][$AxisID]["Display"];
5705
-             $AxisFormat   = $Data["Axis"][$AxisID]["Format"];
5706
-             $AxisUnit     = $Data["Axis"][$AxisID]["Unit"];
5707
-
5708
-             $Serie = "";
5709
-             if ( isset($Data["Extended"]["Palette"][$Index] ) )
5710
-              {
5711
-               $Serie["R"] = $Data["Extended"]["Palette"][$Index]["R"];
5712
-               $Serie["G"] = $Data["Extended"]["Palette"][$Index]["G"];
5713
-               $Serie["B"] = $Data["Extended"]["Palette"][$Index]["B"];
5714
-               $Serie["Alpha"] = $Data["Extended"]["Palette"][$Index]["Alpha"];
5715
-              }
5716
-             else
5717
-              {
5718
-               $Serie["R"] = $Data["Series"][$SerieName]["Color"]["R"];
5719
-               $Serie["G"] = $Data["Series"][$SerieName]["Color"]["G"];
5720
-               $Serie["B"] = $Data["Series"][$SerieName]["Color"]["B"];
5721
-               $Serie["Alpha"] = $Data["Series"][$SerieName]["Color"]["Alpha"];
5722
-              }
5723
-
5724
-             if ( count($SeriesName) == 1 && isset($Data["Series"][$SerieName]["XOffset"]) )
5725
-              $SerieOffset = $Data["Series"][$SerieName]["XOffset"];
5726
-             else
5727
-              $SerieOffset = 0;
5728
-
5729
-             $Value = $Data["Series"][$SerieName]["Data"][$Index];
5730
-             if ( $ForceLabels != NULL )
5731
-              $Caption = isset($ForceLabels[$Key]) ? $ForceLabels[$Key] : "Not set";
5732
-             else
5733
-              $Caption = $this->scaleFormat($Value,$AxisMode,$AxisFormat,$AxisUnit);
5734
-             if ( $Value == VOID ) { $Value = "NaN"; }
5735
-
5736
-             if ( $this->LastChartLayout == CHART_LAST_LAYOUT_STACKED )
5737
-              {
5738
-               if ( $Value >=0 ) { $LookFor = "+"; } else { $LookFor = "-"; }
5739
-
5740
-               $Value = 0; $Done = FALSE;
5741
-               foreach($Data["Series"] as $Name => $SerieLookup)
5700
+                }
5701
+                elseif ( isset($Data["Abscissa"]) && isset($Data["Series"][$Data["Abscissa"]]["Data"][$Index]) )
5702
+                $Description = $Data["Series"][$Data["Abscissa"]]["Data"][$Index];
5703
+
5704
+                $AxisMode     = $Data["Axis"][$AxisID]["Display"];
5705
+                $AxisFormat   = $Data["Axis"][$AxisID]["Format"];
5706
+                $AxisUnit     = $Data["Axis"][$AxisID]["Unit"];
5707
+
5708
+                $Serie = "";
5709
+                if ( isset($Data["Extended"]["Palette"][$Index] ) )
5710
+                {
5711
+                $Serie["R"] = $Data["Extended"]["Palette"][$Index]["R"];
5712
+                $Serie["G"] = $Data["Extended"]["Palette"][$Index]["G"];
5713
+                $Serie["B"] = $Data["Extended"]["Palette"][$Index]["B"];
5714
+                $Serie["Alpha"] = $Data["Extended"]["Palette"][$Index]["Alpha"];
5715
+                }
5716
+                else
5717
+                {
5718
+                $Serie["R"] = $Data["Series"][$SerieName]["Color"]["R"];
5719
+                $Serie["G"] = $Data["Series"][$SerieName]["Color"]["G"];
5720
+                $Serie["B"] = $Data["Series"][$SerieName]["Color"]["B"];
5721
+                $Serie["Alpha"] = $Data["Series"][$SerieName]["Color"]["Alpha"];
5722
+                }
5723
+
5724
+                if ( count($SeriesName) == 1 && isset($Data["Series"][$SerieName]["XOffset"]) )
5725
+                $SerieOffset = $Data["Series"][$SerieName]["XOffset"];
5726
+                else
5727
+                $SerieOffset = 0;
5728
+
5729
+                $Value = $Data["Series"][$SerieName]["Data"][$Index];
5730
+                if ( $ForceLabels != NULL )
5731
+                $Caption = isset($ForceLabels[$Key]) ? $ForceLabels[$Key] : "Not set";
5732
+                else
5733
+                $Caption = $this->scaleFormat($Value,$AxisMode,$AxisFormat,$AxisUnit);
5734
+                if ( $Value == VOID ) { $Value = "NaN"; }
5735
+
5736
+                if ( $this->LastChartLayout == CHART_LAST_LAYOUT_STACKED )
5737
+                {
5738
+                if ( $Value >=0 ) { $LookFor = "+"; } else { $LookFor = "-"; }
5739
+
5740
+                $Value = 0; $Done = FALSE;
5741
+                foreach($Data["Series"] as $Name => $SerieLookup)
5742 5742
                 {
5743
-                 if ( $SerieLookup["isDrawable"] == TRUE && $Name != $Data["Abscissa"] && !$Done )
5744
-                  {
5745
-                   if ( isset($Data["Series"][$Name]["Data"][$Index]) && $Data["Series"][$Name]["Data"][$Index] != VOID )
5743
+                    if ( $SerieLookup["isDrawable"] == TRUE && $Name != $Data["Abscissa"] && !$Done )
5744
+                    {
5745
+                    if ( isset($Data["Series"][$Name]["Data"][$Index]) && $Data["Series"][$Name]["Data"][$Index] != VOID )
5746 5746
                     {
5747
-                     if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+" ) { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; }
5748
-                     if ($Data["Series"][$Name]["Data"][$Index] < 0 && $LookFor == "-" )  { $Value = $Value - $Data["Series"][$Name]["Data"][$Index]; }
5749
-                     if ($Name == $SerieName ) { $Done = TRUE; }
5747
+                        if ($Data["Series"][$Name]["Data"][$Index] >= 0 && $LookFor == "+" ) { $Value = $Value + $Data["Series"][$Name]["Data"][$Index]; }
5748
+                        if ($Data["Series"][$Name]["Data"][$Index] < 0 && $LookFor == "-" )  { $Value = $Value - $Data["Series"][$Name]["Data"][$Index]; }
5749
+                        if ($Name == $SerieName ) { $Done = TRUE; }
5750 5750
                     }
5751
-                  }
5751
+                    }
5752
+                }
5752 5753
                 }
5753
-              }
5754 5754
 
5755
-             $X = floor($this->scaleComputeY($Value,array("AxisID"=>$AxisID)));
5756
-             $Y = floor($this->GraphAreaY1 + $XMargin + $Index * $XStep + $SerieOffset);
5755
+                $X = floor($this->scaleComputeY($Value,array("AxisID"=>$AxisID)));
5756
+                $Y = floor($this->GraphAreaY1 + $XMargin + $Index * $XStep + $SerieOffset);
5757 5757
 
5758
-             if ($X < $MinX) { $MinX = $X; }
5758
+                if ($X < $MinX) { $MinX = $X; }
5759 5759
 
5760
-             if ( $DrawPoint == LABEL_POINT_CIRCLE )
5761
-              $this->drawFilledCircle($X,$Y,3,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5762
-             elseif ( $DrawPoint == LABEL_POINT_BOX )
5763
-              $this->drawFilledRectangle($X-2,$Y-2,$X+2,$Y+2,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5760
+                if ( $DrawPoint == LABEL_POINT_CIRCLE )
5761
+                $this->drawFilledCircle($X,$Y,3,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5762
+                elseif ( $DrawPoint == LABEL_POINT_BOX )
5763
+                $this->drawFilledRectangle($X-2,$Y-2,$X+2,$Y+2,array("R"=>255,"G"=>255,"B"=>255,"BorderR"=>0,"BorderG"=>0,"BorderB"=>0));
5764 5764
 
5765
-             $Series[] = array("Format"=>$Serie,"Caption"=>$Caption);
5765
+                $Series[] = array("Format"=>$Serie,"Caption"=>$Caption);
5766 5766
             }
5767
-          }
5768
-         $this->drawLabelBox($MinX,$Y-3,$Description,$Series,$Format);
5767
+            }
5768
+            $this->drawLabelBox($MinX,$Y-3,$Description,$Series,$Format);
5769 5769
 
5770 5770
         }
5771
-      }
5771
+        }
5772 5772
     }
5773 5773
 
5774
-   /* Draw a label box */
5775
-   function drawLabelBox($X,$Y,$Title,$Captions,$Format="")
5774
+    /* Draw a label box */
5775
+    function drawLabelBox($X,$Y,$Title,$Captions,$Format="")
5776 5776
     {
5777
-     $NoTitle		= isset($Format["NoTitle"]) ? $Format["NoTitle"] : NULL;
5778
-     $BoxWidth		= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 50;
5779
-     $DrawSerieColor	= isset($Format["DrawSerieColor"]) ? $Format["DrawSerieColor"] : TRUE;
5780
-     $SerieR		= isset($Format["SerieR"]) ? $Format["SerieR"] : NULL;
5781
-     $SerieG		= isset($Format["SerieG"]) ? $Format["SerieG"] : NULL;
5782
-     $SerieB		= isset($Format["SerieB"]) ? $Format["SerieB"] : NULL;
5783
-     $SerieAlpha	= isset($Format["SerieAlpha"]) ? $Format["SerieAlpha"] : NULL;
5784
-     $SerieBoxSize	= isset($Format["SerieBoxSize"]) ? $Format["SerieBoxSize"] : 6;
5785
-     $SerieBoxSpacing	= isset($Format["SerieBoxSpacing"]) ? $Format["SerieBoxSpacing"] : 4;
5786
-     $VerticalMargin	= isset($Format["VerticalMargin"]) ? $Format["VerticalMargin"] : 10;
5787
-     $HorizontalMargin	= isset($Format["HorizontalMargin"]) ? $Format["HorizontalMargin"] : 8;
5788
-     $R			= isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
5789
-     $G			= isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
5790
-     $B			= isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
5791
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
5792
-     $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
5793
-     $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
5794
-     $TitleMode		= isset($Format["TitleMode"]) ? $Format["TitleMode"] : LABEL_TITLE_NOBACKGROUND;
5795
-     $TitleR		= isset($Format["TitleR"]) ? $Format["TitleR"] : $R;
5796
-     $TitleG		= isset($Format["TitleG"]) ? $Format["TitleG"] : $G;
5797
-     $TitleB		= isset($Format["TitleB"]) ? $Format["TitleB"] : $B;
5798
-     $TitleBackgroundR	= isset($Format["TitleBackgroundR"]) ? $Format["TitleBackgroundR"] : 0;
5799
-     $TitleBackgroundG	= isset($Format["TitleBackgroundG"]) ? $Format["TitleBackgroundG"] : 0;
5800
-     $TitleBackgroundB	= isset($Format["TitleBackgroundB"]) ? $Format["TitleBackgroundB"] : 0;
5801
-     $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
5802
-     $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
5803
-     $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
5804
-     $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 220;
5805
-     $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 220;
5806
-     $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 220;
5807
-
5808
-     if ( !$DrawSerieColor ) { $SerieBoxSize = 0; $SerieBoxSpacing = 0; }
5809
-
5810
-     $TxtPos      = $this->getTextBox($X,$Y,$FontName,$FontSize,0,$Title);
5811
-     $TitleWidth  = ($TxtPos[1]["X"] - $TxtPos[0]["X"])+$VerticalMargin*2;
5812
-     $TitleHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);
5813
-
5814
-     if ( $NoTitle ) { $TitleWidth = 0; $TitleHeight = 0; }
5815
-
5816
-     $CaptionWidth = 0; $CaptionHeight = -$HorizontalMargin;
5817
-     foreach($Captions as $Key =>$Caption)
5818
-      {
5819
-       $TxtPos        = $this->getTextBox($X,$Y,$FontName,$FontSize,0,$Caption["Caption"]);
5820
-       $CaptionWidth  = max($CaptionWidth,($TxtPos[1]["X"] - $TxtPos[0]["X"])+$VerticalMargin*2);
5821
-       $CaptionHeight = $CaptionHeight + max(($TxtPos[0]["Y"] - $TxtPos[2]["Y"]),($SerieBoxSize+2)) + $HorizontalMargin;
5822
-      }
5823
-
5824
-     if ( $CaptionHeight <= 5 ) { $CaptionHeight = $CaptionHeight + $HorizontalMargin/2; }
5825
-
5826
-     if ( $DrawSerieColor ) { $CaptionWidth = $CaptionWidth + $SerieBoxSize + $SerieBoxSpacing; }
5827
-
5828
-     $BoxWidth = max($BoxWidth,$TitleWidth,$CaptionWidth);
5829
-
5830
-     $XMin = $X - 5 - floor(($BoxWidth-10) / 2);
5831
-     $XMax = $X + 5 + floor(($BoxWidth-10) / 2);
5832
-
5833
-     $RestoreShadow = $this->Shadow;
5834
-     if ( $this->Shadow == TRUE )
5835
-      {
5836
-       $this->Shadow = FALSE;
5837
-
5838
-       $Poly = "";
5839
-       $Poly[] = $X+$this->ShadowX; $Poly[] = $Y+$this->ShadowX;
5840
-       $Poly[] = $X+5+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5841
-       $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5842
-
5843
-       if ( $NoTitle )
5844
-        {
5845
-         $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2+$this->ShadowX;
5846
-         $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2+$this->ShadowX;
5847
-        }
5848
-       else
5849
-        {
5850
-         $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3+$this->ShadowX;
5851
-         $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3+$this->ShadowX;
5852
-        }
5853
-
5854
-       $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5855
-       $Poly[] = $X-5+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5856
-       $this->drawPolygon($Poly,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
5857
-      }
5858
-
5859
-     /* Draw the background */
5860
-     $GradientSettings = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB);
5861
-     if ( $NoTitle )
5862
-      $this->drawGradientArea($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-6,DIRECTION_VERTICAL,$GradientSettings);
5863
-     else
5864
-      $this->drawGradientArea($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-6,DIRECTION_VERTICAL,$GradientSettings);
5865
-     $Poly = ""; $Poly[] = $X; $Poly[] = $Y; $Poly[] = $X-5; $Poly[] = $Y-5; $Poly[] = $X+5; $Poly[] = $Y-5;
5866
-     $this->drawPolygon($Poly,array("R"=>$GradientEndR,"G"=>$GradientEndG,"B"=>$GradientEndB,"NoBorder"=>TRUE));
5867
-
5868
-     /* Outer border */
5869
-     $OuterBorderColor = $this->allocateColor($this->Picture,100,100,100,100);
5870
-     imageline($this->Picture,$XMin,$Y-5,$X-5,$Y-5,$OuterBorderColor);
5871
-     imageline($this->Picture,$X,$Y,$X-5,$Y-5,$OuterBorderColor);
5872
-     imageline($this->Picture,$X,$Y,$X+5,$Y-5,$OuterBorderColor);
5873
-     imageline($this->Picture,$X+5,$Y-5,$XMax,$Y-5,$OuterBorderColor);
5874
-     if ( $NoTitle )
5875
-      {
5876
-       imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMin,$Y-5,$OuterBorderColor);
5877
-       imageline($this->Picture,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-5,$OuterBorderColor);
5878
-       imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$OuterBorderColor);
5879
-      }
5880
-     else
5881
-      {
5882
-       imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMin,$Y-5,$OuterBorderColor);
5883
-       imageline($this->Picture,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5,$OuterBorderColor);
5884
-       imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$OuterBorderColor);
5885
-      }
5886
-
5887
-     /* Inner border */
5888
-     $InnerBorderColor = $this->allocateColor($this->Picture,255,255,255,100);
5889
-     imageline($this->Picture,$XMin+1,$Y-6,$X-5,$Y-6,$InnerBorderColor);
5890
-     imageline($this->Picture,$X,$Y-1,$X-5,$Y-6,$InnerBorderColor);
5891
-     imageline($this->Picture,$X,$Y-1,$X+5,$Y-6,$InnerBorderColor);
5892
-     imageline($this->Picture,$X+5,$Y-6,$XMax-1,$Y-6,$InnerBorderColor);
5893
-     if ( $NoTitle )
5894
-      {
5895
-       imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMin+1,$Y-6,$InnerBorderColor);
5896
-       imageline($this->Picture,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax-1,$Y-6,$InnerBorderColor);
5897
-       imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$InnerBorderColor);
5898
-      }
5899
-     else
5900
-      {
5901
-       imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMin+1,$Y-6,$InnerBorderColor);
5902
-       imageline($this->Picture,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax-1,$Y-6,$InnerBorderColor);
5903
-       imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$InnerBorderColor);
5904
-      }
5905
-
5906
-     /* Draw the separator line */
5907
-     if ( $TitleMode == LABEL_TITLE_NOBACKGROUND && !$NoTitle )
5908
-      {
5909
-       $YPos    = $Y-7-$CaptionHeight-$HorizontalMargin-$HorizontalMargin/2;
5910
-       $XMargin = $VerticalMargin / 2;
5911
-       $this->drawLine($XMin+$XMargin,$YPos+1,$XMax-$XMargin,$YPos+1,array("R"=>$GradientEndR,"G"=>$GradientEndG,"B"=>$GradientEndB));
5912
-       $this->drawLine($XMin+$XMargin,$YPos,$XMax-$XMargin,$YPos,array("R"=>$GradientStartR,"G"=>$GradientStartG,"B"=>$GradientStartB));
5913
-      }
5914
-     elseif ( $TitleMode == LABEL_TITLE_BACKGROUND )
5915
-      {
5916
-       $this->drawFilledRectangle($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2,array("R"=>$TitleBackgroundR,"G"=>$TitleBackgroundG,"B"=>$TitleBackgroundB));
5917
-       imageline($this->Picture,$XMin+1,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2+1,$XMax-1,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2+1,$InnerBorderColor);
5918
-      }
5919
-
5920
-     /* Write the description */
5921
-     if ( !$NoTitle )
5922
-      $this->drawText($XMin+$VerticalMargin,$Y-7-$CaptionHeight-$HorizontalMargin*2,$Title,array("Align"=>TEXT_ALIGN_BOTTOMLEFT,"R"=>$TitleR,"G"=>$TitleG,"B"=>$TitleB));
5923
-
5924
-     /* Write the value */
5925
-     $YPos = $Y-5-$HorizontalMargin; $XPos = $XMin+$VerticalMargin+$SerieBoxSize+$SerieBoxSpacing;
5926
-     foreach($Captions as $Key => $Caption)
5927
-      {
5928
-       $CaptionTxt    = $Caption["Caption"];
5929
-       $TxtPos        = $this->getTextBox($XPos,$YPos,$FontName,$FontSize,0,$CaptionTxt);
5930
-       $CaptionHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);
5931
-
5932
-       /* Write the serie color if needed */
5933
-       if ( $DrawSerieColor )
5934
-        {
5935
-         $BoxSettings = array("R"=>$Caption["Format"]["R"],"G"=>$Caption["Format"]["G"],"B"=>$Caption["Format"]["B"],"Alpha"=>$Caption["Format"]["Alpha"],"BorderR"=>0,"BorderG"=>0,"BorderB"=>0);
5936
-         $this->drawFilledRectangle($XMin+$VerticalMargin,$YPos-$SerieBoxSize,$XMin+$VerticalMargin+$SerieBoxSize,$YPos,$BoxSettings);
5937
-        }
5938
-
5939
-       $this->drawText($XPos,$YPos,$CaptionTxt,array("Align"=>TEXT_ALIGN_BOTTOMLEFT));
5940
-
5941
-       $YPos = $YPos - $CaptionHeight - $HorizontalMargin;
5942
-      }
5943
-
5944
-     $this->Shadow = $RestoreShadow;
5777
+        $NoTitle		= isset($Format["NoTitle"]) ? $Format["NoTitle"] : NULL;
5778
+        $BoxWidth		= isset($Format["BoxWidth"]) ? $Format["BoxWidth"] : 50;
5779
+        $DrawSerieColor	= isset($Format["DrawSerieColor"]) ? $Format["DrawSerieColor"] : TRUE;
5780
+        $SerieR		= isset($Format["SerieR"]) ? $Format["SerieR"] : NULL;
5781
+        $SerieG		= isset($Format["SerieG"]) ? $Format["SerieG"] : NULL;
5782
+        $SerieB		= isset($Format["SerieB"]) ? $Format["SerieB"] : NULL;
5783
+        $SerieAlpha	= isset($Format["SerieAlpha"]) ? $Format["SerieAlpha"] : NULL;
5784
+        $SerieBoxSize	= isset($Format["SerieBoxSize"]) ? $Format["SerieBoxSize"] : 6;
5785
+        $SerieBoxSpacing	= isset($Format["SerieBoxSpacing"]) ? $Format["SerieBoxSpacing"] : 4;
5786
+        $VerticalMargin	= isset($Format["VerticalMargin"]) ? $Format["VerticalMargin"] : 10;
5787
+        $HorizontalMargin	= isset($Format["HorizontalMargin"]) ? $Format["HorizontalMargin"] : 8;
5788
+        $R			= isset($Format["R"]) ? $Format["R"] : $this->FontColorR;
5789
+        $G			= isset($Format["G"]) ? $Format["G"] : $this->FontColorG;
5790
+        $B			= isset($Format["B"]) ? $Format["B"] : $this->FontColorB;
5791
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : $this->FontColorA;
5792
+        $FontName		= isset($Format["FontName"]) ? $Format["FontName"] : $this->FontName;
5793
+        $FontSize		= isset($Format["FontSize"]) ? $Format["FontSize"] : $this->FontSize;
5794
+        $TitleMode		= isset($Format["TitleMode"]) ? $Format["TitleMode"] : LABEL_TITLE_NOBACKGROUND;
5795
+        $TitleR		= isset($Format["TitleR"]) ? $Format["TitleR"] : $R;
5796
+        $TitleG		= isset($Format["TitleG"]) ? $Format["TitleG"] : $G;
5797
+        $TitleB		= isset($Format["TitleB"]) ? $Format["TitleB"] : $B;
5798
+        $TitleBackgroundR	= isset($Format["TitleBackgroundR"]) ? $Format["TitleBackgroundR"] : 0;
5799
+        $TitleBackgroundG	= isset($Format["TitleBackgroundG"]) ? $Format["TitleBackgroundG"] : 0;
5800
+        $TitleBackgroundB	= isset($Format["TitleBackgroundB"]) ? $Format["TitleBackgroundB"] : 0;
5801
+        $GradientStartR	= isset($Format["GradientStartR"]) ? $Format["GradientStartR"] : 255;
5802
+        $GradientStartG	= isset($Format["GradientStartG"]) ? $Format["GradientStartG"] : 255;
5803
+        $GradientStartB	= isset($Format["GradientStartB"]) ? $Format["GradientStartB"] : 255;
5804
+        $GradientEndR	= isset($Format["GradientEndR"]) ? $Format["GradientEndR"] : 220;
5805
+        $GradientEndG	= isset($Format["GradientEndG"]) ? $Format["GradientEndG"] : 220;
5806
+        $GradientEndB	= isset($Format["GradientEndB"]) ? $Format["GradientEndB"] : 220;
5807
+
5808
+        if ( !$DrawSerieColor ) { $SerieBoxSize = 0; $SerieBoxSpacing = 0; }
5809
+
5810
+        $TxtPos      = $this->getTextBox($X,$Y,$FontName,$FontSize,0,$Title);
5811
+        $TitleWidth  = ($TxtPos[1]["X"] - $TxtPos[0]["X"])+$VerticalMargin*2;
5812
+        $TitleHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);
5813
+
5814
+        if ( $NoTitle ) { $TitleWidth = 0; $TitleHeight = 0; }
5815
+
5816
+        $CaptionWidth = 0; $CaptionHeight = -$HorizontalMargin;
5817
+        foreach($Captions as $Key =>$Caption)
5818
+        {
5819
+        $TxtPos        = $this->getTextBox($X,$Y,$FontName,$FontSize,0,$Caption["Caption"]);
5820
+        $CaptionWidth  = max($CaptionWidth,($TxtPos[1]["X"] - $TxtPos[0]["X"])+$VerticalMargin*2);
5821
+        $CaptionHeight = $CaptionHeight + max(($TxtPos[0]["Y"] - $TxtPos[2]["Y"]),($SerieBoxSize+2)) + $HorizontalMargin;
5822
+        }
5823
+
5824
+        if ( $CaptionHeight <= 5 ) { $CaptionHeight = $CaptionHeight + $HorizontalMargin/2; }
5825
+
5826
+        if ( $DrawSerieColor ) { $CaptionWidth = $CaptionWidth + $SerieBoxSize + $SerieBoxSpacing; }
5827
+
5828
+        $BoxWidth = max($BoxWidth,$TitleWidth,$CaptionWidth);
5829
+
5830
+        $XMin = $X - 5 - floor(($BoxWidth-10) / 2);
5831
+        $XMax = $X + 5 + floor(($BoxWidth-10) / 2);
5832
+
5833
+        $RestoreShadow = $this->Shadow;
5834
+        if ( $this->Shadow == TRUE )
5835
+        {
5836
+        $this->Shadow = FALSE;
5837
+
5838
+        $Poly = "";
5839
+        $Poly[] = $X+$this->ShadowX; $Poly[] = $Y+$this->ShadowX;
5840
+        $Poly[] = $X+5+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5841
+        $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5842
+
5843
+        if ( $NoTitle )
5844
+        {
5845
+            $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2+$this->ShadowX;
5846
+            $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2+$this->ShadowX;
5847
+        }
5848
+        else
5849
+        {
5850
+            $Poly[] = $XMax+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3+$this->ShadowX;
5851
+            $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3+$this->ShadowX;
5852
+        }
5853
+
5854
+        $Poly[] = $XMin+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5855
+        $Poly[] = $X-5+$this->ShadowX; $Poly[] = $Y-5+$this->ShadowX;
5856
+        $this->drawPolygon($Poly,array("R"=>$this->ShadowR,"G"=>$this->ShadowG,"B"=>$this->ShadowB,"Alpha"=>$this->Shadowa));
5857
+        }
5858
+
5859
+        /* Draw the background */
5860
+        $GradientSettings = array("StartR"=>$GradientStartR,"StartG"=>$GradientStartG,"StartB"=>$GradientStartB,"EndR"=>$GradientEndR,"EndG"=>$GradientEndG,"EndB"=>$GradientEndB);
5861
+        if ( $NoTitle )
5862
+        $this->drawGradientArea($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-6,DIRECTION_VERTICAL,$GradientSettings);
5863
+        else
5864
+        $this->drawGradientArea($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-6,DIRECTION_VERTICAL,$GradientSettings);
5865
+        $Poly = ""; $Poly[] = $X; $Poly[] = $Y; $Poly[] = $X-5; $Poly[] = $Y-5; $Poly[] = $X+5; $Poly[] = $Y-5;
5866
+        $this->drawPolygon($Poly,array("R"=>$GradientEndR,"G"=>$GradientEndG,"B"=>$GradientEndB,"NoBorder"=>TRUE));
5867
+
5868
+        /* Outer border */
5869
+        $OuterBorderColor = $this->allocateColor($this->Picture,100,100,100,100);
5870
+        imageline($this->Picture,$XMin,$Y-5,$X-5,$Y-5,$OuterBorderColor);
5871
+        imageline($this->Picture,$X,$Y,$X-5,$Y-5,$OuterBorderColor);
5872
+        imageline($this->Picture,$X,$Y,$X+5,$Y-5,$OuterBorderColor);
5873
+        imageline($this->Picture,$X+5,$Y-5,$XMax,$Y-5,$OuterBorderColor);
5874
+        if ( $NoTitle )
5875
+        {
5876
+        imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMin,$Y-5,$OuterBorderColor);
5877
+        imageline($this->Picture,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-5,$OuterBorderColor);
5878
+        imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$OuterBorderColor);
5879
+        }
5880
+        else
5881
+        {
5882
+        imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMin,$Y-5,$OuterBorderColor);
5883
+        imageline($this->Picture,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5,$OuterBorderColor);
5884
+        imageline($this->Picture,$XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$OuterBorderColor);
5885
+        }
5886
+
5887
+        /* Inner border */
5888
+        $InnerBorderColor = $this->allocateColor($this->Picture,255,255,255,100);
5889
+        imageline($this->Picture,$XMin+1,$Y-6,$X-5,$Y-6,$InnerBorderColor);
5890
+        imageline($this->Picture,$X,$Y-1,$X-5,$Y-6,$InnerBorderColor);
5891
+        imageline($this->Picture,$X,$Y-1,$X+5,$Y-6,$InnerBorderColor);
5892
+        imageline($this->Picture,$X+5,$Y-6,$XMax-1,$Y-6,$InnerBorderColor);
5893
+        if ( $NoTitle )
5894
+        {
5895
+        imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMin+1,$Y-6,$InnerBorderColor);
5896
+        imageline($this->Picture,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax-1,$Y-6,$InnerBorderColor);
5897
+        imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*2,$InnerBorderColor);
5898
+        }
5899
+        else
5900
+        {
5901
+        imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMin+1,$Y-6,$InnerBorderColor);
5902
+        imageline($this->Picture,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax-1,$Y-6,$InnerBorderColor);
5903
+        imageline($this->Picture,$XMin+1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax-1,$Y-4-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$InnerBorderColor);
5904
+        }
5905
+
5906
+        /* Draw the separator line */
5907
+        if ( $TitleMode == LABEL_TITLE_NOBACKGROUND && !$NoTitle )
5908
+        {
5909
+        $YPos    = $Y-7-$CaptionHeight-$HorizontalMargin-$HorizontalMargin/2;
5910
+        $XMargin = $VerticalMargin / 2;
5911
+        $this->drawLine($XMin+$XMargin,$YPos+1,$XMax-$XMargin,$YPos+1,array("R"=>$GradientEndR,"G"=>$GradientEndG,"B"=>$GradientEndB));
5912
+        $this->drawLine($XMin+$XMargin,$YPos,$XMax-$XMargin,$YPos,array("R"=>$GradientStartR,"G"=>$GradientStartG,"B"=>$GradientStartB));
5913
+        }
5914
+        elseif ( $TitleMode == LABEL_TITLE_BACKGROUND )
5915
+        {
5916
+        $this->drawFilledRectangle($XMin,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin*3,$XMax,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2,array("R"=>$TitleBackgroundR,"G"=>$TitleBackgroundG,"B"=>$TitleBackgroundB));
5917
+        imageline($this->Picture,$XMin+1,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2+1,$XMax-1,$Y-5-$TitleHeight-$CaptionHeight-$HorizontalMargin+$HorizontalMargin/2+1,$InnerBorderColor);
5918
+        }
5919
+
5920
+        /* Write the description */
5921
+        if ( !$NoTitle )
5922
+        $this->drawText($XMin+$VerticalMargin,$Y-7-$CaptionHeight-$HorizontalMargin*2,$Title,array("Align"=>TEXT_ALIGN_BOTTOMLEFT,"R"=>$TitleR,"G"=>$TitleG,"B"=>$TitleB));
5923
+
5924
+        /* Write the value */
5925
+        $YPos = $Y-5-$HorizontalMargin; $XPos = $XMin+$VerticalMargin+$SerieBoxSize+$SerieBoxSpacing;
5926
+        foreach($Captions as $Key => $Caption)
5927
+        {
5928
+        $CaptionTxt    = $Caption["Caption"];
5929
+        $TxtPos        = $this->getTextBox($XPos,$YPos,$FontName,$FontSize,0,$CaptionTxt);
5930
+        $CaptionHeight = ($TxtPos[0]["Y"] - $TxtPos[2]["Y"]);
5931
+
5932
+        /* Write the serie color if needed */
5933
+        if ( $DrawSerieColor )
5934
+        {
5935
+            $BoxSettings = array("R"=>$Caption["Format"]["R"],"G"=>$Caption["Format"]["G"],"B"=>$Caption["Format"]["B"],"Alpha"=>$Caption["Format"]["Alpha"],"BorderR"=>0,"BorderG"=>0,"BorderB"=>0);
5936
+            $this->drawFilledRectangle($XMin+$VerticalMargin,$YPos-$SerieBoxSize,$XMin+$VerticalMargin+$SerieBoxSize,$YPos,$BoxSettings);
5937
+        }
5938
+
5939
+        $this->drawText($XPos,$YPos,$CaptionTxt,array("Align"=>TEXT_ALIGN_BOTTOMLEFT));
5940
+
5941
+        $YPos = $YPos - $CaptionHeight - $HorizontalMargin;
5942
+        }
5943
+
5944
+        $this->Shadow = $RestoreShadow;
5945 5945
     }
5946 5946
 
5947
-   /* Draw a basic shape */
5948
-   function drawShape($X,$Y,$Shape,$PlotSize,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha)
5947
+    /* Draw a basic shape */
5948
+    function drawShape($X,$Y,$Shape,$PlotSize,$PlotBorder,$BorderSize,$R,$G,$B,$Alpha,$BorderR,$BorderG,$BorderB,$BorderAlpha)
5949 5949
     {
5950
-     if ( $Shape == SERIE_SHAPE_FILLEDCIRCLE )
5951
-      {
5952
-       if ( $PlotBorder ) { $this->drawFilledCircle($X,$Y,$PlotSize+$BorderSize,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5953
-       $this->drawFilledCircle($X,$Y,$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5954
-      }
5955
-     elseif ( $Shape == SERIE_SHAPE_FILLEDSQUARE )
5956
-      {
5957
-       if ( $PlotBorder ) { $this->drawFilledRectangle($X-$PlotSize-$BorderSize,$Y-$PlotSize-$BorderSize,$X+$PlotSize+$BorderSize,$Y+$PlotSize+$BorderSize,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5958
-       $this->drawFilledRectangle($X-$PlotSize,$Y-$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5959
-      }
5960
-     elseif ( $Shape == SERIE_SHAPE_FILLEDTRIANGLE )
5961
-      {
5962
-       if ( $PlotBorder )
5963
-        {
5964
-         $Pos = ""; $Pos[]=$X; $Pos[]=$Y-$PlotSize-$BorderSize; $Pos[]=$X-$PlotSize-$BorderSize; $Pos[]=$Y+$PlotSize+$BorderSize; $Pos[]=$X+$PlotSize+$BorderSize; $Pos[]=$Y+$PlotSize+$BorderSize;
5965
-         $this->drawPolygon($Pos,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha));
5966
-        }
5967
-
5968
-       $Pos = ""; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X-$PlotSize; $Pos[]=$Y+$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y+$PlotSize;
5969
-       $this->drawPolygon($Pos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5970
-      }
5971
-     elseif ( $Shape == SERIE_SHAPE_TRIANGLE )
5972
-      {
5973
-       $this->drawLine($X,$Y-$PlotSize,$X-$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5974
-       $this->drawLine($X-$PlotSize,$Y+$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5975
-       $this->drawLine($X+$PlotSize,$Y+$PlotSize,$X,$Y-$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5976
-      }
5977
-     elseif ( $Shape == SERIE_SHAPE_SQUARE )
5978
-      $this->drawRectangle($X-$PlotSize,$Y-$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5979
-     elseif ( $Shape == SERIE_SHAPE_CIRCLE )
5980
-      $this->drawCircle($X,$Y,$PlotSize,$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5981
-     elseif ( $Shape == SERIE_SHAPE_DIAMOND )
5982
-      {
5983
-       $Pos = ""; $Pos[]=$X-$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize;
5984
-       $this->drawPolygon($Pos,array("NoFill"=>TRUE,"BorderR"=>$R,"BorderG"=>$G,"BorderB"=>$B,"BorderAlpha"=>$Alpha));
5985
-      }      
5986
-     elseif ( $Shape == SERIE_SHAPE_FILLEDDIAMOND )
5987
-      {
5988
-       if ( $PlotBorder )
5989
-        {
5990
-         $Pos = ""; $Pos[]=$X-$PlotSize-$BorderSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize-$BorderSize; $Pos[]=$X+$PlotSize+$BorderSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize+$BorderSize;
5991
-         $this->drawPolygon($Pos,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha));
5992
-        }
5993
-
5994
-       $Pos = ""; $Pos[]=$X-$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize;
5995
-       $this->drawPolygon($Pos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5996
-      }      
5950
+        if ( $Shape == SERIE_SHAPE_FILLEDCIRCLE )
5951
+        {
5952
+        if ( $PlotBorder ) { $this->drawFilledCircle($X,$Y,$PlotSize+$BorderSize,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5953
+        $this->drawFilledCircle($X,$Y,$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5954
+        }
5955
+        elseif ( $Shape == SERIE_SHAPE_FILLEDSQUARE )
5956
+        {
5957
+        if ( $PlotBorder ) { $this->drawFilledRectangle($X-$PlotSize-$BorderSize,$Y-$PlotSize-$BorderSize,$X+$PlotSize+$BorderSize,$Y+$PlotSize+$BorderSize,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha)); }
5958
+        $this->drawFilledRectangle($X-$PlotSize,$Y-$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5959
+        }
5960
+        elseif ( $Shape == SERIE_SHAPE_FILLEDTRIANGLE )
5961
+        {
5962
+        if ( $PlotBorder )
5963
+        {
5964
+            $Pos = ""; $Pos[]=$X; $Pos[]=$Y-$PlotSize-$BorderSize; $Pos[]=$X-$PlotSize-$BorderSize; $Pos[]=$Y+$PlotSize+$BorderSize; $Pos[]=$X+$PlotSize+$BorderSize; $Pos[]=$Y+$PlotSize+$BorderSize;
5965
+            $this->drawPolygon($Pos,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha));
5966
+        }
5967
+
5968
+        $Pos = ""; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X-$PlotSize; $Pos[]=$Y+$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y+$PlotSize;
5969
+        $this->drawPolygon($Pos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5970
+        }
5971
+        elseif ( $Shape == SERIE_SHAPE_TRIANGLE )
5972
+        {
5973
+        $this->drawLine($X,$Y-$PlotSize,$X-$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5974
+        $this->drawLine($X-$PlotSize,$Y+$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5975
+        $this->drawLine($X+$PlotSize,$Y+$PlotSize,$X,$Y-$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5976
+        }
5977
+        elseif ( $Shape == SERIE_SHAPE_SQUARE )
5978
+        $this->drawRectangle($X-$PlotSize,$Y-$PlotSize,$X+$PlotSize,$Y+$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5979
+        elseif ( $Shape == SERIE_SHAPE_CIRCLE )
5980
+        $this->drawCircle($X,$Y,$PlotSize,$PlotSize,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5981
+        elseif ( $Shape == SERIE_SHAPE_DIAMOND )
5982
+        {
5983
+        $Pos = ""; $Pos[]=$X-$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize;
5984
+        $this->drawPolygon($Pos,array("NoFill"=>TRUE,"BorderR"=>$R,"BorderG"=>$G,"BorderB"=>$B,"BorderAlpha"=>$Alpha));
5985
+        }      
5986
+        elseif ( $Shape == SERIE_SHAPE_FILLEDDIAMOND )
5987
+        {
5988
+        if ( $PlotBorder )
5989
+        {
5990
+            $Pos = ""; $Pos[]=$X-$PlotSize-$BorderSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize-$BorderSize; $Pos[]=$X+$PlotSize+$BorderSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize+$BorderSize;
5991
+            $this->drawPolygon($Pos,array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha));
5992
+        }
5993
+
5994
+        $Pos = ""; $Pos[]=$X-$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y-$PlotSize; $Pos[]=$X+$PlotSize; $Pos[]=$Y; $Pos[]=$X; $Pos[]=$Y+$PlotSize;
5995
+        $this->drawPolygon($Pos,array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha));
5996
+        }      
5997 5997
     }
5998 5998
 
5999
-   function drawPolygonChart($Points,$Format="")
5999
+    function drawPolygonChart($Points,$Format="")
6000 6000
     {
6001
-     $R			= isset($Format["R"]) ? $Format["R"] : 0;
6002
-     $G			= isset($Format["G"]) ? $Format["G"] : 0;
6003
-     $B			= isset($Format["B"]) ? $Format["B"] : 0;
6004
-     $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
6005
-     $NoFill		= isset($Format["NoFill"]) ? $Format["NoFill"] : FALSE;
6006
-     $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
6007
-     $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
6008
-     $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
6009
-     $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
6010
-     $BorderAlpha 	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha / 2;
6011
-     $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
6012
-     $Threshold         = isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
6013
-
6014
-     if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
6015
-
6016
-     $RestoreShadow = $this->Shadow;
6017
-     $this->Shadow = FALSE;
6018
-
6019
-     $AllIntegers = TRUE;
6020
-     for($i=0;$i<=count($Points)-2;$i=$i+2)
6021
-      { if ( $this->getFirstDecimal($Points[$i+1]) != 0 ) { $AllIntegers = FALSE; } }
6022
-
6023
-     /* Convert polygon to segments */
6024
-     $Segments = "";
6025
-     for($i=2;$i<=count($Points)-2;$i=$i+2)
6026
-      { $Segments[] = array("X1"=>$Points[$i-2],"Y1"=>$Points[$i-1],"X2"=>$Points[$i],"Y2"=>$Points[$i+1]); }
6027
-     $Segments[] = array("X1"=>$Points[$i-2],"Y1"=>$Points[$i-1],"X2"=>$Points[0],"Y2"=>$Points[1]);
6028
-
6029
-     /* Simplify straight lines */
6030
-     $Result = ""; $inHorizon = FALSE; $LastX = VOID;
6031
-     foreach($Segments as $Key => $Pos)
6032
-      {
6033
-       if ( $Pos["Y1"] != $Pos["Y2"] )
6034
-        {
6035
-         if ( $inHorizon ) { $inHorizon = FALSE; $Result[] = array("X1"=>$LastX,"Y1"=>$Pos["Y1"],"X2"=>$Pos["X1"],"Y2"=>$Pos["Y1"]); }
6036
-
6037
-         $Result[] = array("X1"=>$Pos["X1"],"Y1"=>$Pos["Y1"],"X2"=>$Pos["X2"],"Y2"=>$Pos["Y2"]);
6038
-        }
6039
-       else { if ( !$inHorizon ) { $inHorizon = TRUE; $LastX = $Pos["X1"];} }
6040
-      }
6041
-     $Segments = $Result;
6042
-
6043
-     /* Do we have something to draw */
6044
-     if ( $Segments == "" ) { return(0); }
6045
-
6046
-     /* For segments debugging purpose */
6047
-     //foreach($Segments as $Key => $Pos)
6048
-     // echo $Pos["X1"].",".$Pos["Y1"].",".$Pos["X2"].",".$Pos["Y2"]."\r\n";
6049
-
6050
-     /* Find out the min & max Y boundaries */
6051
-     $MinY = OUT_OF_SIGHT; $MaxY = OUT_OF_SIGHT;
6052
-     foreach($Segments as $Key => $Coords)
6053
-      {
6054
-       if ( $MinY == OUT_OF_SIGHT || $MinY > min($Coords["Y1"],$Coords["Y2"]) ) { $MinY = min($Coords["Y1"],$Coords["Y2"]); }
6055
-       if ( $MaxY == OUT_OF_SIGHT || $MaxY < max($Coords["Y1"],$Coords["Y2"]) ) { $MaxY = max($Coords["Y1"],$Coords["Y2"]); }
6056
-      }
6057
-
6058
-     if ( $AllIntegers ) { $YStep = 1; } else { $YStep = .5; }
6059
-
6060
-     $MinY = floor($MinY); $MaxY = floor($MaxY);
6061
-
6062
-     /* Scan each Y lines */
6063
-     $DefaultColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
6064
-     $DebugLine = 0; $DebugColor = $this->allocateColor($this->Picture,255,0,0,100);
6065
-
6066
-     $MinY = floor($MinY); $MaxY = floor($MaxY); $YStep = 1; 
6067
-
6068
-     if ( !$NoFill )
6069
-      {
6070
-       //if ( $DebugLine ) { $MinY = $DebugLine; $MaxY = $DebugLine; }
6071
-       for($Y=$MinY;$Y<=$MaxY;$Y=$Y+$YStep)
6072
-        {
6073
-         $Intersections = ""; $LastSlope = NULL; $RestoreLast = "-";
6074
-         foreach($Segments as $Key => $Coords)
6075
-          {
6076
-           $X1 = $Coords["X1"]; $X2 = $Coords["X2"]; $Y1 = $Coords["Y1"]; $Y2 = $Coords["Y2"];
6077
-
6078
-           if ( min($Y1,$Y2) <= $Y && max($Y1,$Y2) >= $Y )
6079
-            {
6080
-             if ( $Y1 == $Y2 )
6081
-              { $X = $X1; }
6082
-             else
6083
-              { $X = $X1 + ( ($Y-$Y1)*$X2 - ($Y-$Y1)*$X1 ) / ($Y2-$Y1); }
6084
-
6085
-             $X = floor($X);
6086
-
6087
-             if ( $X2 == $X1 )
6088
-              { $Slope = "!"; }
6089
-             else
6090
-              {
6091
-               $SlopeC = ($Y2 - $Y1) / ($X2 - $X1);
6092
-               if( $SlopeC == 0 )
6001
+        $R			= isset($Format["R"]) ? $Format["R"] : 0;
6002
+        $G			= isset($Format["G"]) ? $Format["G"] : 0;
6003
+        $B			= isset($Format["B"]) ? $Format["B"] : 0;
6004
+        $Alpha		= isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
6005
+        $NoFill		= isset($Format["NoFill"]) ? $Format["NoFill"] : FALSE;
6006
+        $NoBorder		= isset($Format["NoBorder"]) ? $Format["NoBorder"] : FALSE;
6007
+        $BorderR		= isset($Format["BorderR"]) ? $Format["BorderR"] : $R;
6008
+        $BorderG		= isset($Format["BorderG"]) ? $Format["BorderG"] : $G;
6009
+        $BorderB		= isset($Format["BorderB"]) ? $Format["BorderB"] : $B;
6010
+        $BorderAlpha 	= isset($Format["BorderAlpha"]) ? $Format["BorderAlpha"] : $Alpha / 2;
6011
+        $Surrounding	= isset($Format["Surrounding"]) ? $Format["Surrounding"] : NULL;
6012
+        $Threshold         = isset($Format["Threshold"]) ? $Format["Threshold"] : NULL;
6013
+
6014
+        if ( $Surrounding != NULL ) { $BorderR = $R+$Surrounding; $BorderG = $G+$Surrounding; $BorderB = $B+$Surrounding; }
6015
+
6016
+        $RestoreShadow = $this->Shadow;
6017
+        $this->Shadow = FALSE;
6018
+
6019
+        $AllIntegers = TRUE;
6020
+        for($i=0;$i<=count($Points)-2;$i=$i+2)
6021
+        { if ( $this->getFirstDecimal($Points[$i+1]) != 0 ) { $AllIntegers = FALSE; } }
6022
+
6023
+        /* Convert polygon to segments */
6024
+        $Segments = "";
6025
+        for($i=2;$i<=count($Points)-2;$i=$i+2)
6026
+        { $Segments[] = array("X1"=>$Points[$i-2],"Y1"=>$Points[$i-1],"X2"=>$Points[$i],"Y2"=>$Points[$i+1]); }
6027
+        $Segments[] = array("X1"=>$Points[$i-2],"Y1"=>$Points[$i-1],"X2"=>$Points[0],"Y2"=>$Points[1]);
6028
+
6029
+        /* Simplify straight lines */
6030
+        $Result = ""; $inHorizon = FALSE; $LastX = VOID;
6031
+        foreach($Segments as $Key => $Pos)
6032
+        {
6033
+        if ( $Pos["Y1"] != $Pos["Y2"] )
6034
+        {
6035
+            if ( $inHorizon ) { $inHorizon = FALSE; $Result[] = array("X1"=>$LastX,"Y1"=>$Pos["Y1"],"X2"=>$Pos["X1"],"Y2"=>$Pos["Y1"]); }
6036
+
6037
+            $Result[] = array("X1"=>$Pos["X1"],"Y1"=>$Pos["Y1"],"X2"=>$Pos["X2"],"Y2"=>$Pos["Y2"]);
6038
+        }
6039
+        else { if ( !$inHorizon ) { $inHorizon = TRUE; $LastX = $Pos["X1"];} }
6040
+        }
6041
+        $Segments = $Result;
6042
+
6043
+        /* Do we have something to draw */
6044
+        if ( $Segments == "" ) { return(0); }
6045
+
6046
+        /* For segments debugging purpose */
6047
+        //foreach($Segments as $Key => $Pos)
6048
+        // echo $Pos["X1"].",".$Pos["Y1"].",".$Pos["X2"].",".$Pos["Y2"]."\r\n";
6049
+
6050
+        /* Find out the min & max Y boundaries */
6051
+        $MinY = OUT_OF_SIGHT; $MaxY = OUT_OF_SIGHT;
6052
+        foreach($Segments as $Key => $Coords)
6053
+        {
6054
+        if ( $MinY == OUT_OF_SIGHT || $MinY > min($Coords["Y1"],$Coords["Y2"]) ) { $MinY = min($Coords["Y1"],$Coords["Y2"]); }
6055
+        if ( $MaxY == OUT_OF_SIGHT || $MaxY < max($Coords["Y1"],$Coords["Y2"]) ) { $MaxY = max($Coords["Y1"],$Coords["Y2"]); }
6056
+        }
6057
+
6058
+        if ( $AllIntegers ) { $YStep = 1; } else { $YStep = .5; }
6059
+
6060
+        $MinY = floor($MinY); $MaxY = floor($MaxY);
6061
+
6062
+        /* Scan each Y lines */
6063
+        $DefaultColor = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
6064
+        $DebugLine = 0; $DebugColor = $this->allocateColor($this->Picture,255,0,0,100);
6065
+
6066
+        $MinY = floor($MinY); $MaxY = floor($MaxY); $YStep = 1; 
6067
+
6068
+        if ( !$NoFill )
6069
+        {
6070
+        //if ( $DebugLine ) { $MinY = $DebugLine; $MaxY = $DebugLine; }
6071
+        for($Y=$MinY;$Y<=$MaxY;$Y=$Y+$YStep)
6072
+        {
6073
+            $Intersections = ""; $LastSlope = NULL; $RestoreLast = "-";
6074
+            foreach($Segments as $Key => $Coords)
6075
+            {
6076
+            $X1 = $Coords["X1"]; $X2 = $Coords["X2"]; $Y1 = $Coords["Y1"]; $Y2 = $Coords["Y2"];
6077
+
6078
+            if ( min($Y1,$Y2) <= $Y && max($Y1,$Y2) >= $Y )
6079
+            {
6080
+                if ( $Y1 == $Y2 )
6081
+                { $X = $X1; }
6082
+                else
6083
+                { $X = $X1 + ( ($Y-$Y1)*$X2 - ($Y-$Y1)*$X1 ) / ($Y2-$Y1); }
6084
+
6085
+                $X = floor($X);
6086
+
6087
+                if ( $X2 == $X1 )
6088
+                { $Slope = "!"; }
6089
+                else
6090
+                {
6091
+                $SlopeC = ($Y2 - $Y1) / ($X2 - $X1);
6092
+                if( $SlopeC == 0 )
6093 6093
                 { $Slope = "="; }
6094
-               elseif( $SlopeC > 0 )
6094
+                elseif( $SlopeC > 0 )
6095 6095
                 { $Slope = "+"; }
6096
-               elseif ( $SlopeC < 0 )
6096
+                elseif ( $SlopeC < 0 )
6097 6097
                 { $Slope = "-"; }
6098
-              }
6098
+                }
6099 6099
 
6100
-             if ( !is_array($Intersections) )
6101
-              { $Intersections[] = $X; }
6102
-             elseif( !in_array($X,$Intersections) )
6103
-              { $Intersections[] = $X; }
6104
-             elseif( in_array($X,$Intersections) )
6105
-              {
6106
-               if ($Y == $DebugLine) { echo $Slope."/".$LastSlope."(".$X.") "; }
6100
+                if ( !is_array($Intersections) )
6101
+                { $Intersections[] = $X; }
6102
+                elseif( !in_array($X,$Intersections) )
6103
+                { $Intersections[] = $X; }
6104
+                elseif( in_array($X,$Intersections) )
6105
+                {
6106
+                if ($Y == $DebugLine) { echo $Slope."/".$LastSlope."(".$X.") "; }
6107 6107
 
6108
-               if ( $Slope == "=" && $LastSlope == "-"  )                             { $Intersections[] = $X; }
6109
-               if ( $Slope != $LastSlope && $LastSlope != "!" && $LastSlope != "=" )  { $Intersections[] = $X; }
6110
-               if ( $Slope != $LastSlope && $LastSlope == "!" && $Slope == "+" )      { $Intersections[] = $X; }
6111
-              }
6108
+                if ( $Slope == "=" && $LastSlope == "-"  )                             { $Intersections[] = $X; }
6109
+                if ( $Slope != $LastSlope && $LastSlope != "!" && $LastSlope != "=" )  { $Intersections[] = $X; }
6110
+                if ( $Slope != $LastSlope && $LastSlope == "!" && $Slope == "+" )      { $Intersections[] = $X; }
6111
+                }
6112 6112
 
6113
-             if ( is_array($Intersections) && in_array($X,$Intersections) && $LastSlope == "=" && ($Slope == "-" )) { $Intersections[] = $X; }
6113
+                if ( is_array($Intersections) && in_array($X,$Intersections) && $LastSlope == "=" && ($Slope == "-" )) { $Intersections[] = $X; }
6114 6114
 
6115
-             $LastSlope = $Slope;
6115
+                $LastSlope = $Slope;
6116
+            }
6116 6117
             }
6117
-          }
6118
-         if ( $RestoreLast != "-" ) { $Intersections[] = $RestoreLast; echo "@".$Y."\r\n"; }
6118
+            if ( $RestoreLast != "-" ) { $Intersections[] = $RestoreLast; echo "@".$Y."\r\n"; }
6119 6119
 
6120
-         if ( is_array($Intersections) )
6121
-          {
6122
-           sort($Intersections);
6120
+            if ( is_array($Intersections) )
6121
+            {
6122
+            sort($Intersections);
6123 6123
 
6124
-           if ($Y == $DebugLine) { print_r($Intersections); }
6124
+            if ($Y == $DebugLine) { print_r($Intersections); }
6125 6125
 
6126
-           /* Remove NULL plots */
6127
-           $Result = "";
6128
-           for($i=0;$i<=count($Intersections)-1;$i=$i+2)
6126
+            /* Remove NULL plots */
6127
+            $Result = "";
6128
+            for($i=0;$i<=count($Intersections)-1;$i=$i+2)
6129 6129
             {
6130
-             if ( isset($Intersections[$i+1]) )
6131
-              { if ( $Intersections[$i] != $Intersections[$i+1] ) { $Result[] = $Intersections[$i]; $Result[] = $Intersections[$i+1]; } }
6130
+                if ( isset($Intersections[$i+1]) )
6131
+                { if ( $Intersections[$i] != $Intersections[$i+1] ) { $Result[] = $Intersections[$i]; $Result[] = $Intersections[$i+1]; } }
6132 6132
             }
6133 6133
 
6134
-           if ( is_array($Result) )
6134
+            if ( is_array($Result) )
6135 6135
             {
6136
-             $Intersections = $Result;
6136
+                $Intersections = $Result;
6137 6137
 
6138
-             $LastX = OUT_OF_SIGHT;
6139
-             foreach($Intersections as $Key => $X)
6140
-              {
6141
-               if ( $LastX == OUT_OF_SIGHT )
6138
+                $LastX = OUT_OF_SIGHT;
6139
+                foreach($Intersections as $Key => $X)
6140
+                {
6141
+                if ( $LastX == OUT_OF_SIGHT )
6142 6142
                 $LastX = $X;
6143
-               elseif ( $LastX != OUT_OF_SIGHT )
6143
+                elseif ( $LastX != OUT_OF_SIGHT )
6144 6144
                 {
6145
-                 if ( $this->getFirstDecimal($LastX) > 1 ) { $LastX++; }
6145
+                    if ( $this->getFirstDecimal($LastX) > 1 ) { $LastX++; }
6146 6146
 
6147
-                 $Color = $DefaultColor;
6148
-                 if ( $Threshold != NULL )
6149
-                  {
6150
-                   foreach($Threshold as $Key => $Parameters)
6147
+                    $Color = $DefaultColor;
6148
+                    if ( $Threshold != NULL )
6151 6149
                     {
6152
-                     if ( $Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"])
6153
-                      {
6154
-                       if ( isset($Parameters["R"]) ) { $R = $Parameters["R"]; } else { $R = 0; }
6155
-                       if ( isset($Parameters["G"]) ) { $G = $Parameters["G"]; } else { $G = 0; }
6156
-                       if ( isset($Parameters["B"]) ) { $B = $Parameters["B"]; } else { $B = 0; }
6157
-                       if ( isset($Parameters["Alpha"]) ) { $Alpha = $Parameters["Alpha"]; } else { $Alpha = 100; }
6158
-                       $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
6159
-                      }
6150
+                    foreach($Threshold as $Key => $Parameters)
6151
+                    {
6152
+                        if ( $Y <= $Parameters["MinX"] && $Y >= $Parameters["MaxX"])
6153
+                        {
6154
+                        if ( isset($Parameters["R"]) ) { $R = $Parameters["R"]; } else { $R = 0; }
6155
+                        if ( isset($Parameters["G"]) ) { $G = $Parameters["G"]; } else { $G = 0; }
6156
+                        if ( isset($Parameters["B"]) ) { $B = $Parameters["B"]; } else { $B = 0; }
6157
+                        if ( isset($Parameters["Alpha"]) ) { $Alpha = $Parameters["Alpha"]; } else { $Alpha = 100; }
6158
+                        $Color = $this->allocateColor($this->Picture,$R,$G,$B,$Alpha);
6159
+                        }
6160
+                    }
6160 6161
                     }
6161
-                  }
6162 6162
 
6163
-                 imageline($this->Picture,$LastX,$Y,$X,$Y,$Color);
6163
+                    imageline($this->Picture,$LastX,$Y,$X,$Y,$Color);
6164 6164
 
6165
-                 if ( $Y == $DebugLine) { imageline($this->Picture,$LastX,$Y,$X,$Y,$DebugColor); }
6165
+                    if ( $Y == $DebugLine) { imageline($this->Picture,$LastX,$Y,$X,$Y,$DebugColor); }
6166 6166
 
6167
-                 $LastX = OUT_OF_SIGHT;
6167
+                    $LastX = OUT_OF_SIGHT;
6168 6168
                 }
6169
-              }
6169
+                }
6170
+            }
6170 6171
             }
6171
-          }
6172 6172
         }
6173
-      }
6173
+        }
6174 6174
 
6175
-     /* Draw the polygon border, if required */
6176
-     if ( !$NoBorder)
6177
-      {
6178
-       foreach($Segments as $Key => $Coords)
6175
+        /* Draw the polygon border, if required */
6176
+        if ( !$NoBorder)
6177
+        {
6178
+        foreach($Segments as $Key => $Coords)
6179 6179
         $this->drawLine($Coords["X1"],$Coords["Y1"],$Coords["X2"],$Coords["Y2"],array("R"=>$BorderR,"G"=>$BorderG,"B"=>$BorderB,"Alpha"=>$BorderAlpha,"Threshold"=>$Threshold));
6180
-      }
6180
+        }
6181 6181
 
6182
-     $this->Shadow = $RestoreShadow;
6182
+        $this->Shadow = $RestoreShadow;
6183 6183
     }
6184 6184
 
6185
-   /* Return the abscissa margin */
6186
-   function getAbscissaMargin($Data)
6185
+    /* Return the abscissa margin */
6186
+    function getAbscissaMargin($Data)
6187 6187
     {
6188
-     foreach($Data["Axis"] as $AxisID => $Values) { if ( $Values["Identity"] == AXIS_X ) { return($Values["Margin"]); } }
6189
-     return(0);
6188
+        foreach($Data["Axis"] as $AxisID => $Values) { if ( $Values["Identity"] == AXIS_X ) { return($Values["Margin"]); } }
6189
+        return(0);
6190 6190
     }
6191 6191
 
6192
-  }
6192
+    }
6193 6193
 ?>
6194 6194
\ No newline at end of file
Please login to merge, or discard this patch.
default/boinc/modules/boincstats/includes/pchart/class/pData.class.php 1 patch
Indentation   +524 added lines, -524 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
- /*
2
+    /*
3 3
      pDraw - class to manipulate data arrays
4 4
 
5 5
      Version     : 2.1.3
@@ -13,50 +13,50 @@  discard block
 block discarded – undo
13 13
      You can find the whole class documentation on the pChart web site.
14 14
  */
15 15
 
16
- /* Axis configuration */
17
- define("AXIS_FORMAT_DEFAULT"		, 680001);
18
- define("AXIS_FORMAT_TIME"		, 680002);
19
- define("AXIS_FORMAT_DATE"		, 680003);
20
- define("AXIS_FORMAT_METRIC"		, 680004);
21
- define("AXIS_FORMAT_CURRENCY"		, 680005);
22
- define("AXIS_FORMAT_CUSTOM"		, 680006);
23
-
24
- /* Axis position */
25
- define("AXIS_POSITION_LEFT"		, 681001);
26
- define("AXIS_POSITION_RIGHT"		, 681002);
27
- define("AXIS_POSITION_TOP"		, 681001);
28
- define("AXIS_POSITION_BOTTOM"		, 681002);
29
-
30
- /* Families of data points */
31
- define("SERIE_SHAPE_FILLEDCIRCLE"	, 681011);
32
- define("SERIE_SHAPE_FILLEDTRIANGLE"	, 681012);
33
- define("SERIE_SHAPE_FILLEDSQUARE"	, 681013);
34
- define("SERIE_SHAPE_FILLEDDIAMOND"	, 681017);
35
- define("SERIE_SHAPE_CIRCLE"		, 681014);
36
- define("SERIE_SHAPE_TRIANGLE"		, 681015);
37
- define("SERIE_SHAPE_SQUARE"		, 681016);
38
- define("SERIE_SHAPE_DIAMOND"		, 681018);
39
-
40
- /* Axis position */
41
- define("AXIS_X"			, 682001);
42
- define("AXIS_Y"			, 682002);
43
-
44
- /* Define value limits */
45
- define("ABSOLUTE_MIN"          	, -10000000000000);
46
- define("ABSOLUTE_MAX"          	, 10000000000000);
47
-
48
- /* Replacement to the PHP NULL keyword */
49
- define("VOID"                  	, 0.123456789);
50
-
51
- /* Euro symbol for GD fonts */
52
- define("EURO_SYMBOL"			, utf8_encode("&#8364;"));
53
-
54
- /* pData class definition */
55
- class pData
56
-  {
57
-   var $Data;
58
-
59
-   var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100),
16
+    /* Axis configuration */
17
+    define("AXIS_FORMAT_DEFAULT"		, 680001);
18
+    define("AXIS_FORMAT_TIME"		, 680002);
19
+    define("AXIS_FORMAT_DATE"		, 680003);
20
+    define("AXIS_FORMAT_METRIC"		, 680004);
21
+    define("AXIS_FORMAT_CURRENCY"		, 680005);
22
+    define("AXIS_FORMAT_CUSTOM"		, 680006);
23
+
24
+    /* Axis position */
25
+    define("AXIS_POSITION_LEFT"		, 681001);
26
+    define("AXIS_POSITION_RIGHT"		, 681002);
27
+    define("AXIS_POSITION_TOP"		, 681001);
28
+    define("AXIS_POSITION_BOTTOM"		, 681002);
29
+
30
+    /* Families of data points */
31
+    define("SERIE_SHAPE_FILLEDCIRCLE"	, 681011);
32
+    define("SERIE_SHAPE_FILLEDTRIANGLE"	, 681012);
33
+    define("SERIE_SHAPE_FILLEDSQUARE"	, 681013);
34
+    define("SERIE_SHAPE_FILLEDDIAMOND"	, 681017);
35
+    define("SERIE_SHAPE_CIRCLE"		, 681014);
36
+    define("SERIE_SHAPE_TRIANGLE"		, 681015);
37
+    define("SERIE_SHAPE_SQUARE"		, 681016);
38
+    define("SERIE_SHAPE_DIAMOND"		, 681018);
39
+
40
+    /* Axis position */
41
+    define("AXIS_X"			, 682001);
42
+    define("AXIS_Y"			, 682002);
43
+
44
+    /* Define value limits */
45
+    define("ABSOLUTE_MIN"          	, -10000000000000);
46
+    define("ABSOLUTE_MAX"          	, 10000000000000);
47
+
48
+    /* Replacement to the PHP NULL keyword */
49
+    define("VOID"                  	, 0.123456789);
50
+
51
+    /* Euro symbol for GD fonts */
52
+    define("EURO_SYMBOL"			, utf8_encode("&#8364;"));
53
+
54
+    /* pData class definition */
55
+    class pData
56
+    {
57
+    var $Data;
58
+
59
+    var $Palette = array("0"=>array("R"=>188,"G"=>224,"B"=>46,"Alpha"=>100),
60 60
                         "1"=>array("R"=>224,"G"=>100,"B"=>46,"Alpha"=>100),
61 61
                         "2"=>array("R"=>224,"G"=>214,"B"=>46,"Alpha"=>100),
62 62
                         "3"=>array("R"=>46,"G"=>151,"B"=>224,"Alpha"=>100),
@@ -65,723 +65,723 @@  discard block
 block discarded – undo
65 65
                         "6"=>array("R"=>92,"G"=>224,"B"=>46,"Alpha"=>100),
66 66
                         "7"=>array("R"=>224,"G"=>176,"B"=>46,"Alpha"=>100));
67 67
 
68
-   /* Class creator */
69
-   function pData()
68
+    /* Class creator */
69
+    function pData()
70 70
     {
71
-     $this->Data = "";
72
-     $this->Data["XAxisDisplay"]	= AXIS_FORMAT_DEFAULT;
73
-     $this->Data["XAxisFormat"]		= NULL;
74
-     $this->Data["XAxisName"]		= NULL;
75
-     $this->Data["XAxisUnit"]		= NULL;
76
-     $this->Data["Abscissa"]		= NULL;
77
-     $this->Data["AbsicssaPosition"]	= AXIS_POSITION_BOTTOM;
71
+        $this->Data = "";
72
+        $this->Data["XAxisDisplay"]	= AXIS_FORMAT_DEFAULT;
73
+        $this->Data["XAxisFormat"]		= NULL;
74
+        $this->Data["XAxisName"]		= NULL;
75
+        $this->Data["XAxisUnit"]		= NULL;
76
+        $this->Data["Abscissa"]		= NULL;
77
+        $this->Data["AbsicssaPosition"]	= AXIS_POSITION_BOTTOM;
78 78
 
79
-     $this->Data["Axis"][0]["Display"]  = AXIS_FORMAT_DEFAULT;
80
-     $this->Data["Axis"][0]["Position"] = AXIS_POSITION_LEFT;
81
-     $this->Data["Axis"][0]["Identity"] = AXIS_Y;
79
+        $this->Data["Axis"][0]["Display"]  = AXIS_FORMAT_DEFAULT;
80
+        $this->Data["Axis"][0]["Position"] = AXIS_POSITION_LEFT;
81
+        $this->Data["Axis"][0]["Identity"] = AXIS_Y;
82 82
     }
83 83
 
84
-   /* Add a single point or an array to the given serie */
85
-   function addPoints($Values,$SerieName="Serie1")
84
+    /* Add a single point or an array to the given serie */
85
+    function addPoints($Values,$SerieName="Serie1")
86 86
     {
87
-     if (!isset($this->Data["Series"][$SerieName]))
88
-      $this->initialise($SerieName);
87
+        if (!isset($this->Data["Series"][$SerieName]))
88
+        $this->initialise($SerieName);
89 89
 
90
-     if ( is_array($Values) )
91
-      {
92
-       foreach($Values as $Key => $Value)
90
+        if ( is_array($Values) )
91
+        {
92
+        foreach($Values as $Key => $Value)
93 93
         { $this->Data["Series"][$SerieName]["Data"][] = $Value; }
94
-      }
95
-     else
96
-      $this->Data["Series"][$SerieName]["Data"][] = $Values;
94
+        }
95
+        else
96
+        $this->Data["Series"][$SerieName]["Data"][] = $Values;
97 97
 
98
-     if ( $Values != VOID )
99
-      {
100
-       $StrippedData = $this->stripVOID($this->Data["Series"][$SerieName]["Data"]);
101
-       if ( empty($StrippedData) ) { $this->Data["Series"][$SerieName]["Max"] = 0; $this->Data["Series"][$SerieName]["Min"] =0; return(0); }
102
-       $this->Data["Series"][$SerieName]["Max"] = max($StrippedData);
103
-       $this->Data["Series"][$SerieName]["Min"] = min($StrippedData);
104
-      }
98
+        if ( $Values != VOID )
99
+        {
100
+        $StrippedData = $this->stripVOID($this->Data["Series"][$SerieName]["Data"]);
101
+        if ( empty($StrippedData) ) { $this->Data["Series"][$SerieName]["Max"] = 0; $this->Data["Series"][$SerieName]["Min"] =0; return(0); }
102
+        $this->Data["Series"][$SerieName]["Max"] = max($StrippedData);
103
+        $this->Data["Series"][$SerieName]["Min"] = min($StrippedData);
104
+        }
105 105
     }
106 106
 
107
-   /* Strip VOID values */
108
-   function stripVOID($Values)
107
+    /* Strip VOID values */
108
+    function stripVOID($Values)
109 109
     { if (!is_array($Values)) { return(array()); } $Result = array(); foreach($Values as $Key => $Value) { if ( $Value != VOID ) { $Result[] = $Value; } } return($Result); }
110 110
 
111
-   /* Return the number of values contained in a given serie */
112
-   function getSerieCount($Serie)
111
+    /* Return the number of values contained in a given serie */
112
+    function getSerieCount($Serie)
113 113
     { if (isset($this->Data["Series"][$Serie]["Data"])) { return(sizeof($this->Data["Series"][$Serie]["Data"])); } else { return(0); } }
114 114
 
115
-   /* Remove a serie from the pData object */
116
-   function removeSerie($Series)
115
+    /* Remove a serie from the pData object */
116
+    function removeSerie($Series)
117 117
     {
118
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
119
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie])) { unset($this->Data["Series"][$Serie]); } }
118
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
119
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie])) { unset($this->Data["Series"][$Serie]); } }
120 120
     }
121 121
 
122
-   /* Return a value from given serie & index */
123
-   function getValueAt($Serie,$Index=0)
122
+    /* Return a value from given serie & index */
123
+    function getValueAt($Serie,$Index=0)
124 124
     { if (isset($this->Data["Series"][$Serie]["Data"][$Index])) { return($this->Data["Series"][$Serie]["Data"][$Index]); } else { return(NULL); } }
125 125
 
126
-   /* Return the values array */
127
-   function getValues($Serie)
126
+    /* Return the values array */
127
+    function getValues($Serie)
128 128
     { if (isset($this->Data["Series"][$Serie]["Data"])) { return($this->Data["Series"][$Serie]["Data"]); } else { return(NULL); } }
129 129
 
130
-   /* Reverse the values in the given serie */
131
-   function reverseSerie($Series)
130
+    /* Reverse the values in the given serie */
131
+    function reverseSerie($Series)
132 132
     {
133
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
134
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]["Data"])) { $this->Data["Series"][$Serie]["Data"] = array_reverse($this->Data["Series"][$Serie]["Data"]); } }
133
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
134
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]["Data"])) { $this->Data["Series"][$Serie]["Data"] = array_reverse($this->Data["Series"][$Serie]["Data"]); } }
135 135
     }
136 136
 
137
-   /* Return the sum of the serie values */
138
-   function getSum($Serie)
137
+    /* Return the sum of the serie values */
138
+    function getSum($Serie)
139 139
     { if (isset($this->Data["Series"][$Serie])) { return(array_sum($this->Data["Series"][$Serie]["Data"])); } else { return(NULL); } }
140 140
 
141
-   /* Return the max value of a given serie */
142
-   function getMax($Serie)
141
+    /* Return the max value of a given serie */
142
+    function getMax($Serie)
143 143
     { if (isset($this->Data["Series"][$Serie]["Max"])) { return($this->Data["Series"][$Serie]["Max"]); } else { return(NULL); } }
144 144
 
145
-   /* Return the min value of a given serie */
146
-   function getMin($Serie)
145
+    /* Return the min value of a given serie */
146
+    function getMin($Serie)
147 147
     { if (isset($this->Data["Series"][$Serie]["Min"])) { return($this->Data["Series"][$Serie]["Min"]); } else { return(NULL); } }
148 148
 
149
-   /* Set the description of a given serie */
150
-   function setSerieShape($Series,$Shape=SERIE_SHAPE_FILLEDCIRCLE)
149
+    /* Set the description of a given serie */
150
+    function setSerieShape($Series,$Shape=SERIE_SHAPE_FILLEDCIRCLE)
151 151
     {
152
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
153
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Shape"] = $Shape; } }
152
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
153
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Shape"] = $Shape; } }
154 154
     }
155 155
 
156
-   /* Set the description of a given serie */
157
-   function setSerieDescription($Series,$Description="My serie")
156
+    /* Set the description of a given serie */
157
+    function setSerieDescription($Series,$Description="My serie")
158 158
     {
159
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
160
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Description"] = $Description; } }
159
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
160
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Description"] = $Description; } }
161 161
     }
162 162
 
163
-   /* Set a serie as "drawable" while calling a rendering function */
164
-   function setSerieDrawable($Series,$Drawable=TRUE)
163
+    /* Set a serie as "drawable" while calling a rendering function */
164
+    function setSerieDrawable($Series,$Drawable=TRUE)
165 165
     {
166
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
167
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["isDrawable"] = $Drawable; } }
166
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
167
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["isDrawable"] = $Drawable; } }
168 168
     }
169 169
 
170
-   /* Set the icon associated to a given serie */
171
-   function setSeriePicture($Series,$Picture=NULL)
170
+    /* Set the icon associated to a given serie */
171
+    function setSeriePicture($Series,$Picture=NULL)
172 172
     {
173
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
174
-     foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Picture"] = $Picture; } }
173
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
174
+        foreach($Series as $Key => $Serie) { if (isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Picture"] = $Picture; } }
175 175
     }
176 176
 
177
-   /* Set the name of the X Axis */
178
-   function setXAxisName($Name)
177
+    /* Set the name of the X Axis */
178
+    function setXAxisName($Name)
179 179
     { $this->Data["XAxisName"] = $Name; }
180 180
 
181
-   /* Set the display mode of the  X Axis */
182
-   function setXAxisDisplay($Mode,$Format=NULL)
181
+    /* Set the display mode of the  X Axis */
182
+    function setXAxisDisplay($Mode,$Format=NULL)
183 183
     { $this->Data["XAxisDisplay"] = $Mode; $this->Data["XAxisFormat"]  = $Format; }
184 184
 
185
-   /* Set the unit that will be displayed on the X axis */
186
-   function setXAxisUnit($Unit)
185
+    /* Set the unit that will be displayed on the X axis */
186
+    function setXAxisUnit($Unit)
187 187
     { $this->Data["XAxisUnit"] = $Unit; }
188 188
 
189
-   /* Set the serie that will be used as abscissa */
190
-   function setAbscissa($Serie)
189
+    /* Set the serie that will be used as abscissa */
190
+    function setAbscissa($Serie)
191 191
     { if (isset($this->Data["Series"][$Serie])) { $this->Data["Abscissa"] = $Serie; } }
192 192
 
193
-   function setAbsicssaPosition($Position = AXIS_POSITION_BOTTOM)
193
+    function setAbsicssaPosition($Position = AXIS_POSITION_BOTTOM)
194 194
     { $this->Data["AbsicssaPosition"] = $Position; }
195 195
 
196
-   /* Set the name of the abscissa axis */
197
-   function setAbscissaName($Name)
196
+    /* Set the name of the abscissa axis */
197
+    function setAbscissaName($Name)
198 198
     { $this->Data["AbscissaName"] = $Name; }
199 199
 
200
-   /* Create a scatter group specifyin X and Y data series */
201
-   function setScatterSerie($SerieX,$SerieY,$ID=0)
200
+    /* Create a scatter group specifyin X and Y data series */
201
+    function setScatterSerie($SerieX,$SerieY,$ID=0)
202 202
     { if (isset($this->Data["Series"][$SerieX]) && isset($this->Data["Series"][$SerieY]) ) { $this->initScatterSerie($ID); $this->Data["ScatterSeries"][$ID]["X"] = $SerieX; $this->Data["ScatterSeries"][$ID]["Y"] = $SerieY; } }
203 203
 
204
-   /* Set the shape of a given sctatter serie */
205
-   function setScatterSerieShape($ID,$Shape=SERIE_SHAPE_FILLEDCIRCLE)
204
+    /* Set the shape of a given sctatter serie */
205
+    function setScatterSerieShape($ID,$Shape=SERIE_SHAPE_FILLEDCIRCLE)
206 206
     { if (isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Shape"] = $Shape; } }
207 207
 
208
-   /* Set the description of a given scatter serie */
209
-   function setScatterSerieDescription($ID,$Description="My serie")
208
+    /* Set the description of a given scatter serie */
209
+    function setScatterSerieDescription($ID,$Description="My serie")
210 210
     { if (isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Description"] = $Description; } }
211 211
 
212
-   /* Set the icon associated to a given scatter serie */
213
-   function setScatterSeriePicture($ID,$Picture=NULL)
212
+    /* Set the icon associated to a given scatter serie */
213
+    function setScatterSeriePicture($ID,$Picture=NULL)
214 214
     { if (isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Picture"] = $Picture; } }
215 215
 
216
-   /* Set a scatter serie as "drawable" while calling a rendering function */
217
-   function setScatterSerieDrawable($ID ,$Drawable=TRUE)
216
+    /* Set a scatter serie as "drawable" while calling a rendering function */
217
+    function setScatterSerieDrawable($ID ,$Drawable=TRUE)
218 218
     { if (isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["isDrawable"] = $Drawable; } }
219 219
 
220
-   /* Define if a scatter serie should be draw with ticks */
221
-   function setScatterSerieTicks($ID,$Width=0)
220
+    /* Define if a scatter serie should be draw with ticks */
221
+    function setScatterSerieTicks($ID,$Width=0)
222 222
     { if ( isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Ticks"] = $Width; } }
223 223
 
224
-   /* Define if a scatter serie should be draw with a special weight */
225
-   function setScatterSerieWeight($ID,$Weight=0)
224
+    /* Define if a scatter serie should be draw with a special weight */
225
+    function setScatterSerieWeight($ID,$Weight=0)
226 226
     { if ( isset($this->Data["ScatterSeries"][$ID]) ) { $this->Data["ScatterSeries"][$ID]["Weight"] = $Weight; } }
227 227
 
228
-   /* Associate a color to a scatter serie */
229
-   function setScatterSerieColor($ID,$Format)
228
+    /* Associate a color to a scatter serie */
229
+    function setScatterSerieColor($ID,$Format)
230 230
     {
231
-     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
232
-     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
233
-     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
234
-     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
231
+        $R	    = isset($Format["R"]) ? $Format["R"] : 0;
232
+        $G	    = isset($Format["G"]) ? $Format["G"] : 0;
233
+        $B	    = isset($Format["B"]) ? $Format["B"] : 0;
234
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
235 235
 
236
-     if ( isset($this->Data["ScatterSeries"][$ID]) )
237
-      {
238
-       $this->Data["ScatterSeries"][$ID]["Color"]["R"] = $R;
239
-       $this->Data["ScatterSeries"][$ID]["Color"]["G"] = $G;
240
-       $this->Data["ScatterSeries"][$ID]["Color"]["B"] = $B;
241
-       $this->Data["ScatterSeries"][$ID]["Color"]["Alpha"] = $Alpha;
242
-      }
236
+        if ( isset($this->Data["ScatterSeries"][$ID]) )
237
+        {
238
+        $this->Data["ScatterSeries"][$ID]["Color"]["R"] = $R;
239
+        $this->Data["ScatterSeries"][$ID]["Color"]["G"] = $G;
240
+        $this->Data["ScatterSeries"][$ID]["Color"]["B"] = $B;
241
+        $this->Data["ScatterSeries"][$ID]["Color"]["Alpha"] = $Alpha;
242
+        }
243 243
     }
244 244
 
245
-   /* Compute the series limits for an individual and global point of view */
246
-   function limits()
245
+    /* Compute the series limits for an individual and global point of view */
246
+    function limits()
247 247
     {
248
-     $GlobalMin = ABSOLUTE_MAX;
249
-     $GlobalMax = ABSOLUTE_MIN;
248
+        $GlobalMin = ABSOLUTE_MAX;
249
+        $GlobalMax = ABSOLUTE_MIN;
250 250
 
251
-     foreach($this->Data["Series"] as $Key => $Value)
252
-      {
253
-       if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"] == TRUE)
251
+        foreach($this->Data["Series"] as $Key => $Value)
252
+        {
253
+        if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"] == TRUE)
254 254
         {
255
-         if ( $GlobalMin > $this->Data["Series"][$Key]["Min"] ) { $GlobalMin = $this->Data["Series"][$Key]["Min"]; }
256
-         if ( $GlobalMax < $this->Data["Series"][$Key]["Max"] ) { $GlobalMax = $this->Data["Series"][$Key]["Max"]; }
255
+            if ( $GlobalMin > $this->Data["Series"][$Key]["Min"] ) { $GlobalMin = $this->Data["Series"][$Key]["Min"]; }
256
+            if ( $GlobalMax < $this->Data["Series"][$Key]["Max"] ) { $GlobalMax = $this->Data["Series"][$Key]["Max"]; }
257 257
         }
258
-      }
259
-     $this->Data["Min"] = $GlobalMin;
260
-     $this->Data["Max"] = $GlobalMax;
258
+        }
259
+        $this->Data["Min"] = $GlobalMin;
260
+        $this->Data["Max"] = $GlobalMax;
261 261
 
262
-     return(array($GlobalMin,$GlobalMax));
262
+        return(array($GlobalMin,$GlobalMax));
263 263
     }
264 264
 
265
-   /* Mark all series as drawable */
266
-   function drawAll()
265
+    /* Mark all series as drawable */
266
+    function drawAll()
267 267
     { foreach($this->Data["Series"] as $Key => $Value) { if ( $this->Data["Abscissa"] != $Key ) { $this->Data["Series"][$Key]["isDrawable"]=TRUE; } } }    
268 268
 
269
-   /* Return the average value of the given serie */
270
-   function getSerieAverage($Serie)
269
+    /* Return the average value of the given serie */
270
+    function getSerieAverage($Serie)
271 271
     {
272
-     if ( isset($this->Data["Series"][$Serie]) )
273
-      {
274
-       $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
275
-       return(array_sum($SerieData)/sizeof($SerieData));
276
-      }
277
-     else
278
-      return(NULL);
272
+        if ( isset($this->Data["Series"][$Serie]) )
273
+        {
274
+        $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
275
+        return(array_sum($SerieData)/sizeof($SerieData));
276
+        }
277
+        else
278
+        return(NULL);
279 279
     }
280 280
 
281
-   /* Return the geometric mean of the given serie */
282
-   function getGeometricMean($Serie)
281
+    /* Return the geometric mean of the given serie */
282
+    function getGeometricMean($Serie)
283 283
     {
284
-     if ( isset($this->Data["Series"][$Serie]) )
285
-      {
286
-       $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
287
-       $Seriesum  = 1; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum * $Value; }
288
-       return(pow($Seriesum,1/sizeof($SerieData)));
289
-      }
290
-     else
291
-      return(NULL);
284
+        if ( isset($this->Data["Series"][$Serie]) )
285
+        {
286
+        $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
287
+        $Seriesum  = 1; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum * $Value; }
288
+        return(pow($Seriesum,1/sizeof($SerieData)));
289
+        }
290
+        else
291
+        return(NULL);
292 292
     }
293 293
 
294
-   /* Return the harmonic mean of the given serie */
295
-   function getHarmonicMean($Serie)
294
+    /* Return the harmonic mean of the given serie */
295
+    function getHarmonicMean($Serie)
296 296
     {
297
-     if ( isset($this->Data["Series"][$Serie]) )
298
-      {
299
-       $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
300
-       $Seriesum  = 0; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum + 1/$Value; }
301
-       return(sizeof($SerieData)/$Seriesum);
302
-      }
303
-     else
304
-      return(NULL);
297
+        if ( isset($this->Data["Series"][$Serie]) )
298
+        {
299
+        $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
300
+        $Seriesum  = 0; foreach($SerieData as $Key => $Value) { $Seriesum = $Seriesum + 1/$Value; }
301
+        return(sizeof($SerieData)/$Seriesum);
302
+        }
303
+        else
304
+        return(NULL);
305 305
     }
306 306
 
307
-   /* Return the standard deviation of the given serie */
308
-   function getStandardDeviation($Serie)
307
+    /* Return the standard deviation of the given serie */
308
+    function getStandardDeviation($Serie)
309 309
     {
310
-     if ( isset($this->Data["Series"][$Serie]) )
311
-      {
312
-       $Average   = $this->getSerieAverage($Serie);
313
-       $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
310
+        if ( isset($this->Data["Series"][$Serie]) )
311
+        {
312
+        $Average   = $this->getSerieAverage($Serie);
313
+        $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
314 314
 
315
-       $DeviationSum = 0;
316
-       foreach($SerieData as $Key => $Value)
315
+        $DeviationSum = 0;
316
+        foreach($SerieData as $Key => $Value)
317 317
         $DeviationSum = $DeviationSum + ($Value-$Average)*($Value-$Average);
318 318
 
319
-       $Deviation = sqrt($DeviationSum/count($SerieData));
319
+        $Deviation = sqrt($DeviationSum/count($SerieData));
320 320
 
321
-       return($Deviation);
322
-      }
323
-     else
324
-      return(NULL);
321
+        return($Deviation);
322
+        }
323
+        else
324
+        return(NULL);
325 325
     }
326 326
 
327
-   /* Return the Coefficient of variation of the given serie */
328
-   function getCoefficientOfVariation($Serie)
327
+    /* Return the Coefficient of variation of the given serie */
328
+    function getCoefficientOfVariation($Serie)
329 329
     {
330
-     if ( isset($this->Data["Series"][$Serie]) )
331
-      {
332
-       $Average           = $this->getSerieAverage($Serie);
333
-       $StandardDeviation = $this->getStandardDeviation($Serie);
330
+        if ( isset($this->Data["Series"][$Serie]) )
331
+        {
332
+        $Average           = $this->getSerieAverage($Serie);
333
+        $StandardDeviation = $this->getStandardDeviation($Serie);
334 334
 
335
-       if ( $StandardDeviation != 0 )
335
+        if ( $StandardDeviation != 0 )
336 336
         return($StandardDeviation/$Average);
337
-       else
337
+        else
338
+        return(NULL);
339
+        }
340
+        else
338 341
         return(NULL);
339
-      }
340
-     else
341
-      return(NULL);
342 342
     }
343 343
 
344
-   /* Return the median value of the given serie */
345
-   function getSerieMedian($Serie)
344
+    /* Return the median value of the given serie */
345
+    function getSerieMedian($Serie)
346 346
     {
347
-     if ( isset($this->Data["Series"][$Serie]) )
348
-      {
349
-       $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
350
-       sort($SerieData);
351
-       $SerieCenter = floor(sizeof($SerieData)/2);
347
+        if ( isset($this->Data["Series"][$Serie]) )
348
+        {
349
+        $SerieData = $this->stripVOID($this->Data["Series"][$Serie]["Data"]);
350
+        sort($SerieData);
351
+        $SerieCenter = floor(sizeof($SerieData)/2);
352 352
 
353
-       if ( isset($SerieData[$SerieCenter]) )
353
+        if ( isset($SerieData[$SerieCenter]) )
354 354
         return($SerieData[$SerieCenter]);
355
-       else
355
+        else
356
+        return(NULL);
357
+        }
358
+        else
356 359
         return(NULL);
357
-      }
358
-     else
359
-      return(NULL);
360 360
     }
361 361
 
362
-   /* Return the x th percentil of the given serie */
363
-   function getSeriePercentile($Serie="Serie1",$Percentil=95)
362
+    /* Return the x th percentil of the given serie */
363
+    function getSeriePercentile($Serie="Serie1",$Percentil=95)
364 364
     {
365
-     if (!isset($this->Data["Series"][$Serie]["Data"])) { return(NULL); }
365
+        if (!isset($this->Data["Series"][$Serie]["Data"])) { return(NULL); }
366 366
 
367
-     $Values = count($this->Data["Series"][$Serie]["Data"])-1;
368
-     if ( $Values < 0 ) { $Values = 0; }
367
+        $Values = count($this->Data["Series"][$Serie]["Data"])-1;
368
+        if ( $Values < 0 ) { $Values = 0; }
369 369
 
370
-     $PercentilID  = floor(($Values/100)*$Percentil+.5);
371
-     $SortedValues = $this->Data["Series"][$Serie]["Data"];
372
-     sort($SortedValues);
370
+        $PercentilID  = floor(($Values/100)*$Percentil+.5);
371
+        $SortedValues = $this->Data["Series"][$Serie]["Data"];
372
+        sort($SortedValues);
373 373
 
374
-     if ( is_numeric($SortedValues[$PercentilID]) )
375
-      return($SortedValues[$PercentilID]);
376
-     else
377
-      return(NULL);
374
+        if ( is_numeric($SortedValues[$PercentilID]) )
375
+        return($SortedValues[$PercentilID]);
376
+        else
377
+        return(NULL);
378 378
     }
379 379
 
380
-   /* Add random values to a given serie */
381
-   function addRandomValues($SerieName="Serie1",$Options="")
380
+    /* Add random values to a given serie */
381
+    function addRandomValues($SerieName="Serie1",$Options="")
382 382
     {
383
-     $Values    = isset($Options["Values"]) ? $Options["Values"] : 20;
384
-     $Min       = isset($Options["Min"]) ? $Options["Min"] : 0;
385
-     $Max       = isset($Options["Max"]) ? $Options["Max"] : 100;
386
-     $withFloat = isset($Options["withFloat"]) ? $Options["withFloat"] : FALSE;
383
+        $Values    = isset($Options["Values"]) ? $Options["Values"] : 20;
384
+        $Min       = isset($Options["Min"]) ? $Options["Min"] : 0;
385
+        $Max       = isset($Options["Max"]) ? $Options["Max"] : 100;
386
+        $withFloat = isset($Options["withFloat"]) ? $Options["withFloat"] : FALSE;
387 387
 
388
-     for ($i=0;$i<=$Values;$i++)
389
-      {
390
-       if ( $withFloat ) { $Value = rand($Min*100,$Max*100)/100; } else { $Value = rand($Min,$Max); }
391
-       $this->addPoints($Value,$SerieName);
392
-      }
388
+        for ($i=0;$i<=$Values;$i++)
389
+        {
390
+        if ( $withFloat ) { $Value = rand($Min*100,$Max*100)/100; } else { $Value = rand($Min,$Max); }
391
+        $this->addPoints($Value,$SerieName);
392
+        }
393 393
     }
394 394
 
395
-   /* Test if we have valid data */
396
-   function containsData()
395
+    /* Test if we have valid data */
396
+    function containsData()
397 397
     {
398
-     if (!isset($this->Data["Series"])) { return(FALSE); }
398
+        if (!isset($this->Data["Series"])) { return(FALSE); }
399 399
 
400
-     $Result = FALSE;
401
-     foreach($this->Data["Series"] as $Key => $Value)
402
-      { if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"]==TRUE) { $Result=TRUE; } }
403
-     return($Result);
400
+        $Result = FALSE;
401
+        foreach($this->Data["Series"] as $Key => $Value)
402
+        { if ( $this->Data["Abscissa"] != $Key && $this->Data["Series"][$Key]["isDrawable"]==TRUE) { $Result=TRUE; } }
403
+        return($Result);
404 404
     }
405 405
 
406
-   /* Set the display mode of an Axis */
407
-   function setAxisDisplay($AxisID,$Mode=AXIS_FORMAT_DEFAULT,$Format=NULL)
406
+    /* Set the display mode of an Axis */
407
+    function setAxisDisplay($AxisID,$Mode=AXIS_FORMAT_DEFAULT,$Format=NULL)
408 408
     {
409
-     if ( isset($this->Data["Axis"][$AxisID] ) )
410
-      {
411
-       $this->Data["Axis"][$AxisID]["Display"] = $Mode;
412
-       if ( $Format != NULL ) { $this->Data["Axis"][$AxisID]["Format"] = $Format; }
413
-      }
409
+        if ( isset($this->Data["Axis"][$AxisID] ) )
410
+        {
411
+        $this->Data["Axis"][$AxisID]["Display"] = $Mode;
412
+        if ( $Format != NULL ) { $this->Data["Axis"][$AxisID]["Format"] = $Format; }
413
+        }
414 414
     }
415 415
 
416
-   /* Set the position of an Axis */
417
-   function setAxisPosition($AxisID,$Position=AXIS_POSITION_LEFT)
416
+    /* Set the position of an Axis */
417
+    function setAxisPosition($AxisID,$Position=AXIS_POSITION_LEFT)
418 418
     { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Position"] = $Position; } }
419 419
 
420
-   /* Associate an unit to an axis */
421
-   function setAxisUnit($AxisID,$Unit)
420
+    /* Associate an unit to an axis */
421
+    function setAxisUnit($AxisID,$Unit)
422 422
     { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Unit"] = $Unit; } }
423 423
 
424
-   /* Associate a name to an axis */
425
-   function setAxisName($AxisID,$Name)
424
+    /* Associate a name to an axis */
425
+    function setAxisName($AxisID,$Name)
426 426
     { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Name"] = $Name; } }
427 427
 
428
-   /* Associate a color to an axis */
429
-   function setAxisColor($AxisID,$Format)
428
+    /* Associate a color to an axis */
429
+    function setAxisColor($AxisID,$Format)
430 430
     {
431
-     $R	    = isset($Format["R"]) ? $Format["R"] : 0;
432
-     $G	    = isset($Format["G"]) ? $Format["G"] : 0;
433
-     $B	    = isset($Format["B"]) ? $Format["B"] : 0;
434
-     $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
431
+        $R	    = isset($Format["R"]) ? $Format["R"] : 0;
432
+        $G	    = isset($Format["G"]) ? $Format["G"] : 0;
433
+        $B	    = isset($Format["B"]) ? $Format["B"] : 0;
434
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
435 435
 
436
-     if ( isset($this->Data["Axis"][$AxisID] ) )
437
-      {
438
-       $this->Data["Axis"][$AxisID]["Color"]["R"] = $R;
439
-       $this->Data["Axis"][$AxisID]["Color"]["G"] = $G;
440
-       $this->Data["Axis"][$AxisID]["Color"]["B"] = $B;
441
-       $this->Data["Axis"][$AxisID]["Color"]["Alpha"] = $Alpha;
442
-      }
436
+        if ( isset($this->Data["Axis"][$AxisID] ) )
437
+        {
438
+        $this->Data["Axis"][$AxisID]["Color"]["R"] = $R;
439
+        $this->Data["Axis"][$AxisID]["Color"]["G"] = $G;
440
+        $this->Data["Axis"][$AxisID]["Color"]["B"] = $B;
441
+        $this->Data["Axis"][$AxisID]["Color"]["Alpha"] = $Alpha;
442
+        }
443 443
     }
444 444
 
445 445
 
446
-   /* Design an axis as X or Y member */
447
-   function setAxisXY($AxisID,$Identity=AXIS_Y)
446
+    /* Design an axis as X or Y member */
447
+    function setAxisXY($AxisID,$Identity=AXIS_Y)
448 448
     { if ( isset($this->Data["Axis"][$AxisID] ) ) { $this->Data["Axis"][$AxisID]["Identity"] = $Identity; } }
449 449
 
450
-   /* Associate one data serie with one axis */
451
-   function setSerieOnAxis($Series,$AxisID)
450
+    /* Associate one data serie with one axis */
451
+    function setSerieOnAxis($Series,$AxisID)
452 452
     {
453
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
454
-     foreach($Series as $Key => $Serie)
455
-      {
456
-       $PreviousAxis = $this->Data["Series"][$Serie]["Axis"];
453
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
454
+        foreach($Series as $Key => $Serie)
455
+        {
456
+        $PreviousAxis = $this->Data["Series"][$Serie]["Axis"];
457 457
 
458
-       /* Create missing axis */
459
-       if ( !isset($this->Data["Axis"][$AxisID] ) )
458
+        /* Create missing axis */
459
+        if ( !isset($this->Data["Axis"][$AxisID] ) )
460 460
         { $this->Data["Axis"][$AxisID]["Position"] = AXIS_POSITION_LEFT; $this->Data["Axis"][$AxisID]["Identity"] = AXIS_Y;}
461 461
 
462
-       $this->Data["Series"][$Serie]["Axis"] = $AxisID;
462
+        $this->Data["Series"][$Serie]["Axis"] = $AxisID;
463 463
 
464
-       /* Cleanup unused axis */
465
-       $Found = FALSE;
466
-       foreach($this->Data["Series"] as $SerieName => $Values) { if ( $Values["Axis"] == $PreviousAxis ) { $Found = TRUE; } }
467
-       if (!$Found) { unset($this->Data["Axis"][$PreviousAxis]); }
468
-      }
464
+        /* Cleanup unused axis */
465
+        $Found = FALSE;
466
+        foreach($this->Data["Series"] as $SerieName => $Values) { if ( $Values["Axis"] == $PreviousAxis ) { $Found = TRUE; } }
467
+        if (!$Found) { unset($this->Data["Axis"][$PreviousAxis]); }
468
+        }
469 469
     }
470 470
 
471
-   /* Define if a serie should be draw with ticks */
472
-   function setSerieTicks($Series,$Width=0)
471
+    /* Define if a serie should be draw with ticks */
472
+    function setSerieTicks($Series,$Width=0)
473 473
     {
474
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
475
-     foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Ticks"] = $Width; } }
474
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
475
+        foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Ticks"] = $Width; } }
476 476
     }
477 477
 
478
-   /* Define if a serie should be draw with a special weight */
479
-   function setSerieWeight($Series,$Weight=0)
478
+    /* Define if a serie should be draw with a special weight */
479
+    function setSerieWeight($Series,$Weight=0)
480 480
     {
481
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
482
-     foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Weight"] = $Weight; } }
481
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
482
+        foreach($Series as $Key => $Serie) { if ( isset($this->Data["Series"][$Serie]) ) { $this->Data["Series"][$Serie]["Weight"] = $Weight; } }
483 483
     }
484 484
 
485
-   /* Returns the palette of the given serie */
486
-   function getSeriePalette($Serie)
485
+    /* Returns the palette of the given serie */
486
+    function getSeriePalette($Serie)
487 487
     {
488
-     if ( !isset($this->Data["Series"][$Serie]) ) { return(NULL); }
488
+        if ( !isset($this->Data["Series"][$Serie]) ) { return(NULL); }
489 489
 
490
-     $Result = "";
491
-     $Result["R"] = $this->Data["Series"][$Serie]["Color"]["R"];
492
-     $Result["G"] = $this->Data["Series"][$Serie]["Color"]["G"];
493
-     $Result["B"] = $this->Data["Series"][$Serie]["Color"]["B"];
494
-     $Result["Alpha"] = $this->Data["Series"][$Serie]["Color"]["Alpha"];
490
+        $Result = "";
491
+        $Result["R"] = $this->Data["Series"][$Serie]["Color"]["R"];
492
+        $Result["G"] = $this->Data["Series"][$Serie]["Color"]["G"];
493
+        $Result["B"] = $this->Data["Series"][$Serie]["Color"]["B"];
494
+        $Result["Alpha"] = $this->Data["Series"][$Serie]["Color"]["Alpha"];
495 495
 
496
-     return($Result);
496
+        return($Result);
497 497
     }
498 498
 
499
-   /* Set the color of one serie */
500
-   function setPalette($Series,$Format=NULL)
499
+    /* Set the color of one serie */
500
+    function setPalette($Series,$Format=NULL)
501 501
     {
502
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
503
-
504
-     foreach($Series as $Key => $Serie)
505
-      {
506
-       $R	    = isset($Format["R"]) ? $Format["R"] : 0;
507
-       $G	    = isset($Format["G"]) ? $Format["G"] : 0;
508
-       $B	    = isset($Format["B"]) ? $Format["B"] : 0;
509
-       $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
502
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
510 503
 
511
-       if ( isset($this->Data["Series"][$Serie]) )
504
+        foreach($Series as $Key => $Serie)
512 505
         {
513
-         $OldR = $this->Data["Series"][$Serie]["Color"]["R"]; $OldG = $this->Data["Series"][$Serie]["Color"]["G"]; $OldB = $this->Data["Series"][$Serie]["Color"]["B"];
514
-         $this->Data["Series"][$Serie]["Color"]["R"] = $R;
515
-         $this->Data["Series"][$Serie]["Color"]["G"] = $G;
516
-         $this->Data["Series"][$Serie]["Color"]["B"] = $B;
517
-         $this->Data["Series"][$Serie]["Color"]["Alpha"] = $Alpha;
506
+        $R	    = isset($Format["R"]) ? $Format["R"] : 0;
507
+        $G	    = isset($Format["G"]) ? $Format["G"] : 0;
508
+        $B	    = isset($Format["B"]) ? $Format["B"] : 0;
509
+        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;
518 510
 
519
-         /* Do reverse processing on the internal palette array */
520
-         foreach ($this->Palette as $Key => $Value)
521
-          { if ($Value["R"] == $OldR && $Value["G"] == $OldG && $Value["B"] == $OldB) { $this->Palette[$Key]["R"] = $R; $this->Palette[$Key]["G"] = $G; $this->Palette[$Key]["B"] = $B; $this->Palette[$Key]["Alpha"] = $Alpha;} }
511
+        if ( isset($this->Data["Series"][$Serie]) )
512
+        {
513
+            $OldR = $this->Data["Series"][$Serie]["Color"]["R"]; $OldG = $this->Data["Series"][$Serie]["Color"]["G"]; $OldB = $this->Data["Series"][$Serie]["Color"]["B"];
514
+            $this->Data["Series"][$Serie]["Color"]["R"] = $R;
515
+            $this->Data["Series"][$Serie]["Color"]["G"] = $G;
516
+            $this->Data["Series"][$Serie]["Color"]["B"] = $B;
517
+            $this->Data["Series"][$Serie]["Color"]["Alpha"] = $Alpha;
518
+
519
+            /* Do reverse processing on the internal palette array */
520
+            foreach ($this->Palette as $Key => $Value)
521
+            { if ($Value["R"] == $OldR && $Value["G"] == $OldG && $Value["B"] == $OldB) { $this->Palette[$Key]["R"] = $R; $this->Palette[$Key]["G"] = $G; $this->Palette[$Key]["B"] = $B; $this->Palette[$Key]["Alpha"] = $Alpha;} }
522
+        }
522 523
         }
523
-      }
524 524
     }
525 525
 
526
-   /* Load a palette file */
527
-   function loadPalette($FileName,$Overwrite=FALSE)
526
+    /* Load a palette file */
527
+    function loadPalette($FileName,$Overwrite=FALSE)
528 528
     {
529
-     if ( !file_exists($FileName) ) { return(-1); }
530
-     if ( $Overwrite ) { $this->Palette = ""; }
529
+        if ( !file_exists($FileName) ) { return(-1); }
530
+        if ( $Overwrite ) { $this->Palette = ""; }
531 531
 
532
-     $fileHandle = @fopen($FileName, "r");
533
-     if (!$fileHandle) { return(-1); }
534
-     while (!feof($fileHandle))
535
-      {
536
-       $buffer = fgets($fileHandle, 4096);
537
-       if ( preg_match("/,/",$buffer) )
532
+        $fileHandle = @fopen($FileName, "r");
533
+        if (!$fileHandle) { return(-1); }
534
+        while (!feof($fileHandle))
538 535
         {
539
-         list($R,$G,$B,$Alpha) = preg_split("/,/",$buffer);
540
-         if ( $this->Palette == "" ) { $ID = 0; } else { $ID = count($this->Palette); }
541
-         $this->Palette[$ID] = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
536
+        $buffer = fgets($fileHandle, 4096);
537
+        if ( preg_match("/,/",$buffer) )
538
+        {
539
+            list($R,$G,$B,$Alpha) = preg_split("/,/",$buffer);
540
+            if ( $this->Palette == "" ) { $ID = 0; } else { $ID = count($this->Palette); }
541
+            $this->Palette[$ID] = array("R"=>$R,"G"=>$G,"B"=>$B,"Alpha"=>$Alpha);
542
+        }
542 543
         }
543
-      }
544
-     fclose($fileHandle);
544
+        fclose($fileHandle);
545 545
 
546
-     /* Apply changes to current series */
547
-     $ID = 0;
548
-     if ( isset($this->Data["Series"]))
549
-      {
550
-       foreach($this->Data["Series"] as $Key => $Value)
546
+        /* Apply changes to current series */
547
+        $ID = 0;
548
+        if ( isset($this->Data["Series"]))
551 549
         {
552
-         if ( !isset($this->Palette[$ID]) )
553
-          $this->Data["Series"][$Key]["Color"] = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>0);
554
-         else
555
-          $this->Data["Series"][$Key]["Color"] = $this->Palette[$ID];
556
-         $ID++;
550
+        foreach($this->Data["Series"] as $Key => $Value)
551
+        {
552
+            if ( !isset($this->Palette[$ID]) )
553
+            $this->Data["Series"][$Key]["Color"] = array("R"=>0,"G"=>0,"B"=>0,"Alpha"=>0);
554
+            else
555
+            $this->Data["Series"][$Key]["Color"] = $this->Palette[$ID];
556
+            $ID++;
557
+        }
557 558
         }
558
-      }
559 559
     }
560 560
 
561
-   /* Initialise a given scatter serie */
562
-   function initScatterSerie($ID)
561
+    /* Initialise a given scatter serie */
562
+    function initScatterSerie($ID)
563 563
     {
564
-     if ( isset($this->Data["ScatterSeries"][$ID]) ) { return(0); }
564
+        if ( isset($this->Data["ScatterSeries"][$ID]) ) { return(0); }
565 565
 
566
-     $this->Data["ScatterSeries"][$ID]["Description"]	= "Scatter ".$ID;
567
-     $this->Data["ScatterSeries"][$ID]["isDrawable"]	= TRUE;
568
-     $this->Data["ScatterSeries"][$ID]["Picture"]	= NULL;
569
-     $this->Data["ScatterSeries"][$ID]["Ticks"]		= 0;
570
-     $this->Data["ScatterSeries"][$ID]["Weight"]	= 0;
566
+        $this->Data["ScatterSeries"][$ID]["Description"]	= "Scatter ".$ID;
567
+        $this->Data["ScatterSeries"][$ID]["isDrawable"]	= TRUE;
568
+        $this->Data["ScatterSeries"][$ID]["Picture"]	= NULL;
569
+        $this->Data["ScatterSeries"][$ID]["Ticks"]		= 0;
570
+        $this->Data["ScatterSeries"][$ID]["Weight"]	= 0;
571 571
 
572
-     if ( isset($this->Palette[$ID]) )
573
-      $this->Data["ScatterSeries"][$ID]["Color"] = $this->Palette[$ID];
574
-     else
575
-      {
576
-       $this->Data["ScatterSeries"][$ID]["Color"]["R"] = rand(0,255);
577
-       $this->Data["ScatterSeries"][$ID]["Color"]["G"] = rand(0,255);
578
-       $this->Data["ScatterSeries"][$ID]["Color"]["B"] = rand(0,255);
579
-       $this->Data["ScatterSeries"][$ID]["Color"]["Alpha"] = 100;
580
-      }
572
+        if ( isset($this->Palette[$ID]) )
573
+        $this->Data["ScatterSeries"][$ID]["Color"] = $this->Palette[$ID];
574
+        else
575
+        {
576
+        $this->Data["ScatterSeries"][$ID]["Color"]["R"] = rand(0,255);
577
+        $this->Data["ScatterSeries"][$ID]["Color"]["G"] = rand(0,255);
578
+        $this->Data["ScatterSeries"][$ID]["Color"]["B"] = rand(0,255);
579
+        $this->Data["ScatterSeries"][$ID]["Color"]["Alpha"] = 100;
580
+        }
581 581
     }
582 582
 
583
-   /* Initialise a given serie */
584
-   function initialise($Serie)
583
+    /* Initialise a given serie */
584
+    function initialise($Serie)
585 585
     {
586
-     if ( isset($this->Data["Series"]) ) { $ID = count($this->Data["Series"]); } else { $ID = 0; }
586
+        if ( isset($this->Data["Series"]) ) { $ID = count($this->Data["Series"]); } else { $ID = 0; }
587 587
 
588
-     $this->Data["Series"][$Serie]["Description"]	= $Serie;
589
-     $this->Data["Series"][$Serie]["isDrawable"]	= TRUE;
590
-     $this->Data["Series"][$Serie]["Picture"]		= NULL;
591
-     $this->Data["Series"][$Serie]["Max"]		= NULL;
592
-     $this->Data["Series"][$Serie]["Min"]		= NULL;
593
-     $this->Data["Series"][$Serie]["Axis"]		= 0;
594
-     $this->Data["Series"][$Serie]["Ticks"]		= 0;
595
-     $this->Data["Series"][$Serie]["Weight"]		= 0;
596
-     $this->Data["Series"][$Serie]["Shape"]		= SERIE_SHAPE_FILLEDCIRCLE;
588
+        $this->Data["Series"][$Serie]["Description"]	= $Serie;
589
+        $this->Data["Series"][$Serie]["isDrawable"]	= TRUE;
590
+        $this->Data["Series"][$Serie]["Picture"]		= NULL;
591
+        $this->Data["Series"][$Serie]["Max"]		= NULL;
592
+        $this->Data["Series"][$Serie]["Min"]		= NULL;
593
+        $this->Data["Series"][$Serie]["Axis"]		= 0;
594
+        $this->Data["Series"][$Serie]["Ticks"]		= 0;
595
+        $this->Data["Series"][$Serie]["Weight"]		= 0;
596
+        $this->Data["Series"][$Serie]["Shape"]		= SERIE_SHAPE_FILLEDCIRCLE;
597 597
 
598
-     if ( isset($this->Palette[$ID]) )
599
-      $this->Data["Series"][$Serie]["Color"] = $this->Palette[$ID];
600
-     else
601
-      {
602
-       $this->Data["Series"][$Serie]["Color"]["R"] = rand(0,255);
603
-       $this->Data["Series"][$Serie]["Color"]["G"] = rand(0,255);
604
-       $this->Data["Series"][$Serie]["Color"]["B"] = rand(0,255);
605
-       $this->Data["Series"][$Serie]["Color"]["Alpha"] = 100;
606
-      }
598
+        if ( isset($this->Palette[$ID]) )
599
+        $this->Data["Series"][$Serie]["Color"] = $this->Palette[$ID];
600
+        else
601
+        {
602
+        $this->Data["Series"][$Serie]["Color"]["R"] = rand(0,255);
603
+        $this->Data["Series"][$Serie]["Color"]["G"] = rand(0,255);
604
+        $this->Data["Series"][$Serie]["Color"]["B"] = rand(0,255);
605
+        $this->Data["Series"][$Serie]["Color"]["Alpha"] = 100;
606
+        }
607 607
     }
608 608
      
609
-   function normalize($NormalizationFactor=100,$UnitChange=NULL,$Round=1)
609
+    function normalize($NormalizationFactor=100,$UnitChange=NULL,$Round=1)
610 610
     {
611
-     $Abscissa = $this->Data["Abscissa"];
611
+        $Abscissa = $this->Data["Abscissa"];
612 612
 
613
-     $SelectedSeries = "";
614
-     $MaxVal         = 0;
615
-     foreach($this->Data["Axis"] as $AxisID => $Axis)
616
-      {
617
-       if ( $UnitChange != NULL ) { $this->Data["Axis"][$AxisID]["Unit"] = $UnitChange; }
613
+        $SelectedSeries = "";
614
+        $MaxVal         = 0;
615
+        foreach($this->Data["Axis"] as $AxisID => $Axis)
616
+        {
617
+        if ( $UnitChange != NULL ) { $this->Data["Axis"][$AxisID]["Unit"] = $UnitChange; }
618 618
 
619
-       foreach($this->Data["Series"] as $SerieName => $Serie)
619
+        foreach($this->Data["Series"] as $SerieName => $Serie)
620 620
         {
621
-         if ($Serie["Axis"] == $AxisID && $Serie["isDrawable"] == TRUE && $SerieName != $Abscissa)
622
-          {
623
-           $SelectedSeries[$SerieName] = $SerieName;
621
+            if ($Serie["Axis"] == $AxisID && $Serie["isDrawable"] == TRUE && $SerieName != $Abscissa)
622
+            {
623
+            $SelectedSeries[$SerieName] = $SerieName;
624 624
 
625
-           if ( count($Serie["Data"] ) > $MaxVal ) { $MaxVal = count($Serie["Data"]); }
626
-          }
625
+            if ( count($Serie["Data"] ) > $MaxVal ) { $MaxVal = count($Serie["Data"]); }
626
+            }
627
+        }
627 628
         }
628
-      }
629 629
 
630
-     for($i=0;$i<=$MaxVal-1;$i++)
631
-      {
632
-       $Factor = 0;
633
-       foreach ($SelectedSeries as $Key => $SerieName )
630
+        for($i=0;$i<=$MaxVal-1;$i++)
634 631
         {
635
-         $Value = $this->Data["Series"][$SerieName]["Data"][$i];
636
-         if ( $Value != VOID )
637
-          $Factor = $Factor + abs($Value);
632
+        $Factor = 0;
633
+        foreach ($SelectedSeries as $Key => $SerieName )
634
+        {
635
+            $Value = $this->Data["Series"][$SerieName]["Data"][$i];
636
+            if ( $Value != VOID )
637
+            $Factor = $Factor + abs($Value);
638 638
         }
639 639
 
640
-       if ( $Factor != 0 )
640
+        if ( $Factor != 0 )
641 641
         {
642
-         $Factor = $NormalizationFactor / $Factor;
642
+            $Factor = $NormalizationFactor / $Factor;
643 643
 
644
-         foreach ($SelectedSeries as $Key => $SerieName )
645
-          {
646
-           $Value = $this->Data["Series"][$SerieName]["Data"][$i];
644
+            foreach ($SelectedSeries as $Key => $SerieName )
645
+            {
646
+            $Value = $this->Data["Series"][$SerieName]["Data"][$i];
647 647
 
648
-           if ( $Value != VOID && $Factor != $NormalizationFactor )
648
+            if ( $Value != VOID && $Factor != $NormalizationFactor )
649 649
             $this->Data["Series"][$SerieName]["Data"][$i] = round(abs($Value)*$Factor,$Round);
650
-           elseif ( $Value == VOID || $Value == 0 )
650
+            elseif ( $Value == VOID || $Value == 0 )
651 651
             $this->Data["Series"][$SerieName]["Data"][$i] = VOID;
652
-           elseif ( $Factor == $NormalizationFactor )
652
+            elseif ( $Factor == $NormalizationFactor )
653 653
             $this->Data["Series"][$SerieName]["Data"][$i] = $NormalizationFactor;
654
-          }
654
+            }
655
+        }
655 656
         }
656
-      }
657 657
 
658
-     foreach ($SelectedSeries as $Key => $SerieName )
659
-      {
660
-       $this->Data["Series"][$SerieName]["Max"] = max($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
661
-       $this->Data["Series"][$SerieName]["Min"] = min($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
662
-      }
658
+        foreach ($SelectedSeries as $Key => $SerieName )
659
+        {
660
+        $this->Data["Series"][$SerieName]["Max"] = max($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
661
+        $this->Data["Series"][$SerieName]["Min"] = min($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
662
+        }
663 663
     }
664 664
 
665
-   /* Load data from a CSV (or similar) data source */
666
-   function importFromCSV($FileName,$Options="")
665
+    /* Load data from a CSV (or similar) data source */
666
+    function importFromCSV($FileName,$Options="")
667 667
     {
668
-     $Delimiter		= isset($Options["Delimiter"]) ? $Options["Delimiter"] : ",";
669
-     $GotHeader		= isset($Options["GotHeader"]) ? $Options["GotHeader"] : FALSE;
670
-     $SkipColumns	= isset($Options["SkipColumns"]) ? $Options["SkipColumns"] : array(-1);
671
-     $DefaultSerieName	= isset($Options["DefaultSerieName"]) ? $Options["DefaultSerieName"] : "Serie";
668
+        $Delimiter		= isset($Options["Delimiter"]) ? $Options["Delimiter"] : ",";
669
+        $GotHeader		= isset($Options["GotHeader"]) ? $Options["GotHeader"] : FALSE;
670
+        $SkipColumns	= isset($Options["SkipColumns"]) ? $Options["SkipColumns"] : array(-1);
671
+        $DefaultSerieName	= isset($Options["DefaultSerieName"]) ? $Options["DefaultSerieName"] : "Serie";
672 672
 
673
-     $Handle = @fopen($FileName,"r");
674
-     if ($Handle)
675
-      {
676
-       $HeaderParsed = FALSE; $SerieNames = "";
677
-       while (!feof($Handle))
673
+        $Handle = @fopen($FileName,"r");
674
+        if ($Handle)
678 675
         {
679
-         $Buffer = fgets($Handle, 4096);
680
-         $Buffer = str_replace(chr(10),"",$Buffer);
681
-         $Buffer = str_replace(chr(13),"",$Buffer);
682
-         $Values = preg_split("/".$Delimiter."/",$Buffer);
676
+        $HeaderParsed = FALSE; $SerieNames = "";
677
+        while (!feof($Handle))
678
+        {
679
+            $Buffer = fgets($Handle, 4096);
680
+            $Buffer = str_replace(chr(10),"",$Buffer);
681
+            $Buffer = str_replace(chr(13),"",$Buffer);
682
+            $Values = preg_split("/".$Delimiter."/",$Buffer);
683 683
 
684
-         if ( $Buffer != "" )
685
-          {
686
-           if ( $GotHeader && !$HeaderParsed )
684
+            if ( $Buffer != "" )
685
+            {
686
+            if ( $GotHeader && !$HeaderParsed )
687 687
             {
688
-             foreach($Values as $Key => $Name) { if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $Name; } }
689
-             $HeaderParsed = TRUE;
688
+                foreach($Values as $Key => $Name) { if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $Name; } }
689
+                $HeaderParsed = TRUE;
690 690
             }
691
-           else
691
+            else
692 692
             {
693
-             if ($SerieNames == "" ) { foreach($Values as $Key => $Name) {  if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $DefaultSerieName.$Key; } } }
694
-             foreach($Values as $Key => $Value) {  if ( !in_array($Key,$SkipColumns) ) { $this->addPoints($Value,$SerieNames[$Key]); } }
693
+                if ($SerieNames == "" ) { foreach($Values as $Key => $Name) {  if ( !in_array($Key,$SkipColumns) ) { $SerieNames[$Key] = $DefaultSerieName.$Key; } } }
694
+                foreach($Values as $Key => $Value) {  if ( !in_array($Key,$SkipColumns) ) { $this->addPoints($Value,$SerieNames[$Key]); } }
695 695
             }
696
-          }
696
+            }
697
+        }
698
+        fclose($Handle);
697 699
         }
698
-       fclose($Handle);
699
-      }
700 700
     }
701 701
 
702
-   /* Create a dataset based on a formula */
703
-   function createFunctionSerie($SerieName,$Formula="",$Options="")
702
+    /* Create a dataset based on a formula */
703
+    function createFunctionSerie($SerieName,$Formula="",$Options="")
704 704
     {
705
-     $MinX		= isset($Options["MinX"]) ? $Options["MinX"] : -10;
706
-     $MaxX		= isset($Options["MaxX"]) ? $Options["MaxX"] : 10;
707
-     $XStep		= isset($Options["XStep"]) ? $Options["XStep"] : 1;
708
-     $AutoDescription	= isset($Options["AutoDescription"]) ? $Options["AutoDescription"] : FALSE;
709
-     $RecordAbscissa	= isset($Options["RecordAbscissa"]) ? $Options["RecordAbscissa"] : FALSE;
710
-     $AbscissaSerie	= isset($Options["AbscissaSerie"]) ? $Options["AbscissaSerie"] : "Abscissa";
705
+        $MinX		= isset($Options["MinX"]) ? $Options["MinX"] : -10;
706
+        $MaxX		= isset($Options["MaxX"]) ? $Options["MaxX"] : 10;
707
+        $XStep		= isset($Options["XStep"]) ? $Options["XStep"] : 1;
708
+        $AutoDescription	= isset($Options["AutoDescription"]) ? $Options["AutoDescription"] : FALSE;
709
+        $RecordAbscissa	= isset($Options["RecordAbscissa"]) ? $Options["RecordAbscissa"] : FALSE;
710
+        $AbscissaSerie	= isset($Options["AbscissaSerie"]) ? $Options["AbscissaSerie"] : "Abscissa";
711 711
 
712
-     if ( $Formula == "" ) { return(0); }
712
+        if ( $Formula == "" ) { return(0); }
713 713
 
714
-     $Result = ""; $Abscissa = "";
715
-     for($i=$MinX; $i<=$MaxX; $i=$i+$XStep)
716
-      {
717
-       $Expression = "\$return = '!'.(".str_replace("z",$i,$Formula).");";
718
-       if ( @eval($Expression) === FALSE ) { $return = VOID; }
719
-       if ( $return == "!" ) { $return = VOID; } else { $return = $this->right($return,strlen($return)-1); }
720
-       if ( $return == "NAN" ) { $return = VOID; }
721
-       if ( $return == "INF" ) { $return = VOID; }
722
-       if ( $return == "-INF" ) { $return = VOID; }
723
-
724
-       $Abscissa[] = $i;
725
-       $Result[]   = $return;
726
-      }
714
+        $Result = ""; $Abscissa = "";
715
+        for($i=$MinX; $i<=$MaxX; $i=$i+$XStep)
716
+        {
717
+        $Expression = "\$return = '!'.(".str_replace("z",$i,$Formula).");";
718
+        if ( @eval($Expression) === FALSE ) { $return = VOID; }
719
+        if ( $return == "!" ) { $return = VOID; } else { $return = $this->right($return,strlen($return)-1); }
720
+        if ( $return == "NAN" ) { $return = VOID; }
721
+        if ( $return == "INF" ) { $return = VOID; }
722
+        if ( $return == "-INF" ) { $return = VOID; }
723
+
724
+        $Abscissa[] = $i;
725
+        $Result[]   = $return;
726
+        }
727 727
 
728
-     $this->addPoints($Result,$SerieName);
729
-     if ( $AutoDescription ) { $this->setSerieDescription($SerieName,$Formula); }
730
-     if ( $RecordAbscissa ) { $this->addPoints($Abscissa,$AbscissaSerie); }
728
+        $this->addPoints($Result,$SerieName);
729
+        if ( $AutoDescription ) { $this->setSerieDescription($SerieName,$Formula); }
730
+        if ( $RecordAbscissa ) { $this->addPoints($Abscissa,$AbscissaSerie); }
731 731
     }
732 732
 
733
-   function negateValues($Series)
733
+    function negateValues($Series)
734 734
     {
735
-     if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
736
-     foreach($Series as $Key => $SerieName)
737
-      {
738
-       if (isset($this->Data["Series"][$SerieName]))
735
+        if ( !is_array($Series) ) { $Series = $this->convertToArray($Series); }
736
+        foreach($Series as $Key => $SerieName)
737
+        {
738
+        if (isset($this->Data["Series"][$SerieName]))
739 739
         {
740
-         $Data = "";
741
-         foreach($this->Data["Series"][$SerieName]["Data"] as $Key => $Value)
742
-          { if ( $Value == VOID ) { $Data[] = VOID; } else { $Data[] = -$Value; } }
743
-         $this->Data["Series"][$SerieName]["Data"] = $Data;
740
+            $Data = "";
741
+            foreach($this->Data["Series"][$SerieName]["Data"] as $Key => $Value)
742
+            { if ( $Value == VOID ) { $Data[] = VOID; } else { $Data[] = -$Value; } }
743
+            $this->Data["Series"][$SerieName]["Data"] = $Data;
744 744
 
745
-         $this->Data["Series"][$SerieName]["Max"] = max($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
746
-         $this->Data["Series"][$SerieName]["Min"] = min($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
745
+            $this->Data["Series"][$SerieName]["Max"] = max($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
746
+            $this->Data["Series"][$SerieName]["Min"] = min($this->stripVOID($this->Data["Series"][$SerieName]["Data"]));
747
+        }
747 748
         }
748
-      }
749 749
     }
750 750
 
751
-   /* Return the data & configuration of the series */
752
-   function getData()
751
+    /* Return the data & configuration of the series */
752
+    function getData()
753 753
     { return($this->Data); }
754 754
 
755
-   /* Save a palette element */
756
-   function savePalette($ID,$Color)
755
+    /* Save a palette element */
756
+    function savePalette($ID,$Color)
757 757
     { $this->Palette[$ID] = $Color; }
758 758
 
759
-   /* Return the palette of the series */
760
-   function getPalette()
759
+    /* Return the palette of the series */
760
+    function getPalette()
761 761
     { return($this->Palette); }
762 762
 
763
-   /* Called by the scaling algorithm to save the config */
764
-   function saveAxisConfig($Axis) { $this->Data["Axis"]=$Axis; }
763
+    /* Called by the scaling algorithm to save the config */
764
+    function saveAxisConfig($Axis) { $this->Data["Axis"]=$Axis; }
765 765
 
766
-   /* Save the Y Margin if set */
767
-   function saveYMargin($Value) { $this->Data["YMargin"]=$Value; }
766
+    /* Save the Y Margin if set */
767
+    function saveYMargin($Value) { $this->Data["YMargin"]=$Value; }
768 768
 
769
-   /* Save extended configuration to the pData object */
770
-   function saveExtendedData($Tag,$Values) { $this->Data["Extended"][$Tag]=$Values; }
769
+    /* Save extended configuration to the pData object */
770
+    function saveExtendedData($Tag,$Values) { $this->Data["Extended"][$Tag]=$Values; }
771 771
 
772
-   /* Called by the scaling algorithm to save the orientation of the scale */
773
-   function saveOrientation($Orientation) { $this->Data["Orientation"]=$Orientation; }
772
+    /* Called by the scaling algorithm to save the orientation of the scale */
773
+    function saveOrientation($Orientation) { $this->Data["Orientation"]=$Orientation; }
774 774
 
775
-   /* Convert a string to a single elements array */
776
-   function convertToArray($Value)
775
+    /* Convert a string to a single elements array */
776
+    function convertToArray($Value)
777 777
     { $Values = ""; $Values[] = $Value; return($Values); }
778 778
 
779
-   /* Class string wrapper */
780
-   function __toString()
779
+    /* Class string wrapper */
780
+    function __toString()
781 781
     { return("pData object."); }
782 782
 
783
-   function left($value,$NbChar)	{ return substr($value,0,$NbChar); }  
784
-   function right($value,$NbChar)	{ return substr($value,strlen($value)-$NbChar,$NbChar); }  
785
-   function mid($value,$Depart,$NbChar)	{ return substr($value,$Depart-1,$NbChar); }  
786
-  }
783
+    function left($value,$NbChar)	{ return substr($value,0,$NbChar); }  
784
+    function right($value,$NbChar)	{ return substr($value,strlen($value)-$NbChar,$NbChar); }  
785
+    function mid($value,$Depart,$NbChar)	{ return substr($value,$Depart-1,$NbChar); }  
786
+    }
787 787
 ?>
788 788
\ No newline at end of file
Please login to merge, or discard this patch.