Note that there are some explanatory texts on larger screens.

plurals
  1. POTrouble setting up chartkick with flask
    text
    copied!<p>I would like to use the python package <a href="https://pypi.python.org/pypi/chartkick/0.4.0" rel="nofollow">chartkick-0.4.0</a> to add graphs in my flask app. However, I am new to flask and having trouble setting it up. The <code>readme</code> file for the project states:</p> <pre><code> Add chartkick to jinja_env and static_folder: app = Flask(__name__, static_folder=chartkick.js(), static_url_path='/static') app.jinja_env.add_extension("chartkick.ext.charts") </code></pre> <p>I have added chartstick.js to my templates/js folder. However, the line </p> <pre><code>app=Flask(__name__,static_folder=chartkick.js(), static_url_path='/static/js/') </code></pre> <p>throws a</p> <pre><code>NameError: "chartstic" is not defined. </code></pre> <p>What am I doing wrong ? How do i set up chartstick properly with flask?</p> <p>This is my template: </p> <pre><code>&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt; &lt;script src="http://code.highcharts.com/highcharts.js"&gt;&lt;/script&gt; &lt;script src=""{{ url_for('static', filename='js/chartkick.js') }}"&gt;&lt;/script&gt; {% bar_chart data %} </code></pre> <p>UPDATE <em>*</em>* and this is my views file now: </p> <pre><code>from flask import Flask, jsonify, render_template, request import chartkick app=Flask(__name__,static_folder=chartkick.js(), static_url_path='/static/js/') app.jinja_env.add_extension("chartkick.ext.charts") @app.route('/chart') def first_graph(): data = {'Chrome': 52.9, 'Opera': 1.6, 'Firefox': 27.7} return render_template('first_graph.html', data=data) if __name__=="__main__": app.run(debug=True) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload