Use array-`int`-indexing on single feed

Might as well since it makes the chart look less gappy and we can easily
flip the index switch now B)

Also adds a new `'i_slow_last'` key to `DisplayState` for a singleton
across all slow charts and thus no more need for special case logic in
`viz.incr_info()`.
multichartz_backup
Tyler Goodlet 2022-12-16 18:19:39 -05:00
parent 95e7c8648c
commit 5892c79737
1 changed files with 27 additions and 7 deletions

View File

@ -206,10 +206,12 @@ async def graphics_update_loop(
assert hist_chart
# per-viz-set global last index tracking for global chart
# view UX incrementing.
# view UX incrementing; these values are singleton
# per-multichart-set such that automatic x-domain shifts are only
# done once per time step update.
globalz = {
'i_last': 0,
'i_last_append': 0,
'i_last': 0, # multiview-global fast (1s) step index
'i_last_slow': 0, # multiview-global slow (1m) step index
}
dss: dict[str, DisplayState] = {}
@ -286,8 +288,7 @@ async def graphics_update_loop(
fast_chart.show()
last_quote = time.time()
# global _i_last
i_last = ohlcv.index
i_last: float = 0
dss[fqsn] = ds = linked.display_state = DisplayState(**{
'godwidget': godwidget,
@ -369,13 +370,15 @@ async def graphics_update_loop(
do_append
and liv
):
# hist_chart.increment_view(steps=i_diff)
viz = hist_chart._vizs[fqsn]
viz.plot.vb._set_yrange(
# yrange=hist_chart.maxmin(name=fqsn)
)
# hist_chart.view._set_yrange(yrange=hist_chart.maxmin())
if should_incr:
hist_chart.increment_view(steps=i_diff)
nurse.start_soon(increment_history_view)
# main real-time quotes update loop
@ -872,7 +875,18 @@ async def link_views_with_region(
# set the region on the history chart
# to the range currently viewed in the
# HFT/real-time chart.
region.setRegion(viewRange[0])
rng = mn, mx = viewRange[0]
# hist_viz = hist_chart.get_viz(flume.symbol.fqsn)
# hist = hist_viz.shm.array[-3:]
# print(
# f'mn: {mn}\n'
# f'mx: {mx}\n'
# f'slow last 3 epochs: {list(hist["time"])}\n'
# f'slow last 3: {hist}\n'
# )
region.setRegion(rng)
else:
# poll for datums load and timestep detection
@ -1107,6 +1121,12 @@ async def display_symbol_data(
tuple[str, Flume]
] = list(feed.flumes.items())
# use array int-indexing when no aggregate feed overlays are
# loaded.
if len(fitems) == 1:
from ._dataviz import Viz
Viz._index_field = 'index'
# for the "first"/selected symbol we create new chart widgets
# and sub-charts for FSPs
fqsn, flume = fitems[0]