[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 18.8k
- Forks
- 2.8k
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 21
Beschreibung
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)
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die Beispiel-Dash-App auszuführen und die dcc.Graph-Figure vor und nach dem Hover zu untersuchen, wobei der Schwerpunkt auf Typed-Array-Daten und dem Feld _inputArray liegt. Verfolge die Verarbeitung der Figure- und Callback-Payloads rund um dcc.Graph und Plotly.js. Die Aufgabe ist abgeschlossen, wenn das gewählte Verhalten für _inputArray konsistent implementiert ist, das Verhalten von customdata mit Typed Arrays berücksichtigt wurde und die Payload-Größe überprüft wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, numpy, python
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 50/100