Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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;"


In reply to (crazyinsomniac:D) Re: Fame, Fortune, ChicksStuds, and XP! by crazyinsomniac
in thread Fame, Fortune, ChicksStuds, and XP! by jcwren

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (7)
    As of 2019-06-26 22:40 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Is there a future for codeless software?



      Results (111 votes). Check out past polls.

      Notices?