Move margin settings to class scope

basic_orders
Tyler Goodlet 2021-03-16 15:58:17 -04:00
parent 61198818dc
commit adf6437449
1 changed files with 19 additions and 16 deletions

View File

@ -113,13 +113,23 @@ class LineDot(pg.CurvePoint):
return False
# TODO: likely will need to tweak this based on dpi...
_y_margin = 5
# TODO: change this into our own ``Label``
class ContentsLabel(pg.LabelItem):
"""Label anchored to a ``ViewBox`` typically for displaying
datum-wise points from the "viewed" contents.
"""
_corner_anchors = {
'top': 0,
'left': 0,
'bottom': 1,
'right': 1,
}
_y_margin = 5
# XXX: fyi naming here is confusing / opposite to coords
_corner_margins = {
('top', 'left'): (-4, -_y_margin),
@ -129,13 +139,6 @@ _corner_margins = {
('bottom', 'right'): (4, lambda font_size: font_size + 2*_y_margin),
}
# TODO: change this into our own ``Label``
class ContentsLabel(pg.LabelItem):
"""Label anchored to a ``ViewBox`` typically for displaying
datum-wise points from the "viewed" contents.
"""
def __init__(
self,
chart: 'ChartPlotWidget', # noqa
@ -155,8 +158,8 @@ class ContentsLabel(pg.LabelItem):
self.chart = chart
v, h = anchor_at
index = (_corner_anchors[h], _corner_anchors[v])
margins = _corner_margins[(v, h)]
index = (self._corner_anchors[h], self._corner_anchors[v])
margins = self._corner_margins[(v, h)]
ydim = margins[1]
if inspect.isfunction(margins[1]):