D3.js log.clamp() Function
Last Updated :
23 Aug, 2020
The log.clamp() function is used to enable the clamp or disable the clamp. If the clamp is disabled then the range of the return value may be outside the given range through extrapolation.
Syntax:
log.clamp(clamp);
Parameters: This function accepts single parameter as mentioned above and described below.
Return Value: This function does not return any value.
Example 1: When the clamp is false.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" />
< meta name = "viewport" path1tent =
"width=device-width, initial-scale=1.0" />
</ script >
</ head >
< body >
< h2 style = "color:green;" >GeekforGeeks</ h2 >
< p >log.clamp() Function</ p >
< script >
// Calling the .scaleLog() function
var log = d3.scaleLog()
.domain([1, 100])
.range([0, 960])
.clamp(false);
// Calling log() and .invert() function
var a = log(10);
var b = log.invert(1000);
document.write("< h3 >" + a + "</ h3 >");
document.write("< h3 >" + b + "</ h3 >");
</ script >
</ body >
</ html >
|
Output:
Example 2: When the clamp is true.
HTML
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" />
< meta name = "viewport" path1tent =
"width=device-width, initial-scale=1.0" />
</ script >
</ head >
< body >
< h2 style = "color:green" >GeekforGeeks</ h2 >
< p >log.clamp() Function</ p >
< script >
// Calling the .scaleLog() function
var log = d3.scaleLog()
.domain([1, 100])
.range([0, 960])
.clamp(true);
// Calling log() and .invert() function
var a = log(10);
var b = log.invert(1000);
document.write("< h3 >" + a + "</ h3 >");
document.write("< h3 >" + b + "</ h3 >");
</ script >
</ body >
</ html >
|
Output:
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...