Changeset 1198


Ignore:
Timestamp:
Oct 4, 2010, 2:17:57 PM (13 years ago)
Author:
Peter Johansson
Message:

plot stairs only when count changes in a revision. refs #475

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Graph.cc

    r1197 r1198  
    115115
    116116    pls_.col0(1);
    117     // FIXME: loop over segments instead of revs, i.e., use Vector::iterator
    118     for (unsigned int i=1; i<y.size(); ++i) {
    119       PLFLT x0=i-1;
    120       PLFLT x1=i;
    121       if (date_xticks()) {
    122         x0=xticks_[i-1];
    123         x1=xticks_[i];
    124       }
    125       pls_.join(x0, y[i-1], x0, y[i]);
    126       pls_.join(x0, y[i]  , x1, y[i]);
    127     }
     117
     118    SumVector::const_iterator iter = y.begin();
     119    svn_revnum_t x0=0;
     120    PLFLT y0=0;
     121    for (; iter!=y.end(); ++iter) {
     122      staircase(x0, y0, iter->first, iter->second);
     123      x0 = iter->first;
     124      y0 = iter->second;
     125    }
     126    staircase(x0, y0, y.size()-1, y0);
    128127
    129128    legend_data legend;
     
    169168
    170169
     170  void Graph::staircase(svn_revnum_t rev0, PLFLT y0,
     171                        svn_revnum_t rev1, PLFLT y1)
     172  {
     173    PLFLT x0 = rev0;
     174    PLFLT x1 = rev1;
     175    if (date_xticks()) {
     176      x0 = xticks_[rev0];
     177      x1 = xticks_[rev1];
     178    }
     179#ifdef HAVE_PLPLOT
     180    // join {x0,x0} with {x1,y1} via {x1,y0}
     181    pls_.join(x0,y0,x1,y0);
     182    pls_.join(x1,y0,x1,y1);
     183#endif
     184  }
     185
     186
    171187  unsigned int Graph::tick_spacing(const double range) const
    172188  {
  • trunk/lib/Graph.h

    r1197 r1198  
    138138    void current_color(const legend_data&);
    139139    void print_legend(void);
     140    void staircase(svn_revnum_t rev0, PLFLT y0, svn_revnum_t rev1, PLFLT y1);
    140141    unsigned int tick_spacing(const double range) const;
    141142
Note: See TracChangeset for help on using the changeset viewer.