當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


d3.js queue()用法及代碼示例

d3.queue()函數用於創建指定大小的隊列。如果默認情況下未指定大小,則將其視為無窮大。

用法:

 d3.queue(size);

參數:此函數接受上麵提到並在下麵描述的單個參數:

  • size:如果未指定,則為可選參數,則隊列的大小為無限,否則隊列的大小為給定的數字。大小指定要同時運行的函數數。

返回值:此函數返回對象。

下麵給出了上述函數的一些示例。



範例1:默認情況下,如果未指定隊列的大小,則它的大小是無限的。

HTML

<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport"
            path1tent="width=device-width,  
                       initial-scale=1.0">  
    <title>D3.js queue() Function</title>  
</head>  
<style>  
</style>  
<body>   
  <script src =  
"https://d3js.org/d3.v4.min.js">  
  </script>  
  <script> 
    let q=d3.queue() 
    console.log(q) 
    console.log("Size of q is:",q._size) 
  </script>  
</body>  
</html>

輸出:

範例2:給定隊列的大小。

HTML

<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport"
            path1tent="width=device-width,  
                       initial-scale=1.0">  
    <title>D3.js queue() Function</title>  
</head>  
<style>  
    h1 {  
        color:green;  
    }  
    svg{  
        background-color:#f2f2f2;  
    }  
  .path2{  
        stroke:#000;  
    } 
</style>  
<body>  
  <div>  
    <svg width="100" height="100">  
      <path class="path2">  
    </svg> 
  </div>  
  <script src =  
"https://d3js.org/d3.v4.min.js">  
  </script>  
  <script> 
    let q=d3.queue(10) 
    console.log(q) 
    console.log("Size of q is:",q._size) 
  </script>  
</body>  
</html>

輸出:




相關用法


注:本文由純淨天空篩選整理自tarun007大神的英文原創作品 D3.js queue() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。