Afloz
Afloz

Reputation: 3665

Why is this Bokeh plot not showing up when embedded in Flask App?

I'm using Bokeh in a Python Flask app. In the test_app.py file have this code:

See the Code, data and output in iPython notebook...

def make_figure():
     plot = figure(tools=TOOLS, width=750, height=450, title='United States Import/Exports',
              x_axis_label='date', x_axis_type='datetime')

     plot.line(dframe.index, dframe.get('Exports'), color='#A6CEE3', legend='Exports')
     return plot


@app.route('/')
def greet():
    greetings = 'Hello World, I am BOKEH'
    plot = make_figure()
    script, div = components(plot)

    return render_template('index.html', greetings=greetings, script=script, div=div)


if __name__ == '__main__':
    app.run(debug=True)

In the index.html file, I have the following core part along with the required js and css links:

<body>
   <h1>{{ greetings | safe }} </h1>
    {{ script | safe }}
    {{ div | safe }}
</body>

Problem is, the Bokeh canvas, controls, etc show up but the line plot itself does not. What am I missing in this code?

Upvotes: 1

Views: 2278

Answers (1)

euri10
euri10

Reputation: 2626

remove dframe = dframe.set_index('Month') and your good to go

Upvotes: 1

Related Questions