Only update x-axis cursor if chart has a 'bottom' axis
parent
9e18afe0d7
commit
1ccff37677
|
@ -418,13 +418,16 @@ class Cursor(pg.GraphicsObject):
|
||||||
# keep x-axis right below main chart
|
# keep x-axis right below main chart
|
||||||
plot_index = -1 if _xaxis_at == 'bottom' else 0
|
plot_index = -1 if _xaxis_at == 'bottom' else 0
|
||||||
|
|
||||||
self.xaxis_label = XAxisLabel(
|
# ONLY create an x-axis label for the cursor
|
||||||
parent=self.plots[plot_index].getAxis('bottom'),
|
# if this plot owns the 'bottom' axis.
|
||||||
opacity=_ch_label_opac,
|
if 'bottom' in plot.plotItem.axes:
|
||||||
bg_color=self.label_color,
|
self.xaxis_label = XAxisLabel(
|
||||||
)
|
parent=self.plots[plot_index].getAxis('bottom'),
|
||||||
# place label off-screen during startup
|
opacity=_ch_label_opac,
|
||||||
self.xaxis_label.setPos(self.plots[0].mapFromView(QPointF(0, 0)))
|
bg_color=self.label_color,
|
||||||
|
)
|
||||||
|
# place label off-screen during startup
|
||||||
|
self.xaxis_label.setPos(self.plots[0].mapFromView(QPointF(0, 0)))
|
||||||
|
|
||||||
def add_curve_cursor(
|
def add_curve_cursor(
|
||||||
self,
|
self,
|
||||||
|
@ -525,17 +528,18 @@ class Cursor(pg.GraphicsObject):
|
||||||
for cursor in opts.get('cursors', ()):
|
for cursor in opts.get('cursors', ()):
|
||||||
cursor.setIndex(ix)
|
cursor.setIndex(ix)
|
||||||
|
|
||||||
# update the label on the bottom of the crosshair
|
# update the label on the bottom of the crosshair
|
||||||
self.xaxis_label.update_label(
|
if 'bottom' in plot.plotItem.axes:
|
||||||
|
self.xaxis_label.update_label(
|
||||||
|
|
||||||
# XXX: requires:
|
# XXX: requires:
|
||||||
# https://github.com/pyqtgraph/pyqtgraph/pull/1418
|
# https://github.com/pyqtgraph/pyqtgraph/pull/1418
|
||||||
# otherwise gobbles tons of CPU..
|
# otherwise gobbles tons of CPU..
|
||||||
|
|
||||||
# map back to abs (label-local) coordinates
|
# map back to abs (label-local) coordinates
|
||||||
abs_pos=plot.mapFromView(QPointF(ix + line_offset, iy)),
|
abs_pos=plot.mapFromView(QPointF(ix + line_offset, iy)),
|
||||||
value=ix,
|
value=ix,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._datum_xy = ix, iy
|
self._datum_xy = ix, iy
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue