D3.js | color.opacity
Last Updated :
12 Jul, 2019
The color.opacity in D3.js is used to fade the color. The opacity value is in the range of [0, 1].
Syntax:
color.opacity
Parameters: This function does not accept any parameters.
Return Value: This function returns the opacity value of the specified color.
Below program illustrate the color.opacity function in D3.js:
Example:
<!DOCTYPE html>
<html>
<head>
<title>color.rgb() function </title>
</script>
</head>
<body>
<script>
var color1 = d3.color( "red" );
var color2 = d3.color( "green" );
var color3 = d3.color( "blue" );
var A = color1.opacity;
var B = color2.opacity;
var C = color3.opacity;
console.log(A);
console.log(B);
console.log(C);
</script>
</body>
</html>
|
Output:
1
1
1
Ref: https://devdocs.io/d3~5/d3-color#color_opacity
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...