Trouble adding interaction (/w MultiSelect) into TimeSeries

Hello,

I wish to use the MultiSelect tool to determine what lines are plotted on a TimeSeries based on the value selected in the MultiSelect Widget. I got it working for using MultiLine, but I am having trouble implementing the same solution using TimeSeries.

Highlighted below is where I’m having trouble:

···

from pandas_datareader import data

import pandas as pd

import datetime as dt

import itertools as iter

from bokeh.io import curdoc

from bokeh.layouts import layout, widgetbox

from bokeh.models import ColumnDataSource

from bokeh.models.widgets import MultiSelect, CheckboxButtonGroup

from bokeh.plotting import show

from bokeh.charts import TimeSeries

#get data in DF

def get_stock_data(ticker, start):

return data.get_data_yahoo(ticker, start, interval = ‘m’)[“Adj Close”]

#df[“Mthly Rtn”] = df[“Adj Close”].pct_change(1)

#df[“Cum Rtn”] = df[“Adj Close”]/df[“Adj Close”][0] - 1

start = dt.date(2010, 1, 1)

sector_dict = {“Healthcare”:[“JNJ”, “NVS”, “PFE”],

“Technology”:[“GOOG”, “MSFT”]}

list_sectors = sector_dict.keys()

sector_dict[“All”] = list(iter.chain.from_iterable(sector_dict.values()))

stock_prices = pd.DataFrame()

for ticker in sector_dict[“All”]:

stock_prices[ticker] = get_stock_data(ticker, start)

#set up widgets

stock_select = MultiSelect(title = ‘Stock:’, value = sector_dict[‘All’], options = sector_dict[‘All’])

#create ColumnDateSource that will be used by the plot

source = ColumnDataSource(data = dict(y = , color = ))

p = TimeSeries(stock_prices, x = ‘index’, source = source)

def update():

source.data = dict(

    y = stock_select.value,

    color = stock_select.value

 )

controls = [stock_select]

for control in controls:

control.on_change('value', lambda attr, old, new: update())    

l = layout([[stock_select, p]], sizing_mode = ‘fixed’)

update()

curdoc().add_root(l)

curdoc().title = ‘Test Stocks’