3

I was following Figure 16.7's example from https://plotly-r.com/client-side-linking.html and cannot figure out why there is a selection called "(All)" or how to remove it.

Image of what it looks like here

Code I was using is below

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)
)

Thanks for the help!

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
Daniel L
  • 158
  • 1
  • 8
  • All doesn't show up when I run the code. Also your widths are should add up to 12, so maybe use `c(6,6)`. It gave me an error using `c(12,12)`. – william3031 Jan 21 '22 at 03:50
  • @william3031 That's interesting. Despite changing the widths, I am still getting the (All) selection. Do you know which version of crosstalk you are using? – Daniel L Jan 21 '22 at 15:44
  • 1
    Hi, these versions: crosstalk_1.1.1 plotly_4.9.2.1 ggplot2_3.3.5 – william3031 Jan 23 '22 at 20:57
  • 3
    @william3031 Installing version 1.1.1 of crosstalk fixed the error, thanks for the help! – Daniel L Feb 09 '22 at 20:02

1 Answers1

1

This javascript works for Crosstalk 1.2.0 on a leaflet map:

function remove_all_option() {
    document.getElementById("Your ID Here").getElementsByClassName("selectized")[0].selectize.removeOption("");
}
    
window.onload = remove_all_option;
Mikael Jagan
  • 9,012
  • 2
  • 17
  • 48
mmfc
  • 11
  • 1