Learn R Programming

ECharts2Shiny (version 0.2.13)

deliverChart: Deliver the Chart in the UI Component of Shiny Applications

Description

This function helps deliver the charts plotted by ECharts into Shiny applications.

Usage

deliverChart(div_id, running_in_shiny = TRUE)

Arguments

div_id

The id of the div which you need to specify first with tags$div() function of Shiny.

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.

Details

This will help us deliver the interactive charts. At the back-end, everything is donw by Javascript.

Examples

Run this code
# NOT RUN {
if (interactive()) {
  library(shiny)
  library(ECharts2Shiny)

  # Prepare sample data for plotting --------------------------
  dat <- data.frame(c(1, 2, 3))
  names(dat) <- c("Type-A")
  row.names(dat) <- c("Time-1", "Time-2", "Time-3")

  # Server function -------------------------------------------
  server <- function(input, output) {
    # Call functions from ECharts2Shiny to render charts
    renderBarChart(div_id = "test", grid_left = '1%', direction = "vertical", 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)
}


# }

Run the code above in your browser using DataLab