Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <title>Title</title>
  5. <script src="//d3js.org/d3.v4.min.js"></script>
  6. </head>
  7.  
  8. <body>
  9.  
  10. <script>
  11. var jsonCircles =
  12. <!--begin.rcode echo=FALSE, results='asis'
  13. library(jsonlite)
  14. N = 1e4
  15. d <- data.frame(x = runif(N, 50, 800),
  16. y = runif(N, 50, 600),
  17. radius = runif(N, 0.1, 2),
  18. colour = hcl(runif(N, 0, 360)),
  19. stringsAsFactors = FALSE)
  20. x <- toJSON(d)
  21. cat(x)
  22. end.rcode-->;
  23.  
  24. var svgContainer = d3.select("body").append("svg")
  25. .attr("width", 800)
  26. .attr("height", 600);
  27.  
  28. var circles = svgContainer.selectAll("circle")
  29. .data(jsonCircles)
  30. .enter()
  31. .append("circle");
  32.  
  33. var circleAttributes = circles
  34. .attr("cx", function (d) { return d.x; })
  35. .attr("cy", function (d) { return d.y; })
  36. .attr("r", function (d) { return d.radius; })
  37. .style("fill", function(d) { return d.colour; });
  38.  
  39. </script>
  40.  
  41. </body>
  42. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement