Move margin settings to class scope
parent
61198818dc
commit
adf6437449
|
@ -113,13 +113,23 @@ class LineDot(pg.CurvePoint):
|
||||||
return False
|
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 = {
|
_corner_anchors = {
|
||||||
'top': 0,
|
'top': 0,
|
||||||
'left': 0,
|
'left': 0,
|
||||||
'bottom': 1,
|
'bottom': 1,
|
||||||
'right': 1,
|
'right': 1,
|
||||||
}
|
}
|
||||||
_y_margin = 5
|
|
||||||
# XXX: fyi naming here is confusing / opposite to coords
|
# XXX: fyi naming here is confusing / opposite to coords
|
||||||
_corner_margins = {
|
_corner_margins = {
|
||||||
('top', 'left'): (-4, -_y_margin),
|
('top', 'left'): (-4, -_y_margin),
|
||||||
|
@ -129,13 +139,6 @@ _corner_margins = {
|
||||||
('bottom', 'right'): (4, lambda font_size: font_size + 2*_y_margin),
|
('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__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
chart: 'ChartPlotWidget', # noqa
|
chart: 'ChartPlotWidget', # noqa
|
||||||
|
@ -155,8 +158,8 @@ class ContentsLabel(pg.LabelItem):
|
||||||
self.chart = chart
|
self.chart = chart
|
||||||
|
|
||||||
v, h = anchor_at
|
v, h = anchor_at
|
||||||
index = (_corner_anchors[h], _corner_anchors[v])
|
index = (self._corner_anchors[h], self._corner_anchors[v])
|
||||||
margins = _corner_margins[(v, h)]
|
margins = self._corner_margins[(v, h)]
|
||||||
|
|
||||||
ydim = margins[1]
|
ydim = margins[1]
|
||||||
if inspect.isfunction(margins[1]):
|
if inspect.isfunction(margins[1]):
|
||||||
|
|
Loading…
Reference in New Issue