diff options
author | loit <michael.foiani@gmail.com> | 2025-07-28 15:00:02 -0400 |
---|---|---|
committer | loit <michael.foiani@gmail.com> | 2025-07-28 15:00:02 -0400 |
commit | 8062d3a9cc10ccfec3dab7f859fa0d1d4c118d38 (patch) | |
tree | dc6ca70dd923e900a752c0201d86719ea2345a96 /app.py | |
parent | bf04bf3d8b256b7d8c0ea581ec5c846699a4f959 (diff) |
basic functionality to pull data uising requests and make a chart using Dash and plotly
Diffstat (limited to 'app.py')
-rw-r--r-- | app.py | 42 |
1 files changed, 42 insertions, 0 deletions
@@ -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 |