source: trunk/lib/Graph.h @ 882

Last change on this file since 882 was 882, checked in by Jari Häkkinen, 13 years ago

Renaming poorly selected varialble name.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1#ifndef _theplu_svndigest_graph_
2#define _theplu_svndigest_graph_
3
4// $Id: Graph.h 882 2009-11-24 19:00:04Z jari $
5
6/*
7  Copyright (C) 2009 Jari Häkkinen
8
9  This file is part of svndigest, http://dev.thep.lu.se/svndigest
10
11  svndigest is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation; either version 3 of the License, or
14  (at your option) any later version.
15
16  svndigest is distributed in the hope that it will be useful, but
17  WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  General Public License for more details.
20
21  You should have received a copy of the GNU General Public License
22  along with svndigest. If not, see <http://www.gnu.org/licenses/>.
23*/
24
25#include <string>
26#include <vector>
27
28#include <plplot/plstream.h>
29
30namespace theplu {
31namespace svndigest {
32
33  class Graph
34  {
35  public:
36
37    /**
38       \brief Constructor
39
40       \a filename to be defined depending on whether we'll support
41       more output formats than SVG.
42    */
43    explicit Graph(const std::string& filename);
44
45    /**
46       \brief Destructor
47    */
48    ~Graph(void);
49
50    static bool date_xticks(void);
51
52    /**
53       \brief Set the pen colour to use in next drawing call
54    */
55    void current_colour(unsigned char r, unsigned char g, unsigned char b);
56
57    /**
58       \brief Plot \a data using \a timeformat for x-axis values when
59       dates are used.
60    */
61    void plot(const std::vector<unsigned int>& data, const std::string& legend,
62              const std::string& timeformat="%y-%b");
63
64    /**
65       \brief Function setting the dates.
66
67       The date strings must be in svn format since underlying time
68       conversion are done with the Date class.
69
70       \see Date::svntime(std::string)
71    */
72    static void set_dates(const std::vector<std::string>& date);
73
74    static const std::vector<std::string>& xticks(void);
75
76    /**
77       \brief Set max y value in the plot
78
79       The plot area is (xstart,0) to (xend,\a ymax) where xend is
80       either the length of vector to plot (corresponds to latest
81       revision number) or the date of the last revision commit,
82       xstart is 0 or the date of the first commit.
83    */
84    double ymax(double ymax=0.0);
85
86  private:
87    void print_legend(PLFLT xmin, PLFLT ymin, PLFLT xmax, PLFLT ymax,
88                      const std::string& legend);
89    unsigned int tick_spacing(const double range) const;
90
91    unsigned int plots_; // keep track of number of plots drawn
92    plstream pls_;
93    std::string title_;
94    static std::vector<std::string> xticks_;
95    double ymax_;
96  };
97
98}} // end of namespace svndigest and namespace theplu
99
100#endif
Note: See TracBrowser for help on using the repository browser.