Size level line markers to dpi aware font size
parent
54d36f26f0
commit
0dfa92230d
|
@ -18,6 +18,7 @@
|
||||||
Lines for orders, alerts, L2.
|
Lines for orders, alerts, L2.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
from math import floor
|
||||||
from typing import Tuple, Optional, List
|
from typing import Tuple, Optional, List
|
||||||
|
|
||||||
import pyqtgraph as pg
|
import pyqtgraph as pg
|
||||||
|
@ -27,7 +28,7 @@ from PyQt5.QtCore import QPointF
|
||||||
|
|
||||||
from .._annotate import mk_marker, qgo_draw_markers
|
from .._annotate import mk_marker, qgo_draw_markers
|
||||||
from .._label import Label, vbr_left, right_axis
|
from .._label import Label, vbr_left, right_axis
|
||||||
from .._style import hcolor
|
from .._style import hcolor, _font
|
||||||
|
|
||||||
|
|
||||||
# TODO: probably worth investigating if we can
|
# TODO: probably worth investigating if we can
|
||||||
|
@ -628,11 +629,17 @@ def order_line(
|
||||||
)
|
)
|
||||||
|
|
||||||
if show_markers:
|
if show_markers:
|
||||||
|
font_size = _font.font.pixelSize()
|
||||||
|
|
||||||
|
# scale marker size with dpi-aware font size
|
||||||
|
arrow_size = floor(1.375 * font_size)
|
||||||
|
alert_size = arrow_size * 0.666
|
||||||
|
|
||||||
# add arrow marker on end of line nearest y-axis
|
# add arrow marker on end of line nearest y-axis
|
||||||
marker_style, marker_size = {
|
marker_style, marker_size = {
|
||||||
'buy': ('|<', 20),
|
'buy': ('|<', arrow_size),
|
||||||
'sell': ('>|', 20),
|
'sell': ('>|', arrow_size),
|
||||||
'alert': ('v', 12),
|
'alert': ('v', alert_size),
|
||||||
}[action]
|
}[action]
|
||||||
|
|
||||||
# this fixes it the artifact issue! .. of course, bouding rect stuff
|
# this fixes it the artifact issue! .. of course, bouding rect stuff
|
||||||
|
@ -695,7 +702,7 @@ def order_line(
|
||||||
rlabel = line.add_label(
|
rlabel = line.add_label(
|
||||||
side='right',
|
side='right',
|
||||||
side_of_axis='left',
|
side_of_axis='left',
|
||||||
x_offset=3*marker_size + 5,
|
x_offset=4*marker_size,
|
||||||
fmt_str=(
|
fmt_str=(
|
||||||
'{size:.{size_digits}f} '
|
'{size:.{size_digits}f} '
|
||||||
),
|
),
|
||||||
|
@ -739,14 +746,6 @@ def position_line(
|
||||||
hide_xhair_on_hover=False,
|
hide_xhair_on_hover=False,
|
||||||
use_marker_margin=True,
|
use_marker_margin=True,
|
||||||
)
|
)
|
||||||
if size > 0:
|
|
||||||
arrow_path = mk_marker('|<')
|
|
||||||
|
|
||||||
elif size < 0:
|
|
||||||
arrow_path = mk_marker('>|')
|
|
||||||
|
|
||||||
line.add_marker(arrow_path)
|
|
||||||
|
|
||||||
# hide position marker when out of view (for now)
|
# hide position marker when out of view (for now)
|
||||||
vb = line.getViewBox()
|
vb = line.getViewBox()
|
||||||
|
|
||||||
|
@ -775,6 +774,20 @@ def position_line(
|
||||||
rlabel.render()
|
rlabel.render()
|
||||||
rlabel.show()
|
rlabel.show()
|
||||||
|
|
||||||
|
# arrow marker
|
||||||
|
# scale marker size with dpi-aware font size
|
||||||
|
font_size = _font.font.pixelSize()
|
||||||
|
|
||||||
|
# scale marker size with dpi-aware font size
|
||||||
|
arrow_size = floor(1.375 * font_size)
|
||||||
|
|
||||||
|
if size > 0:
|
||||||
|
style = '|<'
|
||||||
|
elif size < 0:
|
||||||
|
style = '>|'
|
||||||
|
|
||||||
|
arrow_path = mk_marker(style, size=arrow_size)
|
||||||
|
line.add_marker(arrow_path)
|
||||||
line.set_level(level)
|
line.set_level(level)
|
||||||
|
|
||||||
# sanity check
|
# sanity check
|
||||||
|
|
Loading…
Reference in New Issue