PATCH: graph_image.php and gadgets

Anything that you think should be in Cacti.

Moderators: Developers, Moderators

Post Reply
User avatar
calh
Posts: 15
Joined: Mon Mar 09, 2009 12:32 pm
Location: Fargo, ND

PATCH: graph_image.php and gadgets

Post by calh »

Hi everyone,

I'm not sure where the best place to submit a patch is -- mailing list, or somewhere on the forum?

Anyway, I've been working on pulling in images directly from graph_image.php for use in some outside "web gadgets." I didn't need a title in the image since my web app already does this, and it was a real pain to try and shoehorn the resolution of the full image into a specific size of a div tag. (Since RRD is generating a graph based on the resolution of the data canvas, not the entire image with legend and stuff) If the resolution is off, the browser attempts to do a quick & dirty resize of the image which results in some nasty looking artifacts in the graphs.

I've added these options to graph_image.php:

graph_notitle=Y -- disable generation of the title in the graph. (Translates to the --title option on rrdgraph)

graph_full_size=Y -- the graph_width and graph_height resolutions specify the FINAL dimensions of the image, including title, legend, and rules. (Translates to the --full-size-mode option to rrdgraph)

This patch was created against Cacti 0.8.7g.

Thanks for your consideration into the official source! It would be handy to do upgrades and not have to manually apply my patch to new versions. ;-)
Attachments
cals_gadget.patch
Patch to graph_image.php and lib/rrd.php
(2.35 KiB) Downloaded 272 times
--Cal
User avatar
calh
Posts: 15
Joined: Mon Mar 09, 2009 12:32 pm
Location: Fargo, ND

Re: PATCH: graph_image.php and gadgets

Post by calh »

I can show a little example of this. Here's what it looked like before:
gadget_before.jpeg
gadget_before.jpeg (23.24 KiB) Viewed 4518 times
Some graphs look worse than others, but you can see artifacts in the title and legend text.

With my patch, and creating an image that matches the exact dimensions of the div around it, it's nice and clear:
gadget_after.jpeg
gadget_after.jpeg (28.93 KiB) Viewed 4518 times
Much cleaner looking! :D
--Cal
noname
Cacti Guru User
Posts: 1566
Joined: Thu Aug 05, 2010 2:04 am
Location: Japan

Re: PATCH: graph_image.php and gadgets

Post by noname »

Nice work! :D

Especially,
calh wrote:graph_full_size=Y -- the graph_width and graph_height resolutions specify the FINAL dimensions of the image, including title, legend, and rules. (Translates to the --full-size-mode option to rrdgraph)
thanks to this, I can place graphs like as "tile", regardless of plot area size.
(Notice: "--full-size-mode" option is available since RRDtool 1.3)

Here is a sample for my 24-port switch.
Image
(I added some "--color" options to 'rrd.php', and using customized graph template)
User avatar
calh
Posts: 15
Joined: Mon Mar 09, 2009 12:32 pm
Location: Fargo, ND

Re: PATCH: graph_image.php and gadgets

Post by calh »

Thanks!

I didn't realize that option was only available after RRD 1.3... I suppose a version check could be added, but then again, most new Cacti installs should be using the latest RRD tool as well.
--Cal
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: PATCH: graph_image.php and gadgets

Post by gandalf »

Many of this options are now implemented in TRUNK. I'm eagerly awaiting an alpha of this as I don't want to backport all those options. Many, many code changes ...
R.
User avatar
calh
Posts: 15
Joined: Mon Mar 09, 2009 12:32 pm
Location: Fargo, ND

Re: PATCH: graph_image.php and gadgets

Post by calh »

Oh did you already code this stuff, it just hadn't been released yet? Or did you add my patch to subversion?

I'll also be on the pulse of another Cacti release, as there are quite a few things I'm looking forward to for features / fixes.

Thank you!
--Cal
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: PATCH: graph_image.php and gadgets

Post by gandalf »

I didn't check your patch, to be honest. But I implemented virtually _every_ rrdtool graph option available with rrdtool 1.4.4. This has been done more than 6 months ago ...
R.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests