[BUG] `dcc.Graph` `figure` prop may include Plotly.js `_inputArray` for typed arrays
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
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)
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先运行示例 Dash 应用,并检查 hover 前后的 dcc.Graph figure,重点关注 typed-array 数据和 _inputArray 字段。跟踪 dcc.Graph 和 Plotly.js 周围的 figure 与 callback payload 处理。完成的标准是:为 _inputArray 选择的行为已一致地实现,已考虑 typed-array 的 customdata 行为,并已验证 payload 大小。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, numpy, python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 50/100