summaryrefslogtreecommitdiffstats
path: root/grapher/Graph.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-22 11:35:38 +0100
committerTim Moore <timoore@redhat.com>2009-12-23 00:04:11 +0100
commite3a546d81cd115d7cd9105fc31ecccecfb48b71d (patch)
treeedaf59835ce9774b69c72ddbe9ec28dfb925b188 /grapher/Graph.cxx
parent2d0ddea123e8d5d1113b80692689a80f37d46e6f (diff)
downloadsystemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.tar.gz
systemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.tar.xz
systemtap-steved-e3a546d81cd115d7cd9105fc31ecccecfb48b71d.zip
grapher: scroll continuously with time
Don't scale graph based on how much data will fit. This didn't work very well and resulted in distracting, weird scale changes. We now assume that scripts output their time (x axis) in milliseconds. * grapher/Graph.hxx (setCurrentTime): New function. * grapher/Graph.cxx (Graph::draw): Assume a fixed default scale of 1 pixel = 5 milliseconds and don't do any autoscaling. * grapher/GraphWidget.cxx (GraphWidget constructor): Set global time base on startup. (on_expose_event): Don't search graphs for earliest time. * grapher/GraphWidget.hxx (_timeBaseInitialized): delete * grapher/Time.hxx: new file; interface to timeval.
Diffstat (limited to 'grapher/Graph.cxx')
-rw-r--r--grapher/Graph.cxx55
1 files changed, 6 insertions, 49 deletions
diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx
index dc808fa4..27b6a24f 100644
--- a/grapher/Graph.cxx
+++ b/grapher/Graph.cxx
@@ -19,7 +19,9 @@ using namespace std::tr1;
GraphDataList GraphDataBase::graphData;
sigc::signal<void> GraphDataBase::graphDataChanged;
-
+
+int64_t Graph::_currentTime = 0;
+
Graph::Graph(double x, double y)
: _width(600), _height(200), _graphX(0), _graphY(0),
_graphWidth(580), _graphHeight(180),
@@ -39,55 +41,10 @@ void Graph::draw(Cairo::RefPtr<Cairo::Context> cr)
if (_autoScaling)
{
- // line separation
- int linesPossible = (int)(_graphWidth / (_lineWidth + 2.0));
// Find latest time.
- int64_t latestTime = 0;
- for (GraphDataList::iterator ditr = _datasets.begin(),
- de = _datasets.end();
- ditr != de;
- ++ditr)
- {
- if (!(*ditr)->times.empty())
- {
- int64_t lastDataTime = (*ditr)->times.back();
- if (lastDataTime > latestTime)
- latestTime = lastDataTime;
- }
- }
- int64_t minDiff = 0;
- int64_t maxTotal = 0;
- for (GraphDataList::iterator ditr = _datasets.begin(),
- de = _datasets.end();
- ditr != de;
- ++ditr)
- {
- GraphDataBase::TimeList& gtimes = (*ditr)->times;
- if (gtimes.size() <= 1)
- continue;
- double totalDiff = 0.0;
- for (GraphDataBase::TimeList::reverse_iterator ritr = gtimes.rbegin(),
- re = gtimes.rend();
- ritr + 1 != gtimes.rend();
- ritr++)
- {
- int64_t timeDiff = *ritr - *(ritr + 1);
- if (timeDiff < minDiff || (timeDiff != 0 && minDiff == 0))
- minDiff = timeDiff;
- if (minDiff != 0
- && ((totalDiff + timeDiff) / minDiff + 1) > linesPossible)
- break;
- totalDiff += timeDiff;
- }
- if (totalDiff > maxTotal)
- maxTotal = totalDiff;
- }
- // Now we have a global scale.
- _right = latestTime;
- if (maxTotal != 0)
- _left = latestTime - maxTotal;
- else
- _left = _right - 1;
+ _right = _currentTime / 1000;
+ // Assume 1 pixel = 5 milliseconds
+ _left = _right - 5000;
}
cr->save();
double horizScale