Always show a minimum bars during startup
This is particularly more "good looking" when we boot with a pair that doesn't have historical 1s OHLC and thus the fast chart is empty from outset. In this case it's a lot nicer to be already zoomed to a comfortable preset number of "datums in view" even when the history isn't yet filled in. Adjusts the chart display `Viz.default_view()` startup to explicitly ensure this happens via the `do_min_bars=True` flag B)storage_cli
parent
5bf40ceb79
commit
73089e5612
|
@ -1082,12 +1082,10 @@ class Viz(Struct):
|
||||||
data_diff = last_datum - first_datum
|
data_diff = last_datum - first_datum
|
||||||
rl_diff = vr - vl
|
rl_diff = vr - vl
|
||||||
rescale_to_data: bool = False
|
rescale_to_data: bool = False
|
||||||
# new_uppx: float = 1
|
|
||||||
|
|
||||||
if rl_diff > data_diff:
|
if rl_diff > data_diff:
|
||||||
rescale_to_data = True
|
rescale_to_data = True
|
||||||
rl_diff = data_diff
|
rl_diff = data_diff
|
||||||
new_uppx: float = data_diff / self.px_width()
|
|
||||||
|
|
||||||
# orient by offset from the y-axis including
|
# orient by offset from the y-axis including
|
||||||
# space to compensate for the L1 labels.
|
# space to compensate for the L1 labels.
|
||||||
|
@ -1097,14 +1095,28 @@ class Viz(Struct):
|
||||||
offset = l1_offset
|
offset = l1_offset
|
||||||
|
|
||||||
if rescale_to_data:
|
if rescale_to_data:
|
||||||
|
new_uppx: float = data_diff / self.px_width()
|
||||||
offset = (offset / uppx) * new_uppx
|
offset = (offset / uppx) * new_uppx
|
||||||
|
|
||||||
else:
|
else:
|
||||||
offset = (y_offset * step) + uppx*step
|
offset = (y_offset * step) + uppx*step
|
||||||
|
|
||||||
|
# NOTE: if we are in the midst of start-up and a bunch of
|
||||||
|
# widgets are spawning/rendering concurrently, it's likely the
|
||||||
|
# label size above `l1_offset` won't have yet fully rendered.
|
||||||
|
# Here we try to compensate for that ensure at least a static
|
||||||
|
# bar gap between the last datum and the y-axis.
|
||||||
|
if (
|
||||||
|
do_min_bars
|
||||||
|
and offset <= (6 * step)
|
||||||
|
):
|
||||||
|
offset = 6 * step
|
||||||
|
|
||||||
# align right side of view to the rightmost datum + the selected
|
# align right side of view to the rightmost datum + the selected
|
||||||
# offset from above.
|
# offset from above.
|
||||||
r_reset = (self.graphics.x_last() or last_datum) + offset
|
r_reset = (
|
||||||
|
self.graphics.x_last() or last_datum
|
||||||
|
) + offset
|
||||||
|
|
||||||
# no data is in view so check for the only 2 sane cases:
|
# no data is in view so check for the only 2 sane cases:
|
||||||
# - entire view is LEFT of data
|
# - entire view is LEFT of data
|
||||||
|
@ -1129,7 +1141,6 @@ class Viz(Struct):
|
||||||
else:
|
else:
|
||||||
log.warning(f'Unknown view state {vl} -> {vr}')
|
log.warning(f'Unknown view state {vl} -> {vr}')
|
||||||
return
|
return
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# maintain the l->r view distance
|
# maintain the l->r view distance
|
||||||
l_reset = r_reset - rl_diff
|
l_reset = r_reset - rl_diff
|
||||||
|
@ -1138,7 +1149,11 @@ class Viz(Struct):
|
||||||
do_min_bars
|
do_min_bars
|
||||||
and (r_reset - l_reset) < min_bars_from_y
|
and (r_reset - l_reset) < min_bars_from_y
|
||||||
):
|
):
|
||||||
l_reset = r_reset - min_bars_from_y
|
l_reset = (
|
||||||
|
(r_reset + offset)
|
||||||
|
-
|
||||||
|
min_bars_from_y * step
|
||||||
|
)
|
||||||
|
|
||||||
# remove any custom user yrange setttings
|
# remove any custom user yrange setttings
|
||||||
if chartw._static_yrange == 'axis':
|
if chartw._static_yrange == 'axis':
|
||||||
|
@ -1152,7 +1167,6 @@ class Viz(Struct):
|
||||||
|
|
||||||
if do_ds:
|
if do_ds:
|
||||||
view.interact_graphics_cycle()
|
view.interact_graphics_cycle()
|
||||||
view.interact_graphics_cycle()
|
|
||||||
|
|
||||||
def incr_info(
|
def incr_info(
|
||||||
self,
|
self,
|
||||||
|
|
|
@ -416,7 +416,9 @@ async def graphics_update_loop(
|
||||||
ds.vlm_chart = vlm_chart
|
ds.vlm_chart = vlm_chart
|
||||||
ds.vlm_sticky = vlm_sticky
|
ds.vlm_sticky = vlm_sticky
|
||||||
|
|
||||||
fast_chart.main_viz.default_view()
|
fast_chart.main_viz.default_view(
|
||||||
|
do_min_bars=True,
|
||||||
|
)
|
||||||
|
|
||||||
# ds.hist_vars.update({
|
# ds.hist_vars.update({
|
||||||
# 'i_last_append': 0,
|
# 'i_last_append': 0,
|
||||||
|
@ -1456,7 +1458,9 @@ async def display_symbol_data(
|
||||||
for fqsn, flume in feed.flumes.items():
|
for fqsn, flume in feed.flumes.items():
|
||||||
|
|
||||||
# size view to data prior to order mode init
|
# size view to data prior to order mode init
|
||||||
rt_chart.main_viz.default_view()
|
rt_chart.main_viz.default_view(
|
||||||
|
do_min_bars=True,
|
||||||
|
)
|
||||||
rt_linked.graphics_cycle()
|
rt_linked.graphics_cycle()
|
||||||
|
|
||||||
# TODO: look into this because not sure why it was
|
# TODO: look into this because not sure why it was
|
||||||
|
@ -1467,7 +1471,9 @@ async def display_symbol_data(
|
||||||
# determine if auto-range adjustements should be made.
|
# determine if auto-range adjustements should be made.
|
||||||
# rt_linked.subplots.pop('volume', None)
|
# rt_linked.subplots.pop('volume', None)
|
||||||
|
|
||||||
hist_chart.main_viz.default_view()
|
hist_chart.main_viz.default_view(
|
||||||
|
do_min_bars=True,
|
||||||
|
)
|
||||||
hist_linked.graphics_cycle()
|
hist_linked.graphics_cycle()
|
||||||
|
|
||||||
godwidget.resize_all()
|
godwidget.resize_all()
|
||||||
|
@ -1510,10 +1516,14 @@ async def display_symbol_data(
|
||||||
|
|
||||||
# default view adjuments and sidepane alignment
|
# default view adjuments and sidepane alignment
|
||||||
# as final default UX touch.
|
# as final default UX touch.
|
||||||
rt_chart.main_viz.default_view()
|
rt_chart.main_viz.default_view(
|
||||||
|
do_min_bars=True,
|
||||||
|
)
|
||||||
await trio.sleep(0)
|
await trio.sleep(0)
|
||||||
|
|
||||||
hist_chart.main_viz.default_view()
|
hist_chart.main_viz.default_view(
|
||||||
|
do_min_bars=True,
|
||||||
|
)
|
||||||
hist_viz = hist_chart.get_viz(fqsn)
|
hist_viz = hist_chart.get_viz(fqsn)
|
||||||
await trio.sleep(0)
|
await trio.sleep(0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue