# Generated by detroit
# See https://github.com/bourbonut/detroit/tree/main/api_maker

from functools import partial
from operator import is_not

class stack:
    def __init__(self, content="stack"):
        self.content = content

    def __repr__(self):
        return self.content

    def __str__(self):
        return self.content

    def __call__(self, *args):
        arguments = ", ".join(map(repr, args))
        return f"{self}({arguments})"

    def keys(self, keys=None):
        """
        Source · If keys is specified, sets the keys accessor to the specified function or
        array and returns this stack generator.
        .. code:: javascript

            const stack = d3.stack().keys(["apples", "bananas", "cherries", "durians"]);

        If keys is not specified, returns the current keys accessor.
        .. code:: javascript

            stack.keys() // () => ["apples", "bananas", "cherries", "durians"]

        The keys accessor defaults to the empty array. A series (layer) is generated for each
        key. Keys are typically strings, but they may be arbitrary values; see InternMap. The
        series’ key is passed to the value accessor, along with each data point, to compute the
        point’s value.

        See more informations `here <https://d3js.org/d3-shape/stack#stack_keys>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (keys,))))
        return stack(content=f"{self.content}.keys({arguments})")


    def value(self, value=None):
        """
        Source · If value is specified, sets the value accessor to the specified function or
        number and returns this stack generator.
        .. code:: javascript

            const stack = d3.stack().value((d, key) => d[key]);

        If value is not specified, returns the current value accessor.
        .. code:: javascript

            stack.value() // (d, key) => d[key]

        The value accessor defaults to:
        .. code:: javascript

            function value(d, key) {
              return d[key];
            }


        See more informations `here <https://d3js.org/d3-shape/stack#stack_value>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (value,))))
        return stack(content=f"{self.content}.value({arguments})")


    def order(self, order=None):
        """
        Source · If order is specified, sets the order accessor to the specified function or
        array and returns this stack generator.
        .. code:: javascript

            const stack = d3.stack().order(d3.stackOrderNone);

        If order is a function, it is passed the generated series array and must return an
        array of numeric indexes representing the stack order. For example, to use reverse key
        order:
        .. code:: javascript

            const stack = d3.stack().order(series => d3.range(series.length).reverse());

        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.
        If order is not specified, returns the current order accessor.
        .. code:: javascript

            stack.order() // d3.stackOrderNone

        The order accessor defaults to stackOrderNone; this uses the order given by the key
        accessor. See stack orders for the built-in orders.

        See more informations `here <https://d3js.org/d3-shape/stack#stack_order>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (order,))))
        return stack(content=f"{self.content}.order({arguments})")


    def offset(self, offset=None):
        """
        Source · If offset is specified, sets the offset accessor to the specified function and
        returns this stack generator.
        .. code:: javascript

            const stack = d3.stack().offset(d3.stackOffsetExpand);

        The offset function is passed the generated series array and the order index array; it
        is then responsible for updating the lower and upper values in the series array. See
        the built-in offsets for a reference implementation.
        If offset is not specified, returns the current offset acccesor.
        .. code:: javascript

            stack.offset() // d3.stackOffsetExpand

        The offset accessor defaults to stackOffsetNone; this uses a zero baseline. See stack
        offsets for the built-in offsets.

        See more informations `here <https://d3js.org/d3-shape/stack#stack_offset>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (offset,))))
        return stack(content=f"{self.content}.offset({arguments})")

