In bokeh.models.actions.Action
, there is a callback
class for user defined callback. It passes the current plot_object
as cb_obj
implicitly.
However, I don't know how to access the data from the plot_object
.
fig = figure()
fig.circle(x=[1,2,3], y=[4,5,6])
tap_tool.action = Callback(
code="""
alert('clicked')
console.log(cb_obj)
""")
How can I access the information, e.g. x, y of a clicked circle? In a template string we can use @variable
or $x
to get information about each data point.
Furthermore, it seems to me that there is only 1 Circle Glyph
, despite of 3 circles. So glyph has nothing to do with the number of data points, is it correct?
Does cb_obj
refer to this Glyph
, or the glyphRenderer
that contains this glyph?
In the docs an example shows:
var inds = cb_obj.get('selected')['1d'].indices;
var d1 = cb_obj.get('data');
Where does select, id, indices, data
come from? What's the structure of cb_obj
.
As of Bokeh 0.9.0, for
TapTool
actions, the value ofcb_obj
is the data source for the glyph that reported the hit. This example shows how to access the data columns:https://docs.bokeh.org/en/latest/docs/user_guide/interaction/callbacks.html#customjs-for-tools