in reply to GD::Graph creating a clustered bar chart while some dataset are cumulative

Is this possible using GD:Graph?

No. There is no facility in the module for that.

If not, is there a workaround to get this done?

A work-around would be to give datasets A & B different X values to datasets C & D and use custom labels to tie them together.

Ie. If (say) for April the values were: a(4,10), b(4,12), c(4,3), d(4,7) then adjust them so that they become a(3.75,10),b(3.75,12), c(4.25,3), d(4.25,7).

That way, with cumulate enabled you should get:

25| | 20| B | B 15| B | B 10| A D | A D 5| A D | A C 0+------------------------------------------------- 1 2 3 4 5 6 7 8 9 10 11 12

Update: For hbar graphs it would be the Y values you adjust.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
  • Comment on Re: GD::Graph creating a clustered bar chart while some dataset are cumulative
  • Download Code

Replies are listed 'Best First'.
Re^2: GD::Graph creating a clustered bar chart while some dataset are cumulative
by huzefa52 (Novice) on Aug 28, 2013 at 04:02 UTC
    I Have tried with my below code as you have said, but its not working. Can you please help me and let me know where i am doing wrong.
    use GD::Graph::bars; use GD::Graph::hbars; require '/root/.cpan/build/GDGraph-1.48/samples/save.pl'; my @data = ( ["1st","2nd"], [ (3.75,10),(3.75,12) ], [ (4.25,3),(4.25,7) ], ); my @names = qw/sample15 sample15-h/; for my $my_graph (GD::Graph::bars->new, GD::Graph::hbars->new) { my $name = shift @names; print STDERR "Processing $name\n"; $my_graph->set( x_label => 'X Label', y_label => 'Y label', title => 'Stacked Bars (incremental)', #y_max_value => 50, #y_tick_number => 10, #y_label_skip => 2, cumulate => 4, overwrite => 1, borderclrs => $my_graph->{dclrs}, #cycle_clrs => 4, bar_spacing => 2, #shadow_depth => 4, transparent => 0, ); $my_graph->set_legend( qw(offset increment more)); $my_graph->plot(\@data); save_chart($my_graph, $name); }
      I Have tried with my below code as you have said, but its not working.

      I ran your code and it produced this and this which looks pretty much exactly how I envisioned it would.

      So, how is it "not working"?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        But i want multi-stacked graph, like you have said before i.e in my 1st set of x-axis it should contain both the bars, with different colors. i.e ABCD all with different colors in 1 set as your example shows ABCD all in 4th set.
        25| | 20| B | B 15| B | B 10| A D | A D 5| A D | A C 0+------------------------------------------------- 1 2 3 4 5 6 7 8 9 10 11 12