Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axis limit doesn't looks right when using dui_for_reactable() #6

Open
choux130 opened this issue Oct 2, 2020 · 0 comments
Open

Axis limit doesn't looks right when using dui_for_reactable() #6

choux130 opened this issue Oct 2, 2020 · 0 comments

Comments

@choux130
Copy link

choux130 commented Oct 2, 2020

The Y axis limit doesn't change automatically when I used standalone sparkline version but it works well in htmlwidget version.
Am I missing something?

set.seed(123)
df = tibble(
  id = 1:3,
  plot = list(
    list(data = lapply(1:35, function(i) {
      list(
        x = paste0("Day ", i),
        gmv = sample(c(0,100,2,1,0,0,0,0,0), 9)[1]
    ) 
      })
    )
  , 
  list(data = lapply(1:35, function(i) {
    list(
      x = paste0("Day ", i),
      gmv = sample(c(0,100,2,1,0,0,0,0,0), 9)[1]
    ) 
  })
  ),
  list(data = lapply(1:35, function(i) {
    list(
      x = paste0("Day ", i),
      gmv = sample(c(10,100,20,10,100,100,1000,100,30), 9)[1]
    ) 
  })
  )
)) 
df %>% 
  reactable(
    showSortable = TRUE,
    columns = list(
      plot = colDef(
        minWidth = 150,
        align = "center",
        filterable = FALSE,
        sortable = FALSE,
        cell = dui_for_reactable(
          dui_sparkline(
            height = 100,
            margin = list(left = 50, top = 50),
            data = htmlwidgets::JS("cellInfo.value.data"),
            valueAccessor =  htmlwidgets::JS("(d) => d.gmv"),
            components = list(
              dui_sparklineseries(),
              dui_sparkpointseries()
            )
          )  
        )
      )
    )) %>% 
  dataui::dui_add_reactable_dep() 

standalone

df %>% 
  reactable(
    showSortable = TRUE,
    columns = list(
      plot = colDef(
        minWidth = 150,
        align = "center",
        filterable = FALSE,
        sortable = FALSE,
        cell = function(value)(
          dui_sparkline(
            data = value$data,
            valueAccessor =  htmlwidgets::JS("(d) => d.gmv"),
            components = list(
              dui_sparklineseries(),
              dui_sparkpointseries()
            )
          )
        )
      )
    )) 

htmlwidget

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant