假设源代码有4列,名为time_s
,time_min
,time_h
和y
。在
source = ColumnDataSource(...)
然后从这些列中首先选择time_s
和{
在CustomJS回调代码块中,我希望将x列从time_s
切换到time_min
,并相应地重新呈现绘图。我知道如何通过在DevTools控制台中分析来浏览/访问一些数据和对象,但是我无法从p.line
对象中找到x='time_s'
,也无法找到如何访问它们。在
js = """
// Explore Objects in DevTools Console
console.log(data)
console.log(source)
console.log(plot)
data = source.data
data['time_s'] = do something to column here ...
if (widget.value === 'xyz') {
// Looking for something like:
plot.line.x = data['time_min'] // not working
}
// After data change -> rerender
source.change.emit()
"""
cb = CustomJS(args=dict(src=source, plot=p, widget=mywidget), code=js)
mywidget.js_on_change('value', cb)
那么如何才能做到这一点呢?在
我可以想象有很多种方法可以做到这一点。假设您可以容忍在数据源中复制一列,我建议您这样做:
如果不能将选定的列复制到“y”列中,则可以更新glyph,以更改它指向的列。看起来像这样:
^{pr2}$相关问题 更多 >
编程相关推荐