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.linked = linkedsplits
self.graphics: dict[str, pg.GraphicsObject] = {} 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.plots: list['PlotChartWidget'] = [] # type: ignore # noqa
self.active_plot = None self.active_plot = None
self.digits: int = digits self.digits: int = digits
@ -508,12 +510,23 @@ class Cursor(pg.GraphicsObject):
self.graphics[plot]['hl'].show() self.graphics[plot]['hl'].show()
self.graphics[plot]['yl'].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]['hl'].hide()
self.graphics[plot]['yl'].hide() self.graphics[plot]['yl'].hide()
if (
not self.always_show_xlabel
and self.xaxis_label.isVisible()
):
self.xaxis_label.hide()
def mouseMoved( def mouseMoved(
self, self,
coords: tuple[QPointF], # noqa coords: tuple[QPointF], # noqa
@ -602,6 +615,10 @@ class Cursor(pg.GraphicsObject):
left_axis_width += left.width() left_axis_width += left.width()
# map back to abs (label-local) coordinates # map back to abs (label-local) coordinates
if (
self.always_show_xlabel
or self.xaxis_label.isVisible()
):
self.xaxis_label.update_label( self.xaxis_label.update_label(
abs_pos=( abs_pos=(
plot.mapFromView(QPointF(vl_x, iy)) - plot.mapFromView(QPointF(vl_x, iy)) -

View File

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