plotly / plotly/plotly.py

Error on shape editing with `dcc.Graph`: Invalid property specified for object of type plotly.graph_objs.layout.shape.label: 'texttemplate'

未关闭
#4,462 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3 sev-2
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

I use dash components in my Flask app to render shapes on a dcc.Graph figure input. Oftentimes, this involves appending a list of shapes to the graph using the formula below:

for center in center_list:
            center = region.centroid
            annotation = cluster_frame[cluster_frame['cell_id'] == mask_id]['cluster']
            if len(annotation) > 0:
                annotation = str(annotation.tolist()[0])
                # boundary[int(center[0]), int(center[1])] = mask_id
                shapes.append(
                    {'editable': False, 'line': {'color': 'white'}, 'type': 'circle',
                     'x0': (int(center[1]) - circle_size), 'x1': (int(center[1]) + circle_size),
                     'xref': 'x', 'y0': (int(center[0]) - circle_size), 'y1': (int(center[0]) + circle_size),
                     'yref': 'y',
                     'fillcolor': cluster_assignments[data_selection][annotation]})
        self.figure['layout']['shapes'] = shapes

In the example above, a series of circles are generated around centroids for objects in the graph.
This scheme generally works well, but occasionally there will be in the following error when calling go.Figure(self.figure):

Invalid property specified for object of type plotly.graph_objs.layout.shape.label: 'texttemplate'

When I evaluate the shapes, sometimes they have a strange property added to them:

{'editable': False, 'line': {'color': 'white'}, 'type': 'circle', 'x0': 763, 'x1': 779, 'xref': 'x', 'y0': 284, 'y1': 300, 'yref': 'y', 'label': {'texttemplate': ''}}

It appears that plotly will randomly generate the label portion of the shape dictionary with a blank text template, which causes an error. It seems to happen indiscriminately and without a discernible pattern.

By comparison, most shapes appear to have a valid dictionary structure:

{'editable': True, 'line': {'color': 'white'}, 'type': 'circle', 'x0': 796, 'x1': 812, 'xref': 'x', 'y0': 293, 'y1': 309, 'yref': 'y'}

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 go.Figure(self.figure) 调用开始,检查 shape 字典如何传递到 plotly.graph_objs.layout.shape.label。使用提供的圆形 shape 进行复现,并比较有和没有 label.texttemplate 的情况;当所报告的间歇性 invalid-property 错误得到解释,并且不再针对所示输入发生时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
flask, python
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。