D3.js pow.interpolate() Function
The pow.interpolate() function is used to set the range interpolator factory which is used to create the interpolators for each pair of values from the adjacent ranges.
Syntax:
pow.interpolate(interpolate);
Parameters: This function accepts a single parameter as mentioned above and described below.
- interpolator: This parameter accepts an interpolator.
Return Value: This function does not return anything.
Below examples illustrate the pow.interpolate() function in D3.js:
Example: Below given is a example of the function given mentioned above.
<!DOCTYPE html>
< html lang = "en" >
< head >
< meta charset = "UTF-8" />
< meta name = "viewport" path1tent =
"width=device-width,initial-scale=1.0" />
</ script >
< script src =
</ script >
< script src =
</ script >
< script src =
</ script >
</ head >
< body >
< h2 style = "color:green;" >
GeeksforGeeks
</ h2 >
< p >D3.js pow.interpolate() Function</ p >
< script >
var pow = d3.scalePow()
// Domain ranges -10, 0, 10
.domain([-10, 0, 10])
// Range for the domain
.range([10, 20, 30, 40, 50, 60, 70, 80, 90])
// Using interpolateRound
.interpolate(d3.interpolateRound);
document.write("< h3 >pow(1.0): " + pow(1.0) + "</ h3 >");
document.write("< h3 >pow(2.0): " + pow(2.0) + "</ h3 >");
document.write("< h3 >pow(3.5): " + pow(3.5) + "</ h3 >");
document.write("< h3 >pow(4.1): " + pow(4.1) + "</ h3 >");
document.write("< h3 >pow(1.3): " + pow(1.3) + "</ h3 >");
document.write("< h3 >pow(-1.5): " + pow(-2.5) + "</ h3 >");
</ script >
</ body >
</ html >
|
Output:
Last Updated :
31 Aug, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...