The d3.interpolateViridis() function in D3.js is used to return a particular color from the “viridis” sequential color scheme which is returned as an RGB string.
Syntax:
d3.interpolateViridis(t)
Parameters: This function accepts a single parameter as mentioned above and described below:
- t: “t” is a number in a range [0, 1]
Return Values: It returns an RGB string.
Below given are a few examples of the function given above.
Example1:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" path1tent="width=device-width, initial-scale=1.0"/> <title>D3.js interpolateViridis() Function</title> </head> <body> <center> <h1 style="color:green;">GeeksForGeeks</h1> <h3>D3.js interpolateViridis() Function</h3> <script> document.write(d3.interpolateViridis(0)+"<br>"); document.write(d3.interpolateViridis(0.1)+"<br>"); document.write(d3.interpolateViridis(0.2)+"<br>"); document.write(d3.interpolateViridis(0.3)+"<br>"); document.write(d3.interpolateViridis(0.4)+"<br>"); document.write(d3.interpolateViridis(0.5)+"<br>"); document.write(d3.interpolateViridis(0.6)+"<br>"); document.write(d3.interpolateViridis(0.7)+"<br>"); document.write(d3.interpolateViridis(0.8)+"<br>"); document.write(d3.interpolateViridis(0.9)+"<br>"); document.write(d3.interpolateViridis(1)); </script> </center> </body> </html> |
[tabbyending
