Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Fame, Fortune, ChicksStuds, and XP!

by jcwren (Prior)
on Jun 05, 2002 at 05:17 UTC ( #171725=monkdiscuss: print w/replies, xml ) Need Help??

featuring much gratuitous linking...

Are you looking for fame? Do you want fortune? Need XP? Want to impress a potential significant other? Here's how you can get all these! And do it all with Perl, no less.

As many of you know, the stats pages are written in PHP. There are several pages that produce wonderfully colored bar charts, the most important being your personal XP change chart. The code for the charts is 3rd party stuff, and pretty crappy. It incorrectly handles negative XP, and columns don't always scale correctly.

I'm looking for someone to write a script to produce nearly identical (but correct) graphs to replace the defective PHP graphs. This needs to be done because the server that serves the stats pages needs to be upgraded, and the graphing package fails to compile under the latest versions of PHP.

I'm happy to face the fact that I suck at graphics (hell, most people would say web page design, too). I don't have have the bandwidth available to make these changes, nor the skills to make graphs that look good. I need your help.

You'll get your name on the stats pages (in the Credits section), and a node in this thread for people to vote you up. You'll have my undying gratitude (with that, and $0.79USD, you can get a cup of coffee at McDonalds), and make lots of people happy that the graphs finally work right.

I'll provide the existing PHP code for that section, along with a snapshot of a portion of the stats database. If you're a account holder, you can use the MySQL database there, and I'll install any modules you need for testing. I'll also create a custom copy of the stats pages that link to your script to pull the charts.

If you're seriously interested and have the skills, please, I'd love your help. If multiple people volunteer, I'm at a bit of a loss how to handle that. Best functionality? First finished? Dunno. You can /msg me for information, or follow up in the this thread.


e-mail jcwren

Replies are listed 'Best First'.
(crazyinsomniac:D) Re: Fame, Fortune, ChicksStuds, and XP!
by crazyinsomniac (Prior) on Jun 05, 2002 at 08:42 UTC
    I don't know how pretty, but you can judge for yourself.

    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)

    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;"

Fortune Fame, Mirror Vain... but the memory remains....
by Chady (Priest) on Jun 05, 2002 at 06:29 UTC

    count me in.

    Update: yeah right... got beaten up before I even got home to my linux machine to access GD... :p

    Update 2: Ok so here is what I was working on, but I didn't post after I saw crazyinsomniac's results.

    #!/usr/bin/perl -w use strict; use Chart::Plot; my $img = Chart::Plot->new(600,400); my @xdata = (1..30); my @ydata = 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 }; $img->setData (\@xdata, \@ydata, 'Point Dashedline Red'); $img->setGraphOptions ('horGraphOffset' => 75, 'vertGraphOffset' => 100, 'title' => 'Chady\'s XP Change for June', 'horAxisLabel' => 'Days', 'vertAxisLabel' => 'XP Change' ); print $img->draw();

    results can be seen here.

    Update 3: following crazy's suggestion here's a simple mix of bars and lines.. but no 3D bars yet :-/

    #!/usr/bin/perl -w use strict; use Chart::Composite; my $img = Chart::Composite->new(600,400); my @data = 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 }; $img->add_dataset (1..30); $img->add_dataset (@data); $img->add_dataset (@data); $img->set ('legend' => 'none', 'title' => 'Chady\'s XP Plot', 'brush_size' => 2, 'pt_size' => 10, 'composite_info' => [ ['Bars', [1]], ['LinesPoints', [2]] ], 'y_label' => 'XP Change', 'colors' => {'y_label' => [0,0,255], 'dataset0' => [0,153,153], 'dataset1' => [0,0,127] } ); $img->png("chart.png");

    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.

    Chady |
      Would it be completely insane to: 1. create a project on Sourceforge so we could all work on this project _together_ :-)

      2. have someone at PerlMonks send us the data dictionary and we could replicate that structure for our development


      I also like chicken.

Re: Fame, Fortune, ChicksStuds, and XP!
by talexb (Canon) on Jun 07, 2002 at 13:36 UTC
    I'm interested .. perhaps the job can be sliced up and shared for some redundancy? (Oh you suggested that already.)

    My graphing experience is with GnuPlot, but I did try out GD::Graph recently and had an example working pretty quickly.

    Sorry, no groovy sample code as demo of my work. You'll have to visit here for an example of what my graphs look like. :)

    --t. alex

    "Nyahhh (munch, munch) What's up, Doc?" --Bugs Bunny

Re: Fame, Fortune, ChicksStuds, and XP!
by darrel3edndcom (Novice) on Jun 07, 2002 at 14:45 UTC
    I would also like to help, I've been doing dynamic web graph generation for a big company using a different tool (SAS) for 2 years now. I could share my "lessons learned" and "best practices" for doing dynamic web graph generation, and actually write some code, I'm an aspiring-JAPH.


    I also like chicken.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://171725]
Approved by jcwren
Front-paged by jarich
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2017-01-20 04:57 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (173 votes). Check out past polls.