diff options
Diffstat (limited to 'type/Default.class.php')
-rw-r--r-- | type/Default.class.php | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/type/Default.class.php b/type/Default.class.php index 0eab459..48460f3 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
@@ -32,6 +32,30 @@ class Type_Default { | |||
32 | $this->identifiers = $this->file2identifier($this->files); | 32 | $this->identifiers = $this->file2identifier($this->files); |
33 | } | 33 | } |
34 | 34 | ||
35 | function generate_colors() { | ||
36 | $base = array( array(255, 0, 0), | ||
37 | array( 0, 255, 0), | ||
38 | array( 0, 0, 255), | ||
39 | array(255, 120, 0), | ||
40 | array(255, 0, 120), | ||
41 | array( 0, 255, 120), | ||
42 | array(120, 255, 0), | ||
43 | array(120, 0, 255), | ||
44 | array( 0, 120, 255)); | ||
45 | |||
46 | $this->colors = array(); | ||
47 | $n = 0; | ||
48 | $p = 0; | ||
49 | foreach($base as $b) { | ||
50 | $n = $p; | ||
51 | for($i = 100; $i >= 20; $i -= 30) { | ||
52 | $this->colors[$n] = sprintf('%02x%02x%02x', $b[0] * $i / 100, $b[1] * $i / 100, $b[2] * $i / 100); | ||
53 | $n += count($base); | ||
54 | } | ||
55 | $p++; | ||
56 | } | ||
57 | } | ||
58 | |||
35 | # parse $_GET values | 59 | # parse $_GET values |
36 | function parse_get() { | 60 | function parse_get() { |
37 | $this->args = array( | 61 | $this->args = array( |
@@ -204,16 +228,19 @@ class Type_Default { | |||
204 | } | 228 | } |
205 | 229 | ||
206 | if(count($this->files)<=1) { | 230 | if(count($this->files)<=1) { |
231 | $c = 0; | ||
207 | foreach ($sources as $source) { | 232 | foreach ($sources as $source) { |
208 | $rrdgraph[] = sprintf('AREA:max_%s#%s', crc32hex($source), $this->get_faded_color($this->colors[$source])); | 233 | $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors; |
234 | $rrdgraph[] = sprintf('AREA:max_%s#%s', crc32hex($source), $this->get_faded_color($color)); | ||
209 | $rrdgraph[] = sprintf('AREA:min_%s#%s', crc32hex($source), 'ffffff'); | 235 | $rrdgraph[] = sprintf('AREA:min_%s#%s', crc32hex($source), 'ffffff'); |
210 | break; # only 1 area to draw | 236 | break; # only 1 area to draw |
211 | } | 237 | } |
212 | } | 238 | } |
213 | 239 | ||
240 | $c = 0; | ||
214 | foreach ($sources as $source) { | 241 | foreach ($sources as $source) { |
215 | $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; | 242 | $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; |
216 | $color = is_array($this->colors) ? $this->colors[$source]: $this->colors; | 243 | $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors; |
217 | $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $dsname); | 244 | $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $dsname); |
218 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format); | 245 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format); |
219 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format); | 246 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format); |