pthomas
unread,Feb 4, 2021, 3:07:37 PM2/4/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to pyqtgraph
I am collaborating on code that uses a custom class for the time axis:
class TimeStringAxis(pg.AxisItem):
def __init__(self, orientation='bottom', **kwargs):
super().__init__(orientation, **kwargs)
self.tick_strings_mode = 1
def tickSpacing(self, minVal, maxVal, size):
span = abs(maxVal - minVal)
for major, minordiv in const.TICK_SPACINGS:
if span >= 3*major:
break
return [
(major, 0),
(major/minordiv, 0),
]
def tickStrings(self, values, scale, spacing):
if self.tick_strings_mode == 0:
return values
elif self.tick_strings_mode == 1:
return [str(util.TDStr(t)) for t in values]
else:
return values
def setTickStringsMode(self, mode):
self.tick_strings_mode = mode
self.update()
The current goal is to be able to change the format of the tick strings from the plot context menu. The issue is that the tick strings do not update until a zoom or pan changes the range. Calling update doesn't seem to do anything. Is there a means to force the axis to repaint after the call to setTickStringsMode?