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:
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">                neveropen            </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">                neveropen            </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:Â
Â

