changed chart to line graph with date using stock prices for placeholder

This commit is contained in:
Nico Melone
2025-01-22 17:45:11 -06:00
parent 0c6098a011
commit 4c1593b230
3 changed files with 14 additions and 9 deletions

9
app.py
View File

@@ -1,5 +1,6 @@
import requests, os
import plotly.graph_objects as go
import plotly.express as px
from flask import Flask, render_template, jsonify, make_response
from weasyprint import HTML
@@ -8,12 +9,14 @@ app = Flask(__name__)
@app.route('/report')
def report():
# Create Plotly graph
fig = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[10, 20, 30], mode='lines')])
#fig = go.Figure(data=[go.Scatter(x=[1, 2, 3], y=[10, 20, 30], mode='lines')])
df = px.data.stocks()
fig = px.line(df, x='date', y=['AAPL', 'GOOG'])
# Save the graph as an image
image_path = os.path.join('static', 'graph.svg')
fig.write_image(image_path)
return render_template('report.html', graph_image=image_path)
return render_template('report.html', graph_image=image_path, table_data = df)
@app.route('/')
def home():

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

@@ -8,15 +8,17 @@
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Date</th>
<th>Google Stock Price</th>
<th>Apple Stock Price</th>
</tr>
</thead>
<tbody>
{% for row in table_data %}
{% for index,row in table_data.iterrows() %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
<td>{{ row['date'] }}</td>
<td>{{ row['GOOG'] }}</td>
<td>{{ row['AAPL'] }}</td>
</tr>
{% endfor %}
</tbody>