Skip to content

plotly + dplyr verbs + crosstalk; not behaving like before #1799

Closed
@robertmitchellv

Description

@robertmitchellv

Before I start; big thanks again to everyone that contributes to plotly on both the r and js side--your work is so appreciated 🙌🏻

I recently updated to the github versions of both plotly and crosstalk and some flexdashboards I maintain for work are not behaving in the way they used to. Here's an example of what used to work:

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

data <- SharedData$new(diamonds, ~clarity)

bscols(
  widths = c(3, NA),
  filter_select(id = "select", label = "Select clarity", sharedData = data, ~ clarity),
  plot_ly(data) %>%
    group_by(clarity, cut) %>%
    summarise(count = n()) %>%
    add_bars(x = ~cut, y = ~count)
)

I've figured out that this now works, which didn't before:

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

clarity_cut <- diamonds %>%
  group_by(clarity, cut) %>%
  summarise(count = n())

data <- SharedData$new(clarity_cut, ~clarity)

bscols(
  widths = c(3, NA),
  filter_select(id = "select", label = "Select clarity", sharedData = data, ~ clarity),
  plot_ly(data) %>%
    add_bars(x = ~cut, y = ~count)
)

I'm just curious if the second code chunk I shared is the way things will be set up moving forward or if this change was unintended.

I wanted to check before I begin to refactor code since I didn't see anything indicating this change was intentional.

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