Skip to content

Commit

Permalink
Merge pull request #2278 from jerneju/gh-2162-silhouette-labels
Browse files Browse the repository at this point in the history
[FIX]Silhouette Plot: elide hover labels if labels are long
  • Loading branch information
janezd authored May 26, 2017
2 parents c167230 + 2b02478 commit 77ed48b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Orange/widgets/visualize/owsilhouetteplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@
from Orange.widgets.widget import Msg


ROW_NAMES_WIDTH = 200


class OWSilhouettePlot(widget.OWWidget):
name = "Silhouette Plot"
description = "Visually assess cluster quality and " \
Expand Down Expand Up @@ -506,7 +509,10 @@ def setRowNames(self, names):
item = layout.itemAt(i + 1, 3)

if grp.rownames is not None:
item.setItems(grp.rownames)
metrics = QFontMetrics(self.font())
rownames = [metrics.elidedText(rowname, Qt.ElideRight, ROW_NAMES_WIDTH)
for rowname in grp.rownames]
item.setItems(rownames)
item.setVisible(self.__rowNamesVisible)
else:
item.setItems([])
Expand Down Expand Up @@ -906,8 +912,7 @@ def event(self, event):
return super().event(event)

def sizeHint(self, which, constraint=QSizeF()):
spacing = max(self.__spacing * (self.count() - 1), 0)
return QSizeF(300, self.__barsize * self.count() + spacing)
return QSizeF(300, (self.__barsize + self.__spacing) * self.count())

def setPreferredBarSize(self, size):
if self.__barsize != size:
Expand All @@ -917,11 +922,6 @@ def setPreferredBarSize(self, size):
def spacing(self):
return self.__spacing

def setSpacing(self, spacing):
if self.__spacing != spacing:
self.__spacing = spacing
self.updateGeometry()

def setPen(self, pen):
pen = QPen(pen)
if self.__pen != pen:
Expand Down

0 comments on commit 77ed48b

Please sign in to comment.