plotly / plotly/plotly.py

[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays

Open
#5,676 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P2 size: 3
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 _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):

Image

After hover (with _inputArray):

Image

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.