0

I have been trying to render a chart using r2d3 package and RShiny. The code runs without an error but the chart doesn't get displayed. The D3 visualization works when implemented outside R. Can someone help me get this particular chart to work?

My app.R code is as below

library(shiny)
library(r2d3)

ui <- fluidPage(

  d3Output("d3")
)

server <- function(input, output) {
  output$d3 <- renderD3({
    r2d3(
      #runif(5, 0, input$bar_max),
      data=data_C,
      script = system.file("examples/mult2.js" , package = "r2d3", d3_version = c("3"))
    )
  })
}

shinyApp(ui = ui, server = server)

In the .js file, I replaced

d3.tsv("data.tsv", function(error, data) {
  color.domain(d3.keys(data[0]).filter(function(key) { return key !== "date"; }));

with

d3.tsv(r2d3.data, function(error, data) {
  color.domain(d3.keys(data[0]).filter(function(key) { return key !== "date"; }));

based on the example from the r2d3 page. The animated bar chart example, shown at the bottom of the page, works great for me. But this chart doesn't. Any help would be greatly appreciated

ismirsehregal
  • 30,045
  • 5
  • 31
  • 78
  • Have you looked at the console of your browser? Most likely you have errors regarding it can't fetch a URL. You might need to use `d3.tsvParse`, Or forget TSV parsing and put `r2d3.data` as argument to the callback function. – rioV8 Aug 23 '18 at 05:35
  • I have not checked. I’ve been away from the computer that I use the run D3. I will take a look. Thank you for the advice – adamcamroon Aug 26 '18 at 15:12
  • I have noticed that many of the d3 examples expect the d3.js file to be local but you can add `https//:`and they work. `` – adm Dec 05 '18 at 19:00
  • Where does `r2d3.data` come from? Is it actually a TSV file, or a JavaScript string object that contains TSV formatted data? Somehow I doubt that. – CJ Yetman Jan 17 '19 at 21:17

0 Answers0