amPieChart | R Documentation |
Create a HTML widget displaying a pie chart.
amPieChart( data, category, value, innerRadius = 0, threeD = FALSE, depth = ifelse(variableDepth, 100, 10), colorStep = 3, variableRadius = FALSE, variableDepth = FALSE, chartTitle = NULL, theme = NULL, animated = TRUE, backgroundColor = NULL, legend = TRUE, caption = NULL, image = NULL, width = NULL, height = NULL, export = FALSE, chartId = NULL, elementId = NULL )
data |
a dataframe |
category |
name of the column of |
value |
name of the column of |
innerRadius |
the inner radius of the pie chart in percent |
threeD |
whether to render a 3D pie chart |
depth |
for a 3D chart, this parameter controls the height of the slices |
colorStep |
the step in the color palette |
variableRadius |
whether to render slices with variable radius |
variableDepth |
for a 3D chart, whether to render slices with variable depth |
chartTitle |
chart title, it can be |
theme |
theme, |
animated |
Boolean, whether to animate the rendering of the graphic |
backgroundColor |
a color for the chart background; it can be
given by the name of a R color, the name of a CSS color, e.g.
|
legend |
either a logical value, whether to display the legend, or
a list of settings for the legend created with |
caption |
|
image |
option to include an image at a corner of the chart;
|
width |
the width of the chart, e.g. |
height |
the height of the chart, e.g. |
export |
logical, whether to enable the export menu |
chartId |
a HTML id for the chart |
elementId |
a HTML id for the container of the chart; ignored if the chart is displayed in Shiny, in which case the id is given by the Shiny id |
library(rAmCharts4) dat <- data.frame( country = c( "Lithuania", "Czechia", "Ireland", "Germany", "Australia", "Austria" ), value = c(260, 230, 200, 165, 139, 128) ) amPieChart( data = dat, category = "country", value = "value", variableRadius = TRUE ) # shiny app demonstrating the options #### library(rAmCharts4) library(shiny) dat <- data.frame( country = c( "Lithuania", "Czechia", "Ireland", "Germany", "Australia", "Austria" ), value = c(260, 230, 200, 165, 139, 128) ) ui <- fluidPage( sidebarLayout( sidebarPanel( sliderInput( "innerRadius", "Inner radius", min = 0, max = 60, value = 0, step = 20 ), checkboxInput("variableRadius", "Variable radius", TRUE), checkboxInput("threeD", "3D"), conditionalPanel( "input.threeD", checkboxInput("variableDepth", "Variable depth") ) ), mainPanel( amChart4Output("piechart", height = "500px") ) ) ) server <- function(input, output, session){ piechart <- reactive({ amPieChart( data = dat, category = "country", value = "value", innerRadius = input[["innerRadius"]], threeD = input[["threeD"]], variableDepth = input[["variableDepth"]], depth = ifelse(input[["variableDepth"]], 300, 10), variableRadius = input[["variableRadius"]], theme = "dark" ) }) output[["piechart"]] <- renderAmChart4({ piechart() }) } if(interactive()){ shinyApp(ui, server) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.