Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptD3.js | d3.continuous() Function

D3.js | d3.continuous() Function

The d3.continuous() function in D3.js  is used to return the corresponding value from the range if a value from the domain is given.
Syntax: 
 

d3.continuous().domain(array of values).range(array of values);

Parameters: This function does not accept any parameters.
Return Value: This function returns the corresponding range value for the domain’s value. 
Below programs illustrate the d3.continuous() function in D3.js:
Example 1: 
 

javascript




<!DOCTYPE html>
<html>
     
<head>
    <title>
        D3.js | d3.continuous() Function
    </title>
     
    <script src =
    </script>
</head>
 
<body>
    <script>
         
        // Calling the scaleLinear() function
        var A = d3.scaleLinear().domain([10, 50])
                .range([0, 100]);
         
        // Getting the corresponding range for
        // the domain value
        console.log(A('15'));
        console.log(A('20'));
        console.log(A('25'));
        console.log(A('30'));
    </script>
</body>
 
</html>


Output: 
 

12.5
25
37.5
50

Example 2: 
 

javascript




<!DOCTYPE html>
<html>
     
<head>
    <title>
        D3.js | d3.continuous() Function
    </title>
     
    <script src =
    </script>
</head>
 
<body>
    <script>
         
        // Calling the scaleLinear() function
        var A = d3.scaleLinear().domain([1, 5])
                .range([0, 10]);
          
        // Getting the corresponding range for
        // the domain value
        console.log(A('1'));
        console.log(A('2'));
        console.log(A('3'));
        console.log(A('4'));
    </script>
</body>
 
</html>


Output: 
 

0
2.5
5
7.5

Reference: https://devdocs.io/d3~5/d3-scale#_continuous
 

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

RELATED ARTICLES

Most Popular

Recent Comments