R plotly,鼠标悬停在绘图上时的正常光标

R plotly, normal cursor when mouse over the plot

默认情况下,当鼠标悬停在 plotly 中时,图形光标变为 "pointer",知道如何保持正常光标吗?

有点老套的解决方案,但您可以使用 htmlwidgets 和 Javascript 自己指定光标。

通过 d3.select 我们得到所有使用 cursor-crosshair class 的元素,并将光标设置覆盖为默认值,因此所有其他光标都保持不变,例如轴的调整大小光标。

library(plotly)
library(htmlwidgets)

plot_ly(type='bar', 
             x = c(1, 2), 
             y = c(3, 5)) %>% onRender("
function(el, x) {
  Plotly.d3.select('.cursor-crosshair').style('cursor', 'default')
}
")