GithubHelp home page GithubHelp logo

chanified / d3-wordcloud Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wvengen/d3-wordcloud

0.0 2.0 0.0 327 KB

Plug-and-play wordcloud with D3

License: MIT License

JavaScript 96.96% HTML 3.04%

d3-wordcloud's Introduction

Easy Word Cloud using D3

There is an amazing D3 wordcloud plugin for creating beautiful wordclouds. But it's not trivial for everyone to put it to use. This plugin makes it easy to create such a wordcloud.

Usage

A simple html page with a wordcloud might contain:

<html>
  <head>
    <title>Word Cloud</title>
    <script src="lib/d3/d3.js"></script>
    <script src="lib/d3/d3.layout.cloud.js"></script>
    <script src="d3.wordcloud.js"></script>
  </head>
  <body>
    <div id='cloud'></div>
    <script>
      d3.wordcloud()
        .size([800, 400])
        .selector('#cloud')
        .words([{text: 'word', size: 5}, {text: 'cloud', size: 15}])
        .start();
    </script>
  </body>
</html>

That's all! The following properties are accepted:

  • selector() which css selector to create the wordcloud on
  • element() an element instead of the previous selector
  • scale() a d3 scale for sizing words, e.g. sqrt, log or linear
  • fill() a d3 scale for coloring words, e.g. d3.scale.category20b()
  • transitionDuration() how many milliseconds a resize transation takes

In addition to this, the following d3-cloud properties are accepted:

  • size() dimensions [width, height]
  • words() array of {text: 'word', size: 1} hashes
  • font()
  • fontStyle()
  • fontWeight()
  • spiral(), which can be archimedean or rectangular
  • padding()
  • rotate()

As a bonus, if a word contains a href key, the word will link to the value, and the word will become slightly larger when the mouse hovers over (to indicate that it is clickable, in addition to the mouse hand pointer).

Links

d3-wordcloud's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.