D3.js中的d3.utcMinute函数用于以分钟为单位返回所有时间,其中日期在协调世界时(UTC)的给定开始和结束时间范围内。
用法:
d3.utcMinute.range( start, end, step );
参数:该函数接受以下三个参数:
- Start:此参数保存给定的开始时间。
 - end:此参数保存给定的结束时间。
 - step:它是可选参数,其中包含用于跳过分钟的值。
 
返回值:此函数返回给定范围内所有可能的分钟。
以下程序说明了D3.js中的d3.utcMinute函数:
示例1:
<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        D3.js | d3.utcMinute Function 
    </title> 
      
    <script src =  
        "https://d3js.org/d3.v4.min.js"> 
    </script> 
</head> 
  
<body> 
    <script> 
          
        // Initialising start and end time 
        var start = new Date(2015, 07, 01, 4, 10); 
        var end = new Date(2015, 07, 01, 4, 15); 
          
        // Calling the utcMinute function 
        // without step value 
        var a = d3.utcMinute.range(start, end); 
          
        // Getting the minute values 
        console.log(a); 
    </script> 
</body> 
  
</html>    输出:
["2015-07-31T22:40:00.000Z", "2015-07-31T22:41:00.000Z", "2015-07-31T22:42:00.000Z", "2015-07-31T22:43:00.000Z", "2015-07-31T22:44:00.000Z"]
示例2:
<!DOCTYPE html> 
<html> 
  
<head> 
    <title> 
        D3.js | d3.utcMinute Function 
    </title> 
      
    <script src =  
        "https://d3js.org/d3.v4.min.js"> 
    </script> 
</head> 
  
<body> 
    <script> 
          
        // Initialising start and end time 
        var start = new Date(2015, 07, 01, 4, 10); 
        var end = new Date(2015, 07, 01, 4, 15); 
            
        // Calling the utcMinute function 
        // with step value 
        var a = d3.utcMinute.range(start, end, 2); 
            
        // Getting the minute values 
        console.log(a); 
    </script> 
</body> 
  
</html>输出:
["2015-07-31T22:40:00.000Z", "2015-07-31T22:42:00.000Z", "2015-07-31T22:44:00.000Z"]
参考: https://devdocs.io/d3~5/d3-time#timeMinute
相关用法
- p5.js cos()用法及代码示例
 - d3.js d3.hsl()用法及代码示例
 - p5.js log()用法及代码示例
 - p5.js tan()用法及代码示例
 - PHP pos()用法及代码示例
 - d3.js d3.sum()用法及代码示例
 - PHP key()用法及代码示例
 - p5.js sin()用法及代码示例
 - p5.js second()用法及代码示例
 - PHP Ds\Map put()用法及代码示例
 - PHP each()用法及代码示例
 - PHP each()用法及代码示例
 
注:本文由纯净天空筛选整理自Kanchan_Ray大神的英文原创作品 D3.js | d3.utcMinute Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
