D3.js areaRadial.innerRadius() method

The areaRadial.innerRadius() method is used to set or return the innerRadius accessor of the areaRadial. It can be a number or a function that returns a number representing the innerRadius of our areaRadial.

Syntax:

areaRadial.innerRadius(inner_Rad);

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

  • inner_Rad: This parameter holds the innerRadius that can be a number or a function returning the innerRadius.

Return Value: This method returns the innerRadius accessor function of the area radial.

Example 1:



HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
  
    <script src=
        "https://d3js.org/d3.v5.min.js">
    </script>
</head>
  
<body>
    <h1 style="text-align: center; color: green;">
        GeeksforGeeks
    </h1>
  
    <h3 style="text-align: center;">
        D3.js | areaRadial.innerRadius() Method
    </h3>
    <center>
        <svg id="gfg" width="200" height="200">
            <g transform="translate(100, 100)"></g>
        </svg>
    </center>
  
    <script>
        var points = [
                {x: 0, y: 0},
                {x: 2, y: 3},
                {x: 4, y: 1},
                {x: 6, y: 8},
                {x: 8, y: 17},
                {x: 10, y: 15},
                {x: 12, y: 20}];
  
        var xScale = d3.scaleLinear().domain([0, 6])
                           .range([0, 2 * Math.PI]);
        var yScale = d3.scaleLinear()
                   .domain([0, 20]).range([90, 30]);
  
        var Gen = d3.areaRadial()
             .angle(d => xScale(d.x/2))
  
             // Setting innerRadius function
             .innerRadius(d => yScale(d.x/4))
             .outerRadius(d => yScale(d.y));
  
        d3.select("#gfg")
          .select("g")
          .append("path")
          .attr("d", Gen(points))
          .attr("fill", "green")
          .attr("stroke", "black");
    </script>
</body>
  
</html>

chevron_right


Output:

Example 2:

HTML

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
  
    <script src=
        "https://d3js.org/d3.v5.min.js">
    </script>
</head>
  
<body>
    <h1 style="text-align: center; color: green;">
        GeeksforGeeks
    </h1>
  
    <h3 style="text-align: center;">
        D3.js | areaRadial.innerRadius() Method
    </h3>
  
    <center>
        <svg id="gfg" width="500" height="500">
            <g transform="translate(180, 180)"></g>
        </svg>
    </center>
  
    <script>
        var data = [
          {x: 10, y: 1},
          {x: 15, y: 3},
          {x: 20, y: 5},
          {x: 25, y: 7},
          {x: 30, y: 9},
          {x: 35, y: 11},
          {x: 40, y: 13}];
  
        var xScale = d3.scaleLinear()
          .domain([0, 8]).range([25, 200]);
  
        var yScale = d3.scaleLinear()
          .domain([0, 20]).range([200, 25]);
  
        var Gen = d3.areaRadial()
             .angle(d => xScale(d.x))
  
             // Setting innerRadius function
             .innerRadius(d => yScale(d.y / 3))
             .outerRadius(d => yScale(d.y));
  
        d3.select("#gfg")
          .select("g")
          .append("path")
          .attr("d", Gen(data))
          .attr("fill", "green")
          .attr("stroke", "black");
    </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.