• Stars
    star
    193
  • Rank 201,081 (Top 4 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

☁️ Simple React + D3 wordcloud component with powerful features.

☁️ react-wordcloud

Simple React + D3 wordcloud component with powerful features. Uses the d3-cloud layout.

image

Install

npm install react-wordcloud

Note that react-wordcloud requires react^16.13.0 as a peer dependency.

Use

Simple

import React from 'react';
import ReactWordcloud from 'react-wordcloud';

import 'tippy.js/dist/tippy.css';
import 'tippy.js/animations/scale.css';

const words = [
  {
    text: 'told',
    value: 64,
  },
  {
    text: 'mistake',
    value: 11,
  },
  {
    text: 'thought',
    value: 16,
  },
  {
    text: 'bad',
    value: 17,
  },
]

function SimpleWordcloud() {
  return <ReactWordcloud words={words} />
}

By default, ReactWordcloud is configured with animated tooltips enabled and requires CSS for styling. Tippy provides base styling in the resources above or you can create your own.

Kitchen Sink

An example showing various features (callbacks, options, size).

const callbacks = {
  getWordColor: word => word.value > 50 ? "blue" : "red",
  onWordClick: console.log,
  onWordMouseOver: console.log,
  getWordTooltip: word => `${word.text} (${word.value}) [${word.value > 50 ? "good" : "bad"}]`,
}
const options = {
  rotations: 2,
  rotationAngles: [-90, 0],
};
const size = [600, 400];
const words = [...];

function MyWordcloud() {
  return (
    <ReactWordcloud
      callbacks={callbacks}
      options={options}
      size={size}
      words={words}
    />
  );
}

Examples

View all documented examples and gallery of react-wordcloud applications at https://react-wordcloud.netlify.com/.

You can also run the examples locally:

git clone [email protected]:chrisrzhou/react-wordcloud

cd react-wordcloud
npm install && npm run docs

No props

Edit react-wordcloud-simple

Responsive

Edit react-wordcloud-simple

Configurable Options

Edit react-wordcloud-interactive

Callbacks

Edit react-wordcloud-interactive

Wordcloud Generator

Create wordclouds using this wordcloud generator: https://wordcloud-generator.netlify.com/

Features supported:

  • Edit and Upload text inputs
  • Various NLP features (stopwords, ngrams)
  • Wordcloud configurations
  • Export/save/share wordclouds

Contributing

The code is written in typescript, linted with xo, and built with microbundle. Examples and documentations are built with docz.

Feel free to contribute by submitting a pull request.

More Repositories

1

react-globe

Create beautiful and interactive React + ThreeJS globe visualizations with ease.
JavaScript
274
star
2

RShiny-EC2Bootstrap

R Shiny EC2 Bootstrap Guide
80
star
3

google-globe-trends

Create beautiful and interactive Google Trends globe visualizations with ease
JavaScript
34
star
4

egghead-redux

Egghead Redux Series by Dan Abramov
JavaScript
33
star
5

surveyless

Build, run, and analyze simple serverless surveys
JavaScript
14
star
6

qraffiti

Generete graffiti with QR codes
JavaScript
13
star
7

unified-doc

📜 unified document APIs and renderers
JavaScript
12
star
8

RShiny-LaborForceStatistics

R Shiny application: Labor Force Statistics visualizations
R
9
star
9

RShiny-PowerToChoose

R Shiny application: Power to Choose electricity plans
R
9
star
10

RShiny-BoxOfficeMojo

R Shiny application: Box Office Mojo Visualizations
R
8
star
11

wordcloud-generator

Create and share wordcloud visualizations!
JavaScript
8
star
12

react-3d-globe

[DEPRECATED] React ThreeJS Globe
JavaScript
8
star
13

hackjs

Functional programs for hacking in node
JavaScript
6
star
14

io

Imprinting myself digitally on the web, one commit at a time.
JavaScript
4
star
15

RShiny-StateCrimeRates

R Shiny application: State Crime Rates Vsualizations
R
4
star
16

noodles

Making Chinese homemade noodles
3
star
17

quotes

A simple UI built around quotes written in markdown
JavaScript
3
star
18

ui

Simple progressive design system and documentation for personal projects.
JavaScript
3
star
19

datanaut.io

datanaut.io - chrisrzhou's data blog
HTML
2
star
20

ctf

hacking fun
2
star
21

dear-rajiv

2
star
22

d2cube-mirror

A mirror of d2cube/d2cube for serving the NextJS app
JavaScript
2
star
23

dev

My development setup
Vim Script
2
star
24

dev-2020

My developer journey leading up to 2020
JavaScript
2
star
25

init-js

A simple config-driven CLI to initialize JS projects.
JavaScript
2
star
26

unverse

A personal collection of writings and meditations in the Unverse
2
star
27

cypress-code-coverage-issue-472

Bug repro for issue #472
JavaScript
1
star
28

chris-and-monika

Chris + Monika's wedding page!
JavaScript
1
star