Sunday, November 17, 2024
Google search engine
HomeLanguagesJavascriptD3.js arc.padAngle() Function

D3.js arc.padAngle() Function

The arc.padAngle() function in D3.js library is used to set the padding angle of the arc to the specified number. This function sets the angle between adjacent arcs for some padded arc.

Syntax:

 arc.padAngle([angle]);

Parameters: This function accepts a single parameter as mentioned above and described below.

  • angle: This takes a number that corresponds to the padding angle of the arc.

Return values: This function does not return anything.

Example 1:

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, 
        initial-scale=1.0" />
  
    <!--Fetching from CDN of D3.js -->
    <script src=
        "https://d3js.org/d3.v6.min.js">
    </script>
</head>
  
<body>
    <div style="width:300px; height:300px;">
        <center>
            <h1 style="color:green">
                neveropen
            </h1>
            <h2>
                arc.padAngle()
            </h2>
        </center>
        <svg width="300" height="300">
        </svg>
    </div>
      
    <script>
        var svg = d3.select("svg")
            .append("g")
            .attr("transform", "translate(150, 100)");
  
        // An arc will be produced
        var arc = d3.arc()
            .outerRadius(20)
            .innerRadius(90)
            .startAngle(5)
            // Use of arc.padAngle() Function 
            .padAngle(.5)
            .endAngle(0.5);
  
        svg.append("path")
            .attr("class", "arc")
            .attr("d", arc);
  
        let p = document.querySelector(".arc");
        p.style.fill = "green";
    </script>
</body>
  
</html>


Output:

Example 2:

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content=
        "width=device-width, 
        initial-scale=1.0" />
  
    <!--Fetching from CDN of D3.js -->
    <script src=
        "https://d3js.org/d3.v6.min.js">
    </script>
</head>
  
<body>
    <div style="width:300px; height:300px;">
        <center>
            <h1 style="color:green">
                neveropen
            </h1>
            <h2>
                arc.padAngle()
            </h2>
        </center>
        <svg width="300" height="300">
        </svg>
    </div>
  
    <script>
        var svg = d3.select("svg")
            .append("g")
            .attr("transform", 
                "translate(150, 100)");
  
        // An arc will be produced
        var arc = d3.arc()
            .outerRadius(30)
            .innerRadius(100)
            .startAngle(10)
            // Use of arc.padAngle() Function 
            .padAngle(12)
            .endAngle(12);
  
        svg.append("path")
            .attr("class", "arc")
            .attr("d", arc);
  
        let p = document.querySelector(".arc");
        p.style.fill = "green";
    </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

Recent Comments