Filter source data with callback

Hi,

I have a data source: source = ColumnDataSource(data) as a list of dicts in this schema:

[

{

‘x’: int,

‘y’: int,

‘attribute’: str,

‘value’: float,

‘year’: int

},

]

and I want to make scatter plot with a slider for selecting each year interactively.

I understand basic interaction workflow as in Making Interactions — Bokeh 2.4.2 Documentation

However I can not see how to reduce source data to specific year in scatter plot:

plot.scatter(‘x’, ‘y’, source=source)

nor, how to make javascript callback function that would filter this data on a specific year. Yep.

Can I get some pointers how to do it (without using flask server)?

Let me ask differently…

How to put whole data in ColumnDataSource, which is referenced in plot, and then filter it with slider, w/o using server?

Hi,

I have a data source: `source = ColumnDataSource(data)` as a list of dicts in this schema:

[
    {
        'x': int,
        'y': int,
        'attribute': str,
        'value': float,
        'year': int
    },
    ...
]

and I want to make scatter plot with a slider for selecting each year interactively.

I understand basic interaction workflow as in Interaction — Bokeh 3.3.2 Documentation

However I can not see how to reduce source data to specific year in scatter plot:

    plot.scatter('x', 'y', source=source)

nor, how to make javascript callback function that would filter this data on a specific year. Yep.

It would be much simpler to do this with the Bokeh server than with a CustomJS callback, but if that is your requirement, I'd suggest studying the example notebook here which does exactly why you describe:

  https://github.com/bokeh/bokeh/blob/master/examples/howto/interactive_bubble/gapminder.ipynb

Note: Bokeh plots do not render on GH due to JavaScript scrubbing by GH. You will have to run the notebook locally. There is an associated python module in the same directory as that notebook that is needed as well.

Can I get some pointers how to do it (without using flask server)?

Bokeh does not use, or depend on, Flask.

Thanks,

Bryan

···

On Jul 1, 2016, at 6:04 PM, vedar <[email protected]> wrote:

Thanks exactly what I needed.

Thanks!