Created
April 23, 2014 12:44
-
-
Save AlexFrazer/11213786 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "index.html" %} | |
{% block charts %} | |
{% for c in charts %} | |
<div id="{{ c['id']}}"></div> | |
{% endfor %} | |
<script type="text/javascript"> | |
var charts = {{ charts }} | |
</script> | |
<script src="{{ url_for('static', filename='render_charts.js') }}"></script> | |
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
$.each(charts, function(index, chart){ | |
$('#'+chart['id']).highcharts(chart); | |
}) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@app.route('/render/') | |
def render_charts(): | |
try: | |
charts = [{'chart_id': c['id'], 'chart': get_json(c['id']) | |
for c in dict(request.args)] | |
return render_template('render.html', charts=charts) | |
except KeyError as e: | |
abort(400) | |
def get_json(c): | |
with open(os.path.join(app.root_path, app.config['JSON'], c['id'], '.json'),'r') as j: | |
return j |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment