View Source Contex.SimplePie (ContEx v0.5.0)
Generates a simple pie chart from an array of tuples like {"Cat", 10.0}
.
Usage:
SimplePie.new([{"Cat", 10.0}, {"Dog", 20.0}, {"Hamster", 5.0}])
|> SimplePie.colours(["aa0000", "00aa00", "0000aa"]) # Optional - only if you don't like the defaults
|> SimplePie.draw() # Emits svg pie chart
The colours are using default from Contex.CategoryColourScale.new/1
by names in tuples.
The size defaults to 50 pixels high and wide. You can override by updating
:height
directly in the SimplePie
struct before call draw/1
.
The height and width of pie chart is always same, therefore set only height is enough.
Link to this section Summary
Functions
Update the colour palette used for the slices.
Renders the SimplePie to svg, including the svg wrapper, as a string or improper string list that is marked safe.
Create a new SimplePie struct from list of tuples.
Link to this section Types
Link to this section Functions
@spec colours(t(), Contex.CategoryColourScale.colour_palette()) :: t()
Update the colour palette used for the slices.
Renders the SimplePie to svg, including the svg wrapper, as a string or improper string list that is marked safe.
Create a new SimplePie struct from list of tuples.