Skip to content

ScatterPlotItem: hoverable=True does not create Tooltip #2135

@marlemion

Description

@marlemion

Tested with python -m pyqtgraph.examples

--> GraphicsItems --> Scatter Plot

Changed:
g.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120))
to:
g.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120), hoverable=True)
or:
g.ScatterPlotItem(size=10, pen=pg.mkPen(None), brush=pg.mkBrush(255, 255, 255, 120), hoverable=True, tip='x: {x:.3g}\ny: {y:.3g}\ndata={data}'.format)

Expected behaviour: When hovering over the data points a tooltip should be shown.
Experienced behaviour: Tooltip is not shown.

Tested on:
0.12.2 on Windows
0.11.1 on Linux (Arch)

The respective code lies in ScatterPlotItem.py (l. 1224):

           # Show information about hovered points in a tool tip
            vb = self.getViewBox()
            if vb is not None and self.opts['tip'] is not None:
                cutoff = 3
                tip = [self.opts['tip'](x=pt.pos().x(), y=pt.pos().y(), data=pt.data())
                       for pt in points[:cutoff]]
                if len(points) > cutoff:
                    tip.append('({} others...)'.format(len(points) - cutoff))
                print('\n\n'.join(tip)) # ADDED to TEST
                vb.setToolTip('\n\n'.join(tip))

            self.sigHovered.emit(self, points, ev)

The added line shows that the tip is created, but it is never shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions