Changeset 39 for trunk/lib


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

Gnuplot working.

Location:
trunk/lib
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Gnuplot.cc

    r36 r39  
    1414
    1515  Gnuplot::Gnuplot(void)
    16     : linestyle_("lines"), pipe_(NULL)
     16    : linestyle_("steps"), pipe_(NULL)
    1717  {
    1818    acquire_program_path("gnuplot");
  • trunk/lib/Gnuplot.h

    r36 r39  
    1818  ///
    1919  struct GnuplotException : public std::runtime_error
    20   { inline GnuplotException(const std::string &msg) : runtime_error(msg) {} };
     20  { inline GnuplotException(const std::string& msg) : runtime_error(msg) {} };
    2121
    2222  ///
     
    6161    /// @note The \a style is not checked to be valid.
    6262    ///
    63     inline void linestyle(std::string style) { linestyle_=style; }
     63    inline void linestyle(const std::string& style) { linestyle_=style; }
    6464
    6565    ///
     
    6868    /// called again.
    6969    ///
    70     inline void linetitle(std::string title) { linetitle_=title; }
     70    inline void linetitle(const std::string& title) { linetitle_=title; }
    7171
    7272    ///
  • 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  }
  • trunk/lib/utility.h

    r23 r39  
    5858
    5959  ///
     60  /// Jari, is this obsolete? And thus erasable?
     61  ///
    6062  struct CodingMore :
    6163    public std::binary_function<std::pair<std::string,std::vector<u_int> >,
Note: See TracChangeset for help on using the changeset viewer.