D3.js zip() Function Last Updated : 10 Apr, 2023 Comments Improve Suggest changes Like Article Like Report The zip() function in D3.js is used to form a matrix from an array given as a parameter. It helps to visualize data. D3.js stands for Data-Driven Documents. Syntax: d3.zip(arrays…) Parameters: This function accepts a single parameter as mentioned above and described below: arrays: This parameter holds the series of arrays. Return Value: It returns the array of arrays. Below examples illustrate the zip() function in D3.js: Example 1: HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <!--fetching from CDN of D3.js--> <script type = "text/javascript" src = "https://d3js.org/d3.v4.min.js"> </script> <script> console.log("Making matrix using zip function: ") let m=d3.zip(["aa","ab","ac"], ["ac","ad","ah"],["ae","af","ag"]); console.log("Matrix returned by zip function is: ",m) </script> </body> </html> Output: Example 2: When nothing is given in the parameter an empty array is returned by the zip function. HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <!--fetching from CDN of D3.js --> <script type = "text/javascript" src = "https://d3js.org/d3.v4.min.js"> </script> <script> let m=d3.zip(); console.log("Type of m is: ",typeof(m)) console.log("Matrix returned by zip function is: ",m) </script> </body> </html> Output: Comment More infoAdvertise with us Next Article D3.js zip() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js | d3.min() function The d3.min() function in D3.js is used to returns the minimum value in the given array using natural order. If an array is empty then it returns undefined as output. Syntax: d3.min(Array) Parameters: This function accepts a parameters Array which is an array of elements whose minimum value is to be 2 min read D3.js json() Function The d3.json() function is used to fetch the JSON file. If this function got an init parameter, then this is called along with the fetch operation. Syntax: d3.json(input[, init]); Parameters: This function accepts two parameters as mentioned above and described below. input: This parameter takes the 1 min read Collect.js | zip() Function The zip() function is used to combine the values of given array with the values of original collection at a given index. In JavaScript, the array is first converted to a collection and then the function is applied to the collection. Syntax:Â data.zip(value) Parameters:Â This function accept a single 2 min read D3.js dsv() Function The d3.dsv() function in D3.js is a part of the request API that returns a request for the file of type DSV. The mime type is text/DSV. Syntax:d3.dsv(delimiter, inputfile, function);Parameters: This function accepts three parameters as mentioned above and described below:delimiter: It is the delimit 1 min read D3.js csv() Function The d3.csv() function in D3.js is a part of the request API that returns a request for the file of type CSV at the specified URL. The mime type is text/CSV. Syntax: d3.csv(url[[, row], callback]) Parameters: url: It is the URL of the file that is to be fetched.callback: It is the function that is to 2 min read Like