diff --git a/app.py b/app.py index 8650222..918c19e 100644 --- a/app.py +++ b/app.py @@ -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() diff --git a/static/graph.svg b/static/graph.svg index 1a9d5e8..59e78b1 100644 --- a/static/graph.svg +++ b/static/graph.svg @@ -1 +1 @@ -Jan 2018Jul 2018Jan 2019Jul 20190.911.11.21.31.41.51.61.7variableAAPLGOOGdatevalue \ No newline at end of file +Jan 2018Jul 2018Jan 2019Jul 20190.911.11.21.31.41.51.61.7variableAAPLGOOGdatevalue \ No newline at end of file