Skip to content

encode_plotly does not handle plot_ly objects made with plotly::subplot  #83

Closed

Description

@sacul-git

Creating a plotly object with subplot gives a data element, and no visdat element, so encode_plotly fails to mutate it to contain just data and layout elements. These objects then fail to render on dashr apps.

The issue seems to be here:

dashR/R/utils.R

Lines 578 to 581 in eff322c

encode_plotly <- function(layout_objs) {
if (is.list(layout_objs)) {
if ("x" %in% names(layout_objs) &&
"visdat" %in% names(layout_objs$x)) {

reproducible example:

library(plotly)

linePlot <- plot_ly(x = c(1,2,3), y = rnorm(3), type = "scatter", mode='line')
subPlot <- subplot(list(linePlot, linePlot), nrows=2)

str(subPlot)
#List of 8
 #$ x            :List of 7
  #..$ data     :List of 2              # <- data element instead of visdat, cannot be mutated by encode_plotly
  #.. ..$ :List of 10
  #.. .. ..$ x      : num [1:3] 1 2 3
  #.. .. .. ..- attr(*, "apiSrc")= logi TRUE
# ....

str(linePlot)
#List of 8
 #$ x            :List of 6
  #..$ visdat  :List of 1               # <- visdat element can correctly be mutated by encode_plotly 
  #.. ..$ 45f77f423b03:function ()
  #..$ cur_data: chr "45f77f423b03"
  #..$ attrs   :List of 1

Activity

  1. self-assigned this
    on Apr 17, 2019
  2. rpkyle commented on Apr 17, 2019

    @rpkyle
    Contributor

    @sacul-git Thanks for this 🌟 issue! I'm going to open a PR to address this one, it's an easy fix.

  3. added this to the DashR Launch milestone on Apr 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions