From 9677273f556b0d8de8566a98022fa7a82c5acf6c Mon Sep 17 00:00:00 2001 From: ANormalPerson1 <39001006+ANormalPerson1@users.noreply.github.com> Date: Thu, 21 Mar 2019 21:18:05 +0100 Subject: [PATCH] Attempt at doing json I fucked up big time. I have attempted to make a custom made chart, while, to my knowledge, one is readily available and more easily incorporated to the website design. --- backend/graph.js | 9 +++++++++ backend/main.py | 16 +++++++++++++++- {frontend => backend}/website.html | 22 ++++++++++++++++++++-- frontend/FlaskModule.py | 14 ++++++++++++++ frontend/JsonJs.js | 1 + frontend/org.json | 17 +++++++++++++++++ 6 files changed, 76 insertions(+), 3 deletions(-) create mode 100644 backend/graph.js rename {frontend => backend}/website.html (53%) create mode 100644 frontend/FlaskModule.py create mode 100644 frontend/JsonJs.js create mode 100644 frontend/org.json diff --git a/backend/graph.js b/backend/graph.js new file mode 100644 index 0000000..1c053db --- /dev/null +++ b/backend/graph.js @@ -0,0 +1,9 @@ +$(document).ready(function() { + $(chart_id).highcharts({ + chart: chart, + title: title, + xAxis: xAxis, + yAxis: yAxis, + series: series + }); +}); \ No newline at end of file diff --git a/backend/main.py b/backend/main.py index 27c0d5c..e0c6b55 100644 --- a/backend/main.py +++ b/backend/main.py @@ -1,4 +1,4 @@ -from flask import Flask, redirect, url_for, request +from flask import Flask, redirect, url_for, request, render_template app = Flask(__Name__) @app.route('/list') @@ -14,3 +14,17 @@ def deposit(): #Request .json, store json if request.isJson(): request.json. + + + +@app.route('/graph') +def graph(chartID = 'chart_ID', chart_type = 'line', chart_height = 500): + chart = {"renderTo": chartID, "type": chart_type, "height": chart_height,} + series = [{"name": 'Label1', "data": [1,2,3]}, {"name": 'Label2', "data": [4, 5, 6]}] + title = {"text": 'My Title'} + xAxis = {"categories": ['xAxis Data1', 'xAxis Data2', 'xAxis Data3']} + yAxis = {"title": {"text": 'yAxis Label'}} + return render_template('index.html', chartID=chartID, chart=chart, series=series, title=title, xAxis=xAxis, yAxis=yAxis) + +if __name__ == "__main__": + app.run(debug = True, host='0.0.0.0', port=8080, passthrough_errors=True) \ No newline at end of file diff --git a/frontend/website.html b/backend/website.html similarity index 53% rename from frontend/website.html rename to backend/website.html index 31392a5..1fdd49f 100644 --- a/frontend/website.html +++ b/backend/website.html @@ -18,11 +18,29 @@