npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tagcloud

v1.1.0-1

Published

A simple tag cloud library.

Downloads

797

Readme

TagCloud jQuery plugin

A dynamic JavaScript tag/keyword cloud plugin for jQuery, designed to use with Ajax: the cloud is generated from an array.

MIT license.

  • Original: Schaffer Krisztián: http://woophoo.com
  • Updated: Tim Groeneveld: http://timg.ws

Usage:

Basic Usage example.

Call it on a jQuery object created from one element and pass an array of objects with "tag" and "count" attributes.

    var tags = [
    {
        tag: "computers",
        count: 56
    }, {
        tag: "mobile",
        count :12
    }, ... ];

    $("#tagcloud").tagCloud(tags);

Advanced usage example

Similar to the Basic Usage, you could perform an AJAX request, and with the response, then build a tag cloud.

    $.ajax('http://example.org/the-tagcloud/').done(function(response)) {
        $("#tagcloud").tagCloud(response.tags, {
            click: function(tag, e) {
                alert("You just clicked on: " + tag);
            },
            min: response.min,
            max: response.max
        });
    });

In this example, min & max are calculated inside the JSON data.

Configuration:

You can pass a configuration object to tagCloud as the second parameter.

Configuration Settings:

Allowed settings are:

  • sort: Comparator function used for sort the tags before displaying, or false if no sorting needed.

default: sort by tag text using

      function (a, b) {return a.tag < b.tag ? -1 : (a.tag == b.tag ? 0 : 1)
  • click: Event handler which receives the tag name as first parameter and the original click event as second. The preventDefault() is called on event before passing so don't bother.

default: does nothing:

      function(tag, event) {}
  • maxFontSizeEm: Size of the largest tag in the cloud in css 'em'. The smallest one's size is 1em so this value is the ratio of the smallest and largest sizes.

default: 4

  • template: The template that is used to generate a link. Allows different variables.

  • tag: The tag provided in the tags object

  • count: The number of times that the tag appears

  • size: The relative size of the tag (in em)

  • data: object containing data that should be added to all of the links.

Default link template

<a href="{href}" class="tagcloudlink" style="font-size: {size}em">{tag}</a>

Styling:

By default, the plugin adds the "tagcloudlink" class to the generated tag links. Note that an "&nbsp;" is generated between the links too. You can change the style by modifying the template that is used to generate the links.

Originally based on DynaCloud v3 by Johann Burkard http://johannburkard.de mailto:[email protected]

CHANGES:

  • 9 march 2015 (Tim Groeneveld) ** Prepare repository for adding to jQuery Plugin Repository
  • 16 july 2014 (Tim Groeneveld) ** Allow the link layout to be changed with the "template" option.
  • 15 july 2014 (Tim Groeneveld) ** Add the ability to set max & min and not have tag cloud calculate values. ** Improved documentation a little.
  • 05 sept. 2008 (Schaffer Krisztián) ** Improved normalization algorithm - better looking font sizes ** New settings: click, maxFontSizeEm ** Documentation
  • 04 sept. 2008 (Schaffer Krisztián) ** Initial version