Skip to content

Commit bcedaa3

Browse files
authored
Merge pull request #2980 from astaric/scatterplot-prune-tooltip
[FIX] scatterplot: limit number of points displayed in tooltip
2 parents 029d3d4 + ca678b5 commit bcedaa3

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

Orange/widgets/visualize/owscatterplotgraph.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636

3737
SELECTION_WIDTH = 5
3838
MAX = 11 # maximum number of colors or shapes (including Other)
39+
MAX_POINTS_IN_TOOLTIP = 5
40+
3941

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

12281230
act_pos = self.scatterplot_item.mapFromScene(event.scenePos())
12291231
points = self.scatterplot_item.pointsAt(act_pos)
1232+
12301233
if len(points):
1231-
text = "<hr/>".join(point_data(point) for point in points)
1234+
if len(points) > MAX_POINTS_IN_TOOLTIP:
1235+
text = "{} instances<hr/>{}<hr/>...".format(
1236+
len(points),
1237+
"<hr/>".join(point_data(point) for point in points[:MAX_POINTS_IN_TOOLTIP])
1238+
)
1239+
else:
1240+
text = "<hr/>".join(point_data(point) for point in points)
1241+
12321242
QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)
12331243
return True
12341244
else:

0 commit comments

Comments
 (0)