Changeset 1327 for trunk/lib/Graph.cc


Ignore:
Timestamp:
Jan 27, 2011, 2:23:15 AM (11 years ago)
Author:
Peter Johansson
Message:

refs #489 and #490. Use default tickspacing provided by plplot. With
current implementation, v6.9.6, it means range 6-15 -> spacing=2;
range 15-30 -> spacing=5; range 30-60 -> spacing=10 and similarly for
other order of magnitudes. For dates it is similar, but the unit
changes dynamically depending on the range. Basically they choose the
largest unit of seconds, minutes, hours, days, weeks, and years, such
that range is at least 3 in that unit. So when the range is more than
3 years we're counting in years and when the range is between 3 weeks
and 3 years we're counting in weeks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Graph.cc

    r1325 r1327  
    33/*
    44  Copyright (C) 2009, 2010 Jari Häkkinen, Peter Johansson
     5  Copyright (C) 2011 Peter Johansson
    56
    67  This file is part of svndigest, http://dev.thep.lu.se/svndigest
     
    3839  Graph::Graph(const std::string& filename, const std::string& format)
    3940#ifdef HAVE_PLPLOT
    40     : plots_(0), pls_(1,1,format.c_str(),filename.c_str()), timeformat_("%y-%b"),
     41    : plots_(0), pls_(1,1,format.c_str(),filename.c_str()),
    4142      title_(filename), xmin_(0.0), xmax_(0.0), ymin_(0.0), ymax_(0.0)
    4243  {
     
    108109      std::string xopt("bcnstv");
    109110      if (date_xticks()) {
    110         pls_.timefmt(timeformat_.c_str());
     111        pls_.timefmt("%y-%b");
    111112        xopt="bcnstd";
    112113      }
    113114
    114       unsigned int ytickspacing=tick_spacing(yrange_);
    115       unsigned int xtickspacing=tick_spacing(xrange_);
    116       pls_.box(xopt.c_str(), xtickspacing, 1, "bcnstv", ytickspacing, 2);
     115      pls_.box(xopt.c_str(), 0, 1, "bcnstv", 0, 2);
    117116      pls_.lab("Date", "Number of lines", title_.c_str());
    118117    }
     
    232231
    233232
    234   void Graph::timeformat(const std::string& format)
    235   {
    236     timeformat_=format;
    237   }
    238 
    239 
    240233  const std::vector<time_t>& Graph::xticks(void)
    241234  {
Note: See TracChangeset for help on using the changeset viewer.