Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

(crazyinsomniac:D) Re: Fame, Fortune, ChicksStuds, and XP!

by crazyinsomniac (Prior)
on Jun 05, 2002 at 08:42 UTC ( [id://171760]=note: print w/replies, xml ) Need Help??


in reply to Fame, Fortune, ChicksStuds, and XP!

I don't know how pretty, but you can judge for yourself.

http://crazyinsomniac.perlmonk.org/images/jcgraph.png

I'm trying to improve this, help is welcome. As it stands now, i think it looks pretty good. Feel free to play with the colors/fonts.

#!/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, $y +ear" ) 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)
update: ya know, caching these chart images might be nice, so you can do a per month lookup, with the current month being dynamic of course .

update: i overheard jcwren say something in the cb, so i tweaked a little more (stuff in readmore)

http://crazyinsomniac.perlmonk.org/images/jcgraph2.png
#!/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, $y +ear" ) 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)

 
______crazyinsomniac_____________________________
Of all the things I've lost, I miss my mind the most.
perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;"

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://171760]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-19 20:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found