mrjoh3 / c3

c3 HTMLWidget Ploting
39 stars 51 forks source link

c3 charts behave inconsistently in shiny #20

Closed SNaveenMathew closed 3 years ago

SNaveenMathew commented 3 years ago

Disclaimer: I'm unable to produce 'reproducible' code because of the following reasons:

Definition: "not working": svg is created and rendered in the browser, but it is blank

The input types for charts are:

Summary of attempts, successes and failures:

The input to charts is a reactiveValues object that updates based on user's inputs. In both cases I'm using c3::c3Output(...) and defined a suitable output$... <- c3::renderC3({ ... }). To be safe I avoided using %>% and returned c3_pie() or c3_gauge object. I saved (cached) the data frame used for plotting, read it in R and plotted (c3_gauge or c3_pie) - it worked as expected. I also observed that replacing the dynamic data with static data (Eg: data.frame(x=10, y=10)) makes the plot appear in R shiny. I experimented a bit more and found that there is no clear relationship between the type of data (reactive or static) and the behavior of the R shiny output.

Is there a universal fix for this problem?

mrjoh3 commented 3 years ago

Hi @SNaveenMathew, it sound like it is an issue with your reactive element. Please produce a minimal version based on the code below. This works fine add your reactive code until it does not work then I can attempt to debug:

library(shiny)
library(c3)

ui <- fluidPage(
        c3Output("plot")
)

server <- function(input, output) {

   output$plot <- renderC3({
     data.frame(x=10, y=10) %>%
       c3() %>%
       #c3_pie()
       c3_gauge()
   })
}

shinyApp(ui = ui, server = server)
SNaveenMathew commented 3 years ago

My apologies, I'm not able to produce a minimal reproducible example. I went with the temporary fix - I changed the type of chart from

I will reopen this issue if I find a more concrete explanation.