Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width">
- <title>JS Bin</title>
- </head>
- <body>
- <svg height="1000" width="1000">
- <rect x="100" y="100" width="20" height="20"></rect>
- <rect x="200" y="200" width="40" height="40"></rect>
- <rect x="300" y="300" width="60" height="60"></rect>
- </svg>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
- <script>
- let my_data = [1, 2, 3, 4, 5];
- let svg = d3.select('svg');
- svg.selectAll('rect')
- .data(my_data)
- .enter()
- .append('rect')
- .attr('width', function(d, i, nodes) {
- return d * 20;
- })
- .attr('height', function(d, i, nodes) {
- return d * 20;
- })
- .attr('x', function(d, i, nodes) {
- return d * 100;
- })
- .attr('y', function(d, i, nodes) {
- return d * 100;
- });
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement