Bug: ggplotly with geom_line and custom tooltip does not show lines when tooltip varies per data point

オープン
#2,502 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
r

調査の方向性

Start by running the three reproductions in the issue. Compare the trace that ggplotly() builds for geom_point against geom_line when the text aesthetic varies, for example by inspecting plotly_build() output. The fault is probably in how the line trace's hover text is converted, not in the plot itself. Done when a geom_line with a per-point tooltip renders its line and the tooltip still works.

索引モデルが issue の本文から書いたものです。

説明

Hello,

I have stumbled across a very strange little bug, if I try to make a custom tooltip on a plot converted from ggplot2 with ggplotly, then it works fine with geom_point but breaks (nothing is plotted) with geom_line. But, only when the text of the tooltip varies with the data.

For example, here we have everything working as expected with geom_point:

library(plotly)
p <- mtcars |>
  mutate(
    text = paste0("test: ", row.names(mtcars))
  ) |>
  ggplot(aes(x = disp, y = mpg, text = text)) +
  geom_point()

ggplotly(p, tooltip = "text")
Image

However, if I now use geom_line instead, the data disappears even though it must be there as the tooltip works:

library(plotly)
p <- mtcars |>
  mutate(
    text = paste0("test: ", row.names(mtcars))
  ) |>
  ggplot(aes(x = disp, y = mpg, text = text)) +
  geom_line()

ggplotly(p, tooltip = "text")
Image

But, if I change the tooltip text back so that it's a constant string (i.e. doesn't change with the data) then everything plots fine, again.

library(plotly)
p <- mtcars |>
  mutate(
    text = paste0("test: ", "constant")
  ) |>
  ggplot(aes(x = disp, y = mpg, text = text)) +
  geom_line()

ggplotly(p, tooltip = "text")
Image

What's even weirder is that the plotting will work fine with a varying tooltip, but only when it's the default tooltip:

library(plotly)
p <- mtcars |>
  mutate(
    text = paste0("test: ", "constant")
  ) |>
  ggplot(aes(x = disp, y = mpg)) +
  geom_line()

ggplotly(p)
Image
主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

plotly/plotly.R のほかの issue

plotly/plotly.R の issue をすべて見る

似ている issue

R の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。