Clipped AxisItem tick value labels to prevent drawing artifacts #732 (#1447)

This commit is contained in:
Matt Liberty 2020-11-21 03:46:31 -05:00 committed by GitHub
parent 71a92a6fd2
commit a3fbd18239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -649,7 +649,6 @@ class AxisItem(GraphicsWidget):
self.picture = None self.picture = None
self.update() self.update()
def tickSpacing(self, minVal, maxVal, size): def tickSpacing(self, minVal, maxVal, size):
"""Return values describing the desired spacing and offset of ticks. """Return values describing the desired spacing and offset of ticks.
@ -1149,6 +1148,8 @@ class AxisItem(GraphicsWidget):
if self.style['tickFont'] is not None: if self.style['tickFont'] is not None:
p.setFont(self.style['tickFont']) p.setFont(self.style['tickFont'])
p.setPen(self.textPen()) p.setPen(self.textPen())
bounding = self.boundingRect().toAlignedRect()
p.setClipRect(bounding)
for rect, flags, text in textSpecs: for rect, flags, text in textSpecs:
p.drawText(rect, int(flags), text) p.drawText(rect, int(flags), text)