View on GitHub

d3-easy

download .ZIPdownload .TGZ

Generate WordCloud

EasyWordCloud is the easiest way to create beautiful word cloud for all of your projects. You don't need to install anything complicated. Just load the js files and call one function. That's it!!

Preparation

How to use

Below is the simplest case, but be careful. EasyWordCloud uses the svg class name as an identifier. If you do not give name to your svg, easywordcloud automatically think all "svg" as wordcluod canvas. So, it may updates or destroy the other svgs. I recommend to name it. Also, when you wanna create another wordcloud at same time, they should be named separately. Do not give them same names.

// simple example

$().ready(function(){

    data = [
        {"text": "田中", "value": 3}, 
        {"text": "太郎", "value": 13}, 
        {"text": "西尾", "value": 8},
    ]
    
    var href_func = function(d){ return "#" + d.text }
    window.makeWordCloud(data, href_func, "body", 200)

})

With more options

// more option example

$().ready(function(){

    data = [
        {"text": "田中", "value": 3}, 
        {"text": "太郎", "value": 13}, 
        {"text": "西尾", "value": 8},
    ]

    var my_color = d3.scale.category20();
    var href_func = function(d){ return "#" + d.text }

    window.makeWordCloud(data, href_func, "body", 500, "my_svg", "Impact", true, my_color)

})

Parameters Format

ParameterMust Or NotType of FormatExample
DataMust[ {"text": String, "value": Number}, {...}, {...} ][ {"text": "田中", "value": 3}, {"text": "太郎", "value": 13}, {"text": "西尾", "value": 8}, ]
Href FunctionMustStringfunction(d){ return "#" + d.text }
Css SelectorMustfunction(each data){ return string that represents url }"#my_id_dom", ".my_class_dom"
Svg ScaleMustNumber500
Svg Class NameOptionalstring but not css selector"my_dom"
Font FamilyOptionalString"Impact"
Rotate Words Or NotOptionalBooleantrue, false
Color Converting FunctionOptionalfunction(number){ return some color code as string; }function MyColoring(i){ if(i > 0){ return "#696969"; }else{ return "#f0f8ff"; }

For More Details

To see whole the example, please check out demo.html and demo.js