From 4a1df686a5c0f08997c27a03c4dd29087ac3b7f7 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Thu, 11 Mar 2021 21:42:38 -0500 Subject: [PATCH] Update max l1 label size on chart --- piker/ui/_graphics/_curve.py | 3 ++- piker/ui/_interaction.py | 2 +- piker/ui/_l1.py | 19 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/piker/ui/_graphics/_curve.py b/piker/ui/_graphics/_curve.py index 4feb5d37..9236ed79 100644 --- a/piker/ui/_graphics/_curve.py +++ b/piker/ui/_graphics/_curve.py @@ -1,5 +1,5 @@ # piker: trading gear for hackers -# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0) +# Copyright (C) Tyler Goodlet (in stewardship for piker0) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -16,6 +16,7 @@ """ Fast, smooth, sexy curves. + """ from typing import Tuple diff --git a/piker/ui/_interaction.py b/piker/ui/_interaction.py index 16ae71f3..41bc8571 100644 --- a/piker/ui/_interaction.py +++ b/piker/ui/_interaction.py @@ -121,7 +121,7 @@ class SelectRect(QtGui.QGraphicsRectItem): p1: QtCore.QPointF, p2: QtCore.QPointF ) -> None: - """Set position of selection rectagle and accompanying label, move + """Set position of selection rect and accompanying label, move label to match. """ diff --git a/piker/ui/_l1.py b/piker/ui/_l1.py index 90cc8aba..ab7f8363 100644 --- a/piker/ui/_l1.py +++ b/piker/ui/_l1.py @@ -152,7 +152,7 @@ class LevelLabel(YAxisLabel): h, w = self.set_label_str(fields) if self._adjust_to_l1: - self._x_offset = _max_l1_line_len + self._x_offset = self._chart._max_l1_line_len self.setPos(QPointF( self._h_shift * (w + self._x_offset), @@ -211,11 +211,6 @@ class LevelLabel(YAxisLabel): self.update() -# global for now but probably should be -# attached to chart instance? -_max_l1_line_len: float = 0 - - class L1Label(LevelLabel): text_flags = ( @@ -232,10 +227,14 @@ class L1Label(LevelLabel): """ h, w = super().set_label_str(fields) - # Set a global "max L1 label length" so we can look it up - # on order lines and adjust their labels not to overlap with it. - global _max_l1_line_len - _max_l1_line_len = max(_max_l1_line_len, w) + # Set a global "max L1 label length" so we can + # look it up on order lines and adjust their + # labels not to overlap with it. + chart = self._chart + chart._max_l1_line_len: float = max( + chart._max_l1_line_len, + w + ) return h, w