Lines¶
- detroit.line(x: Accessor[T, float] | None = None, y: Accessor[T, float] | None = None)¶
The line generator produces a spline or polyline as in a line chart. Lines also appear in many other visualization types, such as the links in hierarchical edge bundling.
- class detroit.shape.line.Line(x: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | None = None, y: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | None = None)¶
The line generator produces a spline or polyline as in a line chart. Lines also appear in many other visualization types, such as the links in hierarchical edge bundling.
- Parameters:
- Returns:
New line generator
- Return type:
- __call__(data: Iterable[T]) str | None¶
Generate a line for the given list of data
- Parameters:
data (Iterable[T]) – Data values
- Returns:
Generated line if the line is not associated to a context
- Return type:
str | None
Examples
>>> svg.append("path").attr("d", line(data)).attr("stroke", "currentColor")
- x(x: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Line¶
Sets x accessor function
- y(y: Callable[[T], float] | Callable[[T, int], float] | Callable[[T, int, list[Element]], float] | int | float) Line¶
Sets y accessor function
- set_defined(defined: Callable[[T], bool] | Callable[[T, int], bool] | Callable[[T, int, list[Element]], bool] | int | float) Line¶
Sets defined accessor
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 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), 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.