Draws a ring split into the share of each part, in the order of data, clockwise
from the top and 2 pixels apart, each in the colour of its language, from language_colors(),
or in the colours given, with the total in the middle; and beside it a legend of the colour,
the name and the share of each part, in the same order. The ring is 54 pixels in radius, or a
little smaller and thinner when the names of the legend need the room. Each part has its name,
value and share as a tooltip, where the SVG itself is shown, not a PNG of it.
Arguments
- data
A data frame of
labelandvalue: for languages, the largest first and"Other"last.- x, w
Where the chart starts, and its width, in pixels.
- col
The colours of the card, from
card_colors().- unit
The unit of the values, for one and for several, for the tooltips.
- fill
The colour of each part, or
NULLfor the colours of the languages.- fmt
A function that writes the values, such as
fmt_bytes(), orNULLfor counts.
Examples
data <- data.frame(label = c("R", "Python", "TeX", "Other"), value = c(1781, 267, 155, 276))
svg <- rghcard:::ring_svg(data, 24, 260, rghcard:::card_colors("dark"), c("commit", "commits"))
cat(substr(svg, 1, 300))
#> <path d="M231.00,264.01 A54.00,54.00 0 1 1 177.26,329.62 L193.94,326.27 A37.00,37.00 0 1 0 231.00,281.01 Z" fill="#198CE7"><title>R: 1,781 commits (71.8%)</title></path>
#> <path d="M176.87,327.66 A54.00,54.00 0 0 1 181.61,294.03 L196.71,301.86 A37.00,37.00 0 0 0 193.54,324.31 Z" fill="#3572A5"><title>