Arc generator for creating circular or annular sectors.
Used for pie charts, donut charts, and radial visualizations. The geometry is d3-shape's
arc: pad_angle narrows the sector at pad_radius, and corner_radius rounds its four
corners with tangent arcs.
Examples
arc = Visualize.Shape.Arc.new()
|> Visualize.Shape.Arc.inner_radius(50)
|> Visualize.Shape.Arc.outer_radius(100)
|> Visualize.Shape.Arc.corner_radius(8)
# Generate from angles
path_data = Visualize.Shape.Arc.generate(arc, %{
start_angle: 0,
end_angle: :math.pi() / 2
})
Summary
Functions
The {start, end} angles the arc's accessors give for a datum, for a label fitted to its sector (spec/14 §5.5, #138).
Generates a centroid point for the arc
Sets the corner radius; applied up to half the ring thickness
Sets the end angle accessor
Generates the SVG path data string.
Generates a Path struct
Sets the inner radius
Creates a new arc generator
Sets the outer radius
Sets the pad angle: the sector is narrowed by half of it on each side
Sets the radius at which the pad angle is measured.
The inner and outer radius of the arc for data, {r0, r1} (spec/14 §5.5).
Sets the start angle accessor
Types
Functions
The {start, end} angles the arc's accessors give for a datum, for a label fitted to its sector (spec/14 §5.5, #138).
Generates a centroid point for the arc
Sets the corner radius; applied up to half the ring thickness
Sets the end angle accessor
Generates the SVG path data string.
Note: For backend-agnostic usage, prefer generate_path/2
and render with your chosen backend.
@spec generate_path(t(), map() | any()) :: Visualize.IR.Path.t()
Generates a Path struct
Sets the inner radius
@spec new() :: t()
Creates a new arc generator
Sets the outer radius
Sets the pad angle: the sector is narrowed by half of it on each side
Sets the radius at which the pad angle is measured.
The linear gap the padding opens is pad_radius · pad_angle, kept constant across the
ring, so the angular shift is larger on the inner edge than on the outer. nil (the
default) uses √(r0² + r1²), as d3 does.
The inner and outer radius of the arc for data, {r0, r1} (spec/14 §5.5).
Sets the start angle accessor