aboutsummaryrefslogtreecommitdiff
path: root/app.py
diff options
context:
space:
mode:
Diffstat (limited to 'app.py')
-rw-r--r--app.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/app.py b/app.py
new file mode 100644
index 0000000..a2e9f07
--- /dev/null
+++ b/app.py
@@ -0,0 +1,42 @@
+from dash import Dash, dcc, html, Input, Output
+import plotly.graph_objects as go
+import json
+import datetime
+
+app = Dash(__name__)
+
+
+app.layout = html.Div([
+ html.H4('Interactive color selection with simple Dash example'),
+ html.P("Select color:"),
+ dcc.Dropdown(
+ id="dropdown",
+ options=['Gold', 'MediumTurquoise', 'LightGreen'],
+ value='Gold',
+ clearable=False,
+ ),
+ dcc.Graph(id="graph"),
+])
+
+# pull stock data from json files
+timestamps_file = open('timestamps.json', 'r')
+timestamps_file_data = timestamps_file.read()
+timestamps = json.loads(timestamps_file_data)
+timestamps = [datetime.datetime.fromtimestamp(t) for t in timestamps]
+
+prices_file = open('close_prices.json', 'r')
+prices = json.loads(prices_file.read())
+
+# print('timestamps:\t', timestamps, '\nprices:\t', prices)
+
+
+@app.callback(
+ Output("graph", "figure"),
+ Input("dropdown", "value"))
+def display_color(color):
+ fig = go.Figure(
+ data=go.Line(x=timestamps, y=prices, marker_color=color))
+ return fig
+
+
+app.run(debug=True) \ No newline at end of file