Changeset 133 for trunk/lib/GnuplotFE.cc


Ignore:
Timestamp:
Aug 2, 2006, 9:52:39 PM (15 years ago)
Author:
Jari Häkkinen
Message:

Fixes ticket:31. Changed GnuplotFE plot and replot to make sure that data vectors have the same length.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/GnuplotFE.cc

    r84 r133  
    2525#include "Gnuplot.h"
    2626
     27#include <cassert>
    2728#include <string>
    2829#include <sstream>
     
    3637
    3738
    38   void GnuplotFE::plot(const std::vector<u_int>& y, const std::string& format)
     39  void GnuplotFE::plot(std::vector<u_int>& y, const std::string& format)
    3940  {
    4041    if (!date_.empty()) {
     42      assert(date_.size()>=y.size());
     43      if (date_.size()!=y.size()) {
     44        y.reserve(date_.size());
     45        for (size_t i=y.size(); i<date_.size(); ++i)
     46          y.push_back(*y.rbegin());
     47      }
    4148      command(std::string("set xdata time"));
    4249      command("set timefmt '" + date_input_format_ + "'");
     
    5057
    5158
    52   void GnuplotFE::replot(const std::vector<u_int>& y)
     59  void GnuplotFE::replot(std::vector<u_int>& y)
    5360  {
    5461    if (!date_.empty()) {
     62      assert(date_.size()>=y.size());
     63      if (date_.size()!=y.size()) {
     64        y.reserve(date_.size());
     65        for (size_t i=y.size(); i<date_.size(); ++i)
     66          y.push_back(*y.rbegin());
     67      }
    5568      command(std::string("set xdata time"));
    5669      Gnuplot::replot(y,date_);
Note: See TracChangeset for help on using the changeset viewer.