| <!doctype html> | |
| <meta charset="UTF-8"> | |
| <style type="text/css" media="screen"> | |
| .path { | |
| stroke: #c00; | |
| stroke-width: 1; | |
| fill: none; | |
| } | |
| </style> | |
| <script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
| <body> | |
| <script type="text/javascript" charset="utf-8"> | |
| var data = [5, 3, 5, 4, 4, 5, 6, 7, 2, 5] | |
| var width = 500, | |
| height = 500 | |
| var vis = d3.select('body').append('svg') | |
| .attr('width', 500) | |
| .attr('height', 500) | |
| var extent = d3.extent(data) | |
| var x = d3.scale.linear().domain([0, data.length]).range([0, width]), | |
| y = d3.scale.linear().domain(extent).range([0, height]) | |
| var path = d3.svg.line() | |
| .x(function(d, i) { return x(i) }) | |
| .y(y) | |
| vis.append('path') | |
| .datum(data) | |
| .attr('class', 'path') | |
| .attr('d', path) | |
| </script> | |
| </body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment