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 and also includes decoded data, increasing callback payload size and overhead for large datasets.
Possible fixs:
- strip _inputArray in dcc.Graph before updating the figure prop. But that might be considered a breaking change since some people are now using _inputArray in callbacks.
- Have an option to not encode np arrays when using dash. This will also fix the issue of customdata not being available is clickData, hoverData if they are np arrays
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.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 and also includes decoded data, increasing callback payload size and overhead for large datasets.
Possible fixs:
Other related issues:
When app first renders (no _inputArray):
After hover (with _inputArray):
Sample App: