What is highcharter
?
Highcharter is a R wrapper for Highcharts javascript library and its modules. Highcharts is very flexible and customizable javascript charting library and it has a great and powerful API.
The main features of highcharter are:
- Chart various R objects with one function: with
hchart(x)
you can chartdata.frames
,numeric
orcharacter
vectors,ts
,xts
,forecast
,survfit
objects. - Support Highstock You can create a candlestick charts in 2 lines of code. Support
xts
class from the {quantmod} package. - Support Highmaps Create choropleth charts or add information in
geojson
format. - Themes: you configure your chart in multiples ways. There are implemented themes like economist, financial times, google, 538 among others.
- A lot of features and plugins: motion, draggable points, font-awesome, tooltips, annotations.
Highcharts
let us start start with a simple example using hchart
function.
library(highcharter)
# install.packages("palmerpenguins")
data(penguins, package = "palmerpenguins")
hchart(penguins, "scatter", hcaes(x = flipper_length_mm, y = bill_length_mm, group = species))
Among its features highcharter can chart various objects depending of its class with the generic (magic) hchart
function.
x <- c(rnorm(10000), rnorm(1000, 4, 0.5))
hchart(x, name = "data")
One of the nicest class which hchart can plot is the
forecast` class from the {forecast} package.
library(forecast)
airforecast <- forecast(auto.arima(AirPassengers), level = 95)
hchart(airforecast)
Highstock
With highcharter you can use the highstock library which include sophisticated navigation options like_
- Small navigator series
- Preset date ranges
- Date picker
- Scrolling and panning.
With highcarter it is easy make candlesticks or ohlc charts using time series data. For example, using data from quantmod package.
library(quantmod)
x <- getSymbols("GOOG", auto.assign = FALSE)
y <- getSymbols("AMZN", auto.assign = FALSE)
highchart(type = "stock") %>%
hc_add_series(x) %>%
hc_add_series(y, type = "ohlc")
Highmaps
We can chart maps elements and choropleth using the highmaps and build interactive maps to display data linked to geographic objects.
data(GNI2014, package = "treemap")
hcmap(
"custom/world-robinson-lowres",
data = GNI2014,
name = "Gross national income per capita",
value = "GNI",
borderWidth = 0,
nullColor = "#d3d3d3",
joinBy = c("iso-a3", "iso3")
) %>%
hc_colorAxis(
stops = color_stops(colors = viridisLite::inferno(10, begin = 0.1)),
type = "logarithmic"
)
Installation
CRAN version:
install.packages("highcharter")
Development version:
remotes::install_github("jbkunst/highcharter")
How to start
There are a lot of vignettes to show how highcharter works and what you can do:
-
vignette("highcharter")
explore the basics of the package. -
vignette("showcase")
to see how much highcharts is flexible in terms of customization and design. -
vignette("highcharts-api")
show the main functions to configure charts with the implemented Highcharts API. -
vignette("highchartsjs-api-basics")
explain the relationship between the highchartsJS API and highcharter.
Licence
Highcharter has a dependency on Highcharts, a commercial JavaScript charting library. Highcharts offers both a commercial license as well as a free non-commercial license. Please review the licensing options and terms before using this software, as the highcharter
license neither provides nor implies a license for Highcharts.
Highcharts (https://highcharts.com) is a Highsoft product which is not free for commercial and Governmental use.
Discount for highcharter users
Highsoft provide a discount to the highcharter users. It is a 50% discount on our Single Developer license. More details in https://newsletter.highcharts.com/foss/.