D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
alex-rind
Full window
Github gist
Area chart v3
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v3.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } .axis path, .axis line { fill: none; stroke: #000; shape-rendering: crispEdges; } .x.axis path { display: none; } .line { fill: steelblue; stroke: steelblue; stroke-width: 1.5px; } </style> </head> <body> <script> // Feel free to change or delete any of the code you see in this editor! var svg = d3.select("body").append("svg") .attr("width", 960) .attr("height", 500) .attr("transform", "translate(50, 10)"); var data = Array.from({length: 10}, () => Math.floor(Math.random() * 9 + 1)); var width = 500, height = 500; var x = d3.scale.linear() .range([0, width]) .domain([0, data.length -1]); var y = d3.scale.linear() .range([height, 0]) .domain([0, 10]); var line = d3.svg.area() .x(function(d, i) { return x(i); }) .y1(function(d) { return y(d); }) .y0(height) .interpolate('cardinal'); svg.append("path") .datum(data) .attr("class", "line") .attr("d", line); </script> </body>
https://d3js.org/d3.v3.min.js