R Shiny rCharts Morris - rChart is not displayed (under certain circumstances)

I encountered a problem when used rChartsin my application Shiny. I generate dynamically 1-3 tabPanels(depending on the user's choice), and in each of them one schedule is created. The plot can be of two types: simple (with libary graphics) or rCharts (with morris library ). Everything is tabsetPaneldisplayed in the component uiOutput, every time the user changes his input. The type ui output( plotOutputfor a simple chart or showOutputfor rCharts) is determined during rendering tabPanel, so the chart has one .

And the problem : Simple graphs (with graphics, ggplot2, etc.) work fine - they display correctly in tabPanel. However, when I work with the application and show 2 or 3 rCharts for display, it happens that one diagram does not display - almost at all (see Images below). Of course, such a problem does not arise with the help of simple graphs.

I tried to keep the output file size fixed, the size flexible, but the problem still exists. I have R series and libraries as follows:

> R.Version()$version.string
[1] "R version 3.0.1 (2013-05-16)"
> packageVersion("Shiny")
[1] ‘0.7.0
> packageVersion("rCharts")
[1] ‘0.3.51

Thanks so much for any suggestions.

rCharts works fine:

enter image description here

rCharts FAIL will be deleted ok:

enter image description here

EDIT: my code is below:

User interface

library(shiny)
library(Epi)

shinyUI(pageWithSidebar(  
  headerPanel("Header"),  

  sidebarPanel(        
    checkboxInput(inputId = "checkboxInputx", label = "function: x", value = TRUE),
    checkboxInput(inputId = "checkboxInputxpower2", label = "function: x^2", value =     FALSE),
    checkboxInput(inputId = "checkboxInput2x", label = "function:  2x", value = FALSE),

    actionButton("gobutton","GO!")
   ),

  mainPanel(    
    radioButtons("plottypechoice", "Choose plot type", c("simple", "rCharts")),    
    uiOutput("plotpanelcontent")
  )   
))

SERVER

library(shiny)
library(rCharts)
library(Epi)
library(reshape2)

# build data frame 
x <- 1:100
df <- data.frame(x, x^2, 2*x)
names(df) <- c("x", "xpower2", "2productx")


shinyServer(function(input, output) {

  # generate tabsetPanel with tabPlots with plot of selected type 
  output$plotpanelcontent <- renderUI({ 

    if(input$gobutton != 0){


        # collect tab names 
        tab.names <- vector()
        if(input$checkboxInputx) tab.names <- c(tab.names, "x")
        if(input$checkboxInputxpower2) tab.names <- c(tab.names, "xpower2")
        if(input$checkboxInput2x) tab.names <- c(tab.names, "2productx")
        print(tab.names)

        # render tabs
        tabs <- lapply(tab.names, function(tab.name){ 
          # define tabPanel content depending on plot type selection 
          if(input$plottypechoice == "simple")
            tab <- tabPanel(tab.name, plotOutput(paste0("simpleplot", tab.name)))
          else
            tab <- tabPanel(tab.name, showOutput(paste0("rchartplot", tab.name), "morris"))
          return(tab)
        })  
        return(do.call(tabsetPanel, tabs))
    }
  })  


  # Render simple plots 
  output$simpleplotx <- renderPlot({ 
    print(plot(df[,1], df[,1]))
    plot(df[,1], df[,1]) 
  })
  output$simpleplotxpower2 <- renderPlot({ 
    print(plot(df[,1], df[,2]))
    plot(df[,1], df[,2])   
  })
  output$simpleplot2productx <- renderPlot({ 
    print(plot(df[,1], df[,3]))
    plot(df[,1], df[,3])   
  })


  # Render rCharts 
  output$rchartplotx <- renderChart({ 
    plot <- mPlot(x="x", y="x", type = "Line", data = df)
    plot$set(dom = "rchartplotx")
    return(plot)
  })
  output$rchartplotxpower2 <- renderChart({ 
    plot <- mPlot(x="x", y="xpower2", type = "Line", data = df)
    plot$set(dom = "rchartplotxpower2")
    return(plot)
  })
  output$rchartplot2productx <- renderChart({ 
    plot <- mPlot(x="x", y="2productx", type = "Line", data = df)
    plot$set(dom = "rchartplot2productx")
    return(plot)
  })
}) 

UPDATE:

I asked Olly Smith , author of the morris.js library, to offer a solution, and I got the following answer:

, . Morris , . redraw(), Morris.Line/Bar/Donut, . , , API, .

2.:

Ramnath Shiny rCharts:

> packageVersion("Shiny")
[1] ‘0.8.0
>  packageVersion("rCharts")
[1] ‘0.3.53

R. , , , . :

  • set: "function: x", "rCharts", GO [OK],

  • add: "function: x ^ 2" [. "not_ok_1", ],

  • add: "function: 2x" [. "not_ok_2", ].

:

  • OK enter image description here

  • "not_ok_1" image enter image description here

  • "not_ok_2" image enter image description here

+4

All Articles