Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Title</title>
- <script src="//d3js.org/d3.v4.min.js"></script>
- </head>
- <body>
- <script>
- var jsonCircles =
- <!--begin.rcode echo=FALSE, results='asis'
- library(jsonlite)
- N = 1e4
- d <- data.frame(x = runif(N, 50, 800),
- y = runif(N, 50, 600),
- radius = runif(N, 0.1, 2),
- colour = hcl(runif(N, 0, 360)),
- stringsAsFactors = FALSE)
- x <- toJSON(d)
- cat(x)
- end.rcode-->;
- var svgContainer = d3.select("body").append("svg")
- .attr("width", 800)
- .attr("height", 600);
- var circles = svgContainer.selectAll("circle")
- .data(jsonCircles)
- .enter()
- .append("circle");
- var circleAttributes = circles
- .attr("cx", function (d) { return d.x; })
- .attr("cy", function (d) { return d.y; })
- .attr("r", function (d) { return d.radius; })
- .style("fill", function(d) { return d.colour; });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement