D3.js scaleLog() Function Last Updated : 23 Aug, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The d3.scaleLog() function is used to create a new continuous scale with the user-defined domain and range, the default base is 10. clamping is disabled by default in this scale. Syntax: d3.scaleLog([[domain, ]range]) Parameters: This function accepts two parameters as mentioned above and described below. domain: This parameter always accepts two or more than two numbers. Default value is [1, 10].range: This parameter accepts a number or a string array. It's default value is [0, 1]. Return Value: This function returns the newly created continuous scale. Below given are a few examples of the function given above. 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> <script> var log = d3.scaleLog() .domain([1, 10]) .range([10, 20, 30, 40, 50, 60]); console.log(log(1)); console.log(log(2)); console.log(log(3)); console.log(log(4)); </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> var log = d3.scaleLog() .domain([-1, 1]) .range([10, 20, 30, 40, 50, 60]); // Returns NaN as Domain cant be less than one console.log("Domain in log scale cannot" + " be less than one : ", log(1)); var log = d3.scaleLog() .domain([10, 100]) .range(["red", "green", "blue", "white"]); console.log("log(1): ", log(1)); console.log("log(1.5): ", log(1.5)); </script> </body> </html> Output: Comment More infoAdvertise with us Next Article D3.js scalePow() Function T tarun007 Follow Improve Article Tags : JavaScript Web Technologies D3.js Similar Reads D3.js scalePow() Function The d3.scalePow() function is used to create and return a new continuous scale. This scale has a specified domain and range. Generally, it acts as a linear scale but when used with exponent it works in a different way. Syntax: d3.scalePow([[domain, ]range]); Parameters: This function accepts two par 2 min read D3.js scalePoint() Function The d3.scalepoint() function is used to create and return a new point scale with a particular domain and range, no rounding, no padding, and center alignment. Syntax: d3.scalePoint([[domain, ]range]); Parameters: This function takes two parameters as given above and described below: domain: It defin 2 min read D3.js scaleTime() Function The d3.scaleTime() function is used to create and return a new time scale which have the particular domain and range. In this function the clamping is disabled by default. Syntax: d3.scaleTime([[domain, ]range]); Parameter: This function accepts two parameters as mentioned above and described below. 2 min read D3.js zoom.scaleTo() Function The zoom.scaleTo() function in D3.js is used to scale the current zoon transform of the selected elements to k.Syntax:zoom.scaleTo(selection, k[, p])Parameters: This function accept two parameter as mentioned above and described belowselection: This parameter can be selection or transition.k: This p 2 min read D3.js zoom.scaleBy() Function The zoom.scaleBy() Function in D3.js is used to scale the current zoom transform of the selected elements by k. The reference point p does move.Syntax:zoom.scaleBy(selection, k[, p])Parameters: This function accepts three parameters as mentioned above and described below:selection: This parameter ca 2 min read D3.js scaleOrdinal() Function The d3.scaleOrdinal() function is used to create and return the ordinal scale which has the specified range and domain. If the domain and range are not given then both are set to empty array. These types of scales have a discrete domain and range. Syntax: d3.scaleOrdinal([[domain, ]range]); Paramete 2 min read Like