D3.js arc.padRadius() Function

The d3.padRadius() function is used to set the pad radius in the arc. If pad radius is provided then it sets the pad radius to the specified function or number and returns this arc generator.

If radius is not provided then it returns the current pad radius accessor, which is by defaults to null, that indicates the pad radius auto computed as sqrt(innerRadius * innerRadius + outerRadius * outerRadius). The pad radius compute the fixed linear distance separating adjacent arcs, defined as padRadius * padAngle.

Syntax: 

arc.padRadius([radius])

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

  • radius: The value of pad radius.

Return : It returns an arc with specified pad radius.



Example 1:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html lang="en"
  
<head
    <meta charset="UTF-8" /> 
    <meta name="viewport"
        content="width=device-width, 
                initial-scale=1.0"/> 
  
  
    <script src
        "https://d3js.org/d3.v6.min.js"
    </script
</head
  
<body
    <div style="width:300px; height:300px;"
        <center
            
    
            <h2 style="color:black"
                d3.arcpad() 
            </h2>  
    
        </center>
          
        <svg width="200" height="200"
        </svg
    </div
  
    <script
        var svg = d3.select("svg") 
            .append("g") 
            .attr("transform", "translate(150,50)"); 
  
        // pading radious =10
        var arcpad = d3.arc() 
            .innerRadius(48) 
            .outerRadius(50)
            .padRadius(10)
            .startAngle(90) 
            .endAngle(2 * 180); 
  
        svg.append("path") 
            .attr("class", "arc") 
            .attr("d", arcpad) 
            .attr("fill","red"); 
    </script
</body
  
</html>

chevron_right


Output :

Example 2:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html> 
<html lang="en"
  
<head
    <meta charset="UTF-8" /> 
    <meta name="viewport"
        content="width=device-width, 
                initial-scale=1.0"/> 
  
  
    <script src
        "https://d3js.org/d3.v6.min.js"
    </script
</head
  
<body
    <div style="width:300px; height:300px;"
        <center
            
    
            <h2 style="color:black"
                d3.arcpad() 
            </h2>  
    
        </center>
          
        <svg width="200" height="200"
        </svg
    </div
  
    <script
        var svg = d3.select("svg") 
            .append("g") 
            .attr("transform", "translate(150,50)"); 
  
        // pading radious =5
        var arcpad = d3.arc() 
            .innerRadius(48) 
            .outerRadius(50)
            .padRadius(5)
            .startAngle(10) 
            .endAngle(5); 
  
        svg.append("path") 
            .attr("class", "arc") 
            .attr("d", arcpad) 
            .attr("fill","red"); 
    </script
</body
  
</html>

chevron_right


Output :

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.