Doc #60125 [NEW]: Incorrect OOP example for rrd graphs
| From: | jeff at freethoughtdesign dot com | Date: | Mon, 24 Oct 2011 23:58:45 +0000 |
| Subject: | Doc #60125 [NEW]: Incorrect OOP example for rrd graphs | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-7348@lists.php.net to get a copy of this message | ||
From:
Operating system: OS X
PHP version: Irrelevant
Package: rrd
Bug Type: Documentation Problem
Bug description:Incorrect OOP example for rrd graphs
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 bug report at https://bugs.php.net/bug.php?id=60125&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=60125&r=trysnapshot54
Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=60125&r=trysnapshot53
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=60125&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=60125&r=fixed
Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=60125&r=needdocs
Fixed in release: https://bugs.php.net/fix.php?id=60125&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=60125&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=60125&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=60125&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=60125&r=support
Expected behavior: https://bugs.php.net/fix.php?id=60125&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=60125&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=60125&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=60125&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=60125&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=60125&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=60125&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=60125&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=60125&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=60125&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=60125&r=mysqlcfg