x = np.array([353, 357, 359, 361, 366, 366, 371, 371, 377, 377, 386, 391, 391,
391, 403, 411, 411, 417, 417, 417, 432, 438, 438, 442, 442, 449,
449, 449, 453, 453, 463, 463, 463, 467, 467, 470, 473, 473, 473,
481, 481, 481, 485, 485, 488, 503, 506, 506, 506, 511, 511, 516,
516, 522, 539, 543, 543, 543, 564, 564, 570, 570, 573, 573, 577,
577, 582, 603, 609, 609, 609, 614, 614, 622, 624])
y = np.array([20.02235595, 19.28528864, 19.66643892, 19.26904172, 19.64506973,
19.64143012, 20.0413838 , 20.04509699, 19.27195117, 19.28541996,
19.2808127 , 20.04783135, 20.03355231, 20.04571818, 20.05257178,
19.26574297, 19.26930808, 19.64753494, 19.6465943 , 19.65775061,
19.27670371, 20.02680767, 20.03292833, 19.63415369, 19.65622231,
19.69038602, 19.6934389 , 19.67559382, 19.67195235, 19.67195235,
20.07102128, 20.01819015, 20.02612501, 19.65234801, 19.65234801,
20.04514541, 19.64782923, 19.64417938, 19.64781992, 19.26428732,
19.27987486, 19.28832848, 19.28898506, 19.28024087, 19.27586924,
19.2805836 , 19.66310851, 19.66310851, 19.67257261, 19.67664715,
19.67993192, 19.688976 , 19.68052331, 19.2977041 , 20.05308494,
19.27149668, 19.2728769 , 19.27069016, 19.69226357, 19.68745049,
19.67695728, 19.67477053, 19.68322415, 19.68322415, 19.67899688,
19.67747044, 19.28737108, 19.66749411, 19.6653083 , 19.67331674,
19.65510938, 19.24687345, 19.25780345, 19.66714021, 20.05782444])
d = np.dstack((x,y)).squeeze()
symbol = "Security 1"
symbol2 = "Security 2"
price_data = pd.DataFrame(
d,
columns=[symbol, symbol2],
index=x,
)
dates_actual = price_data.index.values
prices = price_data[symbol].values
scales = {"x": DateScale(), "y": LinearScale()}
scatter = Scatter(
x=dates_actual,
y=prices,
scales=scales,
colors=["orange"],
selected_style={"opacity": "1"},
unselected_style={"opacity": "0.5"},
)
sel = IndexSelector(marks=[scatter], orientation="vertical", scale=scales["y"])
text_brush = HTML()
def update_text(*args):
text_brush.value = "{}.selected = {}".format(IndexSelector.__name__, sel.selected)
sel.observe(update_text, "selected")
update_text()
x_ax = Axis(label="Index", scale=scales["x"])
x_ay = Axis(label=(symbol + " Price"), scale=scales["y"], orientation="vertical")
fig = Figure(
marks=[scatter],
axes=[x_ax, x_ay],
title="{} Example".format(IndexSelector.__name__),
interaction=sel,
)
display(VBox([fig]))
Describe the bug
When interacting with the mouse in the IndexSelector the vertiacl line keep jumping and going back to the 0 position
To Reproduce
Expected behavior
It should follow the position of the mouse
Screenshots
