Use dashed crosshair, simplify x-axis alloc
parent
19609178ce
commit
30d8e096c6
|
@ -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,20 +90,15 @@ 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
|
|
||||||
self.xaxis_label = XAxisLabel(
|
|
||||||
parent=self.plots[-1].getAxis('bottom'),
|
|
||||||
opacity=0.7
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
# keep x-axis right below main chart
|
# keep x-axis right below main chart
|
||||||
first = self.plots[0]
|
plot_index = -1 if _xaxis_at == 'bottom' else 0
|
||||||
xaxis = first.getAxis('bottom')
|
|
||||||
self.xaxis_label = XAxisLabel(
|
self.xaxis_label = XAxisLabel(
|
||||||
parent=xaxis,
|
parent=self.plots[plot_index].getAxis('bottom'),
|
||||||
opacity=0.7,
|
opacity=_ch_label_opac,
|
||||||
|
color=self.pen,
|
||||||
)
|
)
|
||||||
|
|
||||||
def mouseAction(self, action, plot): # noqa
|
def mouseAction(self, action, plot): # noqa
|
||||||
|
|
Loading…
Reference in New Issue