#!/usr/bin/perl -w use strict; use GD::Graph::bars3d; use GD::Graph::Data; use GD::Graph::colour qw{ add_colour colour_list }; my $username = 'crazyinsomniac'; my $month = 'April'; my $year = '2002'; my @days = ( [1..30], [qw{ 10 1 -1 22 33 1 6 7 4 8 9 34 112 -2 -12 33 22 33 1 6 7 22 33 1 6 7 66 -66 0 1 }], ); my $graph = new GD::Graph::bars3d( 600, 400 ); add_colour('#66CC66'); add_colour('#00fbff'); add_colour('#000000'); $graph->set( y_label => 'XP change', # xp is not Reputation, thanks grinder x_label => 'DAY OF MONTH', box_axis => 1, x_tick_number => undef, # accentclr => '#000000', # this be the bar box edges accentclr => '#009999', # this be the bar box edges # dclrs => [ map{'#66CC66'} 1..@days ], # data color dclrs => [ map{'#00fbff'} 1..@days ], # data color title => "${username}'s XP gains/losses per day for $month, $year" ) or die "$!"; my $days = GD::Graph::Data->new(); $days->copy_from(\@days); $graph->set(show_values => 1 ); ## show values $graph->set_values_font(GD::gdMediumBoldFont); my $gd = $graph->plot( $days ); $gd->interlaced('true'); open(FOUT,'>'.__FILE__.'.png') or die $!; binmode(FOUT); print FOUT $gd->png; close(FOUT) #### #!/usr/bin/perl -w =head JC Graph This was written for chris, aka jcwren, the greatest isp on earth, in response to http://perlmonks.org/index.pl?node_id=171725 In particular, it was written to replace the baaad php chart generation counterpart for use at http://www.tinymicros.com/pm/index.php?goto=PlotChart&nodeid=10277 It mimicks the look pretty well, even though GD::Graph::bars3d does/can not guarantee spacing between the bars and the text. I say it looks pretty good. You can see for your self at http://crazyinsomniac.perlmonk.org/images/jcgraph.png =cut use strict; use GD::Graph::bars3d; use GD::Graph::Data; use GD::Graph::colour qw{ add_colour colour_list }; my $username = 'crazyinsomniac'; my $month = 'April'; my $year = '2002'; my @days = ( [1..30], [qw{ 10 1 -1 22 33 1 6 7 4 8 9 34 112 -2 -12 33 22 33 1 6 7 22 33 1 6 7 66 -66 0 1 }], ); my $graph = new GD::Graph::bars3d( 700, 400 ); ## width probably best calculated ## using bar_spacing and the scalar(@$days[1]) add_colour('#66CC66'); add_colour('#00fbff'); add_colour('#000000'); $graph->set( y_label => 'XP change', # xp is not Reputation, thanks grinder x_label => 'DAY OF MONTH', box_axis => 1, # bar_width => 30, # doesn't work too well, bar_spacing => 10,# doesn't work too well, # esp if mixed together # also has to do with graph size values_space => 15, # how much to padd values_vertical => 1, # print values vertically x_tick_number => undef, # accentclr => '#000000', # this be the bar box edges accentclr => '#009999', # this be the bar box edges # dclrs => [ map{'#66CC66'} 1..@days ], # data color dclrs => [ map{'#00fbff'} 1..@days ], # data color title => "${username}'s XP gains/losses per day for $month, $year" ) or die "$!"; my $days = GD::Graph::Data->new(); $days->copy_from(\@days); $graph->set(show_values => 1 ); ## show values $graph->set_values_font(GD::gdMediumBoldFont); my $gd = $graph->plot( $days ); $gd->interlaced('true'); open(FOUT,'>'.__FILE__.'.png') or die $!; binmode(FOUT); print FOUT $gd->png; close(FOUT)