Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Stats.cc
r23 r34 3 3 #include "Stats.h" 4 4 #include "utility.h" 5 6 #include <cstdio> 7 #include <fstream> 5 8 6 9 #include <map> … … 15 18 namespace svnstat{ 16 19 17 Stats::Stats() 18 { 19 } 20 20 Gnuplot Stats::gnuplot_pipe_; 21 21 22 22 std::vector<u_int> Stats::accumulated(void) const … … 53 53 vec.resize(rev+1); 54 54 for (; i<rev; i++) 55 vec[i]=0;55 vec[i]=0; 56 56 vec[rev]=1; 57 57 } … … 61 61 62 62 } 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 } 63 78 64 79 void Stats::print(std::ostream& os) const … … 79 94 os << "</table>\n"; 80 95 81 os << "<p> [Plot to be here.]</p>\n";96 os << "<p><img src='" << plot() << "' alt='[svnstat plot]' border=0></p>\n"; 82 97 } 83 98 -
trunk/lib/Stats.h
r23 r34 4 4 #define _theplu_svnstat_stats_ 5 5 6 #include "Gnuplot.h" 7 6 8 #include <map> 9 #include <string> 7 10 #include <vector> 8 11 … … 18 21 /// 19 22 /// @brief Default Constructor 20 /// 21 Stats(void); 22 23 /// 24 inline Stats(void) {} 25 23 26 /// 24 27 /// @brief adding a line to user from revision to the stats 25 28 /// 26 29 void add(const std::string& user, const u_int& revision); 30 31 std::string plot(void) const; 27 32 28 33 /// … … 57 62 std::vector<u_int> accumulated(const std::string& user); 58 63 64 static Gnuplot gnuplot_pipe_; 59 65 // Peter, if the vector is sparse make it a map 60 66 typedef std::map<std::string, std::vector<u_int> > Map_;
Note: See TracChangeset
for help on using the changeset viewer.