Doc #60125 [Fbk->NoF]: Incorrect OOP example for rrd graphs
| From: | frozenfire@php.net | Date: | Sat, 07 Jan 2012 18:26:19 +0000 |
| Subject: | Doc #60125 [Fbk->NoF]: Incorrect OOP example for rrd graphs | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-7741@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=60125&edit=1
ID: 60125
Updated by: frozenfire@php.net
Reported by: jeff at freethoughtdesign dot com
Summary: Incorrect OOP example for rrd graphs
-Status: Feedback
+Status: No Feedback
Type: Documentation Problem
Package: rrd
Operating System: OS X
PHP Version: Irrelevant
Assigned To: frozenfire
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2011-12-04 01:28:30] frozenfire@php.net
Could you please try changing your OOP version so that settings like "--slope-
mode" have a value, instead of having the option as the value.
For instance, use "--slope-mode" => true and "--full-size-mode" => true.
The reason I ask this is that the code for setOption in the rrd extension source
uses a particular method to figure out which style you're using, which may screw
up when you switch back and forth.
------------------------------------------------------------------------
[2011-10-24 23:58:44] jeff at freethoughtdesign dot com
Description:
------------
The OOP example (http://www.php.net/manual/en/rrd.examples-oop.php) suggests that options to the
RRDGraph be set as key:value pairs, and that works for some options, but it did not work for --color
options until I used the syntax found on the procedural example page here: http://www.php.net/manual/en/rrd.examples-procedural.php
The key:value syntax makes a bit more sense to me, but either way it seems like it should be
consistent.
The following only partially worked - the color settings had no effect:
<?php
$img->setOptions(
array(
"--start" => time() - 3600,
"--end" => time(),
"--vertical-label" => "Watts",
"--slope-mode",
"--title" => "Power Usage",
"--width" => "600",
"--height" => "300",
"--y-grid" => "100:5",
"--units-exponent" => "0",
"--full-size-mode",
"--color" => "BACK#FAF8CC",
"--color" => "CANVAS#6D7B8D",
"--color" => "MGRID#00ff00",
"--color" => "GRID#E8E8E8",
"--color" => "FONT#153E7E",
"--color" => "AXIS#00ff00",
"--color" => "ARROW#00ff00",
"--color" => "SHADEA#000000",
"--color" => "SHADEB#000000",
"DEF:Watt=$rrd_file:watts:AVERAGE",
"CDEF:Low=Watt,0,1000,LIMIT",
"CDEF:Mid=Watt,1000,2000,LIMIT",
"CDEF:High=Watt,2000,3500,LIMIT",
"CDEF:VHigh=Watt,3500,15000,LIMIT",
"AREA:Low#00ff00:0-1000",
"AREA:Mid#ffbf00:1000-2000",
"AREA:High#FF0000:2000-3500",
"AREA:VHigh#ffffff:> 3500\c",
"COMMENT: \l",
"GPRINT:Watt:LAST:Current\: %4.1lf Watts",
"GPRINT:Watt:AVERAGE:Average\: %4.1lf Watts"
)
);
?>
In this version, based on the syntax in the procedural example, the graph colors worked correctly:
<?php
$img->setOptions(
array(
"--start", time() - 3600,
"--end", time(),
"--vertical-label", "Watts",
"--slope-mode",
"--title", "Power Usage",
"--width", "600",
"--height", "300",
"--y-grid", "100:5",
"--units-exponent", "0",
"--full-size-mode",
"--color", "BACK#FAF8CC",
"--color", "CANVAS#6D7B8D",
"--color", "MGRID#00ff00",
"--color", "GRID#E8E8E8",
"--color", "FONT#153E7E",
"--color", "AXIS#00ff00",
"--color", "ARROW#00ff00",
"--color", "SHADEA#000000",
"--color", "SHADEB#000000",
"DEF:Watt=$rrd_file:watts:AVERAGE",
"CDEF:Low=Watt,0,1000,LIMIT",
"CDEF:Mid=Watt,1000,2000,LIMIT",
"CDEF:High=Watt,2000,3500,LIMIT",
"CDEF:VHigh=Watt,3500,15000,LIMIT",
"AREA:Low#00ff00:0-1000",
"AREA:Mid#ffbf00:1000-2000",
"AREA:High#FF0000:2000-3500",
"AREA:VHigh#ffffff:> 3500\c",
"COMMENT: \l",
"GPRINT:Watt:LAST:Current\: %4.1lf Watts",
"GPRINT:Watt:AVERAGE:Average\: %4.1lf Watts"
)
);
?>
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=60125&edit=1