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> Â Â Â Â <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:

