Quantcast
Channel: 🎛️ Dash - Plotly Community Forum
Viewing all articles
Browse latest Browse all 6271

Plotly Static Image Export in Production Environment

$
0
0

Hey all. I recently built an app that allows users to query and plot data. After plotting, the user will have the option of downloading static images of plots in a PowerPoint. This feature works perfectly on my localhost, but fails in a production environment. I have a feeling the issue is related to Kaleido not being properly installed, which at the current time I’m accomplishing by the following command in my Dockerfile:

RUN pip install -U kaleido

Any thoughts on this are appreciated. Below is a copy of the relevant code.

@ app.callback(
    Output('download', 'data'),
    Input('export-to-pp', 'n_clicks')
)
def display_graph(n):
    if n:
        prs = Presentation()
        slide_layout_index = 1
        inches_from_left = Inches(0)
        inches_from_top = Inches(1.1)

        fig=get_figure_function()

        blank_slide_layout = prs.slide_layouts[slide_layout_index]
        slide = prs.slides.add_slide(blank_slide_layout)

        in_memory_image = io.BytesIO()
        fig.write_image(in_memory_image, format='png', engine="kaleido")
    
        in_memory_image.seek(0)
        pic = slide.shapes.add_picture(in_memory_image, inches_from_left, inches_from_top)

        return send_bytes(lambda out: prs.save(out), filename='data.pptx')

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 6271

Trending Articles