Greetings,
So I’ve dug through the docs to no avail, other than to reach a suspicion that the Plotly graph_objects.Frames (and the corresponding express features) perhaps haven’t been ported to anvil?
The plotly feature I’m looking to utilize is outlined here in more detail here:
On a local machine or jupyter notebook the examples from there, and the code below, works and produces a nice animation.
On Anvil, computing fig serverside and returning it produces a static plot (with the play and stop buttons attached, but which do nothing).
Client side I get the standard module not found error if trying to import or use “Figure” or “Frames” from plotly.
example:
Server module:
import pandas as pd
import plotly.express as px
@anvil.server.callable
def show_animated_plot()
data = pd.Dataframe(
{'x': {0: 21, 1: 18, 2: 17, 3: 20, 4: 23, 5: 17, 6: 20, 7: 20, 8: 17, 9: 21, 10: 25, 11: 23},
'y': {0: 23, 1: 25, 2: 25, 3: 25, 4: 21, 5: 21, 6: 24, 7: 24, 8: 25, 9: 24, 10: 20, 11: 16},
'day': {0: 0, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11}})
fig = px.scatter(data, x="x", y="y", animation_frame="day")
return fig
client module
fig = anvil.server.call('show_animated_plot')
self.plot_1.figure = fig
Hopefully I’m just missing something simple here.
Cheers,
Stuart