Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

D3.js arc.innerRadius() Function

  • Last Updated : 15 Sep, 2021

The arc.innerRadius function in d3.js is used to set the inner radius of the arc. It takes a number that defines the inner radius of the arc.

Syntax:

Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it's lowest price ever!

arc.innerRadius([radius]);

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

  • radius: This defines the size of the inner radius 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=
    </script>
 
</head>
 
<body>
    <div style="width:300px; height:300px;">
        <center>
            <h1 style="color:green">
                GeeksforGeeks
            </h1>
 
            <h2>
                arc.innerRadius()
            </h2>
        </center>
 
        <svg width="300" height="300">
        </svg>
    </div>
 
    <script>
        var svg = d3.select("svg")
            .append("g")
            .attr("transform", "translate(150,100)");
 
        // Arc gernerator function
        var arc = d3.arc()
            .outerRadius(0)
 
            // Use of innerRadius Function
            .innerRadius(60)
            .startAngle(0)
            .endAngle(10);
 
        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=
    </script>
</head>
 
<body>
    <div style="width:300px; height:300px;">
        <center>
            <h1 style="color:green">
                GeeksforGeeks
            </h1>
 
            <h2>
                arc.innerRadius()
            </h2>
        </center>
 
        <svg width="300" height="300">
        </svg>
    </div>
 
    <script>
        var svg = d3.select("svg")
            .append("g")
            .attr("transform", "translate(150,100)");
 
        // Arc generator function
        var arc = d3.arc()
            .outerRadius(10)
 
            // Use of innerRadius Function
            .innerRadius(50)
            .startAngle(0)
            .endAngle(10);
 
        svg.append("path")
            .attr("class", "arc")
            .attr("d", arc);
 
        let p = document.querySelector(".arc");
        p.style.fill="green";
    </script>
</body>
 
</html>

Output: 

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!