D3.js | d3.lab() Function
The d3.lab() function in D3.js is used to construct a new Lab color and returns ‘l’, ‘a’ and ‘b’ properties of the specified color taken as the parameter of the function.
Syntax:
d3.lab(color);
Parameters: This function accepts single parameter color which is specified CSS color.
Return Value: This function returns ‘l’, ‘a’ and ‘b’ properties of the specified CSS color taken as the parameter of the function.
Below programs illustrate the d3.lab() function in D3.js:
Example 1:
<!DOCTYPE html> <html> <head> <title>d3.lab() function</title> </head> <body> <script> // Calling the d3.lab() function fuction // with some parameters var color1 = d3.lab("red"); var color2 = d3.lab("green"); var color3 = d3.lab("blue"); // Getting the LAB properties console.log(color1); console.log(color2); console.log(color3); </script> </body> </html> |
Output:
{"l":53.24079414130722, "a":80.09245959641109, "b":67.20319651585301, "opacity":1}
{"l":46.22743146876261, "a":-51.69849552989111, "b":49.8968460010561, "opacity":1}
{"l":32.297010932850725, "a":79.18751984512224, "b":-107.8601617541481, "opacity":1}
Example 2:
<!DOCTYPE html> <html> <head> <title>d3.lab() function</title> </head> <body> <script> // Calling the d3.lab() function fuction // without any parameters var color = d3.lab(); // Getting the LAB values console.log(color); </script> </body> </html> |
Output:
{"l":null, "a":null, "b":null, "opacity":1}
Reference: https://devdocs.io/d3~5/d3-color#lab
Recommended Posts:
- How to call a function that return another function in JavaScript ?
- How to get the function name from within that function using JavaScript ?
- D3.js | d3.set.has() Function
- D3.js | d3.map.set() Function
- PHP | max( ) Function
- p5.js | nf() Function
- p5.js | nfc() function
- PHP | Ds\Set contains() Function
- CSS | rgb() Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
- D3.js | d3.min() function
- p5.js | box() Function
- PHP | next() Function
- PHP | pos() Function
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.



