D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
harukihill
Full window
Github gist
OLS
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; } .line { fill: none; stroke: steelblue; stroke-width: 2px; } </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); var margin = {top: 20, right: 20, bottom: 20, left: 20}, height = 600 - margin.top - margin.bottom, width = 500 - margin.left - margin.right; var svg = d3.select("body") .append("svg") .attr("height", height) .attr("width", width) .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); d3.csv("OLS.csv", function(error, data){ data.forEach(function(d){ d.index = +d.Index; d.slope = +d.Slope; d.sse = +d.SSE; }); var x = d3.scaleLinear() .domain([0,d3.max(data, function(d){return d.slope;})]) .range([margin.left, width - margin.right]); var y = d3.scaleLinear() .domain([0,d3.max(data, function(d){return d.sse;})]) .range([height - margin.bottom, margin.top]); var valueline = d3.line() .x(function(d) { return x(d.slope);}) .y(function(d) { return y(d.sse);}); svg.append("path") .data([data]) .attr("class", "line") .attr("d", valueline); svg.append("g") .attr("transform", "translate(0," + height + ")") .call(d3.axisBottom(x)); svg.append("g") .call(d3.axisLeft(y)); }); </script> </body>
https://d3js.org/d3.v4.min.js