[rrd-users] rrd_graph: print scale and pixels info to allow cursor tooltip

Steve Shipway s.shipway at auckland.ac.nz
Mon Oct 28 23:20:55 CET 2013

> I am setting up a home website to display what is happening in and
> around the home. Much of which is based on rrd-graph. I was wishing
> to have a tooltip type display of the cursors position when the cursor
> is over an rrd_graph image
> When you use rrd_graph to produce an image it outputs the size of
> the generated image. However if it output a few more values:

I have done something like this in the Routers2 MRTG frontend.  The way I managed it was a little awkward, though.

You already have the X and Y sizes of the whole image; you also have the X and Y sizes of the graph part as you pass these as a parameter when calling rrd_graph.  

The sizes of the various margins depend on two things - your axis options passed to the function, and the version of RRDTool library you're using (the margin width changed in 1.3 slightly).  From these, you can deduce the pixel coordinate of the graph origin, and the righthand limit - and from this, the seconds-per-pixel count along the X-axis as well as the pixels-per-cdp.  I've found that I can be off by one or even 2 pixels under some circumstances, though, depending on browser and image size.

The extra values would definitely be useful for this sort of application, though if you rely on them, you're killing your backwards compatibility between RRDtool versions a bit.


Steve Shipway
ITS Unix Services Design Lead
University of Auckland, New Zealand
Floor 1, 58 Symonds Street, Auckland
Phone: +64 (0)9 3737599 ext 86487
DDI: +64 (0)9 923 6487
Mobile: +64 (0)21 753 189
Email: s.shipway at auckland.ac.nz
 Please consider the environment before printing this e-mail : 打印本邮件,将减少一棵树存活的机会

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 5900 bytes
Desc: not available
Url : http://lists.oetiker.ch/pipermail/rrd-users/attachments/20131028/6945f688/attachment.bin 

More information about the rrd-users mailing list