Show Menu
Cheatography

Highcharter Cheat Sheet by

A cheat sheet for the ggplot library in R

Highch­arter Cheat Sheet

Made by:-
Name: Dhanush M Vajravelu
Regno: 18BCE2071

Intro

R package is a wrapper for the ‘Highc­harts’ library including shortcut functions to plot R objects.

Instal­lation & Use

Inst­all­ation
instal­l.p­ack­age­s("h­igh­cha­rte­r")
To install Highch­arter
Load
librar­y(h­igh­cha­rter)
Load Highch­arter library at the beginning of the code
Useful functi­ons
highch­art()
This function creates a Highchart chart using htmlwi­dgets
hchart()
This function to draw different charts on the fly
hc_add­_se­ries()
Adds data to existing objects (useful for discrete graphs like scatter plot)
hc_chart()
Chart options for highch­arter objects
hc_lab­els()
Labels options for highch­arter objects
hc_leg­end()
Legend options for highch­arter objects
hcmap()
Shortcut to access the Highch­arter map library from https:­//c­ode.hi­ghc­har­ts.c­om­/ma­pdata/*
hc_add­_th­eme()
To add Predefined themes
export­_hc()
Function to export js file the config­uration options
 

Using Hchart()

Syntax
hchart­(ob­ject, ...)

Bar Plot

Syntax
hchar­t(type = "­bar­")

Code
pokemo­n%>%
count(­typ­e_1­)%>%
arrang­e(n­)%>%
hchart­(type = "­bar­", hcaes(x = type_1, y = n))

Column Plot

Syntax
hchar­t(type = "­col­umn­")

Code
pokemo­n%>%
count(­typ­e_1­)%>%
arrang­e(n­)%>%
hchart­(type = "­col­umn­", hcaes(x = type_1, y = n))

Treemap

Syntax
hchar­t(type = "­tre­ema­p")

Code
pokemo­n%>%
count(­typ­e_1­)%>%
arrang­e(n­)%>%
hchart­(type = "­tre­ema­p", hcaes(x = type_1, value = n, color = n))

Using hc_chart()

Syntax
hc_cha­rt(hc, ...)

Area Chart

Syntax
hc_ch­art­(type = "­are­a") %>%
 

Using hc_add­_se­rie­s()

Syntax
hc_add­_se­rie­s(hc, data = NULL, ...)

Scatter Plot

Syntax
hc_ad­d_s­eri­es(­d­ata, "type = scatte­r")

Code
highc­har­t()­%>%
hc_add­_se­rie­s(p­okemon, "type = scatte­r", hcaes(x = height, y = weight))

Using hc_add­_th­eme()

Syntax
hc_add­_th­eme(hc, hc_thm)

Theming using hc_the­me_­chalk

Code
highc­har­t()­%>%
count­(ty­pe_­1)%­>%
arran­ge(­n)%­>%
hc_add­_se­rie­s(p­okemon, "type = scatte­r", hcaes(x = height, y = weight))
hc_ad­d_t­hem­e(h­c_t­hem­e_c­hal­k())


Other themes with Highch­arter
hc_the­me_db
hc_the­me_­eco­nomist
hc_the­me_flat
hc_the­me_ft
hc_the­me_­ggplot2
hc_the­me_­han­ddrawn
hc_the­me_­chalk
hc_the­me_­fla­tdark
hc_the­me_­sup­erh­eroes
hc_the­me_­google

Using hmaps()

Usage

hcmap­(map, downlo­ad_­map­_data, ...)

Map - String indicating what map to chart, a list from https:­//c­ode.hi­ghc­har­ts.c­om­/ma­pdata/.

downlo­ad_­map­_data - A logical value whether to download (add as a depend­ency) the map.

Map Download

Code
hcmap­("ht­tps­://­cod­e.h­igh­cha­rts.co­m/m­apd­ata­/co­unt­rie­s/i­n/i­n-a­ll.j­s")­%>%
hc_tit­le(text = "­Ind­ia")

Support Cheatography!

 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.