Pie Visualization

n_pie(
  data,
  id = NULL,
  value = NULL,
  label = NULL,
  render = c("svg", "canvas"),
  ...,
  width = NULL,
  height = NULL,
  elementId = NULL
)

Arguments

data

a data.frame contains value for create the pie

id

the name of the column used to represent the group.

value

column names for value.

label

column names for label. If not provided, id is used as the label by default.

render

"svg" (responsive) or "canvas". "canvas" is well suited for large data sets as it does not impact DOM tree depth, however you'll lose the isomorphic rendering ability.

...

additional arguments.

width, height

Must be a valid CSS unit (like '100%', '400px', 'auto') or a number, which will be coerced to a string and have 'px' appended.

elementId

element id of widgets

Value

a pie component

See also

Examples

library(nivor) # generate data set.seed(1) data <- data.frame( id = c("Elixir", "Haskell", "Scala", "JavaScript", "Hack"), label = c("Elixir", "Haskell", "Scala", "JavaScript", "Hack"), value = round(rexp(5) * 100, 0), color = c( "hsl(208, 70%, 50%)", "hsl(275, 70%, 50%)", "hsl(141, 70%, 50%)", "hsl(104, 70%, 50%)", "hsl(119, 70%, 50%)" ) ) # the simplest use n_pie(data) # render with customization. n_pie( data = data, margin = list(top = 40, right = 80, bottom = 80, left = 80), innerRadius = 0.5, padAngle = 0.7, cornerRadius = 3, colors = list(scheme = "nivo"), borderWidth = 1, borderColor = list( from = "color", modifiers = list( c("darker", 0.2) ) ), radialLabelsSkipAngle = 10, radialLabelsTextColor = "#333333", radialLabelsLinkColor = list( from = "color" ), sliceLabelsSkipAngle = 10, sliceLabelsTextColor = "#333333", defs = list( list( id = "dots", type = "patternDots", background = "inherit", color = "rgba(255, 255, 255, 0.3)", size = 4, padding = 1, stagger = TRUE ), list( id = "lines", type = "patternLines", background = "inherit", color = "rgba(255, 255, 255, 0.3)", rotation = -45, lineWidth = 6, spacing = 10 ) ), fill = list( list( match = list(id = "JavaScript"), id = "dots" ), list( match = list(id = "Haskell"), id = "lines" ) ), legends = list( list( anchor = "bottom", direction = "row", justify = FALSE, translateX = 0, translateY = 56, itemsSpacing = 0, itemWidth = 100, itemHeight = 18, itemTextColor = "#999", itemDirection = "left-to-right", itemOpacity = 1, symbolSize = 18, symbolShape = "circle", effects = list( list( on = "hover", style = list( itemTextColor = "#999" ) ) ) ) ) )