Changeset 34 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Jan 12, 2006, 2:17:11 AM (16 years ago)
Author:
Jari Häkkinen
Message:

Started implementing gnuplot into Stats.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r23 r34  
    33#include "Stats.h"
    44#include "utility.h"
     5
     6#include <cstdio>
     7#include <fstream>
    58
    69#include <map>
     
    1518namespace svnstat{
    1619
    17   Stats::Stats()
    18   {
    19   }
    20 
     20  Gnuplot Stats::gnuplot_pipe_;
    2121
    2222  std::vector<u_int> Stats::accumulated(void) const
     
    5353      vec.resize(rev+1);
    5454      for (; i<rev; i++)
    55   vec[i]=0;
     55        vec[i]=0;
    5656      vec[rev]=1;
    5757    }
     
    6161
    6262  }
     63
     64  std::string Stats::plot(void) const
     65  {
     66    char name[]="svnstatXXXXXX";
     67    if (mkstemp(name) == -1) {
     68      std::cerr << "Failed to get unique filename: " << name << std::endl;
     69      exit(-1);
     70    }
     71    // Jari, temporary empty files are created that needs to be removed.
     72    std::string cmd=std::string("set term png; set output '")+name+".png'";
     73    gnuplot_pipe_.command(cmd);
     74    cmd="plot sin(x) t 'ddd' w lines";
     75    gnuplot_pipe_.command(cmd);
     76    return std::string(name)+".png";
     77  }
    6378
    6479  void Stats::print(std::ostream& os) const
     
    7994    os << "</table>\n";
    8095
    81     os << "<p>[Plot to be here.]</p>\n";         
     96    os << "<p><img src='" << plot() << "' alt='[svnstat plot]' border=0></p>\n";
    8297  }
    8398
Note: See TracChangeset for help on using the changeset viewer.