Whenever there is overlays, set a title on main chart price-y axis!

basic_buy_bot
Tyler Goodlet 2023-06-02 16:59:37 -04:00
parent 106ebe94bf
commit d027ad5a4f
3 changed files with 34 additions and 13 deletions

View File

@ -215,13 +215,17 @@ class PriceAxis(Axis):
# self.setLabel(title)
# self.showLabel()
label = self.title = Label(
view=view or self.linkedView(),
fmt_str=title,
color=color or self.text_color,
parent=self,
# update_on_range_change=False,
)
label: Label | None = self.title
if label is None:
label = self.title = Label(
view=view or self.linkedView(),
fmt_str=title,
color=color or self.text_color,
parent=self,
# update_on_range_change=False,
)
else:
label.fmt_str: str = title
def below_axis() -> QPointF:
return QPointF(

View File

@ -1121,8 +1121,23 @@ class ChartPlotWidget(pg.PlotWidget):
# add axis title
# TODO: do we want this API to still work?
# raxis = pi.getAxis('right')
axis = self.pi_overlay.get_axis(pi, axis_side)
axis.set_title(axis_title or name, view=pi.getViewBox())
overlay: PlotItemOverlay = self.pi_overlay
# Whenever overlays exist always add a y-axis label to the
# main axis as well!
for name, axis_info in self.plotItem.axes.items():
axis = axis_info['item']
if isinstance(axis, PriceAxis):
axis.set_title(self.linked.mkt.pair())
axis: PriceAxis = overlay.get_axis(
pi,
axis_side,
)
axis.set_title(
axis_title or name,
view=pi.getViewBox(),
)
return pi
@ -1213,11 +1228,13 @@ class ChartPlotWidget(pg.PlotWidget):
if add_sticky:
if pi is not self.plotItem:
main_pi: pgo.PlotItem = self.plotItem
if pi is not main_pi:
# overlay = self.pi_overlay
# assert pi in overlay.overlays
overlay = self.pi_overlay
assert pi in overlay.overlays
assert main_pi is overlay.root_plotitem
axis = overlay.get_axis(
pi,
add_sticky,

View File

@ -1289,7 +1289,7 @@ async def display_symbol_data(
hist_ohlcv: ShmArray = flume.hist_shm
mkt: MktPair = flume.mkt
fqme = mkt.fqme
fqme: str = mkt.fqme
hist_chart = hist_linked.plot_ohlc_main(
mkt,
@ -1386,7 +1386,7 @@ async def display_symbol_data(
hist_pi = hist_chart.overlay_plotitem(
name=fqme,
axis_title=fqme,
axis_title=flume.mkt.pair(),
)
hist_viz = hist_chart.draw_curve(
@ -1416,7 +1416,7 @@ async def display_symbol_data(
rt_pi = rt_chart.overlay_plotitem(
name=fqme,
axis_title=fqme,
axis_title=flume.mkt.pair(),
)
rt_viz = rt_chart.draw_curve(