Bokeh - Link dataframe time series data to Select interaction
<p>I'm trying create a single line chart in Bokeh and linking different charts in one dataframe to a Select interaction.  The dataframe structure looks something like this:</p>

<p>Date, KPI1, KPI2, KPI3, KPI4 ... ...</p>

<p>Date is always x axis, whereas KPI's should be changeable on the y axis.</p>

<p>I can't get it to work.  Please see my current code below.  Explanations are shown as comments</p>

<pre><code>from app import app
from flask import render_template,request

import pandas as pd
import numpy as np

from bokeh.embed import components
from bokeh.plotting import figure
from bokeh.resources import CDN
from bokeh.embed import file_html
from bokeh.plotting import figure, output_file, show
from bokeh.io import output_file, show, vform
from bokeh.charts import Scatter, output_file, show
from bokeh.models import DatetimeTickFormatter
from bokeh.models import CustomJS, ColumnDataSource, Select

from app import data


def createChartHTML():


    #Import data from Excel file
    #Data Structure Looks as follows: Date, KPI 1, KPI 2, KPI 3, KPI 4 ... ... ...
    allData = pd.read_excel(open('Charts.xlsx', 'rb'), sheetname='DATA')

    #Get list of column names
    columnNameList = list(allData.columns.values)
    #Remove date column from column names
    columnNameList.pop(0)


    #Create line chart with markers with initial data
    p = figure(plot_width=800, plot_height=400,x_axis_type="datetime",title="KPI 1")
    p.left[0].formatter.use_scientific = False
    p.line(allData['Date'], allData["KPI 1"], line_width=2)
    p.circle(allData['Date'], allData["KPI 1"], fill_color="white", size=12)

    #Create callback
    source = ColumnDataSource(data=allData)

    #How do I link this code to the allData dataframe?
    #I need to pass a parameter from the selection box to this code to select the right data from the dataframe
    callback = CustomJS(args=dict(source=source), code="""
            var data = source.get('data');
            var f = cb_obj.get('value')
            x = data['LINK THIS TO NEWLY SELECTED DATA?????']
            y = data['Date']
            source.trigger('change');
        """)


    select = Select(title="Option:", value=columnNameList[0], options=columnNameList,callback=callback)
    layout = vform(select,p)
    output_file('plot.html', title='Plot')

    html = file_html(layout, CDN, "my plot")

    return(html)
</code></pre>

<p>I found an answer to my question here:</p>

<p><a href="https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/2rCCRIyXtk8" rel="nofollow">https://groups.google.com/a/continuum.io/forum/#!topic/bokeh/2rCCRIyXtk8</a></p>

python pandas bokeh