Closed joshua-xia closed 1 year ago
@joshua-xia,
In order to create dash-app's it is considered best practice to use the plain
FigureResampler
class instead of using theregister_plotly_resampler
method.I suggest you take a look at our
Hope this helps you further, Jonas
Thanks Jonas very much for your answer.
I reference the https://github.com/predict-idlab/plotly-resampler/blob/main/examples/dash_apps/01_minimal_global.py sample to modify my code, but the figure push to web frontend (browser) still be 20MB.
I wonder the FigureResampler does work for Box figure or not
I update figure as following:
global fig
fig.replace(go.Figure())
fig.add_trace(
go.Box(
x=data[value],
y=data.iloc[:, 1],
name="Box Diagram By Label",
boxpoints="outliers",
)
)
return fig
fig.register_update_graph_callback done "graph-id" and "trace-updater" also be set
@joshua-xia,
My bad, I looked over the line that you use go.Box
in your example.
Indeed, plotly-resampler only supports the aggregation of scatter[gl]
traces; as outlined #229
Some references: possible workaround: https://stackoverflow.com/questions/54128082/how-to-plot-a-boxplot-using-aggregates-in-plotly reason why box-plot sends all data to js: https://github.com/plotly/plotly.py/issues/2456
@joshua-xia,
My bad, I looked over the line that you use
go.Box
in your example. Indeed, plotly-resampler only supports the aggregation ofscatter[gl]
traces; as outlined #229Some references: possible workaround: https://stackoverflow.com/questions/54128082/how-to-plot-a-boxplot-using-aggregates-in-plotly reason why box-plot sends all data to js: plotly/plotly.py#2456
I got it and close this issue please, Thanks!
My original figure is about 20MB, I try the three methods in dash callback to return the figure to web frontend, but it seems the figure is not compressed
code as the following:
@callback( Output("dd-figure-container", "children"), Input("demo-dropdown", "value"), State("sessionStore", "data"), ) def update_output(value, sessionID): data = query_data(sessionID) fig = plot_box(data, value)
register_plotly_resampler(mode='auto')
def plot_box(data, select_column): fig = FigureWidgetResampler(go.Figure()) fig.add_trace( go.Box( x=data[select_column], y=data.iloc[:, 1], boxpoints="outliers", ) )
the data is same