Thursday, October 16, 2025
HomeLanguagesJavascriptD3.js lineRadial.angle() Method

D3.js lineRadial.angle() Method

The d3.lineRadial.angle() method is a radial line accessor method. It sets or returns the angle accessor. If the angle is provided, it must be a number or a function that returns a number representing an angle in radians.

Syntax:

d3.lineRadial.angle( angle );

Parameters:

  • angle: This method takes an angle that can be a number or a function returning the angle.

Return Value: This method returns the angle accessor of the Radial line.

Example 1: Setting the angle using this method. For setting radius, we have used lineRadial.radius() method.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="utf-8">
    <script src=
    </script>
    <script src=
        "https://d3js.org/d3.v4.min.js">
    </script>
</head>
  
<body>
    <h1 style="text-align:center; color:green;">
        neveropen
    </h1>
      
    <center>
        <svg id="gfg" width="200" height="200">
            <g transform="translate(100,100)"></g>
        </svg>
    </center>
  
    <script>
        var lineRadialGenerator = d3.lineRadial();
        var data = [
            { angle: 0, radius: 10 },
            { angle: 3.14 * .5, radius: 35 },
            { angle: 3.14 * .75, radius: 55 },
            { angle: 3.14, radius: 60 },
            { angle: 3.14 * 1.25, radius: 65 },
            { angle: 3.14 * 1.5, radius: 70 },
            { angle: 3.14 * 1.75, radius: 75 },
            { angle: 3.14 * 2, radius: 80 },
            { angle: 3.14 * 2.25, radius: 85 },
            { angle: 3.14 * 2.5, radius: 90 },
            { angle: 3.14 * 2.75, radius: 95 },
            { angle: 3.14 * 3, radius: 100 },
            { angle: 3.14 * 3.25, radius: 105 },
            { angle: 3.14 * 3.5, radius: 110 }
        ];
  
        var lineRadialGenerator = d3.lineRadial()
            .angle((d) => d.angle)
            .radius((d) => d.radius);
  
        d3.select("#gfg")
            .select("g")
            .append("path")
            .attr("d", lineRadialGenerator(data))
            .attr("fill", "none")
            .attr("stroke", "green");
    </script>
</body>
  
</html>


Output:

Example 2: Getting the function for the angle.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="utf-8">
    <script src=
    </script>
    <script src=
        "https://d3js.org/d3.v4.min.js">
    </script>
</head>
  
<body>
    <h1 style="text-align:center; color:green;">
        neveropen
    </h1>
      
    <center>
        <svg id="gfg" width="200" height="200">
            <g transform="translate(100,100)"></g>
        </svg>
    </center>
  
    <script>
        var lineRadialGenerator = d3.lineRadial();
        var data = [
            { angle: 0, radius: 10 },
            { angle: 3.14 * .5, radius: 35 },
            { angle: 3.14 * .75, radius: 55 },
            { angle: 3.14, radius: 60 },
            { angle: 3.14 * 1.25, radius: 65 },
            { angle: 3.14 * 1.5, radius: 70 },
            { angle: 3.14 * 1.75, radius: 75 },
            { angle: 3.14 * 2, radius: 80 },
            { angle: 3.14 * 2.25, radius: 85 },
            { angle: 3.14 * 2.5, radius: 90 },
            { angle: 3.14 * 2.75, radius: 95 },
            { angle: 3.14 * 3, radius: 100 },
            { angle: 3.14 * 3.25, radius: 105 },
            { angle: 3.14 * 3.5, radius: 110 }
        ];
  
        var lineRadialGenerator = d3.lineRadial()
            .angle((d) => d.angle)
            .radius((d) => d.radius);
  
        d3.select("#gfg")
            .select("g")
            .append("path")
            .attr("d", lineRadialGenerator(data))
            .attr("fill", "none")
            .attr("stroke", "green");
  
        console.log(lineRadialGenerator.angle());
        console.log(lineRadialGenerator.angle);
    </script>
</body>
  
</html>


Output:

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS