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

from functools import partial
from operator import is_not

class line:
    def __init__(self, content="line"):
        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 x(self, x=None):
        """
        Source · If x is specified, sets the x accessor to the specified function or number and
        returns this line generator.
        .. code:: javascript

            const line = d3.line().x((d) => x(d.Date));

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

            line.x() // (d) => x(d.Date)

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

            function x(d) {
              return d[0];
            }

        When a line is generated, the x accessor will be invoked for each defined element in
        the input data array, being passed the element d, the index i, and the array data as
        three arguments.
        The default x accessor assumes that the input data are two-element arrays of numbers.
        If your data are in a different format, or if you wish to transform the data before
        rendering, then you should specify a custom accessor.

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


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

            const line = d3.line().y((d) => y(d.Close));

        When a line is generated, the y accessor will be invoked for each defined element in
        the input data array, being passed the element d, the index i, and the array data as
        three arguments.
        If y is not specified, returns the current y accessor.
        .. code:: javascript

            line.y() // (d) => y(d.Close)

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

            function y(d) {
              return d[1];
            }

        The default y accessor assumes that the input data are two-element arrays of numbers.
        See line.x for more information.

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


    def defined(self, defined=None):
        """
        Examples · Source · If defined is specified, sets the defined accessor to the specified
        function or boolean and returns this line generator.
        .. code:: javascript

            const line = d3.line().defined((d) => !isNaN(d.Close));

        When a line is generated, the defined accessor will be invoked for each element in the
        input data array, being passed the element d, the index i, and the array data as three
        arguments. If the given element is defined (i.e., if the defined accessor returns a
        truthy value for this element), the x and y accessors will subsequently be evaluated
        and the point will be added to the current line segment. Otherwise, the element will be
        skipped, the current line segment will be ended, and a new line segment will be
        generated for the next defined point.
        If defined is not specified, returns the current defined accessor.
        .. code:: javascript

            line.defined() // (d) => !isNaN(d.Close)

        The defined accessor defaults to the constant true, and assumes that the input data is
        always defined:
        .. code:: javascript

            function defined() {
              return true;
            }

        Note that if a line segment consists of only a single point, it may appear invisible
        unless rendered with rounded or square line caps. In addition, some curves such as
        curveCardinalOpen only render a visible segment if it contains multiple points.

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


    def curve(self, curve=None):
        """
        Source · If curve is specified, sets the curve factory and returns this line generator.
        .. code:: javascript

            const line = d3.line().curve(d3.curveStep);

        If curve is not specified, returns the current curve factory, which defaults to
        curveLinear.
        .. code:: javascript

            line.curve() // d3.curveStep


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


    def context(self, context=None):
        """
        Source · If context is specified, sets the context and returns this line generator.
        .. code:: javascript

            const context = canvas.getContext("2d");
            const line = d3.line().context(context);

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

            line.context() // context

        The context defaults to null. If the context is not null, then the generated line is
        rendered to this context as a sequence of path method calls. Otherwise, a path data
        string representing the generated line is returned.

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


    def digits(self, digits=None):
        """
        Source · If digits is specified, sets the maximum number of digits after the decimal
        separator and returns this line generator.
        .. code:: javascript

            const line = d3.line().digits(3);

        If digits is not specified, returns the current maximum fraction digits, which defaults
        to 3.
        .. code:: javascript

            line.digits() // 3

        This option only applies when the associated context is null, as when this line
        generator is used to produce path data.

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

