如何在使用工具提示时也更改 ggvis 的图例位置?

How to change legend position of ggvis when using tooltip as well?

显示如何更改图例在 ggvis 对象中的位置。但是,如果还添加了工具提示,则图例会消失。

library(ggvis)
data(mtcars)

mtcars %>% 
    ggvis(x = ~wt, y = ~mpg, fill = ~cyl) %>%
    layer_points() %>%
    add_legend(
        "fill", 
        properties = legend_props(
            legend = list(
                x = scaled_value("x", 3.25), 
                y = scaled_value("y", 40)
            )
        )
    ) %>%
    add_tooltip(function(df) df$wt)

知道如何防止这种情况吗?

这是已知的 issue,您可以尝试在代码末尾添加以下内容作为解决方法:

... %>% set_options(duration = 0)