Saturday, February 7, 2026
HomeLanguagesJavascriptD3.js sequential.domain() Function

D3.js sequential.domain() Function

Sequential scales are very similar to continuous scale. On a continuous scale, mapping is done in a continuous way between domain and range. The only difference is that the output range of this scale is fixed by its interpolator and this range cannot be changed.

The sequential.domain() function is used to set the domain of the given sequential scale. The domain array always accepts two numeric values.

Syntax:

sequential.domain([domain]);

Parameters: This function accepts a single parameter as mentioned above and described below:

  • domain: This sets the minimum and maximum domain value for the scale.

Return Values: This function does not return any value.

Example 1:

HTML




<!DOCTYPE html> 
<html lang="en"> 
  
<head> 
    <meta charset="UTF-8" /> 
    <meta name="viewport"
        path1tent="width=device-width, 
        initial-scale=1.0"/> 
  
    <script src=
        "https://d3js.org/d3.v6.min.js">
    </script>
</head> 
  
<body> 
    <h2 style="color:green"> neveropen </h2>
    
    <h4> D3.js | sequential.domain() Function </h4>
    
    <script> 
        var sequential = d3.scaleSequential()
            // Setting domain to [10,20]
            .domain([10,20]);
  
        document.write("<h4>From original scale:</h4>");
  
        document.write("<p>sequential(11): ", 
                    sequential(11) + "</p>");
  
        document.write("<p>sequential(16): ", 
                    sequential(16) + "</p>");
    </script> 
</body>
  
</html>


Output:

Example 2: When a domain is given as string numbers it is parsed to number.

HTML




<!DOCTYPE html> 
<html lang="en"> 
  
<head> 
    <meta charset="UTF-8" /> 
    <meta name="viewport"
        path1tent="width=device-width, 
        initial-scale=1.0"/> 
  
    <script src=
        "https://d3js.org/d3.v6.min.js">
    </script>
</head> 
  
<body> 
    <h2 style="color:green"> neveropen </h2>
    
    <h4> D3.js | sequential.domain() Function </h4>
    
    <script> 
        var sequential = d3.scaleSequential()
            // Setting domain to ["10","100"]
            .domain(["10","100"]);
  
        document.write("<p>sequential(10): ", 
                    sequential(10) + "</p>");
  
        document.write("<p>sequential(100): ", 
                    sequential(100) + "</p>");
    </script> 
</body>
  
</html>


Output:

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

1 COMMENT

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12083 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7241 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS