JSFiddle - React, Tailwind, and code Playground

by miska knapek

JavaScript

var svgArea = d3.select("body")
                .append("svg")
                .attr("width", 500)
                .attr("height", 500 );


var line_coords = [];

for( var i = 0; i < 30; i++){
    var x = Math.cos( i * (( Math.PI * 2 )/30)  ) * 50;
    var y = Math.sin( i * (( Math.PI * 2 )/30)  ) * 50;
    line_coords[i] = [x, y];
}

console.log( line_coords );

var lineGenerator = d3.svg.line()
    .x( function(d){ return d[0]; })
    .y( function(d){ return d[1]; })
    .interpolate( "basis" );

var line = svgArea.append("path")
            .attr("d", lineGenerator( line_coords ))
            .style("stroke", "orange")
            .style("stroke-width", 5 )
            .style("fill", "none" )
            .attr("transform", "translate( 100, 100)" );