When a dcc.Graph figure data contains typed arrays (for example int8, float32, etc.), the figure can include a Plotly.js internal field _inputArray
In the example below, the _inputArray is included after user interaction but not when the figure is first rendered.
_inputArray duplicates bdata, increasing callback payload size and overhead for large datasets.
A possible fix is to strip _inputArray in dcc.Graph before updating the figure prop.
Other related issues:
When app first renders (no _inputArray):
After hover (with _inputArray):
Sample App:
from dash import Dash, html, dcc, Input, Output
import numpy as np
import plotly.express as px
import json
app = Dash()
data = np.random.normal(0, 1, 250)
fig = px.histogram(data, nbins=20)
app.layout = html.Div([
dcc.Graph(id="graph", figure=fig),
html.Pre(id="fig-data")
])
@app.callback(
Output("fig-data", "children"),
Input("graph", "figure"),
Input("graph", "hoverData"),
)
def debug(figure, hoverData):
return json.dumps(figure["data"][0]["x"], indent=4)
if __name__ == "__main__":
app.run(debug=True)
When a
dcc.Graphfiguredata contains typed arrays (for example int8, float32, etc.), thefigurecan include a Plotly.js internal field_inputArrayIn the example below, the
_inputArrayis included after user interaction but not when the figure is first rendered._inputArrayduplicatesbdata, increasing callback payload size and overhead for large datasets.A possible fix is to strip
_inputArrayin dcc.Graph before updating thefigureprop.Other related issues:
When app first renders (no _inputArray):
After hover (with _inputArray):
Sample App: