From b85a1526bdafe7af5f4d7af17b5599da09efccbc Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sun, 23 Mar 2014 12:24:45 +0100 Subject: add SVG graph support --- .htaccess | 7 ++++--- conf/config.php | 2 +- type/Default.class.php | 23 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/.htaccess b/.htaccess index 889dfc6..7cb13ca 100644 --- a/.htaccess +++ b/.htaccess @@ -1,9 +1,10 @@ Options -Indexes - - SetOutputFilter DEFLATE - + AddOutputFilterByType DEFLATE image/svg+xml + + SetOutputFilter DEFLATE + 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( # show graphs in bits or bytes $CONFIG['network_datasize'] = 'bytes'; -# "png", "canvas" or "hybrid" (canvas on detail page, png on the others) graphs +# "png", "svg", "canvas" or "hybrid" (canvas on detail page, png on the others) graphs $CONFIG['graph_type'] = 'png'; # 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 { print_r($graphdata); print ''; break; + case 'svg': + # caching + if (is_numeric($this->cache) && $this->cache > 0) + header("Expires: " . date(DATE_RFC822,strtotime($this->cache." seconds"))); + header("content-type: image/svg+xml"); + $graphdata = implode(' ', $graphdata); + echo `$graphdata`; + break; case 'png': default: # caching @@ -209,9 +217,18 @@ class Type_Default { } function rrd_options() { - if ($this->graph_type != 'canvas') { - $rrdgraph[] = $this->rrdtool; - $rrdgraph[] = 'graph - -a PNG'; + switch ($this->graph_type) { + case 'png': + case 'hybrid': + $rrdgraph[] = $this->rrdtool; + $rrdgraph[] = 'graph - -a PNG'; + break; + case 'svg': + $rrdgraph[] = $this->rrdtool; + $rrdgraph[] = 'graph - -a SVG'; + break; + default: + break; } if ($this->rrdtool_opts != '') $rrdgraph[] = $this->rrdtool_opts; -- cgit v1.1