1 | // $Id: GnuplotFE.cc 84 2006-03-13 22:04:34Z jari $ |
---|
2 | |
---|
3 | /* |
---|
4 | Copyright (C) 2006 Jari Häkkinen |
---|
5 | |
---|
6 | This file is part of svnstat, http://lev.thep.lu.se/trac/svnstat |
---|
7 | |
---|
8 | svnstat is free software; you can redistribute it and/or modify it |
---|
9 | under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2 of the License, or |
---|
11 | (at your option) any later version. |
---|
12 | |
---|
13 | svnstat is distributed in the hope that it will be useful, but |
---|
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
16 | General Public License for more details. |
---|
17 | |
---|
18 | You should have received a copy of the GNU General Public License |
---|
19 | along with this program; if not, write to the Free Software |
---|
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
21 | 02111-1307, USA. |
---|
22 | */ |
---|
23 | |
---|
24 | #include "GnuplotFE.h" |
---|
25 | #include "Gnuplot.h" |
---|
26 | |
---|
27 | #include <string> |
---|
28 | #include <sstream> |
---|
29 | |
---|
30 | |
---|
31 | namespace theplu { |
---|
32 | namespace svnstat { |
---|
33 | |
---|
34 | |
---|
35 | GnuplotFE* GnuplotFE::instance_=NULL; |
---|
36 | |
---|
37 | |
---|
38 | void GnuplotFE::plot(const std::vector<u_int>& y, const std::string& format) |
---|
39 | { |
---|
40 | if (!date_.empty()) { |
---|
41 | command(std::string("set xdata time")); |
---|
42 | command("set timefmt '" + date_input_format_ + "'"); |
---|
43 | command("set format x '" + format + "'"); |
---|
44 | Gnuplot::plot(y,date_); |
---|
45 | command(std::string("set xdata")); |
---|
46 | } |
---|
47 | else |
---|
48 | Gnuplot::plot(y); |
---|
49 | } |
---|
50 | |
---|
51 | |
---|
52 | void GnuplotFE::replot(const std::vector<u_int>& y) |
---|
53 | { |
---|
54 | if (!date_.empty()) { |
---|
55 | command(std::string("set xdata time")); |
---|
56 | Gnuplot::replot(y,date_); |
---|
57 | command(std::string("set xdata")); |
---|
58 | } |
---|
59 | else |
---|
60 | Gnuplot::replot(y); |
---|
61 | } |
---|
62 | |
---|
63 | |
---|
64 | double GnuplotFE::yrange(double ymax) |
---|
65 | { |
---|
66 | if (ymax<0) |
---|
67 | ymax=0; |
---|
68 | std::ostringstream cmd; |
---|
69 | cmd << "set yrang[0:"; |
---|
70 | if (ymax) |
---|
71 | cmd << ymax; |
---|
72 | cmd << "]"; |
---|
73 | |
---|
74 | command(cmd.str()); |
---|
75 | return ymax; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | }} // end of namespace svnstat and namespace theplu |
---|