Areas¶
- detroit.area(x0: Accessor[T, float] | None = None, y0: Accessor[T, float] | None = None, y1: Accessor[T, float] | None = None)¶
The area generator produces an area defined by a topline and a baseline as in an area chart. Typically, the two lines share the same x-values (x0 = x1), differing only in y-value (y0 and y1); most commonly, y0 is defined as a constant representing zero (the y scale’s output for zero). The topline is defined by x1 and y1 and is rendered first; the baseline is defined by x0 and y0 and is rendered second with the points in reverse order. With a curveLinear curve, this produces a clockwise polygon. See also radial areas.
- class detroit.shape.area.Area(x0: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | None = None, y0: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | None = None, y1: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | None = None)¶
The area generator produces an area defined by a topline and a baseline as in an area chart. Typically, the two lines share the same x-values (x0 = x1), differing only in y-value (y0 and y1); most commonly, y0 is defined as a constant representing zero (the y scale’s output for zero). The topline is defined by x1 and y1 and is rendered first; the baseline is defined by x0 and y0 and is rendered second with the points in reverse order. With a curveLinear curve, this produces a clockwise polygon. See also radial areas.
- Parameters:
- Returns:
New area generator
- Return type:
- __call__(data: Iterable[T]) str | None¶
Generates an area for the given array of data.
- Parameters:
data (Iterable[T]) – Data values
- Returns:
Generated area if the area is not associated to a context
- Return type:
str | None
Examples
>>> svg.append("path").attr("d", area(data))
- x(x: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets x0 accessor function and sets x1 accessor function to
None
- x0(x0: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets x0 accessor function
- x1(x1: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets x1 accessor function
- y(y: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets y0 accessor function and sets y1 accessor function to
None
- y0(y0: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets y accessor function
- y1(y1: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Area¶
Sets y accessor function
- area_line() Line¶
Returns a new line generator from the definition of the area.
- Returns:
Line generator based on the area parameters
- Return type:
- line_x0() Line¶
Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y0-accessor.
- Returns:
Line generator based on the area parameters
- Return type:
- line_y0() Line¶
Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y0-accessor.
- Returns:
Line generator based on the area parameters
- Return type:
- line_x1() Line¶
Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x1-accessor, and the line’s y-accessor is this area’s y0-accessor.
- Returns:
Line generator based on the area parameters
- Return type:
- line_y1() Line¶
Returns a new line generator that has this area generator’s current defined accessor, curve and context. The line’s x-accessor is this area’s x0-accessor, and the line’s y-accessor is this area’s y1-accessor.
- Returns:
Line generator based on the area parameters
- Return type:
- set_defined(defined: Callable[[T], bool] | Callable[[T, int], bool] | Callable[[T, int, list[Element]], bool] | int | float) Area¶
Sets defined accessor
When an area is generated, the defined accessor will be invoked for each element in the input data array, being passed the element
d, the indexi, and the arraydataas three arguments. If the given element is defined (i.e., if the defined accessor returns a truthy value for this element), thex0,x1,y0andy1accessors will subsequently be evaluated and the point will be added to the current area segment. Otherwise, the element will be skipped, the current area segment will be ended, and a new area segment will be generated for the next defined point. As a result, the generated area may have several discrete segments.