Changeset 73 for trunk/lib/Stats.cc


Ignore:
Timestamp:
Mar 4, 2006, 7:10:07 PM (16 years ago)
Author:
Jari Häkkinen
Message:

Divided Gnuplot class into a basic gnuplot communication class
and a front end class specialized for svnstat.
Added option to plot stats against time or revision.
Removed gnuplot usage of temporary files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Stats.cc

    r72 r73  
    22
    33#include "Stats.h"
    4 #include "Gnuplot.h"
     4#include "GnuplotFE.h"
    55#include "utility.h"
    66
     
    88#include <cassert>
    99#include <cstdlib>
     10#include <fstream>
    1011#include <iostream>
    1112#include <map>
     
    2122namespace svnstat{
    2223
    23   Gnuplot Stats::gnuplot_pipe_;
    2424  u_int Stats::latest_revision_=0;
    2525
     
    104104  {
    105105    std::string cmd=std::string("set term png; set output '")+name+"'";
    106     gnuplot_pipe_.command(cmd);
    107     gnuplot_pipe_.command("set key left Left reverse");
     106    GnuplotFE* gp=GnuplotFE::instance();
     107    gp->command(cmd);
     108    gp->command("set key default");
     109    gp->command("set key left Left reverse");
     110    gp->command("set multiplot");
    108111    std::vector<double> x=accumulated();   
    109112    std::stringstream sa;
    110113    sa << x.back() << " total";
    111     gnuplot_pipe_.linetitle(sa.str());
    112     gnuplot_pipe_.date_plot(x);
     114    gp->linetitle(sa.str());
     115    gp->linestyle("steps 1");
     116    gp->plot(x);
     117    size_t plotno=2;
    113118    for (MapConstIter_ i= map_.begin(); i != map_.end(); i++) {
     119      std::stringstream s0;
     120      s0 << "set key height " << plotno;
     121      gp->command(s0.str());
    114122      x=accumulated(i->first);
    115123      std::stringstream s;
    116124      s << x.back() << " " << i->first;
    117       gnuplot_pipe_.linetitle(s.str());
    118       gnuplot_pipe_.date_replot(x);
     125      gp->linetitle(s.str());
     126      // Jari, reuse the stream above
     127      std::stringstream s2;
     128      s2 << "steps " << plotno++;
     129      gp->linestyle(s2.str());
     130      gp->plot(x);
    119131    }
     132    gp->command("unset multiplot");
    120133
    121     // Jari, must rewrite output once since the replots above are not
    122     // added to the plot. Rather, the plot only contains the result
    123     // from the first 'plot' call.
    124     gnuplot_pipe_.command(cmd);
    125     gnuplot_pipe_.command("replot");
    126134    return name;
    127135  }
Note: See TracChangeset for help on using the changeset viewer.