ramnathv / rCharts

Interactive JS Charts from R
http://rcharts.io
Other
1.19k stars 654 forks source link

Patch renderChart2 #211

Open ramnathv opened 11 years ago

ramnathv commented 11 years ago

This is to avoid errors in Shiny, when the chart inputs are being initialized. I think the basic idea should to be check the class of rChart_ and return an empty chart if no chart is returned. I have to figure out how to implement this.

renderChart2 <- function (expr, env = parent.frame(), quoted = FALSE) {
  func <- shiny::exprToFunction(expr, env, quoted)
  function() {
    rChart_ <- func()
    cht_style <- sprintf("<style>.rChart {width: %spx; height: %spx} </style>", 
    rChart_$params$width, rChart_$params$height)
    cht <- paste(capture.output(rChart_$print()), collapse = "\n")
    HTML(paste(c(cht_style, cht), collapse = "\n"))
   }
}
tcash21 commented 11 years ago

Is this causing the same issue I've described here? https://groups.google.com/forum/#!topic/shiny-discuss/J-qc1PMINs4

I know you were able to resolve it at least for Rickshaw by returning Rickshaw$new() but there seem to be some issues with the other classes as well as Rickshaw conflicting with other R Shiny widgets (other widgets don't appear in mainPanel but sidePanel is ok).

ramnathv commented 11 years ago

This issue was created in response to your post on the Shiny group :) I still need to investigate possible solutions, and will update this issue with comments as I do so.

Do you have a link to the source code of your Shiny App, which will help me recreate the issues you encountered?