In __init__:
self.setAnchor(self.anchors[1]) #set to left of line
# self.setAnchor(self.anchors[0]) #set to right of line
Now just change updatePosition as follows:
def updatePosition(self):
# update text position to relative view location along line
self._endpoints = (None, None)
pt1, pt2 = self.getEndpoints()
if pt1 is None:
return
pt = pt2 * self.orthoPos + pt1 * (1-self.orthoPos)
self.setPos(pt)
#This flips the text label automatically to the left or right of the
line when the
#line transverses the middle of the viewbox
# update anchor to keep text visible as it nears the view box edge
# vr = self.line.viewRect()
# if vr is not None:
# logger.debug(vr.center().y())
# self.setAnchor(self.anchors[0 if vr.center().y() < 0 else 1])
On Monday, August 2, 2021 at 6:51:48 PM UTC+2 [email protected] wrote:
> Hey guys,
>
> i'm trying to modify the InfLineLabel class so that its x-position is
> fixed and its y-position is relative to the viewbox, just like when a
> normal InflineLabel is attached to a vertical InfiniteLine. If it's parent
> isn't a InfLine, it behaves like it's attached to a horizontal one, meaning
> it's locked to the y-position instead to the x and it can be moved along
> the x-axis instead of the y. I simply cannot find at all where or how the
> alignment of the line is checked.
>
> The changes are really rudimentary, but i attached the modified class. I'd
> really appreciate if someone could help me out.
--
You received this message because you are subscribed to the Google Groups
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyqtgraph/eb541a09-24b7-46ac-adff-0c7805969ac7n%40googlegroups.com.