summaryrefslogtreecommitdiffstats
path: root/grapher/GraphStyle.cxx
diff options
context:
space:
mode:
authorTim Moore <timoore@redhat.com>2009-12-02 19:27:07 +0100
committerTim Moore <timoore@redhat.com>2009-12-02 19:39:37 +0100
commitc10fce7d6aaa57a4f94f9d7aeea906597456f7ce (patch)
treef518b6a5387c3a015eb1930d44c208ef0b3f7abe /grapher/GraphStyle.cxx
parent6197b0dc80c4f87000d26213293fe2cb72fbe081 (diff)
downloadsystemtap-steved-c10fce7d6aaa57a4f94f9d7aeea906597456f7ce.tar.gz
systemtap-steved-c10fce7d6aaa57a4f94f9d7aeea906597456f7ce.tar.xz
systemtap-steved-c10fce7d6aaa57a4f94f9d7aeea906597456f7ce.zip
Make the hover text conform to data displayed.
Start of code to be more selective about the association between the hover text and the underling graph. Also, show the data set name in hover text. * grapher/GraphStyle.hxx (dataIndexAtPoint): New virtual function. * grapher/GraphStyle.cxx (dataIndexAtPoint): Implementation for bar graphs * grapher/GraphWidget.cxx (onHoverTimeout): Use dataIndexAtPoint.
Diffstat (limited to 'grapher/GraphStyle.cxx')
-rw-r--r--grapher/GraphStyle.cxx26
1 files changed, 26 insertions, 0 deletions
diff --git a/grapher/GraphStyle.cxx b/grapher/GraphStyle.cxx
index 887ed55f..55fc73f4 100644
--- a/grapher/GraphStyle.cxx
+++ b/grapher/GraphStyle.cxx
@@ -8,6 +8,9 @@ namespace systemtap
using namespace std;
using namespace tr1;
+ typedef pair<GraphDataBase::TimeList::iterator,
+ GraphDataBase::TimeList::iterator> TimeListPair;
+
GraphStyleBar GraphStyleBar::instance;
void GraphStyleBar::draw(std::tr1::shared_ptr<GraphDataBase> graphData,
@@ -41,6 +44,29 @@ namespace systemtap
}
}
+ ssize_t GraphStyleBar::dataIndexAtPoint(double x, double y,
+ shared_ptr<GraphDataBase> graphData,
+ shared_ptr<Graph> graph)
+ {
+ shared_ptr<GraphData<double> > realData
+ = dynamic_pointer_cast<GraphData<double> >(graphData);
+ if (!realData)
+ return -1;
+ int64_t left, right;
+ double top, bottom;
+ graph->getExtents(left, right, top, bottom);
+ double t = graph->getTimeAtPoint(x);
+ TimeListPair range
+ = equal_range(graphData->times.begin(), graphData->times.end(), t);
+ size_t dataIndex = distance(graphData->times.begin(), range.first);
+ double val = realData->data[dataIndex];
+ double ycoord = val * graph->_graphHeight / graphData->scale;
+ if (y >= graph->_yOffset + graph->_graphHeight - ycoord)
+ return static_cast<ssize_t>(dataIndex);
+ else
+ return -1;
+ }
+
GraphStyleDot GraphStyleDot::instance;
void GraphStyleDot::draw(std::tr1::shared_ptr<GraphDataBase> graphData,