Use dashed crosshair, simplify x-axis alloc
parent
387a696232
commit
ea2a675adf
|
@ -19,6 +19,7 @@ from ._axes import YAxisLabel, XAxisLabel
|
||||||
|
|
||||||
_mouse_rate_limit = 30
|
_mouse_rate_limit = 30
|
||||||
_debounce_delay = 10
|
_debounce_delay = 10
|
||||||
|
_ch_label_opac = 1
|
||||||
|
|
||||||
|
|
||||||
class CrossHair(pg.GraphicsObject):
|
class CrossHair(pg.GraphicsObject):
|
||||||
|
@ -29,7 +30,13 @@ class CrossHair(pg.GraphicsObject):
|
||||||
digits: int = 0
|
digits: int = 0
|
||||||
) -> None:
|
) -> None:
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
# XXX: not sure why these are instance variables?
|
||||||
|
# It's not like we can change them on the fly..?
|
||||||
self.pen = pg.mkPen(
|
self.pen = pg.mkPen(
|
||||||
|
color=hcolor('default'),
|
||||||
|
style=QtCore.Qt.DashLine,
|
||||||
|
)
|
||||||
|
self.lines_pen = pg.mkPen(
|
||||||
color='#a9a9a9', # gray?
|
color='#a9a9a9', # gray?
|
||||||
style=QtCore.Qt.DashLine,
|
style=QtCore.Qt.DashLine,
|
||||||
)
|
)
|
||||||
|
@ -46,12 +53,13 @@ class CrossHair(pg.GraphicsObject):
|
||||||
) -> None:
|
) -> None:
|
||||||
# add ``pg.graphicsItems.InfiniteLine``s
|
# add ``pg.graphicsItems.InfiniteLine``s
|
||||||
# vertical and horizonal lines and a y-axis label
|
# vertical and horizonal lines and a y-axis label
|
||||||
vl = plot.addLine(x=0, pen=self.pen, movable=False)
|
vl = plot.addLine(x=0, pen=self.lines_pen, movable=False)
|
||||||
hl = plot.addLine(y=0, pen=self.pen, movable=False)
|
hl = plot.addLine(y=0, pen=self.lines_pen, movable=False)
|
||||||
yl = YAxisLabel(
|
yl = YAxisLabel(
|
||||||
parent=plot.getAxis('right'),
|
parent=plot.getAxis('right'),
|
||||||
digits=digits or self.digits,
|
digits=digits or self.digits,
|
||||||
opacity=0.7,
|
opacity=_ch_label_opac,
|
||||||
|
color=self.pen,
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO: checkout what ``.sigDelayed`` can be used for
|
# TODO: checkout what ``.sigDelayed`` can be used for
|
||||||
|
@ -82,21 +90,16 @@ class CrossHair(pg.GraphicsObject):
|
||||||
}
|
}
|
||||||
self.plots.append(plot)
|
self.plots.append(plot)
|
||||||
|
|
||||||
# determine where to place x-axis label
|
# Determine where to place x-axis label.
|
||||||
if _xaxis_at == 'bottom':
|
# Place below the last plot by default, ow
|
||||||
# place below the last plot
|
# keep x-axis right below main chart
|
||||||
self.xaxis_label = XAxisLabel(
|
plot_index = -1 if _xaxis_at == 'bottom' else 0
|
||||||
parent=self.plots[-1].getAxis('bottom'),
|
|
||||||
opacity=0.7
|
self.xaxis_label = XAxisLabel(
|
||||||
)
|
parent=self.plots[plot_index].getAxis('bottom'),
|
||||||
else:
|
opacity=_ch_label_opac,
|
||||||
# keep x-axis right below main chart
|
color=self.pen,
|
||||||
first = self.plots[0]
|
)
|
||||||
xaxis = first.getAxis('bottom')
|
|
||||||
self.xaxis_label = XAxisLabel(
|
|
||||||
parent=xaxis,
|
|
||||||
opacity=0.7,
|
|
||||||
)
|
|
||||||
|
|
||||||
def mouseAction(self, action, plot): # noqa
|
def mouseAction(self, action, plot): # noqa
|
||||||
if action == 'Enter':
|
if action == 'Enter':
|
||||||
|
|
Loading…
Reference in New Issue