aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/type
diff options
context:
space:
mode:
authorPim van den Berg2010-09-17 21:24:35 +0200
committerPim van den Berg2010-09-17 21:24:35 +0200
commit10ad741a22797b6710be1091d9e502e71929f255 (patch)
treeedb5d5046eba5de647f12e8c9480faa054dd09f7 /type
parentplugin/nfs: clean up some duplicate code (diff)
downloadapt-panopticon_cgp-10ad741a22797b6710be1091d9e502e71929f255.zip
apt-panopticon_cgp-10ad741a22797b6710be1091d9e502e71929f255.tar.gz
apt-panopticon_cgp-10ad741a22797b6710be1091d9e502e71929f255.tar.bz2
apt-panopticon_cgp-10ad741a22797b6710be1091d9e502e71929f255.tar.xz
automatic alignment of graph legend
Function fill_ds_names is renamed to parse_ds_names and now also appends spaces to ds_names to make them equal of lenght.
Diffstat (limited to 'type')
-rw-r--r--type/Default.class.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/type/Default.class.php b/type/Default.class.php
index e4d3dec..57d0bf3 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -197,24 +197,26 @@ class Type_Default {
197 # use data_sources as sources 197 # use data_sources as sources
198 $sources = $this->data_sources; 198 $sources = $this->data_sources;
199 } 199 }
200 $this->fill_ds_names($sources); 200 $this->parse_ds_names($sources);
201 return $sources; 201 return $sources;
202 } 202 }
203 203
204 function fill_ds_names($sources) { 204 function parse_ds_names($sources) {
205 # fill ds_names if not defined by plugin
206 if (!is_array($this->ds_names))
207 $this->ds_names = array_combine($sources, $sources);
208
209 # detect length of longest ds_name
205 $max = 0; 210 $max = 0;
206 foreach ($sources as $source) { 211 foreach ($this->ds_names as $ds_name) {
207 if(strlen($source) > $max) { 212 if(strlen((string)$ds_name) > $max)
208 $max = strlen($source); 213 $max = strlen((string)$ds_name);
209 }
210 } 214 }
211 if($max > 0) { 215
212 $fmt = sprintf("%%-%ds", $max); 216 # make all ds_names equal in lenght
213 foreach ($sources as $source) { 217 $format = sprintf("%%-%ds", $max);
214 if(!isset($this->ds_names[$source])) { 218 foreach ($this->ds_names as $index => $value) {
215 $this->ds_names[$source] = sprintf($fmt, $source); 219 $this->ds_names[$index] = sprintf($format, $value);
216 }
217 }
218 } 220 }
219 } 221 }
220 222