move examples
This commit is contained in:
parent
cfd5a9e712
commit
00fe467dcc
|
@ -8,3 +8,4 @@
|
|||
^docs$
|
||||
^cran-comments\.md$
|
||||
^CRAN-RELEASE$
|
||||
^examples$
|
||||
|
|
38
R/apex.R
38
R/apex.R
|
@ -20,43 +20,7 @@
|
|||
#' @importFrom rlang eval_tidy as_label
|
||||
#' @importFrom utils modifyList
|
||||
#'
|
||||
#' @examples
|
||||
#' library(dplyr)
|
||||
#'
|
||||
#'
|
||||
#' # make a barchart with a frequency table
|
||||
#' data("mpg", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = count(mpg, manufacturer),
|
||||
#' mapping = aes(x = manufacturer, y = n),
|
||||
#' type = "bar"
|
||||
#' )
|
||||
#'
|
||||
#' # timeseries
|
||||
#' data("economics", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = economics,
|
||||
#' mapping = aes(x = date, y = uempmed),
|
||||
#' type = "line"
|
||||
#' )
|
||||
#'
|
||||
#' # you can add option to apex result :
|
||||
#' apex(
|
||||
#' data = economics,
|
||||
#' mapping = aes(x = date, y = uempmed),
|
||||
#' type = "line"
|
||||
#' ) %>%
|
||||
#' ax_stroke(width = 1)
|
||||
#'
|
||||
#'
|
||||
#'
|
||||
#' # with group variable
|
||||
#' data("economics_long", package = "ggplot2")
|
||||
#' apex(
|
||||
#' data = economics_long,
|
||||
#' mapping = aes(x = date, y = value01, group = variable),
|
||||
#' type = "line"
|
||||
#' )
|
||||
#' @example examples/apex.R
|
||||
apex <- function(data, mapping, type = "column", ..., auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) {
|
||||
type <- match.arg(type, c("column", "bar", "line", "area", "spline", "area-spline",
|
||||
"pie", "donut", "radialBar", "radar", "scatter", "heatmap"))
|
||||
|
|
|
@ -12,42 +12,7 @@
|
|||
#'
|
||||
#' @importFrom htmlwidgets createWidget sizingPolicy
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' library(apexcharter)
|
||||
#'
|
||||
#' # Use raw API by passing a list of
|
||||
#' # parameters to the function
|
||||
#'
|
||||
#' apexchart(ax_opts = list(
|
||||
#' chart = list(
|
||||
#' type = "bar"
|
||||
#' ),
|
||||
#' series = list(list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )),
|
||||
#' xaxis = list(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#' ))
|
||||
#'
|
||||
#'
|
||||
#' # Or use apexchart() to initialize the chart
|
||||
#' # before passing parameters
|
||||
#'
|
||||
#' apexchart() %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_series(
|
||||
#' list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )
|
||||
#' ) %>%
|
||||
#' ax_xaxis(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#'
|
||||
#' @example examples/apexchart.R
|
||||
apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height = NULL, elementId = NULL) {
|
||||
|
||||
# forward options using x
|
||||
|
@ -102,43 +67,7 @@ apexchart <- function(ax_opts = list(), auto_update = TRUE, width = NULL, height
|
|||
#'
|
||||
#' @importFrom htmlwidgets shinyWidgetOutput shinyRenderWidget
|
||||
#'
|
||||
#' @examples
|
||||
#'
|
||||
#' if (interactive()) {
|
||||
#' library(shiny)
|
||||
#'
|
||||
#' ui <- fluidPage(
|
||||
#' fluidRow(
|
||||
#' column(
|
||||
#' width = 8, offset = 2,
|
||||
#' tags$h2("Apexchart in Shiny"),
|
||||
#' actionButton("redraw", "Redraw chart"),
|
||||
#' apexchartOutput("chart")
|
||||
#' )
|
||||
#' )
|
||||
#' )
|
||||
#'
|
||||
#' server <- function(input, output, session) {
|
||||
#'
|
||||
#' output$chart <- renderApexchart({
|
||||
#' input$redraw
|
||||
#' apexchart() %>%
|
||||
#' ax_chart(type = "bar") %>%
|
||||
#' ax_series(
|
||||
#' list(
|
||||
#' name = "Example",
|
||||
#' data = sample(1:100, 5)
|
||||
#' )
|
||||
#' ) %>%
|
||||
#' ax_xaxis(
|
||||
#' categories = LETTERS[1:5]
|
||||
#' )
|
||||
#' })
|
||||
#'
|
||||
#' }
|
||||
#'
|
||||
#' shinyApp(ui, server)
|
||||
#' }
|
||||
#' @example examples/apexcharter-shiny.R
|
||||
apexchartOutput <- function(outputId, width = '100%', height = '400px'){
|
||||
htmlwidgets::shinyWidgetOutput(outputId, 'apexcharter', width, height, package = 'apexcharter')
|
||||
}
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
library(ggplot2)
|
||||
library(dplyr)
|
||||
library(apexcharter)
|
||||
|
||||
# make a barchart with a frequency table
|
||||
data("mpg", package = "ggplot2")
|
||||
apex(
|
||||
data = count(mpg, manufacturer),
|
||||
mapping = aes(x = manufacturer, y = n),
|
||||
type = "bar"
|
||||
)
|
||||
|
||||
# timeseries
|
||||
data("economics", package = "ggplot2")
|
||||
apex(
|
||||
data = economics,
|
||||
mapping = aes(x = date, y = uempmed),
|
||||
type = "line"
|
||||
)
|
||||
|
||||
# you can add option to apex result :
|
||||
apex(
|
||||
data = economics,
|
||||
mapping = aes(x = date, y = uempmed),
|
||||
type = "line"
|
||||
) %>%
|
||||
ax_stroke(width = 1)
|
||||
|
||||
|
||||
# with group variable
|
||||
data("economics_long", package = "ggplot2")
|
||||
apex(
|
||||
data = economics_long,
|
||||
mapping = aes(x = date, y = value01, group = variable),
|
||||
type = "line"
|
||||
)
|
|
@ -0,0 +1,33 @@
|
|||
library(apexcharter)
|
||||
|
||||
# Use raw API by passing a list of
|
||||
# parameters to the function
|
||||
|
||||
apexchart(ax_opts = list(
|
||||
chart = list(
|
||||
type = "bar"
|
||||
),
|
||||
series = list(list(
|
||||
name = "Example",
|
||||
data = sample(1:100, 5)
|
||||
)),
|
||||
xaxis = list(
|
||||
categories = LETTERS[1:5]
|
||||
)
|
||||
))
|
||||
|
||||
|
||||
# Or use apexchart() to initialize the chart
|
||||
# before passing parameters
|
||||
|
||||
apexchart() %>%
|
||||
ax_chart(type = "bar") %>%
|
||||
ax_series(
|
||||
list(
|
||||
name = "Example",
|
||||
data = sample(1:100, 5)
|
||||
)
|
||||
) %>%
|
||||
ax_xaxis(
|
||||
categories = LETTERS[1:5]
|
||||
)
|
|
@ -0,0 +1,36 @@
|
|||
if (interactive()) {
|
||||
library(shiny)
|
||||
library(apexcharter)
|
||||
|
||||
ui <- fluidPage(
|
||||
fluidRow(
|
||||
column(
|
||||
width = 8, offset = 2,
|
||||
tags$h2("Apexchart in Shiny"),
|
||||
actionButton("redraw", "Redraw chart"),
|
||||
apexchartOutput("chart")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
server <- function(input, output, session) {
|
||||
|
||||
output$chart <- renderApexchart({
|
||||
input$redraw
|
||||
apexchart() %>%
|
||||
ax_chart(type = "bar") %>%
|
||||
ax_series(
|
||||
list(
|
||||
name = "Example",
|
||||
data = sample(1:100, 5)
|
||||
)
|
||||
) %>%
|
||||
ax_xaxis(
|
||||
categories = LETTERS[1:5]
|
||||
)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
shinyApp(ui, server)
|
||||
}
|
|
@ -40,8 +40,9 @@ A \code{apexcharts} \code{htmlwidget} object.
|
|||
Initialize a chart with three main parameters : data, mapping and type of chart.
|
||||
}
|
||||
\examples{
|
||||
library(ggplot2)
|
||||
library(dplyr)
|
||||
|
||||
library(apexcharter)
|
||||
|
||||
# make a barchart with a frequency table
|
||||
data("mpg", package = "ggplot2")
|
||||
|
@ -68,7 +69,6 @@ apex(
|
|||
ax_stroke(width = 1)
|
||||
|
||||
|
||||
|
||||
# with group variable
|
||||
data("economics_long", package = "ggplot2")
|
||||
apex(
|
||||
|
|
|
@ -30,7 +30,6 @@ A \code{apexcharts} \code{htmlwidget} object.
|
|||
Create a apexcharts.js widget
|
||||
}
|
||||
\examples{
|
||||
|
||||
library(apexcharter)
|
||||
|
||||
# Use raw API by passing a list of
|
||||
|
@ -53,16 +52,15 @@ apexchart(ax_opts = list(
|
|||
# Or use apexchart() to initialize the chart
|
||||
# before passing parameters
|
||||
|
||||
apexchart() \%>\%
|
||||
ax_chart(type = "bar") \%>\%
|
||||
apexchart() \%>\%
|
||||
ax_chart(type = "bar") \%>\%
|
||||
ax_series(
|
||||
list(
|
||||
name = "Example",
|
||||
data = sample(1:100, 5)
|
||||
)
|
||||
) \%>\%
|
||||
) \%>\%
|
||||
ax_xaxis(
|
||||
categories = LETTERS[1:5]
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,9 @@ Output and render functions for using apexcharter within Shiny
|
|||
applications and interactive Rmd documents.
|
||||
}
|
||||
\examples{
|
||||
|
||||
if (interactive()) {
|
||||
library(shiny)
|
||||
library(apexcharter)
|
||||
|
||||
ui <- fluidPage(
|
||||
fluidRow(
|
||||
|
|
Loading…
Reference in New Issue