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

vue-wordcloud

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-wordcloud

A Vue.js Word Cloud component

  • 1.1.1
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
568
decreased by-13.15%
Maintainers
1
Weekly downloads
 
Created
Source

vue-wordcloud

A Vue.js Word Cloud component based on the original d3-cloud plugin.

What's New?

V1.1 Nov 25, 2018:

  • Fix #6 add showTooltip option
  • Fix #5 add support for custom color scales

V1.0.2 Aug 12, 2017:

  • Additional font scale options
  • Easy to use rotation setting

For details please refer to options.

Install

npm install vue-wordcloud

Import

import wordcloud from 'vue-wordcloud'

Examples

Using D3 color scheme Category10:

Word Cloud Example

Using single color of your choice, e.g. ['#1f77b4']:

Word Cloud Example

Using single-hue color of your choice, e.g. ['#1f77b4', '#629fc9', '#94bedb', '#c9e0ef']:

Word Cloud Example

Code:

<template>
  <div id="app">
      <wordcloud
      :data="defaultWords"
      nameKey="name"
      valueKey="value"
      :color="myColors"
      :showTooltip="true"
      :wordClick="wordClickHandler">
      </wordcloud>
  </div>
</template>

<script>
import wordcloud from 'vue-wordcloud'

export default {
  name: 'app',
  components: {
    wordcloud
  },
  methods: {
    wordClickHandler(name, value, vm) {
      console.log('wordClickHandler', name, value, vm);
    }
  },
  data() {
    return {
      myColors: ['#1f77b4', '#629fc9', '#94bedb', '#c9e0ef'],
      defaultWords: [{
          "name": "Cat",
          "value": 26
        },
        {
          "name": "fish",
          "value": 19
        },
        {
          "name": "things",
          "value": 18
        },
        {
          "name": "look",
          "value": 16
        },
        {
          "name": "two",
          "value": 15
        },
        {
          "name": "fun",
          "value": 9
        },
        {
          "name": "know",
          "value": 9
        },
        {
          "name": "good",
          "value": 9
        },
        {
          "name": "play",
          "value": 6
        }
      ]
    }
  }
}
</script>

For using D3 categorical color schemes:

<template>
  <div id="app">
      <wordcloud
      :data="defaultWords"
      nameKey="name"
      valueKey="value"
      color="Accent">
      </wordcloud>
  </div>
</template>

Options

选项简介默认值说明
data词云文本数据defaultWords数据格式:数组。数组中每个元素是对象{ 词:数值 }
nameKey数据中表示要显示的词的字段名称'name'-
valueKey数据中表示词的权重的字段名称'value'-
margin图表外边矩{top: 15, right: 15, bottom: 15, left: 15 }-
wordPadding词间间距3-
rotate词的旋转角度{from: -60, to: 60, numOfOrientation: 5 }可设置角度范围及角度的个数
spiral词的布局方式'archimedian'可选择'archimedian'或'rectangular'
fontScale词的大小缩放比例'sqrt'可选择'sqrt','log'或'n'
fontSize词的字号范围[10, 80][minSize, maxSize]
font词的字体名称,对应 font-family 的值"impact"例如,衬线字体'serif',非衬线字体'Arial'
color配色集合,可配置两种类型的值:String (D3 scheme name),或 Array(自定义的颜色列表)'Category10'可采用D3内置的任意 Category 配色,或自定义的颜色列表;单色可通过传入只有一个颜色的数组实现,详见 examples
showTooltip显示 Tooltiptruetrue/false; tooltip 的样式(如宽高、颜色等)可以通过 CSS 类 div.tooltip 配置
wordClick词的点击事件的回调函数null函数传入三个变量,第一个是点击的词 text,第二个是该词对应的权重 value,第三个是 Vue 实例 vm

Todo

  • minimize component
  • add formatter option for tooltip
  • support D3 V5

FAQs

Package last updated on 25 Nov 2018

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