How to use cb_obj in callbacks in bokeh?

In bokeh.models.actions.Actionthere is a class callbackfor custom callback. It skips the current plot_objectas cb_objimplicitly.

However, I do not know how to access data from 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 information, for example. x, y of the clicked circle? In the template line, we can use @variableor $xto obtain information about each data point.

In addition, it seems to me that there is only 1 Circle Glyph, despite 3 circles. So the glyph has nothing to do with the number of data points, is this correct?

Does cb_objthis match Glyphor glyphRenderercontain this character?

In here , an example shows:

var inds = cb_obj.get('selected')['1d'].indices;
var d1 = cb_obj.get('data');

select, id, indices, data? cb_obj.

+4
2

:

console.log(cb_data);
console.log(cb_obj);

, :

scode = """
        console.log(cb_obj);
        console.log(cb_data);
        """
taptool.callback = CustomJS(args=dict(source=source),code = scode)

chrome, cb_obj cb_data ( View-Developer-Javascripts Console)

+1

All Articles