Learn R Programming

apexcharter

Htmlwidget for apexcharts.js : A modern JavaScript charting library to build interactive charts and visualizations with simple API. See the online documentation for examples.

Installation

Install from CRAN with:

install.packages("apexcharter")

Or install the development version from GitHub with:

# install.packages("remotes")
remotes::install_github("dreamRs/apexcharter")

Quick Charts

Use apex function to quickly create visualizations :

library(apexcharter)
data("mpg", package = "ggplot2")
apex(data = mpg, type = "bar", mapping = aes(manufacturer))

With datetime:

data("economics", package = "ggplot2")
apex(data = economics, type = "line", mapping = aes(x = date, y = uempmed)) %>% 
  ax_stroke(width = 1)

Full API

All methods from ApexCharts are available with function like ax_* compatible with pipe from magrittr :

library(apexcharter)
data(mpg, package = "ggplot2")

apexchart() %>% 
  ax_chart(type = "bar") %>% 
  ax_plotOptions(bar = bar_opts(
    horizontal = FALSE,
    endingShape = "flat",
    columnWidth = "70%",
    dataLabels = list(
      position = "top"
    ))
  ) %>% 
  ax_grid(
    show = TRUE,
    position = "front",
    borderColor = "#FFF"
  ) %>% 
  ax_series(list(
    name = "Count",
    data = tapply(mpg$manufacturer, mpg$manufacturer, length)
  )) %>% 
  ax_colors("#112446") %>% 
  ax_xaxis(categories = unique(mpg$manufacturer)) %>% 
  ax_title(text = "Number of models") %>% 
  ax_subtitle(text = "Data from ggplot2")

Raw API

Pass a list of parameters to the function:

apexchart(ax_opts = list(
  chart = list(
    type = "line"
  ),
  stroke = list(
    curve = "smooth"
  ),
  grid = list(
    borderColor = "#e7e7e7",
    row = list(
      colors = c("#f3f3f3", "transparent"),
      opacity = 0.5
    )
  ),
  dataLabels = list(
    enabled = TRUE
  ),
  markers = list(style = "inverted", size = 6),
  series = list(
    list(
      name = "High",
      data = c(28, 29, 33, 36, 32, 32, 33)
    ),
    list(
      name = "Low",
      data = c(12, 11, 14, 18, 17, 13, 13)
    )
  ),
  title = list(
    text = "Average High & Low Temperature",
    align = "left"
  ),
  xaxis = list(
    categories = month.abb[1:7]
  ),
  yaxis = list(
    title = list(text = "Temperature"),
    labels = list(
      formatter = htmlwidgets::JS("function(value) {return value + '\u00b0C';}")
    )
  )
))

Development

This package use {packer} to manage JavaScript assets, see packer's documentation for more.

Install nodes modules with:

packer::npm_install()

Modify srcjs/widgets/apexcharter.js, then run:

packer::bundle()

Re-install R package and try apexcharter() or apex() functions.

Copy Link

Version

Install

install.packages('apexcharter')

Monthly Downloads

622

Version

0.4.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Victor Perrier

Last Published

September 6th, 2024

Functions in apexcharter (0.4.4)

ax_colors_manual

Set specific color's series
ax_markers

Markers properties
apexcharter-shiny-facets

Shiny bindings for faceting with apexcharter
ax_title

Chart's title
ax_fill

Fill property
ax_legend

Legend properties
ax_labs

Modify axis, legend, and chart labels
ax_stroke

Stroke properties
ax_dataLabels

Labels on data
ax_responsive

Responsive options
ax_theme

Theme for charts
ax_subtitle

Chart's subtitle
ax_states

Charts' states
ax_forecast_data_points

Forecast data points
ax_tooltip

Tooltip options
ax_proxy_series

Proxy for updating series.
ax_plotOptions

Specific options for chart
ax_labels

Alternative axis labels
ax_grid

Add grids on chart
ax_proxy_options

Proxy for updating options
ax_xaxis

X-axis options
ax_yaxis2

Secondary Y-axis options
ax_nodata

Configuration for charts with no data
candles

Candlestick demo data
ax_yaxis

Y-axis options
boxplot_opts

Boxplot options
config_update

Configuration for auto update
bar_opts

Bar options
climate_paris

Paris Climate
run_demo_input

Run Shiny input events examples
eco2mix

eco2mix data
events_opts

Events options
radialBar_opts

Radial bar options
life_expec_long

Life expectancy data (long format)
run_demo_sparkbox

Run Shiny spark boxes example
run_demo_sync

Run Shiny synchronization example
life_expec

Life expectancy data
set_input_click

Retrieve click information in Shiny
set_input_export

Retrieve chart's base64 dataURI.
format_num

Format numbers (with D3)
set_input_selection

Retrieve selection information in Shiny
format_date

Format date in JS
set_input_zoom

Retrieve zoom information in Shiny
pie_opts

Pie options
bubble_opts

Bubble options
parse_df

Convert a data.frame to a list
consumption

Electricity consumption and forecasting
label

Label for annotations
heatmap_opts

Heatmap options
set_tooltip_fixed

Fixed tooltip
spark_box

Create a box with a sparkline
temperatures

Temperature data
unhcr_ts

UNHCR data by continent of origin
apex

Quick ApexCharts
apex-facets

Facets for ApexCharts
add-vh-lines

Add horizontal or vertical line
apex_grid

Create a grid of ApexCharts
add_point

Add an annotation point
add_event_marker

Add an event marker to a chart
add-shade

Add a shaded area to a chart
add-line

Add a line to a chart
apexchart

Create an ApexCharts widget
add_event

Add an event to a chart
apexchartProxy

Proxy for apexchart
apexcharter-exports

apexcharter exported operators and S3 methods
ax_chart

Chart parameters
ax_colors

Colors
apexcharter-shiny-grid

Shiny bindings for grid with apexcharter
apexcharter-shiny

Shiny bindings for apexcharter
apexcharter-package

An htmlwidget interface to the ApexCharts javascript chart library
ax-series

Add data to a chart
ax_annotations

Annotations properties