Thursday, February 19, 2026
HomeLanguagesJavascriptD3.js scaleTime time() Function

D3.js scaleTime time() Function

The time() function of d3.scaleTime() is used to return a value from and within the given range from the specified domain.

Syntax:

time(value)

Parameter: This function accepts only one parameter as mentioned above and described below.

  • value: This accepts a value from the specified domain.

Return Value: This function returns a value from the range.

Below example illustrates the scaleTime time() function in D3.js:

Example:

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.v4.min.js">
    </script>
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <h2 style="color:green;">Geeks for neveropen</h2>
  
    <p>d3.scaleTime() | time() Function </p>
      
    <script>
        var time = d3.scaleTime()
            .domain([1, 100])
            .range([1, 100])
        document.write("<h3>The value of time(10): "
                    + time(10) + "</h3>")
        document.write("<h3>The value of time(20): "
                    + time(20) + "</h3>")
        document.write("<h3>The value of time(30): " 
                    + time(30) + "</h3>")
        document.write("<h3>The value of time(40): " 
                    + time(40) + "</h3>")
    </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
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS