Note that there are some explanatory texts on larger screens.

plurals
  1. POHighcharts not rendering
    primarykey
    data
    text
    <p>So I wrote a python app to get stock data for highcharts. I get this in terminal</p> <pre><code>127.0.0.1 - - [28/Mar/2013 13:47:02] "GET / HTTP/1.1" 200 - 127.0.0.1 - - [28/Mar/2013 13:47:02] "GET /favicon.ico HTTP/1.1" 404 - 127.0.0.1 - - [28/Mar/2013 13:47:15] "GET /json/msft/?startdate=2010-01-01?enddate=2011-01-01 HTTP/1.1" 200 - </code></pre> <p>Here is my javascript code</p> <pre><code>&lt;script type="text/javascript"&gt; function stock() { console.log('pass 1') url = 'http://127.0.0.1:5000/json/' + document.getElementById("ticker").value + '/?startdate=' + document.getElementById("startdate").value + '?enddate=' + document.getElementById("enddate").value $.getJSON(url, function(data) { console.log('pass 2') // split the data set into ohlc and volume var ohlc = [], volume = [], dataLength = data.length; for (i = 0; i &lt; dataLength; i++) { ohlc.push([ data[i]["date"], // the date data[i]["open"], // open data[i]["high"], // high data[i]["low"], // low data[i]["close"] // close ]); volume.push([ data[i]["date"], // the date data[i]["volume"] // the volume ]) } // set the allowed units for data grouping var groupingUnits = [[ 'week', // unit name [1] // allowed multiples ], [ 'month', [1, 2, 3, 4, 6] ]]; // create the chart $('#container').highcharts('StockChart', { rangeSelector: { selected: 1 }, title: { text: 'AAPL Historical' }, yAxis: [{ title: { text: 'OHLC' }, height: 200, lineWidth: 2 }, { title: { text: 'Volume' }, top: 300, height: 100, offset: 0, lineWidth: 2 }], series: [{ type: 'candlestick', name: 'AAPL', data: ohlc, dataGrouping: { units: groupingUnits } }, { type: 'column', name: 'Volume', data: volume, yAxis: 1, dataGrouping: { units: groupingUnits } }] }); }); } &lt;/script&gt; </code></pre> <p>and my python code for the json request</p> <pre><code>@app.route('/json/&lt;ticker&gt;/', methods = ['GET']) def json_route(ticker): startdate = request.args.get('startdate','') enddate = request.args.get('enddate','') check = datecheck(startdate,enddate) if check != 'pass': return check check = datacheck(ticker,startdate,enddate) if check != 'got data': urldata(ticker) print '-----------------data-----------------' conn = engine.connect() entries = conn.execute(select([Stocks]).where(Stocks.symbol == ticker ).where(Stocks.date.between(startdate,enddate))).fetchall() stocklist = [] print entries for x in entries: stocklist.append({ 'volume': float('%f' %x[7]), 'high': float('%.2f' %x[4]), 'open': float('%.2f' %x[3]), 'low': float('%.2f' %x[5]), 'close': float('%.2f' %x[6]), 'date': str(x[2]), 'stock': x[1], }) conn.close() return json.dumps(stocklist) </code></pre> <p>What am I doing wrong? I assumed getjson would be doable if its on the same domain localhost. only console.log('pass one') works and shows up in the console when inspecting the element. Pass two is never hit.</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.
    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