d3.linkRadial() método r Es t
Sintaxis:
var link = d3.linkRadial() .angle(function(d) { return d.x; }) .radius(function(d) { return d.y; });
Parámetros: Esta función no toma ningún parámetro.
Valor devuelto: este método devuelve un nuevo generador de enlaces.
Ejemplo:
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src= "https://d3js.org/d3.v5.min.js"> </script> </head> <body> <h1 style="text-align: center; color: green;"> GeeksforGeeks </h1> <h3 style="text-align: center;"> D3.js | linkRadial() Method </h3> <center> <svg id="gfg" width="200" height="200"></svg> </center> <script> var data = [ {source: [100,25], target: [175,175]}, {source: [100,25], target: [25,175]}, {source: [100,25], target: [125,175]}, {source: [100,25], target: [75,175]}, {source: [100,25], target: [225,175]}, {source: [100,25], target: [275,175]}, {source: [100,25], target: [125,175]}]; // Radial link generator var link = d3.linkRadial() .angle(d => xAngleScale(d[0])) .radius(d => yRadiusScale(d[1])); var xAngleScale = d3.scaleLinear().domain([25,175]).range([Math.PI, Math.PI *2 ]); var yRadiusScale = d3.scaleLinear().domain([25,175]).range([0, 80]); //Adding the link paths d3.select("#gfg") .selectAll("path") .data(data) .join("path") .attr("d", link) .classed("link", true) .attr("transform", "translate(100,100)"); </script> </body> </html>
Producción: