Note that there are some explanatory texts on larger screens.

plurals
  1. POrunning highcharts with flaskr and jinja2
    primarykey
    data
    text
    <p>I can't seem to get a working demo of highcharts with flaskr and jinja2. I get these three errors when I open the page.I intend to use javascript to call the json object my python code will provide to render the chart.</p> <pre><code>Uncaught TypeError: undefined is not a function highstock.js:287 Uncaught TypeError: Cannot read property 'prototype' of undefined exporting.js:9 Uncaught TypeError: Object [object Object] has no method 'highcharts' 127.0.0.1:32 </code></pre> <p>Here is my python code that renders the template</p> <pre><code>@app.route('/') def route(): return render_template('login.html') </code></pre> <p>I put the script src for highcharts as well as jquery in a block in the layout.html and the function that should create the chart in login.html. </p> <p>This is the layout.html</p> <pre><code>&lt;title&gt;Flaskr&lt;/title&gt; {% block head %} &lt;script src="http://code.highcharts.com/stock/highstock.js"&gt;&lt;/script&gt; &lt;script src="http://code.highcharts.com/stock/modules/exporting.js"&gt;&lt;/script&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; {% endblock %} &lt;link rel=stylesheet type=text/css href="{{ url_for('static', filename='style.css') }}"&gt; &lt;div class=page&gt; &lt;h1&gt;Flaskr&lt;/h1&gt; &lt;div class=metanav&gt; &lt;/div&gt; {% for message in get_flashed_messages() %} &lt;div class=flash&gt;{{ message }}&lt;/div&gt; {% endfor %} {% block body %}{% endblock %} &lt;/div&gt; </code></pre> <p>This is my login.html where I'm trying to render the code</p> <pre><code>{% extends "layout.html" %} {% block body %} &lt;h2&gt;Login&lt;/h2&gt; {% if error %}&lt;p class=error&gt;&lt;strong&gt;Error:&lt;/strong&gt; {{ error }}{% endif %} &lt;form action="" method=post&gt; &lt;dl&gt; &lt;dt&gt;Username: &lt;dd&gt;&lt;input type=text name=username&gt; &lt;dt&gt;Password: &lt;dd&gt;&lt;input type=password name=password&gt; &lt;dd&gt;&lt;input type=submit value=Login&gt; &lt;/dl&gt; &lt;/form&gt; &lt;script type="text/javascript"&gt; $(document).ready(function() { $.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlc.json&amp;callback=?', function(data) { // create the chart $('#container').highcharts('StockChart', { rangeSelector : { selected : 2 }, title : { text : 'AAPL Stock Price' }, series : [{ type : 'ohlc', name : 'AAPL Stock Price', data : data, dataGrouping : { units : [[ 'week', // unit name [1] // allowed multiples ], [ 'month', [1, 2, 3, 4, 6] ]] } }] }); }); }); &lt;/script&gt; &lt;div id="container" style="height: 500px; min-width: 500px"&gt;&lt;/div&gt; {% endblock %} </code></pre> <p>What am I doing wrong? Also how can I fix this to get a working demo?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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