Plotting Figure from Server code

I’m trying to call a server side func that returns a Plotly Figure object and then assign it to Plot().figure.

My problem is that it won’t display the data or anything. I checked the fig object and it does contain what it looks like a valid serialised figure.

Code Sample:

print("\nCreating plots...")
print("Creating orderbook heatmap...")
orderbook_fig = anvil.server.call('create_orderbook_heatmap', 
    data=orderbook_data, 
    max_distance_percent=int(distance)
)
self.orderbook_plot.figure = orderbook_fig

a very simple heatmap works as expected

e.g. from the plotly docs

    fig = go.Figure(data=go.Heatmap(
                    z=[[1, 20, 30],
                      [20, 1, 60],
                      [30, 60, 1]]))
    return fig

So maybe try simplifying your data for debugging

Hey! Just tried debugging with Uplink and the exact same figure works just fine if called from the code in my uplink script. Any idea what could it be? Perhaps conflicting Plotly versions?

Seems like the problem was incompatibility between the version installed in the Standard env and the one in Client. I installed the same version I had on my Uplink env and it now works fine.

3 Likes