rCharts plot won't appear in shiny app using dimple.js
Asked Answered
D

1

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!

Denesedengue answered 13/2, 2014 at 15:33 Comment(5)
You should mention what version of rCharts you are using.Kary
yeah, good point, done!Denesedengue
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 classChappell
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.Shaeshaef
thank you @Shaeshaef ! that solved everything, really appreciate your help. by the way, rCharts is really great, thanks for that tooDenesedengue
S
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.

Shaeshaef answered 16/2, 2014 at 4:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.