Questions tagged [r2d3]

an R package that provides an interface to D3 visualizations.

24 questions
5
votes
1 answer

Use R data.frame object in d3.js using r2d3

I'm trying to understand how an R data frame is passed to a d3.js script using the package r2d3. An extension of the r2d3 bar chart example to access variables in data.frame object would be helpful. R code: library(r2d3) data <- data.frame(nums =…
ssp3nc3r
  • 3,662
  • 2
  • 13
  • 23
3
votes
1 answer

r2d3 + Shiny: can't render a local image in D3, despite being able to render one using an URL

I'm struggling to get r2d3 + Shiny to render just a .png file. I'm able to do it if I use an URL in the .js file, but nothing is rendered if I use a relative path towards the exact same file, but stored locally. I've of course checked the local file…
Dric
  • 87
  • 13
3
votes
1 answer

r2d3: d3.js bar chart disappears on resize

I'm rendering this d3 chart in an RMarkdown document: Javascript (test.js): // !preview r2d3 data=readr::read_tsv("X:/D3 Practice/data.tsv"), d3_version = "3", container="div" // // r2d3: https://rstudio.github.io/r2d3 var margin = {top: 40,…
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81
3
votes
2 answers

Scoping in r2d3 visualization - d3.selectAll vs svg.selectAll

Why does d3.selectAll('rect')... not work as seen in the script below in the mouseover function, but svg.selectAll('rect')... does? svg is the special pre-set selector from r2d3. Additionally, I have noticed that running e.g.…
moman822
  • 1,904
  • 3
  • 19
  • 33
3
votes
1 answer

R2D3 as compared to D3.js

I want to use the R2D3 pacakge in R but am unsure of this package's relationship to the D3.js library. Does R2D3 limit the functionality of D3 in any way? Can we use all of the D3 functions and features in R with R2D3?
user11768059
2
votes
1 answer

Render JavaScript console output from r2d3 into browser console instead of the visualization?

JavaScript console output from r2d3 is rendered directly into the RStudio viewer visualization instead of the javascript console. See documentation. This also seems to be the behavior when r2d3::r2d3(..., viewer = 'browser') I.e., the console.log()…
ssp3nc3r
  • 3,662
  • 2
  • 13
  • 23
2
votes
1 answer

Dynamic variable selection in r2d3

I'm trying to take a d3 example script and turn it into a plotting function using r2d3. I can use r2d3's "options" parameter to pass strings into the d3 script, but I can't figure out a way to pass in expressions (which, I think, is necessary to…
Tom Greenwood
  • 1,502
  • 14
  • 17
1
vote
0 answers

Sourcing JS file in shinyapp for D3.js plot using r2d3

I am currently having a hard time using r2d3 with shiny. The problem lays in the sourcing of the script file. Which works if the shiny app is run locally, but not when using shiny-server. My understanding so far is that js files should be stored…
user12256545
  • 2,755
  • 4
  • 14
  • 28
1
vote
0 answers

map won't append to container: d3 using r2d3 in R

I'm trying to append a map to a div container using the r2d3 library in Rmarkdown: library(r2d3) library(htmltools) htmltools::tagList( htmltools::tags$script(src = "https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"), …
DiamondJoe12
  • 1,879
  • 7
  • 33
  • 81
1
vote
1 answer

How to add custom conditional colors in D3 tree nodes?

I am learning D3js and I would like to use condition to assign colors to nodes of a tree diagram. For example, if the type of data is "str", the node color will become "read" or "green" if it is "elem". I refer this thread and add the condition, but…
achai
  • 199
  • 1
  • 7
1
vote
1 answer

How do you animate axis transitions with d3 in r2d3?

I'm trying to create a histogram using D3 which has nice animated transitions for both the bars and the axes. It's straightforward to get the bars working, but I'm struggling to see how to do the same thing with the axes. In the example below the…
pseudospin
  • 2,737
  • 1
  • 4
  • 19
1
vote
0 answers

R Shiny + D3js - updating plot with new input results in overlapping graphs

I'm working on a Shiny dashboard where I would like to display a barplot corresponding to a selected dataset a user can choose. While I can create the barplot and switch between the inputs, I have a problem with the switch of the graphs: Switching…
Ruffybeo
  • 78
  • 1
  • 9
1
vote
1 answer

Functions not recognised when using R2D3

I have similar code using just javascript which works fine, but when I try to run it from a flexdashboard using R2D3, additional functions included in scripts are not recognised. I have simplified my code below to focus on the ScaleRadial function…
Chris
  • 1,449
  • 1
  • 18
  • 39
1
vote
0 answers

Interactive chart with r2d3 and shiny app

I am trying to add an interactive bar chart to my Shiny app, using r2d3 package. I have a dataset like this dummy sample containing date, id and motion column just for reference: df <- data.frame(stringsAsFactors=FALSE, date =…
DanG
  • 689
  • 1
  • 16
  • 39
1
vote
0 answers

How do I make the user input in my Rshiny app interact dynamically with my R.js file using R2D3?

I've got a d3.js script as a R.js working perfectly when I run the preview option, but I can't get it run properly in RShiny. The inputs are not re-rendering the output and the colors are not how I set them in the js. I have a dataframe with…
1
2