Only show slow chart xlabel when focussed

history_view
Tyler Goodlet 2022-09-07 16:35:01 -04:00
parent 2a06dc997f
commit 1fa6e8d9ba
2 changed files with 29 additions and 9 deletions

View File

@ -336,6 +336,8 @@ class Cursor(pg.GraphicsObject):
self.linked = linkedsplits
self.graphics: dict[str, pg.GraphicsObject] = {}
self.xaxis_label: Optional[XAxisLabel] = None
self.always_show_xlabel: bool = True
self.plots: list['PlotChartWidget'] = [] # type: ignore # noqa
self.active_plot = None
self.digits: int = digits
@ -508,12 +510,23 @@ class Cursor(pg.GraphicsObject):
self.graphics[plot]['hl'].show()
self.graphics[plot]['yl'].show()
else: # Leave
if (
not self.always_show_xlabel
and not self.xaxis_label.isVisible()
):
self.xaxis_label.show()
# hide horiz line and y-label
# Leave: hide horiz line and y-label
else:
self.graphics[plot]['hl'].hide()
self.graphics[plot]['yl'].hide()
if (
not self.always_show_xlabel
and self.xaxis_label.isVisible()
):
self.xaxis_label.hide()
def mouseMoved(
self,
coords: tuple[QPointF], # noqa
@ -602,13 +615,17 @@ class Cursor(pg.GraphicsObject):
left_axis_width += left.width()
# map back to abs (label-local) coordinates
self.xaxis_label.update_label(
abs_pos=(
plot.mapFromView(QPointF(vl_x, iy)) -
QPointF(left_axis_width, 0)
),
value=ix,
)
if (
self.always_show_xlabel
or self.xaxis_label.isVisible()
):
self.xaxis_label.update_label(
abs_pos=(
plot.mapFromView(QPointF(vl_x, iy)) -
QPointF(left_axis_width, 0)
),
value=ix,
)
self._datum_xy = ix, iy

View File

@ -868,6 +868,9 @@ async def display_symbol_data(
# to avoid internal pane creation.
sidepane=False,
)
# don't show when not focussed
hist_linked.cursor.always_show_xlabel = False
hist_chart.default_view(
bars_from_y=int(len(hist_ohlcv.array)), # size to data
y_offset=6116*2, # push it a little away from the y-axis