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()`.
epoch_indexing_and_dataviz_layer
Tyler Goodlet 2022-12-16 18:19:39 -05:00
parent 50ef4efccb
commit 3300a240c6
1 changed files with 27 additions and 7 deletions

View File

@ -212,10 +212,12 @@ async def graphics_update_loop(
assert hist_chart assert hist_chart
# per-viz-set global last index tracking for global 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 = { globalz = {
'i_last': 0, 'i_last': 0, # multiview-global fast (1s) step index
'i_last_append': 0, 'i_last_slow': 0, # multiview-global slow (1m) step index
} }
dss: dict[str, DisplayState] = {} dss: dict[str, DisplayState] = {}
@ -292,8 +294,7 @@ async def graphics_update_loop(
fast_chart.show() fast_chart.show()
last_quote = time.time() last_quote = time.time()
# global _i_last i_last: float = 0
i_last = ohlcv.index
dss[fqsn] = ds = linked.display_state = DisplayState(**{ dss[fqsn] = ds = linked.display_state = DisplayState(**{
'godwidget': godwidget, 'godwidget': godwidget,
@ -375,13 +376,15 @@ async def graphics_update_loop(
do_append do_append
and liv and liv
): ):
# hist_chart.increment_view(steps=i_diff)
viz = hist_chart._vizs[fqsn] viz = hist_chart._vizs[fqsn]
viz.plot.vb._set_yrange( viz.plot.vb._set_yrange(
# yrange=hist_chart.maxmin(name=fqsn) # yrange=hist_chart.maxmin(name=fqsn)
) )
# hist_chart.view._set_yrange(yrange=hist_chart.maxmin()) # 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) nurse.start_soon(increment_history_view)
# main real-time quotes update loop # main real-time quotes update loop
@ -878,7 +881,18 @@ async def link_views_with_region(
# set the region on the history chart # set the region on the history chart
# to the range currently viewed in the # to the range currently viewed in the
# HFT/real-time chart. # 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: else:
# poll for datums load and timestep detection # poll for datums load and timestep detection
@ -1113,6 +1127,12 @@ async def display_symbol_data(
tuple[str, Flume] tuple[str, Flume]
] = list(feed.flumes.items()) ] = 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 # for the "first"/selected symbol we create new chart widgets
# and sub-charts for FSPs # and sub-charts for FSPs
fqsn, flume = fitems[0] fqsn, flume = fitems[0]