Generates a pie for the given array of data, returning an array of objects representing each datum’s arc angles. Any additional arguments are arbitrary; they are simply propagated to the pie generator’s accessor functions along with the this object. The length of the returned array is the same as data, and each element i in the returned array corresponds to the element i in the input data.
This representation is designed to work with the arc generator’s default startAngle, endAngle and padAngle accessors. The angular units are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify angles in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
Array of data elements.
Rest
...args: any[]Returns the current end angle accessor, which defaults to a function returning a constant 2*pi.
Returns the current end angle accessor, which defaults to a function returning a constant 2*pi.
Rest
...args: any[]Sets the overall end angle of the pie to the specified number and returns this pie generator.
The default end angle is 2*pi.
The end angle here means the overall end angle of the pie, i.e., the end angle of the last arc. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
The value of the end angle is constrained to startAngle ± τ, such that |endAngle - startAngle| ≤ τ.
A constant angle.
Sets the overall end angle of the pie to the specified function and returns this pie generator.
The default end angle is 2*pi.
The end angle here means the overall end angle of the pie, i.e., the end angle of the last arc. The end angle accessor is invoked once, being passed the same arguments and this context as the pie generator. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
The value of the end angle is constrained to startAngle ± τ, such that |endAngle - startAngle| ≤ τ.
An angle accessor function, which is invoked once, being passed the same arguments and this context as the pie generator.
Rest
...args: any[]Returns the current pad angle accessor, which defaults to a function returning a constant zero.
Returns the current pad angle accessor, which defaults to a function returning a constant zero.
Rest
...args: any[]Sets the pad angle to the specified number and returns this pie generator.
The pad angle here means the angular separation between each adjacent arc. The total amount of padding reserved is the specified angle times the number of elements in the input data array, and at most |endAngle - startAngle|; the remaining space is then divided proportionally by value such that the relative area of each arc is preserved. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians.
A constant angle.
Sets the pad angle to the specified function and returns this pie generator.
The pad angle here means the angular separation between each adjacent arc. The total amount of padding reserved is the specified angle times the number of elements in the input data array, and at most |endAngle - startAngle|; the remaining space is then divided proportionally by value such that the relative area of each arc is preserved. The pad angle accessor is invoked once, being passed the same arguments and this context as the pie generator. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians.
An angle accessor function, which is invoked once, being passed the same arguments and this context as the pie generator.
Rest
...args: any[]Returns the current data comparator, which defaults to null.
Sets the data comparator to the specified function and returns this pie generator.
If both the data comparator and the value comparator are null, then arcs are positioned in the original input order. Otherwise, the data is sorted according to the data comparator, and the resulting order is used. Setting the data comparator implicitly sets the value comparator to null.
Sorting does not affect the order of the generated arc array which is always in the same order as the input data array; it merely affects the computed angles of each arc. The first arc starts at the start angle and the last arc ends at the end angle.
A compare function takes two arguments a and b, each elements from the input data array. If the arc for a should be before the arc for b, then the comparator must return a number less than zero; if the arc for a should be after the arc for b, then the comparator must return a number greater than zero; returning zero means that the relative order of a and b is unspecified.
Sets the data comparator to null and returns this pie generator.
If both the data comparator and the value comparator are null, then arcs are positioned in the original input order.
null, to set the pie generator to use the original input order or use the sortValues comparator, if any.
Returns the current value comparator, which defaults to descending value.
Sets the value comparator to the specified function and returns this pie generator.
If both the data comparator and the value comparator are null, then arcs are positioned in the original input order. Otherwise, the data is sorted according to the data comparator, and the resulting order is used. Setting the value comparator implicitly sets the data comparator to null.
The value comparator is similar to the data comparator, except the two arguments a and b are values derived from the input data array using the value accessor, not the data elements. If the arc for a should be before the arc for b, then the comparator must return a number less than zero; if the arc for a should be after the arc for b, then the comparator must return a number greater than zero; returning zero means that the relative order of a and b is unspecified.
Returns the current start angle accessor, which defaults to a function returning a constant zero.
Returns the current start angle accessor, which defaults to a function returning a constant zero.
Rest
...args: any[]Sets the overall start angle of the pie to the specified number and returns this pie generator.
The default start angle is zero.
The start angle here means the overall start angle of the pie, i.e., the start angle of the first arc. The start angle accessor is invoked once, being passed the same arguments and this context as the pie generator. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
A constant angle.
Sets the overall start angle of the pie to the specified function and returns this pie generator.
The default start angle is zero.
The start angle here means the overall start angle of the pie, i.e., the start angle of the first arc. The start angle accessor is invoked once, being passed the same arguments and this context as the pie generator. The units of angle are arbitrary, but if you plan to use the pie generator in conjunction with an arc generator, you should specify an angle in radians, with 0 at -y (12 o’clock) and positive angles proceeding clockwise.
An angle accessor function, which is invoked once, being passed the same arguments and this context as the pie generator.
Rest
...args: any[]Returns the current value accessor, which defaults to a function returning the first argument passed into it. The default value accessor assumes that the input data are numbers, or that they are coercible to numbers using valueOf.
Returns the current value accessor, which defaults to a function returning the first argument passed into it. The default value accessor assumes that the input data are numbers, or that they are coercible to numbers using valueOf.
Sets the value accessor to use the specified constant number and returns this pie generator.
Constant value to be used.
Sets the value accessor to use the specified function and returns this pie generator.
When a pie is generated, the value accessor will be invoked for each element in the input data array. The default value accessor assumes that the input data are numbers, or that they are coercible to numbers using valueOf. If your data are not simply numbers, then you should specify an accessor that returns the corresponding numeric value for a given datum.
A value accessor function, which is invoked for each element in the input data array, being passed the element d, the index i, and the array data as three arguments. It returns a numeric value.
The pie generator does not produce a shape directly, but instead computes the necessary angles to represent a tabular dataset as a pie or donut chart; these angles can then be passed to an arc generator.
The first generic corresponds to the type of the "this" context within which the pie generator and its accessor functions will be invoked.
The second generic refers to the data type of an element in the input array passed into the Pie generator.