Learn R Programming

vchartr

R Htmlwidget for VChart : VChart is a charting component library in VisActor visualization system. See the online documentation for examples.

Installation

Install from CRAN with:

install.packages("vchartr")

You can install the development version of vchartr from GitHub with:

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

Examples

A scatter plot with palmerpenguins dataset and inspired from the documentation:

library(vchartr)
library(palmerpenguins)
vchart(penguins) %>% 
  v_scatter(
    aes(
      x = bill_length_mm,
      y = bill_depth_mm,
      color = species, 
      shape = species
    )
  ) %>%
  v_smooth(
    aes(
      x = bill_length_mm,
      y = bill_depth_mm,
      color = species
    ),
    method = "lm",
    se = FALSE
  ) %>% 
  v_scale_x_continuous(
    name = "Bill length (mm)"
  ) %>% 
  v_scale_y_continuous(
    name = "Bill depth (mm)"
  ) %>% 
  v_labs(
    title = "Penguin bill dimensions",
    subtitle = "Bill length and depth for Adelie, Chinstrap and Gentoo Penguins at Palmer Station LTER"
  ) %>% 
  v_specs_legend(
    orient = "top",
    position = "start",
    layout = "vertical",
    layoutType = "absolute",
    right = 0,
    bottom = 40,
    title = list(
      visible = TRUE,
      text = "Penguin species"
    )
  )

A line chart with area range:

vchart(temperatures, aes(date)) %>% 
  v_area(
    aes(ymin = low, ymax = high),
    area = list(style = list(fill = "#848585", fillOpacity = 0.3)),
    name = "Low/high between 2019 and 2023"
  ) %>% 
  v_line(
    aes(y = `2024`), 
    line = list(style = list(stroke = "firebrick")),
  ) %>%
  v_scale_x_date(
    date_breaks = "2 months", 
    date_labels = "MMMM",
    date_labels_tooltip = "DD MMMM"
  ) %>% 
  v_scale_y_continuous(
    name = "Temperature in degree celsius",
    labels = format_num_d3(".0f", suffix = "°C"),
    labels_tooltip = format_num_d3(".3r", suffix = "°C")
  ) %>% 
  v_labs(
    title = "Temperatures in France in 2024 compared with previous years",
    subtitle = "Source: Enedis"
  ) %>% 
  v_specs_legend(
    visible = TRUE,
    orient = "top",
    position = "left"
  )

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/vchart.js, then run:

packer::bundle()

Re-install R package and try vchart() function.

Copy Link

Version

Install

install.packages('vchartr')

Monthly Downloads

440

Version

0.1.4

License

MIT + file LICENSE

Maintainer

Victor Perrier

Last Published

January 15th, 2025

Functions in vchartr (0.1.4)

electricity_mix

Electricity mix for 10 countries
label_value

Useful labeller functions
format-date

Format date with dayjs JavaScript library
energy_sankey

Data for Sankey Chart
mark-area

Add a rectangle annotation to a chart
mark-line

Add an horizontal or vertical line to a chart
scale-gradient

Color scale for continuous data
v_bar

Create a Bar Chart
v_area

Create an Area Chart
scale-color-manual

Manual color scale
temperatures

Temperature data
aes

Construct aesthetic mappings
scale-continuous

Axis scale for continuous data
v_event

VChart events
v_pie

Create a Pie Chart
v_radar

Create a Radar Chart
v_sankey

Create a Sankey Chart
v_specs_axes

Axes configuration
v_circlepacking

Create a Circle Packing Chart
v_boxplot

Create a BoxPlot
v_scatter

Create a Scatter Chart
v_scale_size

Size scale for continuous data
v_specs_colors

Set color(s) for chart
v_progress

Create a Progress Chart
v_labs

Set chart title and subtitle
v_facet_wrap

Facets for vchart
v_gauge

Create a Gauge Chart
v_specs

Specify configuration options for a vchart().
v_theme

Theme for Charts
v_smooth

Create an Smooth Line Chart
v_treemap

Create a Treemap Chart
v_specs_tooltip

Set tooltip options
vchartr-package

An htmlwidget interface to the VChart javascript chart library
meteo_paris

Paris climate
top_generation

Top electricity-generating countries
v_hist

Create an Histogram
vmap

Create a Map
%>%

Pipe operator
top_cran_downloads

Top CRAN downloads
v_wordcloud

Create a Wordcloud
v_specs_legend

Set legend options
v_jitter

Create Jittered Points Scatter Chart
vars

Quote faceting variables
world_electricity

World low carbon & fossil electricity generation 2014 - 2023
v_heatmap

Create a Heatmap Chart
v_specs_indicator

Add indicator to chart
v_specs_datazoom

Add data zoom to a chart
v_sunburst

Create a Sunburst Chart
v_specs_player

Set player options
v_waterfall

Create a Waterfall Chart
v_specs_custom_mark

Add custom mark to chart
v_specs_crosshair

Add crosshair to chart
v_venn

Create a Venn Diagram
v_line

Create a Line Chart
vchart-shiny

Shiny bindings for vchart
vchart

Create interactive charts with VChart
countries_gdp

Countries GDP
eco2mix

Monthly electricity generation by source in France
co2_world

World CO2 emissions
JS

Mark character strings as literal JavaScript code
co2_emissions

CO2 emissions
scale-date

Axis scale for date/time data
scale-discrete

Axis scale for discrete data
format_num_d3

Format numbers with D3
eco2mix_long

Monthly electricity generation by source in France (long format)