D3.js arc.outerRadius() Function
The arc.outerRadius() function in d3.js library is used to set the outer radius of the produced arc. It takes a number that defines the outer radius of the arc.
Syntax:
arc.outerRadius([radius]);
Parameters: This function accepts a single parameter as mentioned above and described below.
- radius: This defines the size of the outer radius of the arc.
Return Value: This function does not return anything.
Below given are a few examples of the function given above.
Example 1:
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" />
< meta name = "viewport" content =
"width=device-width, initial-scale=1.0" />
< script src =
</ script >
</ head >
< body >
< div style = "width:300px; height:300px;" >
< center >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
arc.outerRadius()
</ 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()
.innerRadius(85)
// Use of outerRadius Function
.outerRadius(88)
.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" />
</ script >
</ head >
< body >
< div style = "width:300px; height:300px;" >
< center >
< h1 style = "color:green" >
GeeksforGeeks
</ h1 >
< h2 >
arc.outerRadius()
</ 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()
.innerRadius(0)
// Use of outerRadius Function
.outerRadius(65)
.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:
Last Updated :
23 Sep, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...