Make `LinearRegion` link using epoch-time index

Turned out to be super simple to get the first draft to work since the
fast and slow chart now use the same domain, however, it seems like
maybe there's an offset issue still where the fast may be a couple
minutes ahead of the slow?

Need to dig in a bit..
epoch_index_backup
Tyler Goodlet 2022-12-15 14:26:50 -05:00
parent 1f356b6e10
commit 72c6b5f646
1 changed files with 100 additions and 80 deletions

View File

@ -847,13 +847,34 @@ async def link_views_with_region(
hist_pi.addItem(region, ignoreBounds=True)
region.setOpacity(6/16)
viz = rt_chart._vizs[flume.symbol.fqsn]
viz = rt_chart.get_viz(flume.symbol.fqsn)
assert viz
index_field = viz.index_field
# XXX: no idea why this doesn't work but it's causing
# a weird placement of the region on the way-far-left..
# region.setClipItem(viz.graphics)
if index_field == 'time':
# in the (epoch) index case we can map directly
# from the fast chart's x-domain values since they are
# on the same index as the slow chart.
def update_region_from_pi(
window,
viewRange: tuple[tuple, tuple],
is_manual: bool = True,
) -> None:
# put linear region "in front" in layer terms
region.setZValue(10)
# set the region on the history chart
# to the range currently viewed in the
# HFT/real-time chart.
region.setRegion(viewRange[0])
else:
# poll for datums load and timestep detection
for _ in range(100):
try:
@ -1327,12 +1348,11 @@ async def display_symbol_data(
)
godwidget.resize_all()
# hist_chart.hide()
# await link_views_with_region(
# rt_chart,
# hist_chart,
# flume,
# )
await link_views_with_region(
rt_chart,
hist_chart,
flume,
)
# start graphics update loop after receiving first live quote
ln.start_soon(