Post updated on Dec 23, 2022
Let`s try using emoji symbols in highcharter/highcharts.
Fistโs some data:
For download tweets I followed the instructions from https://cran.r-project.org/web/packages/rtweet/vignettes/auth.html
Code
token <- create_token(
app = "jbktests",
consumer_key = "consumerkey",
consumer_secret = "consumer_secret",
access_token = "access_token",
access_secret = "access_secret"
)
Chart 1
Using emoji in the axis. In this case is direct, nothing special to do.
Code
# in interactive mode you can avoid/remove the token argument
tweets <- rtweet::search_tweets("#rstats", n = 18000, token = token, include_rts = FALSE)
emoji <- tweets %>%
mutate(emoji = ji_extract_all(text)) %>%
unnest(cols = c(emoji)) %>%
count(emoji, sort = TRUE)
max_count <- emoji %>%
pull(n) %>%
max()
Code
hchart(
emoji,
"bar",
hcaes(emoji, n),
name = "Count",
# dataLabels = list(enabled = TRUE, style = list(fontWeight = "normal"))
) %>%
hc_xAxis(
min = 0,
max = 30,
scrollbar = list(enabled = TRUE)
) %>%
hc_yAxis(
max = max_count,
title = list(
text = "Count",
align = "high"
)
) %>%
hc_tooltip(
headerFormat = "{point.key}",
pointFormat = " {point.y}"
) %>%
hc_size(height = 700)
Chart 2
Using emoji as markers.
Code
# A tibble: 196 ร 3
emoji favorite_count retweet_count
<chr> <int> <int>
1 โ 369 80
2 โฝ 112 22
3 โผ๏ธ 21 15
4 โฌ 29 84
5 โณ 11 6
6 โคต๏ธ 16 7
7 โฌ๏ธ 16 7
8 โถ๏ธ 300 69
9 โก๏ธ 396 81
10 โ๏ธ 27 5
# โฆ with 186 more rows
Code
hchart(
emoji2,
"scatter",
hcaes(favorite_count , retweet_count),
name = "emoji",
marker = list(
radius = 0
),
dataLabels = list(
enabled = TRUE,
format = "{point.emoji}",
allowOverlap = TRUE,
style = list(fontSize = 20),
y = 20
)
) %>%
hc_xAxis(type = "logarithmic", title = list(text = "Favorites"), minRange = 1) %>%
hc_yAxis(type = "logarithmic", title = list(text = "Retweets"), minRange = 1) %>%
hc_chart(zoomType = "xy")
Reuse
Citation
BibTeX citation:
@online{kunstfuentes2021,
author = {Joshua Kunst Fuentes},
title = {Using Emoji with Highcharter and Highcharts},
date = {2021-01-10},
url = {https://jkunst.com/blog/posts/2021-01-10-using-emoji-with-highcharterhighcharts},
langid = {en}
}
For attribution, please cite this work as:
Joshua Kunst Fuentes. 2021. โUsing Emoji with Highcharter and
Highcharts.โ January 10, 2021. https://jkunst.com/blog/posts/2021-01-10-using-emoji-with-highcharterhighcharts.