summaryrefslogtreecommitdiffstats
path: root/grapher/Graph.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-22 19:48:20 +0100
committerTim Moore <timoore@redhat.com>2009-12-23 00:09:19 +0100
commit4fca37ae3561da7d0664e0f943146398a8e554dd (patch)
tree6fefd7787f878001961b904cf02ada6cae556d7b /grapher/Graph.cxx
parent33dc14f9790c82669f48abe40662bee1314f5741 (diff)
downloadsystemtap-steved-4fca37ae3561da7d0664e0f943146398a8e554dd.tar.gz
systemtap-steved-4fca37ae3561da7d0664e0f943146398a8e554dd.tar.xz
systemtap-steved-4fca37ae3561da7d0664e0f943146398a8e554dd.zip
grapher: scale from right end of graph
The right side of the graph represents the most recent time. Since there is never anything interesting to the right of that, it makes sense to have the origin of the scaling be there. * grapher/Graph.hxx (getHorizontalScale): new function * grapher/GraphStyle.cxx (GraphStyleBar::draw, GraphStyleDot::draw, GraphStyleEvent::draw): Use cairo transform functions to set up scaling. (GraphStyleBar::dataIndexAtPoint, GraphStyleEvent::dataIndexAtPoint): Base calculations on scaling from right.
Diffstat (limited to 'grapher/Graph.cxx')
-rw-r--r--grapher/Graph.cxx17
1 files changed, 8 insertions, 9 deletions
diff --git a/grapher/Graph.cxx b/grapher/Graph.cxx
index afb52c74..4d697ae6 100644
--- a/grapher/Graph.cxx
+++ b/grapher/Graph.cxx
@@ -47,8 +47,7 @@ void Graph::draw(Cairo::RefPtr<Cairo::Context> cr)
_left = _right - 5000;
}
cr->save();
- double horizScale
- = _zoomFactor * _graphWidth / static_cast<double>(_right - _left);
+ double horizScale = getHorizontalScale();
cr->translate(_xOffset, _yOffset);
cr->set_line_width(_lineWidth);
@@ -103,10 +102,11 @@ void Graph::draw(Cairo::RefPtr<Cairo::Context> cr)
cr->select_font_face("Sans", Cairo::FONT_SLANT_NORMAL,
Cairo::FONT_WEIGHT_NORMAL);
cr->set_font_size(10.0);
- cr->move_to(_xOffset, _yOffset);
- cr->line_to(_xOffset, _height);
- cr->move_to(_xOffset, _graphHeight);
- cr->line_to(_graphWidth, _graphHeight);
+ cr->translate(_xOffset, 0.0);
+ cr->move_to(0.0, _yOffset);
+ cr->line_to(0.0, _height);
+ cr->move_to(0.0, _graphHeight);
+ cr->line_to(_graphWidth - _xOffset, _graphHeight);
cr->stroke();
std::valarray<double> dash(1);
dash[0] = _graphHeight / 10;
@@ -114,7 +114,7 @@ void Graph::draw(Cairo::RefPtr<Cairo::Context> cr)
double prevTextAdvance = 0;
for (int64_t tickVal = startTime; tickVal <= _right; tickVal += majorUnit)
{
- double x = (tickVal - _left) * horizScale + _xOffset;
+ double x = (tickVal - _right) * horizScale + _graphWidth;
cr->move_to(x, _yOffset);
cr->line_to(x, _graphHeight);
std::ostringstream stream;
@@ -170,8 +170,7 @@ bool Graph::containsPoint(double x, double y)
int64_t Graph::getTimeAtPoint(double x)
{
- return (_left
- + (_right - _left) * ((x - _xOffset)/(_zoomFactor * _graphWidth)));
+ return (x - _graphWidth) / getHorizontalScale() + _right;
}
void Graph::window2GraphCoords(double x, double y,