avoid calling setLabel repeatedly for AxisItem
This commit is contained in:
parent
2e69b9c5e6
commit
b575b56edf
@ -17,7 +17,7 @@ class AxisItem(GraphicsWidget):
|
||||
If maxTickLength is negative, ticks point into the plot.
|
||||
"""
|
||||
|
||||
def __init__(self, orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True):
|
||||
def __init__(self, orientation, pen=None, linkView=None, parent=None, maxTickLength=-5, showValues=True, text='', units='', unitPrefix='', **args):
|
||||
"""
|
||||
============== ===============================================================
|
||||
**Arguments:**
|
||||
@ -28,6 +28,14 @@ class AxisItem(GraphicsWidget):
|
||||
to be linked to the visible range of a ViewBox.
|
||||
showValues (bool) Whether to display values adjacent to ticks
|
||||
pen (QPen) Pen used when drawing ticks.
|
||||
text The text (excluding units) to display on the label for this
|
||||
axis.
|
||||
units The units for this axis. Units should generally be given
|
||||
without any scaling prefix (eg, 'V' instead of 'mV'). The
|
||||
scaling prefix will be automatically prepended based on the
|
||||
range of data displayed.
|
||||
**args All extra keyword arguments become CSS style options for
|
||||
the <span> tag which will surround the axis label and units.
|
||||
============== ===============================================================
|
||||
"""
|
||||
|
||||
@ -67,10 +75,10 @@ class AxisItem(GraphicsWidget):
|
||||
self.fixedWidth = None
|
||||
self.fixedHeight = None
|
||||
|
||||
self.labelText = ''
|
||||
self.labelUnits = ''
|
||||
self.labelUnitPrefix=''
|
||||
self.labelStyle = {}
|
||||
self.labelText = text
|
||||
self.labelUnits = units
|
||||
self.labelUnitPrefix = unitPrefix
|
||||
self.labelStyle = args
|
||||
self.logMode = False
|
||||
self.tickFont = None
|
||||
|
||||
@ -256,11 +264,14 @@ class AxisItem(GraphicsWidget):
|
||||
axis.setLabel('label text', units='V', **labelStyle)
|
||||
|
||||
"""
|
||||
show_label = False
|
||||
if text is not None:
|
||||
self.labelText = text
|
||||
self.showLabel()
|
||||
show_label = True
|
||||
if units is not None:
|
||||
self.labelUnits = units
|
||||
show_label = True
|
||||
if show_label:
|
||||
self.showLabel()
|
||||
if unitPrefix is not None:
|
||||
self.labelUnitPrefix = unitPrefix
|
||||
|
Loading…
Reference in New Issue
Block a user