Advertisement
dhshin

1-2_r

Mar 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.86 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="0" y="0" width="100" height="50"></rect>
  11.     <rect x="0" y="100" width="200" height="50"></rect>
  12.     <rect x="0" y="200" width="300" height="50"></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 * 100;
  26.       })
  27.       .attr('height', 50)
  28.       .attr('x', 0)
  29.       .attr('y', function(d, i, nodes) {
  30.         return (d - 1) * 100;
  31.       });
  32.    
  33.   </script>
  34. </body>
  35. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement