changed for pdf generation also

This commit is contained in:
Nico Melone
2025-01-22 17:46:40 -06:00
parent 4c1593b230
commit 6048c578a1
2 changed files with 5 additions and 4 deletions

7
app.py
View File

@@ -29,15 +29,16 @@ def get_data():
@app.route('/download-pdf')
def download_pdf():
# 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
this_folder = os.path.dirname(os.path.abspath(__file__))
image_path = os.path.join(this_folder, 'static', 'graph.svg')
fig.write_image(image_path)
# Render the HTML template with the graph image
html = render_template('report.html', graph_image="file://" + image_path)
html = render_template('report.html', graph_image="file://" + image_path, table_data = df)
print(html)
pdf = HTML(string=html).write_pdf()

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB