Built with blockbuilder.org
| <!DOCTYPE html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <script src="https://d3js.org/d3.v3.js"></script> | |
| <style> | |
| .bar { | |
| background-color: orange; | |
| position: relative; | |
| float: left; | |
| margin-right: 10px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"></div> | |
| <script> | |
| var containerSelection = d3.select('.container') | |
| .style({ | |
| width: '500px', | |
| height: '300px', | |
| 'background-color': 'aliceblue' | |
| }); | |
| containerSelection.selectAll('div.bar') | |
| .data([1, 2, 3, 4]) | |
| .enter().append('div') | |
| .attr({ | |
| class: 'bar' | |
| }) | |
| .style({ | |
| height: function(d){ return d*50; }, | |
| top: function(d){ return 300 - d*50; }, | |
| width: '20px' | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment