A simple bar chart with d3.js
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Updatable Charts (1 of 4)</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script> | |
| <style> | |
| body { | |
| padding: 20px 0 0 10px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <script> | |
| var milesRun = [2, 5, 4, 1, 2, 6, 5]; | |
| d3.select('body').append('svg') | |
| .attr('height', 300) | |
| .attr('width', 800) | |
| .selectAll('rect') | |
| .data(milesRun) | |
| .enter() | |
| .append('rect') | |
| .attr('y', function (d, i) { return i * 40 }) | |
| .attr('height', 35) | |
| .attr('x', 0) | |
| .attr('width', function (d) { return d*100}) | |
| .style('fill', 'steelblue'); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment