Changeset 74
- Timestamp:
- Mar 7, 2006, 4:46:59 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r73 r74 2 2 3 3 version 0.2: 4 - Improved web page presentation. 4 5 - Removed usage of temporary files. 5 6 - Added option to plot changes against time or revision. -
trunk/lib/Directory.cc
r73 r74 79 79 std::ofstream os(output.c_str()); 80 80 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"; 85 88 // print html links to daughter nodes 86 89 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>"; 90 94 print_footer(os); 91 95 os.close(); -
trunk/lib/File.cc
r72 r74 37 37 std::ofstream os(output.c_str()); 38 38 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>"; 42 41 print_footer(os); 43 42 os.close(); -
trunk/lib/Gnuplot.cc
r73 r74 56 56 57 57 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 58 67 void Gnuplot::tokenizer(const std::string& in, 59 68 std::list<std::string>& tokens, … … 70 79 71 80 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 81 81 }} // end of namespace svnstat and namespace theplu -
trunk/lib/GnuplotFE.cc
r73 r74 5 5 6 6 #include <string> 7 #include <sstream> 7 8 8 9 … … 14 15 15 16 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) 17 18 { 18 19 if (!date_.empty()) { … … 28 29 29 30 30 void GnuplotFE::replot(const std::vector< double>& y)31 void GnuplotFE::replot(const std::vector<u_int>& y) 31 32 { 32 33 if (!date_.empty()) { … … 40 41 41 42 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 42 58 }} // end of namespace svnstat and namespace theplu -
trunk/lib/GnuplotFE.h
r73 r74 40 40 /// 41 41 /// 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"); 43 43 44 44 /// 45 45 /// 46 46 /// 47 void replot(const std::vector< double>& y);47 void replot(const std::vector<u_int>& y); 48 48 49 49 /// … … 67 67 { date_=date; date_input_format_=format; } 68 68 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 69 82 private: 70 83 /// -
trunk/lib/Node.cc
r72 r74 34 34 time ( &rawtime ); 35 35 timeinfo = localtime ( &rawtime ); 36 os << "<p ><font size=1>Generated on "36 os << "<p align=center><font size=-2>Generated on " 37 37 << 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"; 40 40 } 41 41 … … 45 45 os << "<html>\n" 46 46 << "<head>\n" 47 << "<title> svnstat " << name() << " \n"47 << "<title> svnstat " << name() << "</title>\n" 48 48 << "</head>\n" 49 << "<body bgcolor='FFFBFB' \n";49 << "<body bgcolor='FFFBFB'>\n"; 50 50 } 51 51 52 52 53 std::string Node::html_link(void) const54 {55 return "<a href=\"" + output_name() + ".html\">" + name() + "</a><br/>";56 }57 58 53 bool Node::subversion_controlled(void) const 59 54 { -
trunk/lib/Node.h
r72 r74 7 7 8 8 #include <ostream> 9 #include <sstream> 9 10 #include <string> 10 #include <sstream>11 11 12 12 namespace theplu{ … … 29 29 virtual inline ~Node(void) {}; 30 30 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 31 45 inline const std::string& output_name(void) const { return output_name_; } 32 46 … … 41 55 virtual void print(const bool verbose=false) const=0; 42 56 43 ///44 /// @return html link.45 ///46 std::string html_link(void) const;47 48 57 /// 49 58 /// -
trunk/lib/Stats.cc
r73 r74 24 24 u_int Stats::latest_revision_=0; 25 25 26 std::vector< double> Stats::accumulated(void) const26 std::vector<u_int> Stats::accumulated(void) const 27 27 { 28 28 // sum of all users … … 32 32 33 33 // calculate accumulated sum 34 std::vector< double> accum(sum.size());34 std::vector<u_int> accum(sum.size()); 35 35 std::partial_sum(sum.begin(),sum.end(),accum.begin()); 36 36 assert(sum.size()==accum.size()); … … 38 38 } 39 39 40 std::vector< double> Stats::accumulated(const std::string& user) const40 std::vector<u_int> Stats::accumulated(const std::string& user) const 41 41 { 42 42 if (!map_.count(user)) 43 return std::vector< double>();43 return std::vector<u_int>(); 44 44 std::vector<u_int> vec=(map_.find(user))->second; 45 45 … … 47 47 vec.insert(vec.end(), latest_revision_+1-vec.size(), 0); 48 48 49 std::vector< double> accum(vec.size());49 std::vector<u_int> accum(vec.size()); 50 50 std::partial_sum(vec.begin(),vec.end(),accum.begin()); 51 51 return accum; … … 109 109 gp->command("set key left Left reverse"); 110 110 gp->command("set multiplot"); 111 std::vector< double> x=accumulated();111 std::vector<u_int> x=accumulated(); 112 112 std::stringstream sa; 113 113 sa << x.back() << " total"; 114 double yrange_max=1.03*x.back()+1; 115 gp->yrange(yrange_max); 114 116 gp->linetitle(sa.str()); 115 117 gp->linestyle("steps 1"); 116 118 gp->plot(x); 117 size_t plotno= 2;119 size_t plotno=1; 118 120 for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) { 119 121 std::stringstream s0; 120 s0 << "set key height " << plotno;122 s0 << "set key height " << 2*plotno; 121 123 gp->command(s0.str()); 122 124 x=accumulated(i->first); 123 125 std::stringstream s; 124 126 s << x.back() << " " << i->first; 127 gp->yrange(yrange_max); 125 128 gp->linetitle(s.str()); 126 129 // Jari, reuse the stream above 127 130 std::stringstream s2; 128 s2 << "steps " << plotno++;131 s2 << "steps " << ++plotno; 129 132 gp->linestyle(s2.str()); 130 133 gp->plot(x); 131 134 } 132 135 gp->command("unset multiplot"); 136 gp->yrange(); 133 137 134 138 return name; -
trunk/lib/Stats.h
r73 r74 30 30 31 31 /// 32 /// @brief Print statistics32 /// Create statistics graph. 33 33 /// 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; 36 35 37 36 /// … … 39 38 /// 40 39 inline void reset(void) { map_.clear(); } 40 41 /// 42 /// 43 /// 44 inline u_int rows(void) const { return accumulated().back(); } 41 45 42 46 /// … … 54 58 /// @return accumulated vector of total 55 59 /// 56 std::vector< double> accumulated(void) const;60 std::vector<u_int> accumulated(void) const; 57 61 58 62 /// 59 63 /// @return accumulated vector of stats_[user] 60 64 /// 61 std::vector< double> accumulated(const std::string& user) const;65 std::vector<u_int> accumulated(const std::string& user) const; 62 66 63 67 /// … … 65 69 /// 66 70 void add(const std::string& user, const u_int& revision); 67 68 std::string plot(const std::string&) const;69 71 70 72 static u_int latest_revision_; // latest revision for whole project
Note: See TracChangeset
for help on using the changeset viewer.