Advertisement
dhshin

1-2

Mar 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.98 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.   <meta charset="utf-8">
  5.   <meta name="viewport" content="width=device-width">
  6.   <title>JS Bin</title>
  7. </head>
  8. <body>
  9.   <svg height="1000" width="1000">
  10.     <rect x="100" y="100" width="20" height="20"></rect>
  11.     <rect x="200" y="200" width="40" height="40"></rect>
  12.     <rect x="300" y="300" width="60" height="60"></rect>
  13.   </svg>
  14.   <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
  15.   <script>
  16.    
  17.     let my_data = [1, 2, 3, 4, 5];
  18.     let svg = d3.select('svg');
  19.    
  20.     svg.selectAll('rect')
  21.       .data(my_data)
  22.       .enter()
  23.       .append('rect')
  24.       .attr('width', function(d, i, nodes) {
  25.         return d * 20;
  26.       })
  27.       .attr('height', function(d, i, nodes) {
  28.         return d * 20;
  29.       })
  30.       .attr('x', function(d, i, nodes) {
  31.         return d * 100;
  32.       })
  33.       .attr('y', function(d, i, nodes) {
  34.         return d * 100;
  35.       });
  36.    
  37.   </script>
  38. </body>
  39. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement