Changeset 39 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Jan 13, 2006, 4:02:31 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Gnuplot working.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r38 r39  
    1010#include <map>
    1111#include <numeric>
     12#include <sstream>
    1213#include <string>
    1314#include <utility>
     
    7273    std::string cmd=std::string("set term png; set output '")+name+".png'";
    7374    gnuplot_pipe_.command(cmd);
    74     gnuplot_pipe_.plot(accumulated());
    75     for (MapConstIter_ i= map_.begin(); i != map_.end(); i++)
    76       gnuplot_pipe_.replot(accumulated(i->first));
     75    gnuplot_pipe_.command("set key left Left reverse");
     76    std::vector<double> x=accumulated();
     77    std::stringstream sa;
     78    sa << x.back() << " total";
     79    gnuplot_pipe_.linetitle(sa.str());
     80    gnuplot_pipe_.plot(x);
     81    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
     82      x=accumulated(i->first);
     83      std::stringstream s;
     84      s << x.back() << " " << i->first;
     85      gnuplot_pipe_.linetitle(s.str());
     86      gnuplot_pipe_.replot(x);
     87    }
    7788
    7889    // Jari, must rewrite output once since the replots above are not
     
    8697  void Stats::print(std::ostream& os) const
    8798  {
    88     std::vector<std::pair<std::string, std::vector<u_int> > > accum;
    89     for (MapConstIter_ i= map_.begin(); i != map_.end(); i++){
    90       std::pair<std::string, std::vector<u_int> > element(*i);
    91       std::partial_sum(element.second.begin(),element.second.end(),
    92                        element.second.begin());
    93       accum.push_back(element);
    94     }
    95     sort(accum.begin(),accum.end(), CodingMore());
    96     os << "<table>\n";
    97     for (size_t i = 0; i<accum.size(); i++){
    98       os << "<tr><td>\n" << accum[i].first << "</td><td>"
    99          << accum[i].second.back() << "</td></tr>";
    100     }
    101     os << "</table>\n";
    102 
    10399    os << "<p><img src='" << plot() << "' alt='[svnstat plot]' border=0></p>\n";
    104100  }
Note: See TracChangeset for help on using the changeset viewer.