[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
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
_inputArrayin dcc.Graph before updating thefigureprop. But that might be considered a breaking change since some people are now using_inputArrayin callbacks. - Have an option to not encode np arrays when using dash. This will also fix the issue of
customdatanot being available isclickData,hoverDataif they are np arrays
Other related issues:
- Need a way to covert the typed arrays so the data is usable in a dash callback: https://github.com/plotly/dash/issues/3307
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the sample Dash app and inspecting the dcc.Graph figure before and after hover, focusing on typed-array data and the _inputArray field. Trace the figure and callback payload handling around dcc.Graph and Plotly.js. Done means the chosen behavior for _inputArray is implemented consistently, with typed-array customdata behavior considered and payload size verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, numpy, python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 50/100