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

c3 charts behave inconsistently in shiny #20

Closed
SNaveenMathew opened this issue Sep 17, 2020 · 2 comments
Closed

c3 charts behave inconsistently in shiny #20

SNaveenMathew opened this issue Sep 17, 2020 · 2 comments

Comments

@SNaveenMathew
Copy link

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

  • In one R shiny app c3_pie works but c3_gauge does not
  • In another R shiny app c3_gauge works but c3_pie does not
  • In another R shiny app neither of these work

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

The input types for charts are:

  • c3_pie: data frame with 1 row and several columns
  • c3_gauge: data frame with 1 row and 1 column

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
Copy link
Owner

mrjoh3 commented Sep 18, 2020

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
Copy link
Author

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

  • pie to gauge if pie chart did not work
  • gauge to pie if gauge chart did not work
  • other plotting systems (ggplot2) if both did not work

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

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

2 participants