0.0.2 • Published 3 years ago

svelte-d3-cloud v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

svelte-d3-cloud

Svelte wrapper for d3-cloud. See Demo

Installation

npm install svelte-d3-cloud

or

yarn add svelte-d3-cloud

Usage

<script>
import WordCloud from "svelte-d3-cloud";

const words = [
    { text: "Halo", count: 100 },
    { text: "Dunia", count: 50 },
    { text: "Gaib", count: 75 },
  ];

</script>

<div>
  <WordCloud words={words}/>
</div>

Props

PropertyDescriptionDefault Value
wordsArray of object contains text and count value [{text : "some", count: 10},...]undefined
widthSet the word cloud canvas width500
heightSet the word cloud canvas height500
backgroundColorSet the canvas background color'#fff'
fontSet the word font family'Impact'
paddingSet the padding of each text10
schemeSet the word cloud text color scheme based on d3-scale-chromatic (schemeCategory10 , schemeAccent, schemeDark2, schemePaired, schemePastel1, schemePastel2, schemeSet1, schemeSet2, schemeSet3, schemeTableau10)'schemeTableau10'
minRotateSet the minimum rotation of the text0
maxRotateSet the maximum rotation of the text0
maxFontSizeSet the maximum font size of the text50

Events

EventDescription
on:clickListen to event when word is clicked
on:mouseoverListen to event when word is hovered
on:mouseoutListen to event when mouse leave the word
on:mousemoveListen to event when mouse move inside the word