Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wordcloud

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wordcloud - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

8

API.md

@@ -14,3 +14,3 @@ # wordcloud2.js APIs

WordCloud.miniumFontSize
WordCloud.minFontSize

@@ -36,3 +36,7 @@ ## Usage

* `color`: color of the text, can be any CSS color, or a `callback(word, weight, fontSize, distance, theta)` specifies different color for each item in the list.
You may also specify colors with built-in keywords: `random-dark` and `random-light`.
You may also specify colors with built-in keywords: `random-dark` and `random-light`. If this is a DOM cloud, color can also be `null` to disable hardcoding of
color into span elements (allowing you to customize at the class level).
* `classes`: for DOM clouds, allows the user to define the class of the span elements. Can be a normal class string,
applying the same class to every span or a `callback(word, weight, fontSize, distance, theta)` for per-span class definition.
In canvas clouds or if equals `null`, this option has no effect.
* `minSize`: minimum font size to draw on the canvas.

@@ -39,0 +43,0 @@ * `weightFactor`: function to call or number to multiply for `size` of each word in the list.

{
"name": "wordcloud",
"version": "1.0.1",
"version": "1.0.2",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -118,3 +118,3 @@ /*!

// drawing small texts on a canvas and measure it's width.
var miniumFontSize = (function getMiniumFontSize() {
var minFontSize = (function getMinFontSize() {
if (!isSupported) {

@@ -209,2 +209,4 @@ return;

classes: null,
hover: null,

@@ -334,9 +336,12 @@ click: null

var getTextColor;
function random_hsl_color(min, max) {
return 'hsl(' +
(Math.random() * 360).toFixed() + ',' +
(Math.random() * 30 + 70).toFixed() + '%,' +
(Math.random() * (max - min) + min).toFixed() + '%)';
}
switch (settings.color) {
case 'random-dark':
getTextColor = function getRandomDarkColor() {
return 'rgb(' +
Math.floor(Math.random() * 128).toString(10) + ',' +
Math.floor(Math.random() * 128).toString(10) + ',' +
Math.floor(Math.random() * 128).toString(10) + ')';
return random_hsl_color(10, 50);
};

@@ -347,6 +352,3 @@ break;

getTextColor = function getRandomLightColor() {
return 'rgb(' +
Math.floor(Math.random() * 128 + 128).toString(10) + ',' +
Math.floor(Math.random() * 128 + 128).toString(10) + ',' +
Math.floor(Math.random() * 128 + 128).toString(10) + ')';
return random_hsl_color(50, 90);
};

@@ -362,2 +364,8 @@ break;

/* function for getting the classes of the text */
var getTextClasses = null;
if (typeof settings.classes === 'function') {
getTextClasses = settings.classes;
}
/* Interactive */

@@ -368,7 +376,10 @@ var interactive = false;

var getInfoGridFromMouseEvent = function getInfoGridFromMouseEvent(evt) {
var getInfoGridFromMouseTouchEvent =
function getInfoGridFromMouseTouchEvent(evt) {
var canvas = evt.currentTarget;
var rect = canvas.getBoundingClientRect();
var eventX = evt.clientX - rect.left;
var eventY = evt.clientY - rect.top;
var clientX = evt.clientX || evt.touches[0].clientX;
var clientY = evt.clientX || evt.touches[0].clientY;
var eventX = clientX - rect.left;
var eventY = clientY - rect.top;

@@ -382,3 +393,3 @@ var x = Math.floor(eventX * ((canvas.width / rect.width) || 1) / g);

var wordcloudhover = function wordcloudhover(evt) {
var info = getInfoGridFromMouseEvent(evt);
var info = getInfoGridFromMouseTouchEvent(evt);

@@ -401,3 +412,3 @@ if (hovered === info) {

var wordcloudclick = function wordcloudclick(evt) {
var info = getInfoGridFromMouseEvent(evt);
var info = getInfoGridFromMouseTouchEvent(evt);
if (!info) {

@@ -408,2 +419,3 @@ return;

settings.click(info.item, info.dimension, evt);
evt.preventDefault();
};

@@ -485,6 +497,6 @@

var mu = 1;
if (fontSize < miniumFontSize) {
if (fontSize < minFontSize) {
mu = (function calculateScaleFactor() {
var mu = 2;
while (mu * fontSize < miniumFontSize) {
while (mu * fontSize < minFontSize) {
mu += 2;

@@ -676,2 +688,9 @@ }

var classes;
if (getTextClasses) {
classes = getTextClasses(word, weight, fontSize, distance, theta);
} else {
classes = settings.classes;
}
var dimension;

@@ -744,3 +763,2 @@ var bounds = info.bounds;

'height': info.fillTextHeight + 'px',
'color': color,
'lineHeight': fontSize + 'px',

@@ -755,2 +773,5 @@ 'whiteSpace': 'nowrap',

};
if (color) {
styleRules.color = color;
}
span.textContent = word;

@@ -765,2 +786,5 @@ for (var cssProp in styleRules) {

}
if (classes) {
span.className += classes;
}
el.appendChild(span);

@@ -1043,2 +1067,7 @@ }

canvas.addEventListener('click', wordcloudclick);
canvas.addEventListener('touchstart', wordcloudclick);
canvas.addEventListener('touchend', function (e) {
e.preventDefault();
});
canvas.style.webkitTapHighlightColor = 'rgba(0, 0, 0, 0)';
}

@@ -1114,3 +1143,3 @@

WordCloud.isSupported = isSupported;
WordCloud.miniumFontSize = miniumFontSize;
WordCloud.minFontSize = minFontSize;

@@ -1117,0 +1146,0 @@ // Expose the library as an AMD module

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc