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 parametertree.Parameter.sigValueChanging
- Fixed AxisItem.__init__(showValues=False) - Fixed AxisItem.__init__(showValues=False)
- Fixed TableWidget append / sort issues - Fixed TableWidget append / sort issues
- Fixed AxisItem not resizing text area when setTicks() is used
pyqtgraph-0.9.8 2013-11-24 pyqtgraph-0.9.8 2013-11-24

View File

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