in reply to GD::Graph Issues

Unfortunately I don't have it installed locally, so I can't give you code, but look in the installation directory for a directory known as "samples". It should have a few dozen sample scripts demonstrating various uses of GD::Graph. As you run into coding issues, those are useful to look at.

Anyways the two options you list will both solve your problem. The "cumulate" option "stacks" bars. If your first data set is 21 high, while your second is 35, the first bar will go from 0 to 21 and the second from 21 to 56. The "overwrite" option is just what it says, the later bars are drawn over the previous ones. So the first bar is drawn to height 21, then the second to height 35, hiding (oops) all of the first bar. (Advice, draw the tallest bars first, then you just overwrite the bottom of the bar.)

If you have multiple data sets, which appear in the same order every time, this means that either can be used. (When I faced this, it was more convenient to use the overwrite option.) If A is sometimes taller than B and B is sometimes taller than A, then I suspect you will have a lot of work ahead of you. I am going to just hope that you don't face that and not answer that question. :-)

An incidental note. Should your boss notice the two_axes option, say it doesn't work. I found very serious bugs with that option, I came up with a fix, but the maintainer never responded to my email and it has never been patched. If anyone knows how to reach the module author, or if someone else winds up taking over maintainance (I have no such intentions) then I will gladly recontribute the patch, but in the meantime consider that feature seriously broken.

Replies are listed 'Best First'.
Re: Re (tilly) 1: GD::Graph Issues
by seanbo (Chaplain) on Jan 11, 2002 at 20:26 UTC
    YIKES! I was planning on using multiple axes in the near future. That is a bad thing for me. What were the 'serious bugs' you found? Would you mind sharing the patch so I can locally patch my module since you can't contact the module author? Thanks!

    perl -e 'print reverse qw/o b n a e s/;'
      The bug issue was that the two_axes option would, if you don't choose data ranges that are extremely "nice" relative to each other, dynamically make very bad choices and insert a huge number of ticks. My change makes it dynamically choose a much smarter range in parallel.

      The patch that I am posting here is to GD/Graph/axestype.pm. It improves this functionality, but not does not include corresponding documentation patches. (Those should be made in GD/Graph.pm.) It also enhances the y_tick_number option to allow it to take an anonymous array of numbers - it chooses the number of ticks that gives the best fit. The idea for this is based on the existing (undocumented) 'auto' option which corresponds to a range of 3 to 6 ticks. Allowing this results in massively better choices of ranges! (Try it, you will see.) You may wish to change the default value of y_tick_number accordingly.