Fixed AxisItem not resizing text area when setTicks() is used

This commit is contained in:
Luke Campagnola 2014-04-12 17:02:56 -04:00
parent 202edc4e30
commit c5d4c92a75
2 changed files with 13 additions and 13 deletions

View File

@ -82,6 +82,7 @@ pyqtgraph-0.9.9 [unreleased]
- Fixed parametertree.Parameter.sigValueChanging
- Fixed AxisItem.__init__(showValues=False)
- Fixed TableWidget append / sort issues
- Fixed AxisItem not resizing text area when setTicks() is used
pyqtgraph-0.9.8 2013-11-24

View File

@ -690,7 +690,7 @@ class AxisItem(GraphicsWidget):
def generateDrawSpecs(self, p):
"""
Calls tickValues() and tickStrings to determine where and how ticks should
Calls tickValues() and tickStrings() to determine where and how ticks should
be drawn, then generates from this a set of drawing commands to be
interpreted by drawPicture().
"""
@ -739,6 +739,7 @@ class AxisItem(GraphicsWidget):
if lengthInPixels == 0:
return
# Determine major / minor / subminor axis ticks
if self._tickLevels is None:
tickLevels = self.tickValues(self.range[0], self.range[1], lengthInPixels)
tickStrings = None
@ -778,8 +779,7 @@ class AxisItem(GraphicsWidget):
tickPositions = [] # remembers positions of previously drawn ticks
## draw ticks
## (to improve performance, we do not interleave line and text drawing, since this causes unnecessary pipeline switching)
## compute coordinates to draw ticks
## draw three different intervals, long ticks first
tickSpecs = []
for i in range(len(tickLevels)):
@ -814,7 +814,6 @@ class AxisItem(GraphicsWidget):
tickSpecs.append((tickPen, Point(p1), Point(p2)))
profiler('compute ticks')
## This is where the long axis line should be drawn
if self.style['stopAxisAtTick'][0] is True:
stop = max(span[0].y(), min(map(min, tickPositions)))
@ -831,7 +830,6 @@ class AxisItem(GraphicsWidget):
axisSpec = (self.pen(), span[0], span[1])
textOffset = self.style['tickTextOffset'][axis] ## spacing between axis and text
#if self.style['autoExpandTextSpace'] is True:
#textWidth = self.textWidth
@ -878,7 +876,6 @@ class AxisItem(GraphicsWidget):
rects.append(br)
textRects.append(rects[-1])
if i > 0: ## always draw top level
## measure all text, make sure there's enough room
if axis == 0:
textSize = np.sum([r.height() for r in textRects])
@ -887,6 +884,7 @@ class AxisItem(GraphicsWidget):
textSize = np.sum([r.width() for r in textRects])
textSize2 = np.max([r.height() for r in textRects]) if textRects else 0
if i > 0: ## always draw top level
## If the strings are too crowded, stop drawing text now.
## We use three different crowding limits based on the number
## of texts drawn so far.
@ -901,6 +899,7 @@ class AxisItem(GraphicsWidget):
#spacing, values = tickLevels[best]
#strings = self.tickStrings(values, self.scale, spacing)
# Determine exactly where tick text should be drawn
for j in range(len(strings)):
vstr = strings[j]
if vstr is None: ## this tick was ignored because it is out of bounds