JSFiddle - React, Tailwind, and code Playground
JavaScript
var svgName;
var mainWidth=300;
data=[
{
"params": [
{
"strokeWeight": 1.3,
"xyData": [
{
"x0": 0.34827403080754826,
"x1": 0.60600737245405589,
"x2": 0.72278004152764297,
"x3": 0.46504669988113501,
"x4": 0.34827403080754826,
"y0": 0.41161457968694481,
"y1": 0.60527707639332184,
"y2": 0.36347025679680034,
"y3": 0.16980776009042353,
"y4": 0.41161457968694481
}
]
},
{
"strokeWeight": 6.3,
"xyData": [
{
"x0": 0.19665357021794935,
"x1": 0.41914132668202908,
"x2": 0.54254880649843318,
"x3": 0.32006105003435364,
"x4": 0.19665357021794935,
"y0": 0.39756094992379476,
"y1": 0.56473968639682104,
"y2": 0.30919384295958852,
"y3": 0.14201510648656224,
"y4": 0.39756094992379476
}
]
}
],
"view": "view0"
}
];
data.forEach(function(qx){
qx.points=[]; //this makes two curves merged into one curve. I want two separate rectangles
qx.params.forEach(function(kv){
aspect=1.5;
// qx.points=[]; //this makes one curve
kv.xyData.forEach(function(d) {
for (var i = 0; d["x"+i] !== "" && (typeof d["x"+i] !== 'undefined'); i++) {
qx.points.push([mainWidth*d["x"+i], mainWidth/aspect*(d["y"+i])]);
}
});
});
});
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width =...