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

vue3-word-cloud

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-word-cloud

Generates a cloud out of the words.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
57
decreased by-64.81%
Maintainers
1
Weekly downloads
 
Created
Source

Vue3 Word Cloud

Generates a cloud out of the words.

Support Vue 3

demo

Try it out!

setup

npm

npm i vue3-word-cloud

ES module

Register the component globally.

import Vue from 'vue';
import Vue3WordCloud from 'vue3-word-cloud';

Vue.component(Vue3WordCloud.name, VueWordCloud);

or

Register the component in the scope of another component.

import Vue3WordCloud from 'vue3-word-cloud';

export default {
  components: {
    [Vue3WordCloud.name]: Vue3WordCloud,
  },
};

usage

<vue3-word-cloud
  style="
    height: 480px;
    width: 640px;
  "
  :words="[['romance', 19], ['horror', 3], ['fantasy', 7], ['adventure', 3]]"
  :color="([, weight]) => weight > 10 ? 'DeepPink' : weight > 5 ? 'RoyalBlue' : 'Indigo'"
  font-family="Roboto"
/>

Pass custom renderer for the words.

<vue3-word-cloud :words="words">
  <template slot-scope="{text, weight, word}">
    <div :title="weight" style="cursor: pointer;" @click="onWordClick(word)">
      {{ text }}
    </div>
  </template>
</vue3-word-cloud>

properties

propertytypedefaultdescription
animation-durationNumber1000The duration of the animation.
animation-easingString'ease'The easing of the animation.
animation-overlapNumber1The overlap of the animation. Set the value to 1 to animate words all at once. Set the value to 0 to animate words one by one. The value 5 has the same effect as the value 1/5.
color[String, Function]'Black'The default color for each word.
create-canvasFunction*Creates a new Canvas instance.
create-workerFunction*Creates a new Worker instance.
enter-animation[Object, String]*The enter animation.
font-family[String, Function]'serif'The default font family for each word.
font-size-ratioNumber0The font size ratio between the words. For example, if the value is 5, then the largest word will be 5 times larger than the smallest one. The value 5 has the same effect as the value 1/5.
font-style[String, Function]'normal'The default font style for each word.
font-variant[String, Function]'normal'The default font variant for each word.
font-weight[String, Function]'normal'The default font weight for each word.
leave-animation[Object, String]*The leave animation.
load-fontFunction*Loads the font.
rotation-unit[String, Function]'turn'The default rotation unit for each word. Possible values are 'turn', 'deg' and 'rad'.
rotation[Number, Function]0The default rotation for each word.
spacingNumber0The spacing between the words. The value is relative to the font size.
text[String, Function]''The default text for each word.
weight[Number, Function]1The default weight for each word.
wordsArray[]The words to place into the cloud. A value of the array could be either an object, an array or a string.
If the value is an object, it will be resolved to {text, weight, rotation, rotationUnit, fontFamily, fontStyle, fontVariant, fontWeight, color}.
If the value is an array, it will be resolved to [text, weight].
If the value is a string, it will be resolved to text.

let enterAnimation = {opacity: 0};
let leaveAnimation = {opacity: 0};

Make more complex animations.

let enterAnimation = {
  opacity: 0,
  transform: 'scale3d(0.3,0.3,0.3)'
};

Use classes for CSS animations.

let enterAnimation = 'animated bounceIn';
let leaveAnimation = 'animated hinge';

let createCanvas = function() {
  return document.createElement('canvas');
};

let loadFont = function(fontFamily, fontStyle, fontWeight, text) {
  return document.fonts.load([fontStyle, fontWeight, '1px', fontFamily].join(' '), text);
};

Provide custom loadFont function to support older browsers.

import FontFaceObserver from 'fontfaceobserver';

let loadFont = function(family, style, weight, text) {
  return (new FontFaceObserver(family, {style, weight})).load(text);
};

let createWorker = function(code) {
  return new Worker(URL.createObjectURL(new Blob([code])));
};

events

eventdescription
update:progressThe current progress of the cloud words computation.

Keywords

FAQs

Package last updated on 12 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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