Description Usage Arguments Note Author(s) Examples
renderPieChart() function helps render the pie chart into Shiny application.
1 2 3 4 5 6 7 8 |
div_id |
The division id users specified for this chart. The division will be specified in ui.R. |
data |
The data used for the plotting. It should be either a vector or a data.frame. If it's a vector, it should be made up of all the elements you want to count and plot, like c("a", "a", "b", "a", "b", "c"). If it's a data.frame, the data must be made up of only two columns, "name" and "value". The "value" column must be numeric or integer. |
theme |
Which ECharts theme to use. Valid values include "default", "roma", "infographic", "macarons", "vintage", "shine", "caravan", "dark-digerati", "jazz", and "london". |
radius |
The radius of the pie chart. The default value is "75%". |
center_x |
The position of the center of the pie chart (x axis). Default value is "50%". |
center_y |
The position of the center of the pie chart (y axis). Default value is "50%". |
show.label |
Whether display the leble for the pie chart. The default value is TRUE. |
show.legend |
Whether display the legends. The default value is TRUE. |
show.tools |
Whether display the tool bar. The default value is TRUE. |
font.size.legend |
The font size of legend bar. The default value is 12. |
animation |
Whether display the chart with animation. The default value is TRUE. |
hyperlinks |
Vector. Users can link each element in the chart to a hyperlink (URL like http://***.com). Please note this is only supported when the data is in data.frame format, and the length of the "hyperlinks" vector should be the same to the number of rows in the data given. Note that if hyperlinks are available, the fonts in the pop-up window will be in skyblue color and italic style. |
running_in_shiny |
If we're actually running this in a Shiny library, or we're simply doing testing. Default valus is "TRUE". If "FALSE", the function will print what it's supposed to evaluate. |
Users need to state the division for the chart first, with tags$div() function of Shiny packages. Please note that the division id must keep unique (duplicated division id will cause error).
Xiaodong DENG
(ECharts library is authored by Baidu team)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | if (interactive()) {
library(shiny)
library(ECharts2Shiny)
dat <- c(rep("Type-A", 8),
rep("Type-B", 5),
rep("Type-C", 1))
# Server function -------------------------------------------
server <- function(input, output) {
renderPieChart(div_id = "test",
data = dat)
}
# UI layout -------------------------------------------------
ui <- fluidPage(
# We MUST load the ECharts javascript library in advance
loadEChartsLibrary(),
tags$div(id="test", style="width:50%;height:400px;"),
deliverChart(div_id = "test")
)
# Run the application --------------------------------------
shinyApp(ui = ui, server = server)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.