7

I came along with this problem, that rCharts plot won't show in my shiny app. I found this example which perfectly suits my needs. Even though this chart works perfectly while just plotting in R, in shiny it is an blank page.

I am not sure what is wrong with it. Firstly, I am not sure if I am choosing right library in showOuput(), but I didn't find any better solution.

I am trying to plot it more sophisticated app, however, I reproducing my simple app code below of server:

server.R

library(rCharts)
library(reshape2)
options(RCHART_WIDTH = 1700)
meansconferences <-read.csv("https://raw.github.com/patilv/ESPNBball/master/meansconferences.csv")

shinyServer(function(input, output) {
    output$test <- renderChart({
      meltmeansconferences=melt(meansconferences[-c(1,10:14)], id.vars=c("Conference","Year"))
      d1=dPlot(y="Year", x="value",data=meltmeansconferences, groups="variable",type="bar")
      d1$yAxis(type="addCategoryAxis", orderRule="Year")
      d1$xAxis(type="addPctAxis")
      return(d1)
    })
}
)

And ui:

ui.R
options(RCHART_LIB = 'dimple')

shinyUI(pageWithSidebar(

headerPanel("rCharts and shiny"),

sidebarPanel(),

mainPanel(
h4("Graph here"),
showOutput("test","dimple")
)
))

EDITED: I am using R version 3.0.2 and rCharts 0.4.2 shiny 0.8.0.99

If you have any ideas, just let me know. Thank you in advance!

adomasb
  • 496
  • 4
  • 14
  • You should mention what version of rCharts you are using. – Stéphane Laurent Feb 13 '14 at 16:18
  • yeah, good point, done! – adomasb Feb 13 '14 at 17:52
  • I have the same setup (Mac) and don't see the graph in Shiny. The code from server.R does work from the command line. When I inspect element the data etc. seem to be in the DOM. However, an error is shown in the Chrome console: Uncaught The '#chart1dd6feaf41b' selector did not match any elements. Please prefix with '#' to select by id or '.' to select by class – Vincent Feb 13 '14 at 19:50
  • Switch to `renderChart2` or explicitly set `d1$set(dom = "test")` if you are using `renderChart`. I would recommend `renderChart2`, since I hope to combing the two functions in the next version. – Ramnath Feb 13 '14 at 21:09
  • thank you @Ramnath ! that solved everything, really appreciate your help. by the way, rCharts is really great, thanks for that too – adomasb Feb 14 '14 at 07:34

1 Answers1

4

Posting my comment as an answer so that this question can be closed

Switch to renderChart2 or explicitly set d1$set(dom = "test") if you are using renderChart. I would recommend renderChart2, since I hope to combing the two functions in the next version.

Ramnath
  • 54,439
  • 16
  • 125
  • 152