Yoctol/react-d3-cloud

Name: react-d3-cloud

Owner: YOCTOL INFO INC.

Description: A word cloud react component built with d3-cloud.

Created: 2016-08-05 08:01:59.0

Updated: 2018-01-18 01:09:57.0

Pushed: 2017-12-29 17:09:52.0

Homepage: https://yoctol.github.io/react-d3-cloud

Size: 377

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits
??? Wu, Dung-Ie2017-02-24 15:07:47.07
C. T. Lin2017-01-20 03:11:16.024
Po-Hsien Chu2018-02-05 11:21:20.0115
Andy C2017-04-19 18:54:17.03
Greenkeeper2017-05-16 20:07:56.022
hilb-aibod2017-08-04 01:20:51.01

Other Committers

UserEmailMost Recent Commit# Commits
Bruno Rodriguesbrodrigues@eckert-caine.com2017-12-29 17:09:39.04

README

react-d3-cloud

NPM version Build Status Dependency Status

A word cloud react component built with d3-cloud.

image

Usage
install react-d3-cloud
sx
rt React from 'react';
rt { render } from 'react-dom';
rt WordCloud from 'react-d3-cloud';

t data = [
text: 'Hey', value: 1000 },
text: 'lol', value: 200 },
text: 'first impression', value: 800 },
text: 'very cool', value: 1000000 },
text: 'duck', value: 10 },


t fontSizeMapper = word => Math.log2(word.value) * 5;
t rotate = word => word.value % 360;

er(
ordCloud
data={data}
fontSizeMapper={fontSizeMapper}
rotate={rotate}
,
cument.getElementById('root')

Please checkout demo

for more detailed props, please refer to below:

Props

name | description | type | required | default —–|————-|——|———-|——– data | The input data for rendering | Array<{ text: string, value: number }> | ? | width | Width of component (px) | number | | 700 height | Height of component (px) | number | | 600 fontSizeMapper | Map each element of data to font size (px) | Function: (word: string, idx: number): number | | word => word.value; rotate | Map each element of data to font rotation degree. Or simply provide a number for global rotation. (degree) | Function \| number | | 0 padding | Map each element of data to font padding. Or simply provide a number for global padding. (px) | Function \| number | | 5 font | The font of text shown | Function \| string | | serif onWordClick | Function called when clicking in a word | Function: word => onWordClick(word) | | console.log(word)

Build
run build
Test
pre-install
 apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
install
Run test
test
License

MIT © Yoctol


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.