Socket
Socket
Sign inDemoInstall

angular13-d3-cloud

Package Overview
Dependencies
20
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular13-d3-cloud

D3 word cloud component for Angular built upon d3-cloud


Version published
Maintainers
1
Weekly downloads
1

Weekly downloads

Readme

Source

Angular D3 Word Cloud

D3 Cloud component for Angular built upon d3-cloud

Installation

npm install --save angular-d3-cloud

Usage

First import the package to your app module

// app.module.ts
import { AngularD3CloudModule } from 'angular-d3-cloud'
@NgModule({
  imports: [
    AngularD3CloudModule
  ],
  ...
})

Now the component is ready to use.

<!-- app.component.html -->
<angular-d3-cloud
  [data]="data"
  [width]="700"
  [height]="600"
  [padding]="5"
  font="serif"
  [rotate]="0"
  [autoFill]="true"
  (wordClick)="onWorkClick($event)"
></angular-d3-cloud>
// app.component.ts
export class AppComponent {
  data = [
    "Hello", "world", "normally", "you", "want", "more", "words",
    "than", "this"].map(function (d) {
      return { text: d, value: 10 + Math.random() * 90};
    })
}

Props

NameDescriptionTypeRequiredDefault
dataThe input data for renderingArray<{ text: string, value: number }>
widthWidth of component (px)number700
heightHeight of component (px)number600
fontSizeMapperMap each element of data to font size (px)Function: (word: string, idx: number): numberword => word.value;
rotateMap each element of data to font rotation degree. Or simply provide a number for global rotation. (degree)Function | number0
paddingMap each element of data to font padding. Or simply provide a number for global padding. (px)Function | number5
fontThe font of text shownFunction | stringserif
autoFillWhether texts should be fill with random color or notbooleanfalse
fillMapperFunction used by autoFill to map each data item to a fill color. Can be used to customize the way autoFill generate colorsFunction: (word: Word, index: number): stringA function based on schemeCategory10 of d3-scale-chromatic
animationsWhether animated transitions is active or notbooleanfalse

Events

NameDescriptionPayload
wordClickEvent triggered when click event triggered on a word{ event: MouseEvent, word: Word }
wordMouseOverEvent triggered when mouseover event triggered on a word{ event: MouseEvent, word: Word }
wordMouseOutEvent triggered when mouseout event triggered on a word{ event: MouseEvent, word: Word }

The Word interface imported from d3-cloud

Example

Run the following commands to start sample project:

ng build angular-d3-cloud --watch
npm start # in a separate terminal

Thanks

This project is built with the idea of React D3 Cloud

Keywords

FAQs

Last updated on 11 Aug 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc