D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
Gregory-Howard
Full window
Github gist
training
Built with
blockbuilder.org
<!DOCTYPE html> <head> <meta charset="utf-8"> <script src="https://d3js.org/d3.v4.min.js"></script> <style> body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } rect { fill: none; stroke: black; } .line { fill: none; stroke: steelblue; stroke-width: 1.5px; } </style> </head> <body> <script> // set the dimensions and margins of the graph var margin = {top: 20, right: 20, bottom: 30, left: 50}, width = 960 - margin.left - margin.right, height = 500 - margin.top - margin.bottom; // set the ranges var x = d3.scaleLinear().range([0, width]); var y = d3.scaleLinear().range([height, 0]); var points = [ { x: 10, y: 10 }, { x: 200, y: 200 }, { x: 200, y: 400 }, { x: 300, y: 100 }, { x: 400, y: 150 } ] // define the line var valueline = d3.line() .x(function(d) { return x(d.x); }) .y(function(d) { return y(d.y); }); var svg = d3.select("body").append("svg") .attr("width", width + margin.left + margin.right) .attr("height", height + margin.top + margin.bottom) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); // Get the data d3.data(points); </script> </body>
https://d3js.org/d3.v4.min.js