From 4fca37ae3561da7d0664e0f943146398a8e554dd Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 22 Dec 2009 19:48:20 +0100 Subject: 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. --- grapher/Graph.hxx | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'grapher/Graph.hxx') diff --git a/grapher/Graph.hxx b/grapher/Graph.hxx index d9f615b3..0853d988 100644 --- a/grapher/Graph.hxx +++ b/grapher/Graph.hxx @@ -51,6 +51,14 @@ public: int64_t getTimeAtPoint(double x); void window2GraphCoords(double x, double y, double& xgraph, double& ygraph); static void setCurrentTime(int64_t time) { _currentTime = time; } + + /* + * universal horizontal factor + */ + double getHorizontalScale() + { + return _zoomFactor * _graphWidth / static_cast(_right - _left); + } protected: GraphDataList _datasets; int64_t _left; -- cgit