Pie layout generator that computes angles for pie and donut charts.
This doesn't generate paths directly - it computes start and end angles that can be passed to the Arc generator.
Examples
data = [
%{name: "A", value: 30},
%{name: "B", value: 50},
%{name: "C", value: 20}
]
pie = Visualize.Shape.Pie.new()
|> Visualize.Shape.Pie.value(fn d -> d.value end)
arcs = Visualize.Shape.Pie.generate(pie, data)
# Returns list of maps with :data, :value, :index, :start_angle, :end_angle, :pad_angle
Summary
Functions
Sets the end angle (in radians)
Generates arc data from the input data.
Creates a new pie generator
Sets the pad angle between arcs (in radians)
Sets a comparator to sort the data before computing angles.
Sets a comparator to sort by computed values.
Sets the start angle (in radians)
Sets the value accessor
Types
Functions
Sets the end angle (in radians)
@spec generate(t(), Visualize.Data.Table.source()) :: [arc_data()]
Generates arc data from the input data.
Returns a list of maps, each containing:
:data- the original data element:value- the computed value:index- the original index:start_angle- start angle in radians:end_angle- end angle in radians:pad_angle- padding angle in radians
@spec new() :: t()
Creates a new pie generator
Sets the pad angle between arcs (in radians)
@spec sort(t(), comparator() | nil) :: t()
Sets a comparator to sort the data before computing angles.
Takes a function that receives two data elements and returns true if the first should come before the second.
@spec sort_values(t(), comparator() | nil) :: t()
Sets a comparator to sort by computed values.
Takes a function that receives two values and returns true if the first should come before the second.
Sets the start angle (in radians)
Sets the value accessor