D3.js d3.max() function Last Updated : 10 Oct, 2024 Comments Improve Suggest changes Like Article Like Report The d3.max() function in D3.js is used to return the maximum value in the given array using natural order. If an array is empty then it returns undefined as output. Syntax:d3.max(Array)Parameters:This function accepts parameters Array which is an array of elements whose maximum value is to be calculated. Here elements might be integers or any strings. Return Value:It returns the maximum value. Example 1: This example shows the use of max() function. HTML <html> <head> <title>Getting maximum value</title> </head> <body> <script src='https://d3js.org/d3.v4.min.js'> </script> <script> // initialising the array of elements let Array1 = [10, 20, 30, 40, 50, 60]; let Array2 = [1, 2]; let Array3 = [0, 1.5, 6.8]; let Array4 = [.8, .08, .008]; // Calling to d3.max() function A = d3.max(Array1); B = d3.max(Array2); C = d3.max(Array3); D = d3.max(Array4); // Getting maximum value document.write(A + "<br>"); document.write(B + "<br>"); document.write(C + "<br>"); document.write(D + "<br>"); </script> </body> </html> Output:60 2 6.8 0.8Example 2: This example shows the use of max() function. HTML <html> <head> <title>Getting maximum value</title> </head> <body> <script src='https://d3js.org/d3.v4.min.js'> </script> <script> // initialising the array of elements let Array1 = []; let Array2 = ["a", "b", "c"]; let Array3 = ["A", "B", "C"]; let Array4 = ["Geek", "Geeks", "GeeksforGeeks"]; // Calling to d3.max() function A = d3.max(Array1); B = d3.max(Array2); C = d3.max(Array3); D = d3.max(Array4); // Getting maximum value document.write(A + "<br>"); document.write(B + "<br>"); document.write(C + "<br>"); document.write(D + "<br>"); </script> </body> </html> Output:undefined c C GeeksforGeeks Comment More infoAdvertise with us Next Article D3.js d3.max() function K Kanchan_Ray 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 | d3.sum() function The d3.sum() function in D3.js is used to return the sum of the given array's elements. If the array is empty then it returns 0. Syntax: d3.sum(Array) Parameters: This function accepts a parameters Array which is an array of elements whose sum are to be calculated. Return Value: It returns the sum o 2 min read D3.js | d3.median() function The d3.median() function in D3.js is used to return the median or mid point of the given array's elements. If the array is empty then it returns undefined. Syntax: d3.median(Array) Parameters: This function accepts a parameters Array which is an array of elements whose median are to be calculated. H 2 min read D3.js | d3.scan() function The d3.scan() function is a built-in function in D3.js which scans the array linearly and returns the index of the minimum element according to the specified comparator. The function returns undefined when there are no comparable elements in the array. Syntax: d3.scan(array, comparator) Parameters: 2 min read D3.js | d3.map.set() Function The map.set() function in D3.js used to set the values for the specified key string in to the created map. Syntax: d3.map.set(key, value); Parameters: This function accepts two parameters which are illustrated below: key: This is the key string. value: This is the corresponding value for each key st 2 min read D3.js | d3.timeDay() Function The d3.timeDay() function in D3.js is used to return date in "YYYY-MM-DD" format. Syntax: d3.timeDay(Date); Parameters: This function accepts a parameter "Date". Return Value: This function returns the given date in a specific format. Below programs illustrate the d3.timeDay() function in D3.js: Exa 1 min read D3.js | d3.range() function The d3.range() function in D3.js is used to return an array containing an arithmetic progression starting from the start parameter and iterated over a sequence of uniformly-spaced numeric value called a step and ends with a stop parameter.Syntax:Â Â d3.range(start, stop, step) Parameters: This functi 2 min read D3.js | d3.pairs() function The d3.pairs() function in D3.js is used to create pair of array elements from the given array elements. If the given array is having less than two elements then it returns the empty array. Syntax: d3.pairs(Array) Parameters: This function accepts a parameter Array whose elements are going to be pai 2 min read D3.js | d3.map.size() Function The map.size() function in D3.js is used to return the number of entries in the created map. Syntax: map.size() Parameters: This function does not accept any parameters. Return Value: This function returns the number of entries in the created map. Below programs illustrate the d3.map.size() function 1 min read D3.js | d3.timeYear Function The d3.timeYear function in D3.js is used to return all the years with date in the given range of start and end date. Syntax: d3.timeYear.range(start, end, step); Parameters: This function accept three parameters which are given below: Start: This parameter holds the given start date. end: This para 2 min read Like