Skip to content
Related Articles

Related Articles

Improve Article

D3.js | color.opacity

  • Last Updated : 12 Jul, 2019
Geek Week

The color.opacity in D3.js is used to fade the color. The opacity value is in the range of [0, 1].



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:


<!DOCTYPE html>
    <title>color.rgb() function</title>
    <script src=''>
        // Calling the d3.color() function
        // with some parameters
        var color1 = d3.color("red");
        var color2 = d3.color("green");
        var color3 = d3.color("blue");
        // Calling the color.opacity
        var A = color1.opacity;
        var B = color2.opacity;
        var C = color3.opacity;
        // Getting the opacity value




Hey geek! The constant emerging technologies in the world of web development always keeps the excitement for this subject through the roof. But before you tackle the big projects, we suggest you start by learning the basics. Kickstart your web development journey by learning JS concepts with our JavaScript Course. Now at it’s lowest price ever!

My Personal Notes arrow_drop_up
Recommended Articles
Page :