Generates a stack for the given array of data, returning an array representing each series. The resulting array has one element per series. Each series in then typically passed to an area generator to render an area chart, or used to construct rectangles for a bar chart.
Any additional arguments are arbitrary; they are simply propagated to the generator’s accessor functions along with the this object.
Array of data elements.
Returns the current keys accessor, which defaults to the empty array.
Sets the keys accessor to the specified function or array and returns this stack generator.
A series (layer) is generated for each key. Keys are typically strings, but they may be arbitrary values. The series’ key is passed to the value accessor, along with each data point, to compute the point’s value.
An array of keys.
Sets the keys accessor to the specified function or array and returns this stack generator.
A series (layer) is generated for each key. Keys are typically strings, but they may be arbitrary values. The series’ key is passed to the value accessor, along with each data point, to compute the point’s value.
An accessor function returning the array of keys. The accessor function is invoked with the "this" context of the Stack generator and passed the same arguments passed into the generator.
Returns the current offset acccesor, which defaults to stackOffsetNone; this uses a zero baseline.
Reset the offset to use stackOffsetNone; this uses a zero baseline.
null to set to the default stackOffsetNone.
Sets the offset accessor to the specified function and returns this stack generator.
A function which is passed the generated series array and the order index array. The offset function is then responsible for updating the lower and upper values in the series array to layout the stack.
Returns the current order acccesor, which defaults to stackOrderNone; this uses the order given by the key accessor.
Reset the order to use stackOrderNone; this uses the order given by the key accessor.
null to set to the default stackOrderNone.
Sets the order accessor to the specified array and returns this stack generator.
The stack order is computed prior to the offset; thus, the lower value for all points is zero at the time the order is computed. The index attribute for each series is also not set until after the order is computed.
An array of numeric indexes representing the stack order.
Sets the order accessor to the specified function and returns this stack generator.
The stack order is computed prior to the offset; thus, the lower value for all points is zero at the time the order is computed. The index attribute for each series is also not set until after the order is computed.
See stack orders for the built-in orders.
A function returning a sort order array. It is passed the generated series array and must return an array of numeric indexes representing the stack order.
Returns the current value accessor, which defaults to a function return the property corresponding to the relevant key from the data element.
Thus, by default the stack generator assumes that the input data is an array of objects, with each object exposing named properties with numeric values; see stack for an example.
Sets the value accessor to the specified number and returns this stack generator.
A constant value.
Sets the value accessor to the specified function and returns this stack generator.
A value accessor function which returns the numeric value for a given data element and key combination. The accessor function is invoked for each data element and key being passed the datum, the key, index of the data element in the input data array, and the complete data array.
Generated using TypeDoc
A stack generator.
Some shape types can be stacked, placing one shape adjacent to another. For example, a bar chart of monthly sales might be broken down into a multi-series bar chart by product category, stacking bars vertically. This is equivalent to subdividing a bar chart by an ordinal dimension (such as product category) and applying a color encoding.
Stacked charts can show overall value and per-category value simultaneously; however, it is typically harder to compare across categories, as only the bottom layer of the stack is aligned. So, chose the stack order carefully, and consider a streamgraph. (See also grouped charts.)
Like the pie generator, the stack generator does not produce a shape directly. Instead it computes positions which you can then pass to an area generator or use directly, say to position bars.
The first generic corresponds to the "this" context in which the stack generator and its accessor functions are invoked.
The second generic corresponds to the data type of an element in the data array passed into the stack generator.
The third generic corresponds to the data type of key used to identify a series.