Changeset 878
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Graph.cc
r875 r878 61 61 62 62 63 void Graph::plot(const std::vector<unsigned int>& y, const std::string& format) 63 void Graph::plot(const std::vector<unsigned int>& y, const std::string& legend, 64 const std::string& timeformat) 64 65 { 65 66 unsigned int xmin= date_xticks() ? Date(xticks_.front()).seconds() : 0; … … 73 74 74 75 if (date_xticks()) 75 pls_.timefmt( format.c_str());76 pls_.timefmt(timeformat.c_str()); 76 77 77 78 unsigned int ytickspacing=tick_spacing(yrange_); … … 79 80 pls_.box("bcnstd", xtickspacing, 1, "bcnstv", ytickspacing, 2); 80 81 pls_.lab("Date", "Number of lines", title_.c_str()); 81 82 pls_.col0(1);83 82 } 84 83 ++plots_; 84 85 print_legend(xmin,0,xmax,yrange_,legend); 86 pls_.col0(1); 85 87 for (unsigned int i=1; i<y.size(); ++i) { 86 88 PLFLT x0=i-1; … … 93 95 pls_.join(x0, y[i] , x1, y[i]); 94 96 } 97 } 98 99 100 void Graph::print_legend(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax, 101 const std::string& legend) 102 { 103 PLFLT xrange=(xmax-xmin); 104 PLFLT length=0.05*xrange; 105 PLFLT dx=0.01*xrange; 106 PLFLT x=4*dx+xmin+length; 107 PLFLT y=(1.-0.05*plots_)*ymax; 108 pls_.col0(1); 109 pls_.join(x-dx, y, x-dx-length, y); 110 pls_.col0(2); 111 pls_.ptex(x, y, 0, 0, 0, legend.c_str()); 95 112 } 96 113 -
trunk/lib/Graph.h
r875 r878 41 41 more output formats than SVG. 42 42 */ 43 Graph(const std::string& filename);43 explicit Graph(const std::string& filename); 44 44 45 45 /** … … 56 56 57 57 /** 58 \brief Plot \a data using \a format for x-axis values when58 \brief Plot \a data using \a timeformat for x-axis values when 59 59 dates are used. 60 60 */ 61 void plot(const std::vector<unsigned int>& data, 62 const std::string& format="%y-%b"); 63 61 void plot(const std::vector<unsigned int>& data, const std::string& legend, 62 const std::string& timeformat="%y-%b"); 64 63 65 64 /** … … 86 85 87 86 private: 87 void print_legend(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax, 88 const std::string& legend); 88 89 unsigned int tick_spacing(const double range) const; 89 90 -
trunk/lib/Stats.cc
r864 r878 391 391 for (vec_type::iterator i(author_cont.begin()); i!=end; ++i) { 392 392 ss.str(""); 393 ss << "set key height " << 2*plotno;394 // gp->command(ss.str());395 ss.str("");396 393 ss << get_back(*stat, i->first) << " " << i->first; 397 gp.yrange(yrange_max); 398 // gp->linetitle(ss.str()); 399 ss.str(""); 400 ss << "steps " << --plotno+2; 401 // gp->linestyle(ss.str()); 402 // the RGB values below must be replaced ... seg fault will happen! 394 // the RGB values below must be replaced ... seg fault will 395 // happen! plotno will probably become unused when below row is 396 // removed or fixed. 403 397 gp.current_colour(25*plotno,255-25*plotno,75); 404 gp.plot(i->second );398 gp.plot(i->second, ss.str()); 405 399 } 406 400 ss.str(""); 407 401 ss << get_back(*stat, "all") << " total"; 408 // gp->command("set key height 0");409 // gp->linetitle(ss.str());410 402 gp.current_colour(255,0,0); 411 gp.plot(total );403 gp.plot(total, ss.str()); 412 404 413 405 return filename; … … 426 418 std::vector<unsigned int> x(get_vector(code_stats(), "all")); 427 419 ss << x.back() << " code"; 428 // gp->command("set key height 2");429 // gp->linetitle(ss.str());430 420 gp.current_colour(255,255,0); 431 gp.plot(x );421 gp.plot(x, ss.str()); 432 422 433 423 ss.str(""); 434 424 x = get_vector(comment_or_copy_stats(), "all"); 435 425 ss << x.back() << " comment"; 436 // gp->command("set key height 4");437 // gp->linetitle(ss.str());438 426 gp.current_colour(0,0,255); 439 gp.plot(x );427 gp.plot(x, ss.str()); 440 428 441 429 ss.str(""); 442 430 x = get_vector(other_stats(), "all"); 443 431 ss << x.back() << " other"; 444 // gp->command("set key height 6");445 // gp->linetitle(ss.str());446 432 gp.current_colour(0,255,0); 447 gp.plot(x );433 gp.plot(x, ss.str()); 448 434 449 435 ss.str(""); 450 436 ss << total.back() << " total"; 451 // gp->command("set key height 0");452 // gp->linetitle(ss.str());453 437 gp.current_colour(255,0,0); 454 gp.plot(total );438 gp.plot(total, ss.str()); 455 439 } 456 440
Note: See TracChangeset
for help on using the changeset viewer.