knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
library(vchartr)
You can install the development version of vchartr from GitHub with:
# install.packages("remotes") remotes::install_github("dreamRs/vchartr")
The following graphs (and more) can be produced:
See the JavaScript library website for more examples and documentation.
Interactive examples are available here: https://dreamrs.github.io/vchartr/articles/charts.html.
Start by initializing a chart with the vchart()
function, then choose the appropriate function according to the type of chart you wish to make and specify the variables to be used as aesthetics:
vchart(eco2mix) %>% v_line(aes(date, solar))
Modify scales options for aesthetics with v_scale_*
functions:
vchart(eco2mix) %>% v_line(aes(date, solar)) %>% v_scale_x_date( date_breaks = "2 years", date_labels = "MM-YYYY", name = "Date" ) %>% v_scale_y_continuous( labels = "~s", name = "Electricity generation" )
Set any options with v_specs
(see all options available here):
vchart(eco2mix) %>% v_line(aes(date, solar)) %>% v_specs( brush = list( brushType = "x", zoomAfterBrush = TRUE ), dataZoom = list( orient = "bottom", startText = list(formatter = "{label:%Y-%m-%d}"), endText = list(formatter = "{label:%Y-%m-%d}") ) )
Or use v_specs_*
helpers:
vchart(eco2mix) %>% v_line(aes(date, solar)) %>% v_specs_datazoom( start = "{label:%Y-%m-%d}", end = "{label:%Y-%m-%d}", brush = TRUE )
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.