Skip to content

filter_slider should default to round = TRUE when the column is an integer #152

@EDAlnor

Description

@EDAlnor

Hi, experienced R user here, but first time ever posting on github, so please excuse any errors and just let me know if I am not following conventions.

I'm using crosstalk with plot_ly. If the column I provide as filter_slider is an integer, it seems logical to me that decimals should not be shown, i.e., its verbose that I have to provide round = T as an option.

For example in:

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

df <- data.frame(
  area  = rep(c('a', 'b', 'c'), 3),
  value = runif(9, min = 0, max =10),
  year  = as.integer(c(1,1,1,2,2,2,3,3,3))
) %>% highlight_key()

widget <- filter_slider(id = 'year', label = 'Year', dfk, ~mnum)

bscols(
  widget,
  plot_ly(df, x = ~year, y = ~value) %>% add_lines(color = ~area)
)

...the slider lets me select 6.5, 4.2, and so on, which shouldn't be possible given that year is an integer.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions