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

Instal­lation
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 functions
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
hchart­(type = "­bar­")

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

Column Plot

Syntax
hchart­(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
hchart­(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_cha­rt(type = "­are­a") %>%
 

Using hc_add­_se­rie­s()

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

Scatter Plot

Syntax
hc_add­_se­ries(data, "type = scatte­r")

Code
highch­art­()%­>%
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
highch­art­()%­>%
count(­typ­e_1­)%>%
arrang­e(n­)%>%
hc_add­_se­rie­s(p­okemon, "type = scatte­r", hcaes(x = height, y = weight))
hc_add­_th­eme­(hc­_th­eme­_ch­alk())


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(­"­htt­ps:­//c­ode.hi­ghc­har­ts.c­om­/ma­pda­ta/­cou­ntr­ies­/in­/in­-al­l.j­s")%­>%
hc_tit­le(text = "­Ind­ia")
 

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.