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]Silhouette Plot: elide hover labels if labels are long #2278

Merged
merged 1 commit into from
May 26, 2017
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
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 @@ -507,7 +510,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 @@ -907,8 +913,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 @@ -918,11 +923,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