D3.js bisector() Function Last Updated : 29 Jul, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The bisector() Function in D3.js is used to returns a new bisector using the specified accessor or comparator function. This method can be used to bisect arrays of objects instead of being limited to simple arrays of primitives. Syntax: d3.bisector(accessor) d3.bisector(comparator) Parameters: This function accepts only one parameter which is mentioned above and described below: accessor/comparator: This parameter is the can be accessor or comparator function. Return value: This function returns the new bisector. Below given are a few examples of the above function. Example 1: This program illustrates the use of d3.bisector() using the accessor parameters. html <!DOCTYPE html> <html> <head> <title>D3.js d3.bisector() Function</title> <script src='https://d3js.org/d3.v4.min.js'> </script> </head> <body> <script> var data = [ {date: new Date(2011, 1, 1), value: 0.5}, {date: new Date(2012, 2, 1), value: 0.6}, {date: new Date(2013, 3, 1), value: 0.7}, {date: new Date(2014, 4, 1), value: 0.8} ]; var bisectDate = d3.bisector(function(d) { return d.date; }).left; var dat = new Date(2014, 4, 1); document.write(bisectDate(data, dat)); </script> </body> </html> Output: 3 Example 2: This program illustrates the use of d3.bisector() using the comparator function parameters. html <!DOCTYPE html> <html> <head> <title>D3.js d3.bisector() Function</title> <script src='https://d3js.org/d3.v4.min.js'> </script> </head> <body> <script> var data = [ {date: new Date(2011, 1, 1), value: 0.5}, {date: new Date(2012, 2, 1), value: 0.6}, {date: new Date(2013, 3, 1), value: 0.7}, {date: new Date(2014, 4, 1), value: 0.8} ]; var bisectDate = d3.bisector(function(d, x) { return d.date - x; }).right; var dat = new Date(2014, 4, 1); document.write(bisectDate(data, dat)); </script> </body> </html> Output: 4 Comment More infoAdvertise with us Next Article D3.js d3.cross() function S SHUBHAMSINGH10 Follow Improve Article Tags : JavaScript Web Technologies D3.js D3.js Array Similar Reads D3.js | d3.bisectRight() Function The bisectRight() function is a built-in function in D3.js which accepts a value as one of its parameters and returns the index to insert the element in an array passed as another parameter to maintain a sorted order in a specified range or in the whole array. The function considers the whole array 3 min read D3.js brushSelection() Function The d3.brushSelection() function in D3.js is used to get the brush selection for a given node. Syntax: d3.brushSelection(this); Parameters: this: used to get the bounds for the current brush. Return Value: This function returns the array containing the bounds of the brush element. Example: In this e 2 min read D3.js arc() Function The d3.arc() function is used to generate an arc generator that produce a circular chart. It is based on the difference between the start angle and the end angle. Syntax: d3.arc(); Parameters: This function does not accept any parameters. Return Values: This function returns an arc generator functio 2 min read D3.js clientPoint() Function The d3.clientPoint() is used to return the x coordinate and y coordinate of the particular event attached to a particular container or HTML tag. Syntax: d3.clientPoint(container, event); Parameters: This function accepts two parameters as mentioned above and described below. container: The container 2 min read D3.js d3.cross() function The d3.cross() function in D3.js is used to return the cartesian product of the given two arrays A and B. Syntax:d3.cross(Array1, Array2)Parameters:This function accepts two parameters which are mentioned above and described below: Array1: This is the first array whose elements are going to be perfo 2 min read D3.js arc.centroid() Function The arc.centroid() function is used to compute the midpoint of the centerline of the arc. The midpoint that is generated is calculated using (startAngle+endAngle)/2 and (innerRadius+outerRadius)/2. Syntax: arc.centroid(arguments); Parameters: This function accepts a single parameter as mentioned abo 1 min read Like