You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by sb...@hyperreal.org on 1999/05/13 21:44:48 UTC

cvs commit: modperl-site/netcraft graph.gif graph.pl input.data logo.gif index.html

sbekman     99/05/13 12:44:48

  Modified:    netcraft index.html
  Added:       netcraft graph.gif graph.pl input.data logo.gif
  Log:
  Added a mod_perl usage graph, including the dataset file and the script that generates the
  graph so it can be updated with new data as it adds up. Note that you need GIFgraph for this
  script to work.
  
  Revision  Changes    Path
  1.12      +3 -0      modperl-site/netcraft/index.html
  
  Index: index.html
  ===================================================================
  RCS file: /export/home/cvs/modperl-site/netcraft/index.html,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- index.html	1999/05/11 18:28:18	1.11
  +++ index.html	1999/05/13 19:44:47	1.12
  @@ -12,6 +12,9 @@
   which require mod_perl experience.
   <p>
   <hr>
  +<IMG SRC="graph.gif"   HEIGHT=400 WIDTH=700 BORDER=0 ALT="Graph">
  +<BR>
  +<BR>
   <p>
   If your site is running mod_perl, feel free
   to <a href="http://www.netcraft.co.uk/cgi-bin/Survey/whats/">tell</a>
  
  
  
  1.1                  modperl-site/netcraft/graph.gif
  
  	<<Binary file>>
  
  
  1.1                  modperl-site/netcraft/graph.pl
  
  Index: graph.pl
  ===================================================================
  #!/usr/bin/perl
  
  # this script build a graph from 2 data sets, expects to find a file 
  # with data of name "input.data" in the script's directory, data should be
  # separated with tabs, e.g:
  #May 1999        156458  36976
  #April 1999      134255  32570
  #March 1999      112399  28482
  
  # Note: you need GIFgraph to be installed in order to use this script.
  
  # Copyleft by Stas Bekman <sb...@iname.com> 
  # May, 13 1999
  
  use GIFgraph::linespoints;
  
  print STDERR "Processing data\n";
  
  @data =  read_data_from_csv("input.data")
          or die "Cannot read data from input.data";
  
  $my_graph = new GIFgraph::linespoints(700,400);
  
  # make the Y axis to be optimally used
  $max_y = 0;
  foreach $val (@{$data[1]},@{$data[2]}){
    $max_y = $val if $val >  $max_y ;
  }
  # normalize it
  $max_y  = ( int $max_y / 1000 + 1 ) * 1000; 
  
  $my_graph->set( 
          x_label => 'Months',
          y_label => 'Counts',
          title => "mod_perl usage survey (numbers are by courtesy of netcraft.com).",
          y_max_value => $max_y,
          y_label_skip => 1,
          x_label_skip => 1,
          x_labels_vertical => 1,
        	x_label_position => 1/2,
          markers => [ 1, 7 ],
  	marker_size => 2,
  	transparent => 1,
  	t_margin => 10, 
  	b_margin => 10, 
  	l_margin => 10, 
  	r_margin => 10,
  
          two_axes => 1,
          logo => 'logo.gif',
          logo_position => 'LL',
  
  
  );
  
  #$my_graph->set( dclrs => [ qw(green pink blue cyan) ] );
  
  $my_graph->set_x_label_font(GD::gdMediumBoldFont);
  $my_graph->set_y_label_font(GD::gdMediumBoldFont);
  $my_graph->set_x_axis_font(GD::gdMediumBoldFont);
  $my_graph->set_y_axis_font(GD::gdMediumBoldFont);
  $my_graph->set_title_font(GD::gdGiantFont);
  
  $my_graph->set_legend('Hostnames','Unique IP numbers' );
  $my_graph->set_legend_font(GD::gdMediumBoldFont);
  
  $my_graph->plot_to_gif( "graph.gif", \@data );
  
  exit;
  
  sub read_data_from_csv
  {
          my $fn = shift;
          my @d = ();
  
          open(ZZZ, $fn) || return ();
  
          while (<ZZZ>)
          {
                  chomp;
                  # you might want Text::CSV here
                  my @row = split /\t/;
  
                  for (my $i = 0; $i <= $#row; $i++)
                  {
                          undef $row[$i] if ($row[$i] eq 'undef');
                          unshift @{$d[$i]}, $row[$i];
                  }
          }
  
          close (ZZZ);
  
          return @d;
  }
  
  
  
  
  1.1                  modperl-site/netcraft/input.data
  
  Index: input.data
  ===================================================================
  May 1999	156458	36976
  April 1999	134255	32570
  March 1999	112399	28482
  February 1999	103088	25854
  January 1999	81982	23742
  December 1998	72545	22598
  November 1998	63692	19239
  October 1998	64171	15055
  September 1998	57365	12540
  August 1998	54450	12438
  July 1998	47068	9904
  June 1998	42508	9237
  May 1998	39535	8682
  April 1998	33696	6980
  March 1998	30075	6439
  February 1998	25343	5607
  January 1998	16591	4343
  December 1997	14624	3814
  November 1997	13303	3431
  October 1997	12654	3045
  September 1997	7165	2256
  August 1997	1501	1228
  July 1997	1138	580
  June 1997	312	239
  
  
  
  
  
  1.1                  modperl-site/netcraft/logo.gif
  
  	<<Binary file>>