Fix label snap on line highlight bug
parent
cf2f001bcc
commit
61198818dc
|
@ -377,11 +377,12 @@ class Cursor(pg.GraphicsObject):
|
|||
# px perfect...
|
||||
line_offset = self._lw / 2
|
||||
|
||||
if iy != last_iy and self._y_label_update:
|
||||
if iy != last_iy:
|
||||
|
||||
# update y-range items
|
||||
self.graphics[plot]['hl'].setY(iy + line_offset)
|
||||
|
||||
if self._y_label_update:
|
||||
self.graphics[self.active_plot]['yl'].update_label(
|
||||
abs_pos=plot.mapFromView(QPointF(ix, iy + line_offset)),
|
||||
value=iy
|
||||
|
@ -425,15 +426,22 @@ class Cursor(pg.GraphicsObject):
|
|||
except AttributeError:
|
||||
return self.plots[0].boundingRect()
|
||||
|
||||
def show_xhair(self) -> None:
|
||||
def show_xhair(
|
||||
self,
|
||||
y_label_level: float = None,
|
||||
) -> None:
|
||||
g = self.graphics[self.active_plot]
|
||||
# show horiz line and y-label
|
||||
g['hl'].show()
|
||||
g['vl'].show()
|
||||
|
||||
self._y_label_update = True
|
||||
yl = g['yl']
|
||||
# yl.fg_color = pg.mkColor(hcolor('black'))
|
||||
# yl.bg_color = pg.mkColor(hcolor(self.label_color))
|
||||
if y_label_level:
|
||||
yl.update_from_data(0, y_label_level, _save_last=False)
|
||||
|
||||
yl.show()
|
||||
|
||||
def hide_xhair(
|
||||
|
@ -447,12 +455,15 @@ class Cursor(pg.GraphicsObject):
|
|||
g['hl'].hide()
|
||||
g['vl'].hide()
|
||||
|
||||
# only disable cursor y-label updates
|
||||
# if we're highlighting a line
|
||||
yl = g['yl']
|
||||
|
||||
if hide_label:
|
||||
yl.hide()
|
||||
|
||||
elif y_label_level:
|
||||
yl.update_from_data(0, y_label_level)
|
||||
yl.update_from_data(0, y_label_level, _save_last=False)
|
||||
|
||||
if fg_color is not None:
|
||||
yl.fg_color = pg.mkColor(hcolor(fg_color))
|
||||
|
|
|
@ -320,6 +320,7 @@ class LevelLine(pg.InfiniteLine):
|
|||
|
||||
self.currentPen = self.hoverPen
|
||||
|
||||
if self not in cur._trackers:
|
||||
# only disable cursor y-label updates
|
||||
# if we're highlighting a line
|
||||
cur._y_label_update = False
|
||||
|
@ -348,7 +349,7 @@ class LevelLine(pg.InfiniteLine):
|
|||
cur._hovered.remove(self)
|
||||
|
||||
if self not in cur._trackers:
|
||||
cur.show_xhair()
|
||||
cur.show_xhair(y_label_level=self.value())
|
||||
|
||||
if not self._always_show_labels:
|
||||
for at, label in self._labels:
|
||||
|
|
Loading…
Reference in New Issue