diff options
| author | Pim van den Berg | 2011-02-05 20:01:26 +0100 |
|---|---|---|
| committer | Pim van den Berg | 2011-02-05 20:01:26 +0100 |
| commit | b1e34bd1868be418ef5ec26683a8d07f22cebd51 (patch) | |
| tree | c4f7616f7159b71af7a1260b3e049af0fc29d507 /type/Default.class.php | |
| parent | plugin/dns: generate colors in type dns_opcode (diff) | |
| download | apt-panopticon_cgp-b1e34bd1868be418ef5ec26683a8d07f22cebd51.zip apt-panopticon_cgp-b1e34bd1868be418ef5ec26683a8d07f22cebd51.tar.gz apt-panopticon_cgp-b1e34bd1868be418ef5ec26683a8d07f22cebd51.tar.bz2 apt-panopticon_cgp-b1e34bd1868be418ef5ec26683a8d07f22cebd51.tar.xz | |
replace function generate_colors by rainbow_colors
When no colors are defined they will be generated by function rainbow_colors.
Diffstat (limited to 'type/Default.class.php')
| -rw-r--r-- | type/Default.class.php | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/type/Default.class.php b/type/Default.class.php index 57d0bf3..0930fe3 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
| @@ -34,27 +34,25 @@ class Type_Default { | |||
| 34 | $this->identifiers = $this->file2identifier($this->files); | 34 | $this->identifiers = $this->file2identifier($this->files); |
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | function generate_colors() { | 37 | function rainbow_colors() { |
| 38 | $base = array( array(255, 0, 0), | 38 | $sources = count($this->rrd_get_sources()); |
| 39 | array( 0, 255, 0), | 39 | foreach ($this->rrd_get_sources() as $ds) { |
| 40 | array( 0, 0, 255), | 40 | # hue (saturnation=1, value=1) |
| 41 | array(255, 120, 0), | 41 | $h = 360 - ($c * (330/($sources-1))); |
| 42 | array(255, 0, 120), | 42 | |
| 43 | array( 0, 255, 120), | 43 | $h = ($h %= 360) / 60; |
| 44 | array(120, 255, 0), | 44 | $f = $h - floor($h); |
| 45 | array(120, 0, 255), | 45 | $q[0] = $q[1] = 0; |
| 46 | array( 0, 120, 255)); | 46 | $q[2] = 1*(1-1*(1-$f)); |
| 47 | 47 | $q[3] = $q[4] = 1; | |
| 48 | $this->colors = array(); | 48 | $q[5] = 1*(1-1*$f); |
| 49 | $n = 0; | 49 | |
| 50 | $p = 0; | 50 | $hex = ''; |
| 51 | foreach($base as $b) { | 51 | foreach(array(4,2,0) as $j) { |
| 52 | $n = $p; | 52 | $hex .= sprintf('%02x', $q[(floor($h)+$j)%6] * 255); |
| 53 | for($i = 100; $i >= 20; $i -= 30) { | ||
| 54 | $this->colors[$n] = sprintf('%02x%02x%02x', $b[0] * $i / 100, $b[1] * $i / 100, $b[2] * $i / 100); | ||
| 55 | $n += count($base); | ||
| 56 | } | 53 | } |
| 57 | $p++; | 54 | $this->colors[$ds] = $hex; |
| 55 | $c++; | ||
| 58 | } | 56 | } |
| 59 | } | 57 | } |
| 60 | 58 | ||
| @@ -141,6 +139,9 @@ class Type_Default { | |||
| 141 | } | 139 | } |
| 142 | 140 | ||
| 143 | function rrd_graph($debug=false) { | 141 | function rrd_graph($debug=false) { |
| 142 | if (!$this->colors) | ||
| 143 | $this->rainbow_colors(); | ||
| 144 | |||
| 144 | $graphdata = $this->rrd_gen_graph(); | 145 | $graphdata = $this->rrd_gen_graph(); |
| 145 | 146 | ||
| 146 | if(!$debug) { | 147 | if(!$debug) { |
