D3.js | d3.continuous.clamp() Function Last Updated : 31 Jul, 2019 Comments Improve Suggest changes Like Article Like Report The d3.continuous.clamp() function in D3.js is used to enable or disable the clamp. If the clamp is disabled then the range of domain's value might be out of range but if the clamp is enabled then the range of domain's value will always be in range. Syntax: continuous.clamp( Value ) Parameters: This function accept single parameter Value which is either true or false. Return Value: This function does not return any value. Below programs illustrate the d3.continuous.clamp() function in D3.js: Example 1: javascript <!DOCTYPE html> <html> <head> <title> D3.js | d3.continuous.clamp() Function </title> <script src= "https://d3js.org/d3.v4.min.js"> </script> </head> <body> <script> // Calling the .scaleLinear() function var x = d3.scaleLinear() .domain([10, 100]) .range([0, 5]); // Calling the .clamp() function x.clamp(false); // Calling continuous() and .invert() function var A = x(6); var B = x.invert(10); console.log(A); console.log(B); </script> </body> </html> Output: -0.22222222222222224 190 Example 2: javascript <!DOCTYPE html> <html> <head> <title> D3.js | d3.continuous.clamp() Function </title> <script src= "https://d3js.org/d3.v4.min.js"> </script> </head> <body> <script> // Calling the .scaleLinear() function var x = d3.scaleLinear() .domain([10, 100]) .range([0, 5]); // Calling the .clamp() function x.clamp(true); // Calling continuous() and .invert() function var A = x(6); var B = x.invert(10); console.log(A); console.log(B); </script> </body> </html> Output: 0 100 Reference: https://devdocs.io/d3~5/d3-scale#continuous_clamp Comment More infoAdvertise with us Next Article D3.js | d3.continuous.invert() Function K Kanchan_Ray Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js | d3.continuous() Function The d3.continuous() function in D3.js is used to return the corresponding value from the range if a value from the domain is given.Syntax: d3.continuous().domain(array of values).range(array of values); Parameters: This function does not accept any parameters.Return Value: This function returns the 1 min read D3.js continuous.domain() Function The continuous.domain() function is used to set the scale's domain to the specified array of numbers. The array specified here contains two or more than two elements in it. Syntax: continuous.domain([domain]); Parameters: This function accepts a single parameter as mentioned above and described belo 2 min read D3.js | d3.continuous.invert() Function The d3.continuous.invert() function in D3.js is used to return the corresponding value from the domain if a value from the range is given. Syntax: .invert( Value ) Parameters: This function accepts single parameter Value which holds the value of range. Return Value: This function returns the corresp 1 min read D3.js | d3.continuous.invert() Function The d3.continuous.invert() function in D3.js is used to return the corresponding value from the domain if a value from the range is given. Syntax: .invert( Value ) Parameters: This function accepts single parameter Value which holds the value of range. Return Value: This function returns the corresp 1 min read D3.js continuous.copy() Function The continuous.copy() function is used to create and return an exact copy of the given scale. Any change in the original scale will not affect the return scale and vice-versa. Syntax: continuous.copy(); Parameters: This function does not accept any parameters. Return Value: This function returns a c 2 min read D3.js continuous.range() Function The continuous.range() function in d3.js is used to set the range of the scale to the specified array of values that must contain two or more than two values. The elements in the range can be number or string. Syntax: continuous.range([range]); Parameters: This function accepts a single parameter as 2 min read Like