HomeLanguagesJavascriptD3.js namespace() Function

D3.js namespace() Function

The d3.namespace() function is used to return an object that contains space and local attributes that describe the full namespace URL and the local name. If there is a colon in the name than the string on the left side of the colon is a namespace prefix.

Syntax:

d3.namespace(name);

Parameters: This function contains only one parameter that is given above and described below.

  • name: This is a string that contains a prefix that must be registered in d3.namespaces.

Return Value: This function returns an object.

Example 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>
  
    <style>
        h2 {
            color: green;
        }
    </style>
</head>
  
<body>
    <h2>Geeks for neveropen</h2>
    <script>
        console.log(d3.namespace("svg:Geeksforneveropen"));
        document.write("<h3>Space: ", 
            d3.namespace("svg:Geeksforneveropen").space, "</h3>");
        document.write("<h3>Local: ", 
            d3.namespace("svg:Geeksforneveropen").local + "</h3>");
    </script>
</body>
  
</html>


Output:

Example 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>
    <script>
        console.log(d3.namespace("xhtml:Geeksforneveropen"));
        console.log(d3.namespace("xlink:Geeksforneveropen"));
        console.log(d3.namespace("xml:Geeksforneveropen"));
    </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
32543 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6921 POSTS0 COMMENTS
Nicole Veronica
12036 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12143 POSTS0 COMMENTS
Shaida Kate Naidoo
7055 POSTS0 COMMENTS
Ted Musemwa
7293 POSTS0 COMMENTS
Thapelo Manthata
7014 POSTS0 COMMENTS
Umr Jansen
7000 POSTS0 COMMENTS