Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] scatterplot: limit number of points displayed in tooltip #2980

Merged
merged 2 commits into from
Mar 30, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Orange/widgets/visualize/owscatterplotgraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@

SELECTION_WIDTH = 5
MAX = 11 # maximum number of colors or shapes (including Other)
MAX_POINTS_IN_TOOLTIP = 5


class PaletteItemSample(ItemSample):
"""A color strip to insert into legends for discretized continuous values"""
Expand Down Expand Up @@ -1227,8 +1229,16 @@ def point_data(p):

act_pos = self.scatterplot_item.mapFromScene(event.scenePos())
points = self.scatterplot_item.pointsAt(act_pos)

if len(points):
text = "<hr/>".join(point_data(point) for point in points)
if len(points) > MAX_POINTS_IN_TOOLTIP:
text = "{} instances<hr/>{}<hr/>...".format(
len(points),
"<hr/>".join(point_data(point) for point in points[:MAX_POINTS_IN_TOOLTIP])
)
else:
text = "<hr/>".join(point_data(point) for point in points)

QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)
return True
else:
Expand Down