JSFiddle - React, Tailwind, and code Playground
HTML
<pre id="tsvdata">
x0 y0 x1 y1 x2 y2 weight
0.5 0.5 0.2 0.2 2
0.25 0.35 0.7 0.8 0.7 0.6 1
</pre>
CSS
#tsvdata {
display: none;
}
JavaScript
var raw = d3.select("#tsvdata").text();
var data = d3.tsv.parse(raw);
var width = 500;
var height = 500;
var x = d3.scale.linear().range([0, width]);
var y = d3.scale.linear().range([0, height]);
var svg = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height);
var line = d3.svg.line();
data.forEach(function(d) {
d.points = [];
for (var i = 0; d["x"+i] !== "" && (typeof d["x"+i] !== 'undefined'); i++) {
d.points.push([x(d["x"+i]), y(d["y"+i])]);
}
});
svg.selectAll("path")
.data(data)
.enter()
.append("path");
svg.selectAll("path")
.attr("d", function(d) { return line(d.points); })
.attr("stroke-width", function(d) { return (d.weight); })
.attr("stroke", "black")
.attr("fill", "none");