crosstalk icon indicating copy to clipboard operation
crosstalk copied to clipboard

Gaps between bars and x axis not updated when filter_select is applied

Open data-al opened this issue 6 years ago • 1 comments

I experienced strange behavior of a bar plot when using crosstalk::filter_select. It does not update the x axis according to the filter, and shows gaps between the bars.

Here is a reproducible example:

library(crosstalk)
library(dplyr)
library(plotly)

# setting the seed
set.seed(123)

# create data
df <- data.frame(
  a = sample(letters, 40, replace = T),
  b = sample(letters, 40, replace = T),
  val = sample(20:100, 40, replace = F)
) %>%
  mutate(chr = paste0(a, b)) %>% 
  select(-c(a, b))

# make R6 class that represents a shared data frame
df <- SharedData$new(df)

# make the interactive plot 
crosstalk::bscols(
  list(crosstalk::filter_select(
    id = "chr",
    label = "Character",
    sharedData = df,
    group = ~ chr
  )),
  plot_ly(df, x = ~ chr, y = ~ val)
)

When the interactive plot is created, if we choose the following in the dropdown menu: "am", "gc", "rs", the filter creates the following barplot:

image

There are gaps between the bars and the x axis is not updated when the filter is applied.

Is it possible to use crosstalk to fix this issue.

Many thanks in advance

data-al avatar Dec 12 '18 22:12 data-al

Thank you for post. I have just experienced the same thing. Is there any update to this?

mm225022 avatar Jun 21 '23 17:06 mm225022