diff options
author | Tim Moore <timoore@redhat.com> | 2009-12-02 19:27:07 +0100 |
---|---|---|
committer | Tim Moore <timoore@redhat.com> | 2009-12-02 19:39:37 +0100 |
commit | c10fce7d6aaa57a4f94f9d7aeea906597456f7ce (patch) | |
tree | f518b6a5387c3a015eb1930d44c208ef0b3f7abe /grapher/GraphWidget.cxx | |
parent | 6197b0dc80c4f87000d26213293fe2cb72fbe081 (diff) | |
download | systemtap-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/GraphWidget.cxx')
-rw-r--r-- | grapher/GraphWidget.cxx | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/grapher/GraphWidget.cxx b/grapher/GraphWidget.cxx index 9a203d87..9067988a 100644 --- a/grapher/GraphWidget.cxx +++ b/grapher/GraphWidget.cxx @@ -276,20 +276,23 @@ namespace systemtap if (!_hoverText) _hoverText = shared_ptr<CairoTextBox>(new CairoTextBox()); _hoverText->setOrigin(_mouseX + 5, _mouseY - 5); - int64_t t = g->getTimeAtPoint(_mouseX); Graph::DatasetList& dataSets = g->getDatasets(); - if (!dataSets.empty()) - { - shared_ptr<GraphDataBase> gdbase = dataSets[0]; - GraphDataBase::TimeList::iterator itime - = std::lower_bound(gdbase->times.begin(), gdbase->times.end(), t); - if (itime != gdbase->times.end()) { - size_t index = distance(gdbase->times.begin(), itime); - _hoverText->contents = gdbase->elementAsString(index); - _hoverText->setVisible(true); - queue_draw(); + for (Graph::DatasetList::reverse_iterator ritr = dataSets.rbegin(), + end = dataSets.rend(); + ritr != end; + ++ritr) + { + ssize_t index + = (*ritr)->style->dataIndexAtPoint(_mouseX, _mouseY, *ritr, g); + if (index >= 0) + { + _hoverText->contents = (*ritr)->name + + ": " + (*ritr)->elementAsString(index); + _hoverText->setVisible(true); + queue_draw(); + break; } - } + } } return false; } |