From edae75c21a8f657dd6cc9ace9e8e844ef337a951 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 3 May 2014 18:15:12 +0200 Subject: rename ds_names and dsname to legend This had nothing to do with an RRD data source. --- type/Base.class.php | 26 +++++++++++++------------- type/Default.class.php | 4 ++-- type/GenericIO.class.php | 4 ++-- type/GenericStacked.class.php | 4 ++-- type/Uptime.class.php | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) (limited to 'type') diff --git a/type/Base.class.php b/type/Base.class.php index e1aae19..7c06e5d 100644 --- a/type/Base.class.php +++ b/type/Base.class.php @@ -11,7 +11,7 @@ class Type_Base { var $seconds; var $data_sources = array('value'); var $order; - var $ds_names; + var $legend; var $colors; var $rrd_title; var $rrd_vertical; @@ -281,26 +281,26 @@ class Type_Base { $sources = $this->data_sources; } } - $this->parse_ds_names($sources); + $this->parse_legend($sources); return $sources; } - function parse_ds_names($sources) { - # fill ds_names if not defined by plugin - if (!is_array($this->ds_names)) - $this->ds_names = array_combine($sources, $sources); + function parse_legend($sources) { + # fill legend if not defined by plugin + if (!is_array($this->legend)) + $this->legend = array_combine($sources, $sources); - # detect length of longest ds_name + # detect length of longest legend $max = 0; - foreach ($this->ds_names as $ds_name) { - if(strlen((string)$ds_name) > $max) - $max = strlen((string)$ds_name); + foreach ($this->legend as $legend) { + if(strlen((string)$legend) > $max) + $max = strlen((string)$legend); } - # make all ds_names equal in lenght + # make all legend equal in lenght $format = sprintf("%%-%ds", $max); - foreach ($this->ds_names as $index => $value) { - $this->ds_names[$index] = sprintf($format, $value); + foreach ($this->legend as $index => $value) { + $this->legend[$index] = sprintf($format, $value); } } diff --git a/type/Default.class.php b/type/Default.class.php index 52827c2..9f3b97a 100644 --- a/type/Default.class.php +++ b/type/Default.class.php @@ -47,9 +47,9 @@ class Type_Default extends Type_Base { $c = 0; foreach ($sources as $source) { - $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors; - $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); + $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($legend)); $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format); diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php index df3a057..fac7034 100644 --- a/type/GenericIO.class.php +++ b/type/GenericIO.class.php @@ -56,8 +56,8 @@ class Type_GenericIO extends Type_Base { $i = 0; foreach($sources as $source) { - $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; - $rrdgraph[] = sprintf('"LINE1:avg_%s%s#%s:%s"', crc32hex($source), $i == 1 ? '_neg' : '', $this->colors[$source], $this->rrd_escape($dsname)); + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; + $rrdgraph[] = sprintf('"LINE1:avg_%s%s#%s:%s"', crc32hex($source), $i == 1 ? '_neg' : '', $this->colors[$source], $this->rrd_escape($legend)); $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format); diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php index 4a08c91..a74ff18 100644 --- a/type/GenericStacked.class.php +++ b/type/GenericStacked.class.php @@ -49,9 +49,9 @@ class Type_GenericStacked extends Type_Base { $c = 0; foreach ($sources as $source) { - $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors; - $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); + $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($legend)); $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format); $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format); diff --git a/type/Uptime.class.php b/type/Uptime.class.php index 3f8a01e..e57df0b 100644 --- a/type/Uptime.class.php +++ b/type/Uptime.class.php @@ -41,11 +41,11 @@ class Type_Uptime extends Type_Base { $c = 0; foreach ($sources as $source) { - $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors; //current value - $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); + $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($legend)); $rrdgraph[] = sprintf('"GPRINT:c_avg_%s:LAST:%s days\\l"', crc32hex($source), $this->rrd_format); //max value -- cgit v1.1