diff options
| author | Pim van den Berg | 2014-03-23 12:24:45 +0100 |
|---|---|---|
| committer | Pim van den Berg | 2014-03-23 12:29:05 +0100 |
| commit | b85a1526bdafe7af5f4d7af17b5599da09efccbc (patch) | |
| tree | b6013e8cc56f83a389e4886ad03c69157d8e59a3 | |
| parent | plugin/aggregation: cpu: allow 4 digits (diff) | |
| download | apt-panopticon_cgp-b85a1526bdafe7af5f4d7af17b5599da09efccbc.zip apt-panopticon_cgp-b85a1526bdafe7af5f4d7af17b5599da09efccbc.tar.gz apt-panopticon_cgp-b85a1526bdafe7af5f4d7af17b5599da09efccbc.tar.bz2 apt-panopticon_cgp-b85a1526bdafe7af5f4d7af17b5599da09efccbc.tar.xz | |
add SVG graph support
| -rw-r--r-- | .htaccess | 7 | ||||
| -rw-r--r-- | conf/config.php | 2 | ||||
| -rw-r--r-- | type/Default.class.php | 23 |
3 files changed, 25 insertions, 7 deletions
| @@ -1,9 +1,10 @@ | |||
| 1 | Options -Indexes | 1 | Options -Indexes |
| 2 | 2 | ||
| 3 | <IfModule mod_deflate.c> | 3 | <IfModule mod_deflate.c> |
| 4 | <Files "rrd.php"> | 4 | AddOutputFilterByType DEFLATE image/svg+xml |
| 5 | SetOutputFilter DEFLATE | 5 | <Files "rrd.php"> |
| 6 | </Files> | 6 | SetOutputFilter DEFLATE |
| 7 | </Files> | ||
| 7 | </IfModule> | 8 | </IfModule> |
| 8 | 9 | ||
| 9 | RewriteEngine On | 10 | RewriteEngine On |
diff --git a/conf/config.php b/conf/config.php index ffa42cf..b9a5098 100644 --- a/conf/config.php +++ b/conf/config.php | |||
| @@ -42,7 +42,7 @@ $CONFIG['term'] = array( | |||
| 42 | # show graphs in bits or bytes | 42 | # show graphs in bits or bytes |
| 43 | $CONFIG['network_datasize'] = 'bytes'; | 43 | $CONFIG['network_datasize'] = 'bytes'; |
| 44 | 44 | ||
| 45 | # "png", "canvas" or "hybrid" (canvas on detail page, png on the others) graphs | 45 | # "png", "svg", "canvas" or "hybrid" (canvas on detail page, png on the others) graphs |
| 46 | $CONFIG['graph_type'] = 'png'; | 46 | $CONFIG['graph_type'] = 'png'; |
| 47 | 47 | ||
| 48 | # For canvas graphs, use 'async' or 'sync' fetch method | 48 | # For canvas graphs, use 'async' or 'sync' fetch method |
diff --git a/type/Default.class.php b/type/Default.class.php index 909ac32..91f557f 100644 --- a/type/Default.class.php +++ b/type/Default.class.php | |||
| @@ -196,6 +196,14 @@ class Type_Default { | |||
| 196 | print_r($graphdata); | 196 | print_r($graphdata); |
| 197 | print '</pre>'; | 197 | print '</pre>'; |
| 198 | break; | 198 | break; |
| 199 | case 'svg': | ||
| 200 | # caching | ||
| 201 | if (is_numeric($this->cache) && $this->cache > 0) | ||
| 202 | header("Expires: " . date(DATE_RFC822,strtotime($this->cache." seconds"))); | ||
| 203 | header("content-type: image/svg+xml"); | ||
| 204 | $graphdata = implode(' ', $graphdata); | ||
| 205 | echo `$graphdata`; | ||
| 206 | break; | ||
| 199 | case 'png': | 207 | case 'png': |
| 200 | default: | 208 | default: |
| 201 | # caching | 209 | # caching |
| @@ -209,9 +217,18 @@ class Type_Default { | |||
| 209 | } | 217 | } |
| 210 | 218 | ||
| 211 | function rrd_options() { | 219 | function rrd_options() { |
| 212 | if ($this->graph_type != 'canvas') { | 220 | switch ($this->graph_type) { |
| 213 | $rrdgraph[] = $this->rrdtool; | 221 | case 'png': |
| 214 | $rrdgraph[] = 'graph - -a PNG'; | 222 | case 'hybrid': |
| 223 | $rrdgraph[] = $this->rrdtool; | ||
| 224 | $rrdgraph[] = 'graph - -a PNG'; | ||
| 225 | break; | ||
| 226 | case 'svg': | ||
| 227 | $rrdgraph[] = $this->rrdtool; | ||
| 228 | $rrdgraph[] = 'graph - -a SVG'; | ||
| 229 | break; | ||
| 230 | default: | ||
| 231 | break; | ||
| 215 | } | 232 | } |
| 216 | if ($this->rrdtool_opts != '') | 233 | if ($this->rrdtool_opts != '') |
| 217 | $rrdgraph[] = $this->rrdtool_opts; | 234 | $rrdgraph[] = $this->rrdtool_opts; |
