[英]Bokeh - How to Change Glyph Attribute in JS Callback?
I'm making a plot in Bokeh 0.13.0, and I want to change the x
attribute of a Ray
glyph in a custom JS callback. 我正在Bokeh 0.13.0中进行绘图,我想在自定义JS回调中更改Ray
字形的x
属性。
I need to know 2 things: 我需要知道两件事:
x
attribute once it's been passed? 传递x
属性后,如何引用它? Here's the gist: 这是要点:
vline = Ray( x=vline_x, y=0, length=0, angle=1.5708, line_width=1)
plot.add_glyph(source, vline)
callback = CustomJS(args=dict(source=source), code="""
var data = source.data;
// CHANGE ATTRIBUTE HERE
source.change.emit();
""")
Thanks in advance! 提前致谢!
Figured it out. 弄清楚了。 I passed the GlyphRenderer
object for the Ray as an item in the CustomJS
args dict. 我将Ray的GlyphRenderer
对象作为CustomJS
args dict中的CustomJS
。 I was then able to access the Glyph
object for the Ray and was able to change its attributes from there. 然后,我可以访问Ray的Glyph
对象,并可以从那里更改其属性。
Might also have worked if I'd just passed the Glyph
object in the first place, but oh well. 如果我刚通过Glyph
对象,也可能会起作用,但是,哦,好。
Updated code: 更新的代码:
vline = plot.add_glyph(
source,
Ray(x=vline_x,y=0, length=0, angle=1.5708, line_width=1)
)
callback = CustomJS(args=dict(vline=vline, source=source), code="""
vline.glyph.x = <new_value>;
source.change.emit();
""")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.