(the lambda function is to capture context because I’m generating quite a lot of plots.)
the callback itself is fairly simple, it just computes an exponential moving average on the selected curve:
element = radio.labels[radio.active]
lower_xdelim = float(x_box.value)
lower_ydelim = float(y_box.value)
source_local = getattr(self, attrname+"_"+element+"_source") #attr_id+"_"+dataset["sample element"]+"_source"
x = np.array(source_local.data["x"])
y = np.array(source_local.data["y"])
alpha = 0.5 #some number between 0 and 1, needs be adjusted
s1 = y[0]
ema = np.zeros(len(y))
ema[0] = s1
j = 1
for val in y[1:]:
ema[j] = alpha * val + (1-alpha) * ema[j-1]
j += 1
source_local.data = dict(x = x, y = ema, element = [element for i in range(len(x))])
Which works as intended, with the caveat that when I press the button I get redirected to http://localhost:5006/?, pressing backspace takes me to the bokeh session I was working on with the updated plot. Inspecting the button object it seems alright (to me atleast):
for val in y[1:]:
ema[j] = alpha * val + (1-alpha) * ema[j-1]
j += 1
source_local.data = dict(x = x, y = ema, element = [element for i in range(len(x))])
Which works as intended, with the caveat that when I press the button I get redirected to http://localhost:5006/?, pressing backspace takes me to the bokeh session I was working on with the updated plot. Inspecting the button object it seems alright (to me atleast):
alpha = 0.5 #some number between 0 and 1, needs be adjusted
s1 = y[0]
ema = np.zeros(len(y))
ema[0] = s1
j = 1
for val in y[1:]:
ema[j] = alpha * val + (1-alpha) * ema[j-1]
j += 1
source_local.data = dict(x = x, y = ema, element = [element for i in range(len(x))])
Which works as intended, with the caveat that when I press the button I get redirected to http://localhost:5006/?, pressing backspace takes me to the bokeh session I was working on with the updated plot. Inspecting the button object it seems alright (to me atleast):