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


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


pow.copy() 函數用於創建和返回給定比例的精確副本。原始比例的任何變化都不會影響返回比例,反之亦然。

用法:

pow.copy();

參數:該函數不接受任何參數。

返回值:此函數返回原始比例的精確副本。

範例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.v4.min.js">
    </script>
</head>
  
<body>
    <h2 style="color:green;">GeeksforGeeks</h2>
  
    <p>D3.js pow.copy() Function </p>
  
    <script>
        var pow = d3.scalePow()
            .domain([1, 10])
            .range([10, 20, 30, 40, 50, 60]);
              
        let powCopy = pow.copy();
  
        document.write("<h3>Original scale:" 
                + pow(2.5) + "</h3>");
  
        document.write("<h3>Copy scale:" 
                + powCopy(2.5) + "</h3>");
    </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" />
  
    <script src="https://d3js.org/d3.v4.min.js">
    </script>
</head>
  
<body>
    <h2 style="color:green;">GeeksforGeeks</h2>
  
    <p>pow.copy() Function </p>
  
    <script>
        var pow = d3.scalePow()
            .domain([1, 10])
            .range([10, 20, 30, 40, 50, 60]);
  
        let powCopy = pow.copy();
  
        document.write("<h3>Original scale:" 
                + pow(2.5) + "</h3>");
  
        document.write("<h3>Copy scale:" 
                + powCopy(2.5) + "</h3>");
                  
        pow.exponent(2);
        document.write("<p> Changes in original "
            + "scale does not affect copy scale.</p>");
  
        document.write("<h3>Original scale:"
                    + pow(2.5) + "</h3>");
                      
        document.write("<h3>Copy scale:" 
                    + powCopy(2.5) + "</h3>");
    </script>
</body>
  
</html>

輸出:


相關用法


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