Skip to content Skip to sidebar Skip to footer

Specify Position Of Combo Box

I have the following script that generates a combo box (Select) and a plot: import bokeh.plotting as bk from bokeh.models import ColumnDataSource, Plot from bokeh.models.widgets im

Solution 1:

You are able to customize your simpleapp layout by implementing a function that actually builds your layout and then wrap it with the layout decorator. In your case it'd be test_layout.layout decorator. To do so you need to change the code a bit. Here's a version that should do what you need:

import bokeh.plotting as bk
from bokeh.models import ColumnDataSource, Plot
from bokeh.models.widgets import Select, AppVBox
from bokeh.simpleapp import simpleapp

data = {"a": {"x": [1,2,3], "y": [1,2,3]},
        "b": {"x": [3,2,1], "y": [1,2,3]},
        "c": {"x": [2,2,2], "y": [1,2,3]},}


options = ["a", "b", "c"]
select1 = Select(name = 'ticker1', value = options[0], options =     options)

@simpleapp(select1)
def test_layout(ticker1):
    p = bk.figure(title = "layout test")

    chart_data = data[ticker1]

    df = ColumnDataSource(data = chart_data)
    p.circle(x = chart_data["x"], y = chart_data["y"])

    return {'plot': p}

@test_layout.layout
def layout(app):
    return AppVBox(app=app, children=['ticker1', 'plot'])

test_layout.route("/bokeh/layout/")

Post a Comment for "Specify Position Of Combo Box"