D3.js threshold.domain() Function Last Updated : 26 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The threshold.domain() function is used to set the domain of the threshold scale. The values given in this must be in non-descending order, if not then the behavior of the scale is undefined. Syntax: threshold.domain([domain]); Parameters: This function accepts a single parameter as given above and described below. domain: This parameter accepts an array of elements in a sorted order which sets the domain of the scale. Return Value: This function does not return any value. Below programs illustrate the threshold.domain() function in D3.js 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> </head> <body> <h2 style="color: green;">GeeksforGeeks</h2> <p>threshold.domain() Function</p> <script> var threshold = d3.scaleThreshold() // Setting domain for the scale. .domain([1, 2, 3, 4]) .range([10, 20, 30, 40, 50]); let val1 = threshold(1); let val2 = threshold(2); let val3 = threshold(4); document.write("<h4>" + val1 + "</h4>"); document.write("<h4>" + val2 + "</h4>"); document.write("<h4>" + val3 + "</h4>"); </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> <h2 style="color: green;">GeeksforGeeks</h2> <p>threshold.domain() Function </p> <script> var threshold = d3.scaleThreshold() // Setting domain for the scale. .domain([1, 2, 3, 4]); document.write("<h4>" + threshold(0) + "</h4>"); document.write("<h4>" + threshold(4) + "</h4>"); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article D3.js threshold.domain() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js density.thresholds() Function The density.thresholds() function is used to set the thresholds of the density estimator function. If the threshold is given then this sets the threshold generator to the specified function or array. If the thresholds are not given then this function returns the default threshold to the contour gene 4 min read D3.js log.domain() Function The log.domain() function is used to set the scaleâs domain to the specified array of numbers. The array specified here must contain two or more than two elements. By default, the domain is [1,10]. Syntax: log.domain([domain]); Parameters: This function accepts single parameter as mentioned above an 2 min read D3.js pow.domain() Function The pow.domain() function is used to set the scaleâs domain to the specified array of numbers. The array specified here must contain two or more than two elements. Syntax: pow.domain([domain]); Parameters: This function takes a single parameter that is given above and described below. [domain]: An a 1 min read D3.js threshold.copy() Function The threshold.copy() function in d3.js is used to create and return the exact copy of the threshold scale. Any change in the original scale will not affect the copy scale. Syntax: threshold.copy(); Parameters: This function does not accept any parameter. Return Value: This function returns an exact 2 min read D3.js scaleThreshold() Function The d3.scaleThreshold() function in D3.js is used to create and return a new threshold scale that has the specified domain and range. The default value of domain is [0.5] and that of range is [0, 1]. Syntax: d3.scaleThreshold( domain, range ) Parameters: This function accepts two parameters as given 2 min read Like