Highcharter Cheat Sheet
Made by:-
Name: Dhanush M Vajravelu
Regno: 18BCE2071 |
Intro
R package is a wrapper for the ‘Highcharts’ library including shortcut functions to plot R objects. |
Installation & Use
Installation |
install.packages("highcharter") |
To install Highcharter |
Load |
library(highcharter) |
Load Highcharter library at the beginning of the code |
Useful functions |
highchart() |
This function creates a Highchart chart using htmlwidgets |
hchart() |
This function to draw different charts on the fly |
hc_add_series() |
Adds data to existing objects (useful for discrete graphs like scatter plot) |
hc_chart() |
Chart options for highcharter objects |
hc_labels() |
Labels options for highcharter objects |
hc_legend() |
Legend options for highcharter objects |
hcmap() |
|
hc_add_theme() |
To add Predefined themes |
export_hc() |
Function to export js file the configuration options |
|
|
Using Hchart()
Syntax
hchart(object, ...) |
Bar Plot
Syntax
hchart(type = "bar")
Code
pokemon%>%
count(type_1)%>%
arrange(n)%>%
hchart(type = "bar", hcaes(x = type_1, y = n))
Column Plot
Syntax
hchart(type = "column")
Code
pokemon%>%
count(type_1)%>%
arrange(n)%>%
hchart(type = "column", hcaes(x = type_1, y = n))
Treemap
Syntax
hchart(type = "treemap")
Code
pokemon%>%
count(type_1)%>%
arrange(n)%>%
hchart(type = "treemap", hcaes(x = type_1, value = n, color = n))
Using hc_chart()
Syntax
hc_chart(hc, ...) |
Area Chart
Syntax
hc_chart(type = "area") %>%
|
|
Using hc_add_series()
Syntax
hc_add_series(hc, data = NULL, ...) |
Scatter Plot
Syntax
hc_add_series(data, "type = scatter")
Code
highchart()%>%
hc_add_series(pokemon, "type = scatter", hcaes(x = height, y = weight))
Using hc_add_theme()
Syntax
hc_add_theme(hc, hc_thm) |
Theming using hc_theme_chalk
Code
highchart()%>%
count(type_1)%>%
arrange(n)%>%
hc_add_series(pokemon, "type = scatter", hcaes(x = height, y = weight))
hc_add_theme(hc_theme_chalk())
Other themes with Highcharter
hc_theme_db
hc_theme_economist
hc_theme_flat
hc_theme_ft
hc_theme_ggplot2
hc_theme_handdrawn
hc_theme_chalk
hc_theme_flatdark
hc_theme_superheroes
hc_theme_google
Using hmaps()
Usage
hcmap(map, download_map_data, ...)
Map - String indicating what map to chart, a list from https://code.highcharts.com/mapdata/.
download_map_data - A logical value whether to download (add as a dependency) the map. |
Map Download
Code
hcmap("https://code.highcharts.com/mapdata/countries/in/in-all.js")%>%
hc_title(text = "India")
|
Created By
Metadata
Comments
No comments yet. Add yours below!
Add a Comment