Support hiding only "half" the xhair

basic_orders
Tyler Goodlet 2021-03-18 13:27:49 -04:00
parent e1dc2b9225
commit 2c7d8cdbb0
1 changed files with 12 additions and 4 deletions

View File

@ -380,10 +380,8 @@ class Cursor(pg.GraphicsObject):
# px perfect...
line_offset = self._lw / 2
if iy != last_iy:
# update y-range items
self.graphics[plot]['hl'].setY(iy + line_offset)
if iy != last_iy:
if self._y_label_update:
self.graphics[self.active_plot]['yl'].update_label(
@ -391,6 +389,10 @@ class Cursor(pg.GraphicsObject):
value=iy
)
# only update horizontal xhair line if label is enabled
self.graphics[plot]['hl'].setY(iy + line_offset)
# update all trackers
for item in self._trackers:
# print(f'setting {item} with {(ix, y)}')
@ -451,11 +453,16 @@ class Cursor(pg.GraphicsObject):
self,
hide_label: bool = False,
y_label_level: float = None,
just_vertical: bool = False,
fg_color: str = None,
# bg_color: str = 'papas_special',
) -> None:
g = self.graphics[self.active_plot]
g['hl'].hide()
hl = g['hl']
if not just_vertical:
hl.hide()
g['vl'].hide()
# only disable cursor y-label updates
@ -467,6 +474,7 @@ class Cursor(pg.GraphicsObject):
elif y_label_level:
yl.update_from_data(0, y_label_level, _save_last=False)
hl.setY(y_label_level)
if fg_color is not None:
yl.fg_color = pg.mkColor(hcolor(fg_color))