Windowed auto-ranging experiment #14330
Unanswered
bryevdv
asked this question in
Internals and design (Q&A)
Replies: 2 comments 8 replies
-
|
Simplified OHLC I was testing with import numpy as np
from bokeh.driving import count
from bokeh.plotting import curdoc, figure, ColumnDataSource
np.random.seed(1)
source = ColumnDataSource(dict(time=[], average=[]))
p = figure(height=500, tools="", y_axis_location="right")
p.x_range.follow = "end"
p.x_range.follow_interval = 100
p.x_range.range_padding = 0
r = p.line(x='time', y='average', alpha=0.2, line_width=3, color='navy', source=source)
p.y_range.renderers = [r]
def _average(t):
last_average = 100 if t==0 else source.data['average'][-1]
returns = np.asarray(np.random.lognormal(0.001, 0.01, 1))
average = last_average * np.cumprod(returns)
return average[0]
@count()
def update(t):
source.stream(dict(time=[t], average=[_average(t)]), 2000)
curdoc().add_root(p)
curdoc().add_periodic_callback(update, 100) |
Beta Was this translation helpful? Give feedback.
6 replies
-
|
Just recording my thoughts here as they come. Things are on a path to working (hopefully) with the above example because streaming data triggers data-range updates. But another (maybe more common) case is where say a plot is panned in the x-direction, or a range-tool updates an x-range, without new data added. This currently would not trigger a range update anywhere, so a full solution here will need a way to make a data range for update in additional circumstances. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It occurred to me that now that most (all?) glyphs use the spatial index that perhaps we could just leverage that for a windowed auto-range. Maybe it would not be perfect but possibly it could be good enough. So my first experiment was just to try and pass a
Rectwith x coords matching the current range, and unbounded y coords:This actually sort of seems to work for a little while then clearly stops working after a short order (see example code below). @mattpap is there anything obviously wrong with this approach? It seems like it ought to keep things in the ballpark at least, but even that is not the case after ~10 seconds.
Beta Was this translation helpful? Give feedback.
All reactions