plotly / plotly/plotly.py

Hover tooltip works incorrectly in scatter WebGL

未关闭
#3,516 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

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

描述

In the code example below (using the scattergl) when the cursor is rolled over the bubble, the hover tooltip does not appear until the cursor is close to the center of the bubble. The tooltip itself also points to the center of the bubble.

This is different from the expected behavior observed with the regular scatter where the tooltip appears in relation to the boundary of the bubble, rather than its center. And the tooltip points to the boundary as well.

For the Plotly Express px.scatter, one needs to set render_mode='svg' to switch out of WebGL for the correct behaviour.

This results in an incorrect tooltip in WebGL appearing when the cursor is over the larger bubble in an example such as this one:

bubble

import pandas as pd
import plotly.graph_objects as go

df = pd.DataFrame({'x': [1], 'y': [1],'z': [100]})

fig = go.Figure()

fig.add_scattergl(
    x=df['x'],
    y=df['y'],
    marker_size=df['z'],
    mode='markers',
    marker_sizeref=0.01,
    marker_sizemode='area',
    showlegend=True,
    hovertemplate=(
        'x: %{x:.2f}<br>'
        'y: %{y:.2f}<br>'
        '<extra></extra>'
    ),
)

fig.show()

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行提供的、使用 go.Figure.add_scattergl 的 Python 示例,并将其 hover 行为与常规 scatter 进行比较。从 scattergl 入口点开始追踪 WebGL hover 处理,并以预期的基于边界的 tooltip 行为以及与 render_mode='svg' 的比较作为参考。当大气泡在其整个可见区域内都能响应,并且 tooltip 指向边界时,即表示完成。

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

评估

技术栈
python
领域
data-visualization, frontend
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
42/100

把新 issue 发到你的邮箱

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