How to remove (All) from crosstalk's filter_select in R?

问题描述 投票:0回答:1

我正在关注 https://plotly-r.com/client-side-linking.html 中的图 16.7 示例,但无法弄清楚为什么有一个名为“(全部)”的选择或如何删除它。

我使用的代码如下

library(plotly)
library(crosstalk)
data(txhousing, package = "ggplot2")
tx <- highlight_key(txhousing)
gg <- ggplot(tx) + geom_line(aes(date, median, group = city))
filter <- bscols(
  filter_select("id", "Select a city", tx, ~city),
  ggplotly(gg, dynamicTicks = TRUE),
  widths = c(12, 12)
)

感谢您的帮助!

r plotly r-plotly crosstalk
1个回答
0
投票

此 javascript 适用于传单地图上的 Crosstalk 1.2.0

    function remove_all_option() {
      document.getElementById("Your ID Here").getElementsByClassName("selectized")[0].selectize.removeOption("");
    }
    
    window.onload = remove_all_option;
© www.soinside.com 2019 - 2024. All rights reserved.