Changeset 74


Ignore:
Timestamp:
Mar 7, 2006, 4:46:59 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Improved web presentation. Y axises normalized, ticket ticket:15 resolved.

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r73 r74  
    22
    33version 0.2:
     4  - Improved web page presentation.
    45  - Removed usage of temporary files.
    56  - Added option to plot changes against time or revision.
  • trunk/lib/Directory.cc

    r73 r74  
    7979    std::ofstream os(output.c_str());
    8080    print_header(os);
    81     os << std::endl;
    82     stats_.print(os,output_name()+".png");
    83     os << std::endl;
    84 
     81    os << "<p align=center>\n<img src='" << stats_.plot(output_name()+".png")
     82       << "' alt='[plot]' border=0><br>\n";
     83    os << "<table>\n";
     84    os << "<tr><td><strong>Node</strong></td>\n";
     85    os << "<td><strong>Count</strong></td></tr>\n";
     86    os << "<tr><td>Total</td>\n";
     87    os << "<td align=right>" << stats_.rows() << "</td></tr>\n";
    8588    // print html links to daughter nodes
    8689    transform(daughters_.begin(), daughters_.end(),
    87               std::ostream_iterator<std::string>(os,"\n"),
    88               std::mem_fun(&Node::html_link));
    89 
     90              std::ostream_iterator<std::string>(os," "),
     91              std::mem_fun(&Node::html_tablerow));
     92    os << "</table>\n";
     93    os << "</p>";
    9094    print_footer(os);
    9195    os.close();
  • trunk/lib/File.cc

    r72 r74  
    3737    std::ofstream os(output.c_str());
    3838    print_header(os);
    39     os << std::endl;
    40     stats_.print(os,output_name()+".png");
    41     os << std::endl;
     39    os << "<p align=center>\n<img src='" << stats_.plot(output_name()+".png")
     40       << "' alt='[plot]' border=0>\n</p>";
    4241    print_footer(os);
    4342    os.close();
  • trunk/lib/Gnuplot.cc

    r73 r74  
    5656
    5757 
     58  void Gnuplot::command(const std::string& cmdstr)
     59  {
     60    fputs(cmdstr.c_str(),pipe_);
     61    if (*(cmdstr.rbegin())!='\n')
     62      fputc('\n',pipe_);
     63    fflush(pipe_);
     64  }
     65
     66
    5867  void Gnuplot::tokenizer(const std::string& in,
    5968                          std::list<std::string>& tokens,
     
    7079
    7180
    72   void Gnuplot::command(const std::string& cmdstr)
    73   {
    74     fputs(cmdstr.c_str(),pipe_);
    75     if (*(cmdstr.rbegin())!='\n')
    76       fputc('\n',pipe_);
    77     fflush(pipe_);
    78   }
    79 
    80 
    8181}} // end of namespace svnstat and namespace theplu
  • trunk/lib/GnuplotFE.cc

    r73 r74  
    55
    66#include <string>
     7#include <sstream>
    78
    89
     
    1415
    1516
    16   void GnuplotFE::plot(const std::vector<double>& y, const std::string& format)
     17  void GnuplotFE::plot(const std::vector<u_int>& y, const std::string& format)
    1718  {
    1819    if (!date_.empty()) {
     
    2829
    2930
    30   void GnuplotFE::replot(const std::vector<double>& y)
     31  void GnuplotFE::replot(const std::vector<u_int>& y)
    3132  {
    3233    if (!date_.empty()) {
     
    4041
    4142
     43  double GnuplotFE::yrange(double ymax)
     44  {
     45    if (ymax<0)
     46      ymax=0;
     47    std::ostringstream cmd;
     48    cmd << "set yrang[0:";
     49    if (ymax)
     50      cmd << ymax;
     51    cmd << "]";
     52
     53    command(cmd.str());
     54    return ymax;
     55  }
     56
     57
    4258}} // end of namespace svnstat and namespace theplu
  • trunk/lib/GnuplotFE.h

    r73 r74  
    4040    ///
    4141    ///
    42     void plot(const std::vector<double>& y,const std::string& format="%y-%b-%d");
     42    void plot(const std::vector<u_int>& y,const std::string& format="%y-%b-%d");
    4343
    4444    ///
    4545    ///
    4646    ///
    47     void replot(const std::vector<double>& y);
     47    void replot(const std::vector<u_int>& y);
    4848
    4949    ///
     
    6767    { date_=date; date_input_format_=format; }
    6868
     69    ///
     70    /// Set the upper value for the y axis, the lower values is always
     71    /// zero. Call this function with an argument 0 (or without an
     72    /// argument) to cancel the current setting. Negative argument
     73    /// values are treated as zero value.
     74    ///
     75    /// @return Returns the actual set upper value. A zero value is
     76    /// returned if the current setting was cancelled.
     77    ///
     78    /// @see Gnuplot documentation for yrange
     79    ///
     80    double yrange(double ymax=0.0);
     81
    6982  private:
    7083    ///
  • trunk/lib/Node.cc

    r72 r74  
    3434    time ( &rawtime );
    3535    timeinfo = localtime ( &rawtime );
    36     os << "<p><font size=1>Generated on "
     36    os << "<p align=center><font size=-2>Generated on "
    3737       << asctime (timeinfo)
    38        << "by svnstat</font></p></body>\n"
    39        << "</html>";
     38       << "by <a href=http://lev.thep.lu.se/trac/svnstat/>svnstat</a>"
     39       << "</font></p></body>\n</html>\n";
    4040  }
    4141
     
    4545    os << "<html>\n"
    4646       << "<head>\n"
    47        << "<title> svnstat " << name() << "\n"
     47       << "<title> svnstat " << name() << "</title>\n"
    4848       << "</head>\n"
    49        << "<body bgcolor='FFFBFB'\n";
     49       << "<body bgcolor='FFFBFB'>\n";
    5050  }
    5151
    5252
    53   std::string Node::html_link(void) const
    54   {
    55     return "<a href=\"" + output_name() + ".html\">" + name() + "</a><br/>";
    56   }
    57  
    5853  bool Node::subversion_controlled(void) const
    5954  {
  • trunk/lib/Node.h

    r72 r74  
    77
    88#include <ostream>
     9#include <sstream>
    910#include <string>
    10 #include <sstream>
    1111
    1212namespace theplu{
     
    2929    virtual inline ~Node(void) {};
    3030
     31    ///
     32    /// @return A properly formatted html link to this node.
     33    ///
     34    inline std::string html_link(void) const
     35    { return "<a href=\"" + output_name() + ".html\">" + name() + "</a>"; }
     36
     37    inline std::string html_tablerow(void) const
     38    {
     39      std::stringstream ss;
     40      ss << "<tr><td>" << html_link() << "</td><td align=right>" << stats_.rows()
     41         << "</td></tr>\n";
     42      return ss.str();
     43    }
     44
    3145    inline const std::string& output_name(void) const { return output_name_; }
    3246
     
    4155    virtual void print(const bool verbose=false) const=0;
    4256
    43     ///
    44     /// @return html link.
    45     ///
    46     std::string html_link(void) const;
    47  
    4857    ///
    4958    ///
  • trunk/lib/Stats.cc

    r73 r74  
    2424  u_int Stats::latest_revision_=0;
    2525
    26   std::vector<double> Stats::accumulated(void) const
     26  std::vector<u_int> Stats::accumulated(void) const
    2727  {
    2828    // sum of all users
     
    3232
    3333    // calculate accumulated sum
    34     std::vector<double> accum(sum.size());
     34    std::vector<u_int> accum(sum.size());
    3535    std::partial_sum(sum.begin(),sum.end(),accum.begin());
    3636    assert(sum.size()==accum.size());
     
    3838  }
    3939
    40   std::vector<double> Stats::accumulated(const std::string& user) const
     40  std::vector<u_int> Stats::accumulated(const std::string& user) const
    4141  {
    4242    if (!map_.count(user))
    43       return std::vector<double>();
     43      return std::vector<u_int>();
    4444    std::vector<u_int> vec=(map_.find(user))->second;
    4545 
     
    4747      vec.insert(vec.end(), latest_revision_+1-vec.size(), 0);
    4848
    49     std::vector<double> accum(vec.size());
     49    std::vector<u_int> accum(vec.size());
    5050    std::partial_sum(vec.begin(),vec.end(),accum.begin());
    5151    return accum;
     
    109109    gp->command("set key left Left reverse");
    110110    gp->command("set multiplot");
    111     std::vector<double> x=accumulated();   
     111    std::vector<u_int> x=accumulated();   
    112112    std::stringstream sa;
    113113    sa << x.back() << " total";
     114    double yrange_max=1.03*x.back()+1;
     115    gp->yrange(yrange_max);
    114116    gp->linetitle(sa.str());
    115117    gp->linestyle("steps 1");
    116118    gp->plot(x);
    117     size_t plotno=2;
     119    size_t plotno=1;
    118120    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
    119121      std::stringstream s0;
    120       s0 << "set key height " << plotno;
     122      s0 << "set key height " << 2*plotno;
    121123      gp->command(s0.str());
    122124      x=accumulated(i->first);
    123125      std::stringstream s;
    124126      s << x.back() << " " << i->first;
     127      gp->yrange(yrange_max);
    125128      gp->linetitle(s.str());
    126129      // Jari, reuse the stream above
    127130      std::stringstream s2;
    128       s2 << "steps " << plotno++;
     131      s2 << "steps " << ++plotno;
    129132      gp->linestyle(s2.str());
    130133      gp->plot(x);
    131134    }
    132135    gp->command("unset multiplot");
     136    gp->yrange();
    133137
    134138    return name;
  • trunk/lib/Stats.h

    r73 r74  
    3030
    3131    ///
    32     /// @brief Print statistics
     32    /// Create statistics graph.
    3333    ///
    34     void inline print(std::ostream& s, const std::string& name) const
    35     { s << "<p><img src='" << plot(name) << "' alt='[plot]' border=0></p>\n"; }
     34    std::string plot(const std::string&) const;
    3635
    3736    ///
     
    3938    ///
    4039    inline void reset(void) { map_.clear(); }
     40
     41    ///
     42    ///
     43    ///
     44    inline u_int rows(void) const { return accumulated().back(); }
    4145
    4246    ///
     
    5458    /// @return accumulated vector of total
    5559    ///
    56     std::vector<double> accumulated(void) const;
     60    std::vector<u_int> accumulated(void) const;
    5761
    5862    ///
    5963    /// @return accumulated vector of stats_[user]
    6064    ///
    61     std::vector<double> accumulated(const std::string& user) const;
     65    std::vector<u_int> accumulated(const std::string& user) const;
    6266
    6367    ///
     
    6569    ///
    6670    void add(const std::string& user, const u_int& revision);
    67 
    68     std::string plot(const std::string&) const;
    6971
    7072    static u_int latest_revision_; // latest revision for whole project
Note: See TracChangeset for help on using the changeset viewer.