Saturday, November 22, 2025
HomeLanguagesJavascriptD3.js log.copy() Function

D3.js log.copy() Function

The log.copy() function is used to create and return the exact copy of the original scale. This copy is not a reference to the original scale so any change in the original scale will not affect the copy scale.

Syntax:

log.copy()

Parameters: This function does not accept any parameters.

Return Values: This function returns the exact copy of the original scale.

Below given are a few examples of the function given above.

Example 1:




<!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;">
        neveropen
    </h2>
      
    <p>D3.js log.copy() Function</p>
  
    <script>
        var log = d3.scaleLog()
            .domain([1, 20])
            .range([10, 20, 30, 40, 50, 60]);
  
        // Using log.copy() Function
        let logCopy = log.copy();
        document.write("<h3>Original scale: "
                + log(1) + "</h3>");
  
        document.write("<h3>Copy scale: " 
                + logCopy(1) + "</h3>");
    </script>
</body>
  
</html>


Output:

Example 2:




<!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;">
        neveropen
    </h2>
  
    <p>D3.js log.copy() Function</p>
  
    <script>
        var log = d3.scaleLog()
            .domain([1, 20])
            .range([10, 20, 30, 40, 50, 60]);
  
        // Using log.copy() Function
        let logCopy = log.copy();
        document.write("<h3>Original scale: " 
                    + log(15) + "</h3>");
  
        document.write("<h3>Copy scale: " 
                    + logCopy(15) + "</h3>");
                      
        log.interpolate(d3.interpolateRound);
  
        document.write("<p>Changes in original "
            + "scale does not affect copy scale.</p>");
  
        document.write("<h3>Original scale: " 
                        + log(15) + "</h3>");
  
        document.write("<h3>Copy scale: " 
                    + logCopy(15) + "</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

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6784 POSTS0 COMMENTS
Nicole Veronica
11931 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11999 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6863 POSTS0 COMMENTS
Umr Jansen
6848 POSTS0 COMMENTS