Dash.jl: download graph as svg, 'toImageButtonOptions' not working!

Hi, I created a small webapp which reads a csv and generate a plot using Plotly.jl and Dash.jl! I have a custom ‘myPlot’ function which generates the plot! I added the config settings in the ‘myPlot’ function:

function myPlot(...)
trace1 = scatter(....)
conf = PlotConfig(
        toImageButtonOptions=attr(
            format="svg", # one of png, svg, jpeg, webp
            filename="myPlot",
            height=900,
            width=1600,
            scale=1 
        ).fields)
    plot(trace1, config=conf)

This allows me to download the plot as ‘svg’ instead of ‘png’ from the modebar of the plot! but when you use it with dash it some how ignores the ‘PlotConfig’ settings, i can only download as ‘png’! Under ‘dcc_graph’, I added the code:

function create_app()
app = dash(suppress_callback_exceptions = true)
app.title ="myWebApp"
app.layout = html_div() do
   html_div(id="div3", dcc_graph(id="fig", config= toImageButtonOptions=attr(
        format="svg",
        filename = "myplot"
        ).fields, figure = myPlot(df, 200, 50, length(df[!,9]))))

Can someone please help me with it? Is it a bug? Thank you!

PS: I tried to make a custom download button:

    callback!(app, Output("download-image", "data"), Input("fig", "figure"), Input("btn-get-svg", "n_clicks"), prevent_initial_call=true) do figure, get_svg_clicks
        ctx = callback_context()
        if !isempty(ctx.triggered)
            input_id = split(ctx.triggered[1].prop_id, ".")[1]
            action = "download"
            ftype = split(input_id, "-")[end]
            #ftype = "svg"
            return Dict(
                "type" =>  ftype,
                "action" =>  action
            )
            else
            throw(PreventUpdate())
        end
   end

solved:
... dcc_graph(id="fig", config= PlotConfig(toImageButtonOptions=attr( format="svg", filename = "myplot" ).fields) ...

1 Like