D3 Wordcloud

Authors

[Editor] Hu Zheng;

[Contributors]

Modified

2026-01-17

Note

Hiplot website

This page is the tutorial for source code version of the Hiplot D3 Wordcloud plugin. You can also use the Hiplot website to achieve no code ploting. For more information please see the following link:

https://hiplot.cn/basic/d3-wordcloud?lang=en

Display the wordcloud。

Setup

  • System Requirements: Cross-platform (Linux/MacOS/Windows)

  • Programming language: R

  • Dependent packages: data.table; jsonlite; d3wordcloud

# Install packages
if (!requireNamespace("data.table", quietly = TRUE)) {
  install.packages("data.table")
}
if (!requireNamespace("jsonlite", quietly = TRUE)) {
  install.packages("jsonlite")
}
if (!requireNamespace("d3wordcloud", quietly = TRUE)) {
  remotes::install_github("jbkunst/d3wordcloud")
}

# Load packages
library(data.table)
library(jsonlite)
library(d3wordcloud)
sessioninfo::session_info("attached")
─ Session info ───────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.5.2 (2025-10-31)
 os       Ubuntu 24.04.3 LTS
 system   x86_64, linux-gnu
 ui       X11
 language (EN)
 collate  C.UTF-8
 ctype    C.UTF-8
 tz       UTC
 date     2026-01-17
 pandoc   3.1.3 @ /usr/bin/ (via rmarkdown)
 quarto   1.8.27 @ /usr/local/bin/quarto

─ Packages ───────────────────────────────────────────────────────────────────
 package     * version date (UTC) lib source
 d3wordcloud * 0.1     2025-11-02 [1] Github (jbkunst/d3wordcloud@1eb4fe9)
 data.table  * 1.18.0  2025-12-24 [1] RSPM
 jsonlite    * 2.0.0   2025-03-27 [1] RSPM

 [1] /home/runner/work/_temp/Library
 [2] /opt/R/4.5.2/lib/R/site-library
 [3] /opt/R/4.5.2/lib/R/library
 * ── Packages attached to the search path.

──────────────────────────────────────────────────────────────────────────────

Data Preparation

# Load data
data <- data.table::fread(jsonlite::read_json("https://hiplot.cn/ui/basic/d3-wordcloud/data.json")$exampleData$textarea[[1]])
data <- as.data.frame(data)

# convert data structure
row.names(data) <- data[, 1]

# View data
head(data)
         word freq
oil       oil   85
said     said   73
prices prices   48
opec     opec   42
mln       mln   31
the       the   26

Visualization

# D3 Wordcloud
p <- d3wordcloud(
  words = data[, 1], 
  freqs = data[, 2],
  padding = 0,
  rotate.min = 0,
  rotate.max = 0,
  size.scale = "linear",
  color.scale = "linear",
  spiral = "archimedean",
  font = "Arial",
  rangesizefont = c(10, 90)
)

p
FigureΒ 1: D3 Wordcloud