Giter Club home page Giter Club logo

angular-tag-cloud-module's Introduction

angular-tag-cloud-module

All Contributors

Buy Me A Coffee

npm npm PRs Welcome Open Source Love Demo at GH-Pages

npm npm npm npm

With this module you can generate word clouds / tag clouds. The module requires a peer dependency to angular/core >= Version 6.0.0.

The project is based on angular-tag-cloud which provides a tag cloud for Angular 1.X.X applications.

TagCloud

Demo

Check out the demo page to play around with the options: https://d-koppenhagen.github.io/angular-tag-cloud-module/

Version and compability

Version Angular Version Compability
2.6.0 and below between ^4.0.0 and ^5.X.X
3.8.2 and below between ^6.0.0 and ^8.X.X
4.2.0 and below ^9.0.0
5.0.0 and greater ^10.0.0 and greater
6.0.0 and greater ^12.0.0 and greater
13.0.0 and greater ^13.0.0 and greater
14.0.0 and greater ^14.0.0 and greater
15.0.0 and greater ^15.0.0 and greater
16.0.0 and greater ^16.0.0 and greater
17.0.0 and greater ^17.0.0 and greater

Install

To install the module just run the following command on your CLI:

npm install --save angular-tag-cloud-module
# or: npm install --save angular-tag-cloud-module

Or if you use yarn:

yarn add angular-tag-cloud-module
# or yarn add angular-tag-cloud-module

Full Documentation

For having a look at the full documentation clone this repo to your local disk first. Then navigate in the directory and run npm run doc via console (probably you have to install the nodejs dependencies before: npm install). The documentation can be accessed in your browser: localhost:8080.

Usage

  1. Import the module into your Angular-NgModule:
// app.module.ts
import { TagCloudComponent } from 'angular-tag-cloud-module';

@NgModule({
  imports: [
    TagCloudComponent
  ]
})
export class AppModule { }
  1. Setup the cloud:
import { Component } from '@angular/core';
import { CloudData, CloudOptions } from 'angular-tag-cloud-module';

@Component({
  selector: 'my-component',
  template: `
    <div>
      <angular-tag-cloud
        [data]="data"
        [width]="options.width"
        [height]="options.height"
        [overflow]="options.overflow">
      </angular-tag-cloud>
    </div>
  `
})
export class AppComponent {
  options: CloudOptions = {
    // if width is between 0 and 1 it will be set to the width of the upper element multiplied by the value
    width: 1000,
    // if height is between 0 and 1 it will be set to the height of the upper element multiplied by the value
    height: 400,
    overflow: false,
  };

  data: CloudData[] = [
    {text: 'Weight-8-link-color', weight: 8, link: 'https://google.com', color: '#ffaaee'},
    {text: 'Weight-10-link', weight: 10, link: 'https://google.com', tooltip: 'display a tooltip'},
    // ...
  ];
}

You can either pass configuration properties as an Input (As shown in the example above) or pass a an object described by the CloudOptions-Interface using the config property as shown below.

<angular-tag-cloud [config]="options" [data]="data"></angular-tag-cloud>

You can use one of the following HTML-Tags for the tag cloud in your template:

  • <angular-tag-cloud ...></angular-tag-cloud>
  • <ng-tag-cloud ...></ng-tag-cloud>
  • <ngtc ...></ngtc>

Please keep this in mind, that the weight property defines the relative importance of the word (such as the number of occurrencies, etc.). The range of values is arbitrary, and they will be linearly mapped to a discrete scale from 1 to 10. In fact passing just one word to the array has the effect that this is relative to other elements. As there aren't any other elements in that case it's result is that the element becomes a container with the class w5 - right in the middle of the discret scale. So the given value for weight is not directly mapped to the CSS-class. For example you can use also a value like 123 or 34 - it will always be mapped to a scale from 1 to 10 relativly to the other array elements. If you don't want that the tag cloud is calculating the values manually, set the strict property to true and use integer values 1 to 10 within the weight property. If you want the tag cloud to randomly generate an angle for each entry (when it is undefined), set randomizeAngle property to true. The step property defines the steps which will be added for the next cloud element to check during calculation. The calculation starts somewhere in the middle of the canvas. The steps will be increased by the given value like a spiral to the outer canvas area. When the algorithm detects that there is space for the current element, it will be added to the cloud. A lower value for the step attribute is more granular and precisely but needs also more time and processing power during the cloud creation.

Check out the demo-Folder for a complete example

Example: Rotate some elements

If you want to rotate some CloudData elements, you can specify a numeric value for rotation within the rotate-Attribute:

import { Component } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data"></angular-tag-cloud>
  `
})
export class AppComponent {

  data: CloudData[] = [
    { text: 'weight-5-rotate(+10)', weight: 5, rotate: 10 }
    { text: 'weight-7-rotate(-20)', weight: 7, rotate: -20 }
    { text: 'weight-9-rotate(+35)', weight: 9, rotate: 35 }
    // ...
  ];
}

Example: Zoom elements on hover

You can specify the zoomOnHover property with an object that defines the zoom level (scale) and optionally a time for the transition (transitionTime):

import { Component } from '@angular/core';
import { CloudData, ZoomOnHoverOptions } from 'angular-tag-cloud-module';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data" [zoomOnHover]="zoomOnHoverOptions"></angular-tag-cloud>
  `
})
export class AppComponent {
  zoomOnHoverOptions: ZoomOnHoverOptions = {
    scale: 1.3, // Elements will become 130 % of current zize on hover
    transitionTime: 1.2, // it will take 1.2 seconds until the zoom level defined in scale property has been reached
    delay: 0.8 // Zoom will take affect after 0.8 seconds
  };

  data: CloudData[] = [
    { text: 'weight-5', weight: 5 }
    { text: 'weight-7', weight: 7 }
    { text: 'weight-9', weight: 9 }
    // ...
  ];
}

Example: Changing Data after initializing

If you want to change the data after initializing it (e.g. when fetching the data from a backend), you have to pass a new CloudData[] into the component so that it can detect the changes:

import { Component } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';
import { Observable, of } from 'rxjs';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data"></angular-tag-cloud>
    <button (click)="newData()">Get new Data from Observable</button>
  `
})
export class AppComponent {

  data: CloudData[] = [
    { text: 'Initial Data weight-10', weight: 10 }
    // ...
  ];

  newData(){
    const changedData$: Observable<CloudData[]> = of([
      { text: 'Weight-3', weight: 3 },
      // ...
    ]);
    changedData$.subscribe(res => this.data = res);
  }
}

Example: Detect the clicked item

Angular-Tag-Cloud emits an event as soon as an item is clicked.

import { Component } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud
      [data]="data"
      (clicked)="logClicked($event)">
    </angular-tag-cloud>
  `
})
export class AppComponent {

  data: CloudData[] = [
    { text: 'Initial Data weight-10', weight: 10 }
    // ...
  ];

  logClicked(clicked: CloudData){
    console.log(clicked);
  }
}

Example: Using fixed weight values / strict binding of weigth through HTML class

The weight property defines by default the relative importance of the word (such as the number of occurrencies, etc.). The range of values is arbitrary, and they will be linearly mapped to a discrete scale from 1 to 10. This cuases that e.g. passing just one word to the array has the effect that this is relative to other elements. As there aren't any other elements in that case it's result is that the element becomes a container with the class w5 - right in the middle of the discret scale. If you don't want that the tag cloud is calculating the values manually, set the strict property to true and use integer values 1 to 10 within the weight property.

import { Component } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data" [strict]="true"></angular-tag-cloud>
  `
})
export class AppComponent {

  data: CloudData[] = [
    // HTML-Element will have class 8:
    { text: 'Weight-8', weight: 8 },
    // HTML-Element will have class 10 as 10 is the max. value in strict mode:
    { text: 'Weight-12 -> Weight-10', weight: 12 },
    // HTML-Element will have class 1 as 1 is the min. value in strict mode:
    { text: 'Weight-0 -> Weight-1', weight: 0 },
    // HTML-Element will have class 4 as floats are rounded to an int in strict mode:
    { text: 'Weight-4.3 -> Weight-4', weight: 4.3 },
    // ...
  ];
}

Example: Redraw the cloud

You can trigger the tag cloud to be redrawn by running the method reDraw(). This can be useful if e.g. the boundaries of the upper container are changing and you wanna re-order the words to fit into the container.

import { Component, ViewChild } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';
import { TagCloudComponent } from './tag-cloud-module/tag-cloud.component';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data"></angular-tag-cloud>
    <button (click)="reDraw()">Re-draw</button>
  `
})
export class AppComponent {
  @ViewChild(TagCloudComponent) tagCloudComponent: TagCloudComponent;

  data: CloudData[] = [
    { text: 'Weight-8', weight: 8 },
    // ...
  ];

  reDraw() {
    this.tagCloudComponent.reDraw();
  }
}

Example: Place words on fixed position

You can force that words are placed on a specific position by defining the position property for a word. The word won't be placed anymore randomly but at the defined position. Keep in mind that the x and y values must be withing the proportions of the tag cloud.

import { Component, ViewChild } from '@angular/core';
import { CloudData } from 'angular-tag-cloud-module';
import { TagCloudComponent } from './tag-cloud-module/tag-cloud.component';

@Component({
  selector: 'my-component',
  template: `
    <angular-tag-cloud [data]="data"></angular-tag-cloud>
  `
})
export class AppComponent {
  @ViewChild(TagCloudComponent) tagCloudComponent: TagCloudComponent;

  data: CloudData[] = [
    { text: 'Weight-8-fixed', weight: 8, position: { left: 20, top: 30 } },
    { text: 'Weight-8-random', weight: 8 },
    // ...
  ];
}

Using a custom Stylesheet

You can adjust the style for the component. Please read the Wiki article and follow the instructions.

Note that you have to set the class attribute in order for the custom css class to be applied, e.g. :

<angular-tag-cloud [config]="options" [data]="data" [class.custom-css]='true'></angular-tag-cloud>

TagCloud with custom stylesheet

Place data on fixed positions

You can access the component property cloudDataHtmlElements to set / override the final placements for the HTML Elements inside the word cloud.

Options

The HTML-selector <angular-tag-cloud> can/must have the following inputs:

Input Type default value mandatory
config CloudOptions See other default params no
data CloudData[] yes
width number (*) 500 no
height number (*) 300 no
step number 2.0 no
overflow boolean true no
strict boolean false no
delay number null no
zoomOnHover ZoomOnHoverOptions { scale: 1, transitionTime: 0, delay: 0, color: null } no
realignOnResize boolean false no
randomizeAngle boolean false no
font string (CSS font) no
background string (CSS background) no
log 'warn' / 'debug' / false false no

(*) if the value is between 0 and 1, it will be set to the size (width or height respectively) of the upper element multiplied by the value. Setting the value > 1 it will be set the size (width or height respectively) to the appropriate value in Pixel (px).

data-Array elements can/must have the following attributes:

name Type default value mandatory
text string null
weight number 5 no
link string no
external boolean false (only has relevance if link was set) no
color string (CSS color) (a shade of blue, depends on the weight) no
rotate number 0 no
tooltip string no
position { left: number, top: number } no

Also the element can have the following output:

Input Event Return Type default value mandatory Description
clicked CloudData - no Returns the clicked CloudData-Object
dataChanges SimpleChanges from @angular/common - no Returns an SimpleChanges-Object which gives you access to the previous and current values
afterInit - - no Fires after the View was initilized
afterChecked - - no Fires after the View was checked

You can also call the method reDraw() to force the cloud data to be re-drawn:

@ViewChild(TagCloudComponent, { static: false }) child: TagCloudComponent;
...
child.redraw();

Development

For development see README.dev.md

Contributors ✨

Thanks goes to these wonderful people (emoji key):

gaeljaffre
gaeljaffre

🐛
sweinbach
sweinbach

💻
AndreasFroelich
AndreasFroelich

🐛
Gregor Woiwode
Gregor Woiwode

📖
Ray Soto
Ray Soto

🐛
Ignacio Peletier
Ignacio Peletier

🐛
Shruti Bidada
Shruti Bidada

💻
Tuhin Karmakar
Tuhin Karmakar

💻
lkirby1266
lkirby1266

💻
hqjb91
hqjb91

📖
Sheik Althaf
Sheik Althaf

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

angular-tag-cloud-module's People

Contributors

afm497 avatar allcontributors[bot] avatar andreasibm avatar d-koppenhagen avatar gaeljaffre avatar gregonnet avatar hqjb91 avatar oobayly avatar sheikalthaf avatar shrutibidada avatar sorkanius avatar spongyt avatar sweinbach avatar tuhinkarmakar avatar v-jiepeng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

angular-tag-cloud-module's Issues

newData() - detecting data changes

I wanted to change tags color on click.
Passing to newData() an array of 30+ length causes a significant delay. Is there a better way to quickly refresh the tags Array ?
Thanks

weight property not overwriting default of w5 and doesn't reflect what I pass into Array<CloudData>

Hi,
If I pass only one item into the Array it will not overwrite the default weight of 5.
eg.
{ text: 'Weight-10-link-color', weight: 8, link: 'https://google.com', color: '#ffaaee' }.
When I inspect the element it will show 'w5'.

If I pass in:
{ text: 'Weight-10-link-color', weight: 8, link: 'https://google.com', color: '#ffaaee' },
{ text: 'Weight-10-link', weight: 10, link: 'https://google.com' }
and then inspect element it has the class of 'w10' against 'Weight-10-link'
and 'w1' against 'Weight-10-link-color'.

Setting the weight property does not seem to be reliable? Could you please assist with an explanation on how to reliably control the weight of the words.

Thanks!

Support Angular 7

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here

Right now [email protected] requires peer deps of angular/core, compiler, common, platform-browser, platform-browser-dynamic@^6.0.0, it should support ^7.0.0.

Add an input for delayed mode

The delayed mode should specify a value which defines the delay time (in miliseconds). if the values is set to false or if it isn't provided there should be no delay (default value = false).

The value should cause a delay for adding each word with the given specified time.

wrong width applied on refresh when multiple word cloud used in different div elements

I tried to create 3 word cloud elements in different div tags. when my width=1 and i do a reload on screen the parent elements complete width of screen is taken in to consideration with bootstrap.

Fix would be after re calculating the width render it in ngOnChanges
//add the below two lines
this.renderer.setElementStyle(this.el.nativeElement, 'width', this.options.width + 'px');
this.renderer.setElementStyle(this.el.nativeElement, 'height', this.options.height + 'px');

// draw the cloud
this.drawWordCloud();
this would update the DOM with the new proper widths.

Integration Issue with Ionic 4 and Angular 8 (Resolved)

I have a blank Ionic 4/Angular 8 app and try to integrate this package into the app, but getting the below error. I have no issues getting this module to work with standalone Angular 7 and 8 apps. So it must be Ionic that causes the error.

ERROR Error: Uncaught (in promise): Error: Template parse errors:
Can't bind to 'data' since it isn't a known property of 'angular-tag-cloud'.
1. If 'angular-tag-cloud' is an Angular component and it has 'data' input, then verify that it is part of this module.
2. If 'angular-tag-cloud' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("
    <div>
        <angular-tag-cloud [ERROR ->][data]="data" [width]="options.width" [height]="options.height" [overflow]="options.overflow"
       "): ng:///HomePageModule/HomePage.html@17:27

Any help is greatly appreciated.

NPM: 6.13.4
Node: 10.18.0
Angular CLI: 7.3.9
Angular: 8.1.2
Ionic 4.x.x
Ionic CLI 5.4.13
"@ionic/angular": "^4.7.1"
angular-tag-cloud-module version: 3.8.1

See attached package.txt file for all deps.
package.txt

Feature request - Tooltip on hover

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here

Hi,

After a recent talk with Mr. Koppenhagen about a minor feature request, he stated that I should make a Gihub-Issue.

The request is actually simple (for you guys), but for me it's quite harder to implement as I'm fairly new to the angular2 and typescript space. I do wish to learn though. So, in future I would wish to know how I can contribute myself and create a pull request.

The feature request:

  • Adding a tooltip on top of each word which only shows when we are hovering on top of it.
    (default disabled)

This would mean to add a new string entry in the interface CloudData.
And another EventEmitter in the class WordCloudComponent.

I have a general idea how, but I lack to implement and make things work on my end. I might be overlooking something fairly simple.

Kind regards!

Angular Tag cloud height responsiveness as datatables

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ x] feature request
[ ] support request => Please do not submit support request here

Current behavior

Expected behavior

Reproduction of the problem

You can for this template which already includes some example code: https://stackblitz.com/edit/angular-tag-cloud-module

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • NodeJS version: x.x.x
  • NPM version version: x.x.x
  • Angular version: 8.x.x
  • Angular-CLI version: 8.x.x
  • angular-tag-cloud-module version: 3.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Support relative width

Currently the tag cloud accepts only number values for setting the width of the cloud container. There should be the possibility to set a percentage value like this:

<angular-tag-cloud [width]="'80%'" [height]="300" [data]="cloudData"></angular-tag-cloud>

Support Angular 6

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here

Right now [email protected] requires a peer of angular/core, common, platform-browser@^5.0.0, it should support ^6.0.0.

Unable to see tooltip

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
I am trying to use "tooltip" but unable to see tag cloud in UI
but If I remove the "tooltip" from the code I am able to see the tag cloud.

temp.component.ts:

import { CloudData, CloudOptions } from 'angular-tag-cloud-module';
optionsNew: CloudOptions = {
    width: 0.98,
    height: 400,
    overflow: false,
    strict:true,
    zoomOnHover: {
      scale: 1.2,
      transitionTime: 0.3,
      delay: .1
    },
    realignOnResize: true

  };
 let temp: CloudData[];[
 {
            "text": "Sample",
            "weight": 10539,
            "tooltip": "10539"
            }]; 

Please tell us about your environment:
OS- Linux mint

  • NodeJS version: 14.16.0

  • NPM version version: 6.14.11

  • Angular version: 10.1.1

  • Angular-CLI version: 10.1.7

  • angular-tag-cloud-module version: 5.3.0

  • Browser: [all | Chrome | Firefox ]

Tooltips are displayed behind other words

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
When tooltips are enabled, some of them are displayed in background, behind the other words, so they are partially hidden.
This bug appears randomly, on half of the words.

Expected behavior

All the tooltips should be displayed in foreground.

Reproduction of the problem

An example can be found here: https://stackblitz.com/edit/angular-tag-cloud-module-xhvv14

It seems that tooltip depth is linked to its corresponding word. So, from a stacking context point of view, if a word is behind another, its tooltip will also be behind.

  • Angular version: 10.x.x
  • Angular-CLI version: 10.x.x
  • angular-tag-cloud-module version: 3.8.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome

A class member cannot be declared optional

Hi,
I'm new at Angular and I'm trying to use this plugin with Angular2 and Webpack but I'm having this error when I import in my module:

node_modules/angular-tag-cloud-module/tag-cloud.component.d.ts:9:9
A class member cannot be declared optional.

What does it mean?

Thank you.

Width < 1 and each Tag element position not working on Version 2.6.0

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
I am using [email protected] in my Angular 5.2.9 project.

  • If I set the width value as a 0.8 or 1, cloud container width is 0.8px or 1px, so I can't any tags.
  • If width is 1000, I can see tags but it has been overlapped
    Actually, I followed the simple usage in the Readme but it doesn't work for me.

Reproduction of the problem

You can for this template which already includes some example code: https://stackblitz.com/edit/angular-sjqdjc

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
OS: MacOS/HighSierra

  • NodeJS version: x.x.x
  • node : 9.9.0
  • NPM version version: x.x.x
    5.6.0

  • Angular version: 5.x.x
    5.2.9

  • Angular-CLI version: 1.x.x
    1.7.3

  • angular-tag-cloud-module version: 2.x.x
    2.6.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome Browser :Version 67.0.3396.99

  • Language: [all | TypeScript X.X | ES6/7 | ES5]
    This is my package.json file.

"dependencies": {
    "@agm/core": "1.0.0-beta.2",
    "@angular/animations": "5.2.9",
    "@angular/cdk": "5.2.4",
    "@angular/cli": "1.7.3",
    "@angular/common": "5.2.9",
    "@angular/compiler": "5.2.9",
    "@angular/compiler-cli": "5.2.9",
    "@angular/core": "5.2.9",
    "@angular/forms": "5.2.9",
    "@angular/http": "5.2.9",
    "@angular/language-service": "5.2.9",
    "@angular/material": "5.2.4",
    "@angular/platform-browser": "5.2.9",
    "@angular/platform-browser-dynamic": "5.2.9",
    "@angular/router": "5.2.9",
    "@ng-bootstrap/ng-bootstrap": "1.0.2",
    "@ng-select/ng-select": "1.5.2",
    "@ngx-loading-bar/router": "1.3.1",
    "@ngx-translate/core": "9.1.1",
    "@ngx-translate/http-loader": "2.0.1",
    "@swimlane/ngx-charts": "7.1.1",
    "@swimlane/ngx-datatable": "11.2.0",
    "angular-calendar": "0.23.7",
    "angular-font-awesome": "^3.1.2",
    "angular-tag-cloud-module": "2.6.0",
    "angular2-text-mask": "8.0.4",
    "bootstrap": "4.0.0",
    "classlist.js": "^1.1.20150312",
    "core-js": "2.5.3",
    "d3": "4.13.0",
    "devextreme": "^18.1.4",
    "devextreme-angular": "^18.1.4",
    "dragula": "3.7.2",
    "font-awesome": "^4.7.0",
    "intl": "^1.2.5",
    "ng2-dragula": "1.5.0",
    "ng2-file-upload": "1.3.0",
    "ng2-validation": "4.2.0",
    "ngx-ui-switch": "^2.1.0",
    "rxjs": "5.5.7",
    "text-mask-addons": "3.7.2",
    "web-animations-js": "2.3.1",
    "zone.js": "0.8.20"
  },
  "devDependencies": {
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }

screen shot 2018-07-18 at 19 16 15

Anchor link styling

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[X] feature request
[ ] support request => Please do not submit support request here

Hi Im looking for a way to shut off the link highlighting and text decoration but I havent had any luck with that. Simply styling anchors in css does not work. Also is there a hover event thats emitted?

Resize without overflow

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here

Current behavior
When a long word has a high weight it is often positioned in such a way to create an overflow within the container

Expected behavior
It should position these words so they are better centered, with all words positioned relative to the w10, currently w10 always appears on the right.

Reproduction of the problem
A word cloud with Professional as w10

What is the motivation / use case for changing the behavior?
A better experience if there is no scrolling on the word cloud

Please tell us about your environment:
Angular version: 5.2.10
Angular-CLI version: 1.6.3
angular-tag-cloud-module version: 2.4.0
Browser: all

Click Event

Is there an options to give the click listener instead of link. so that when there is a click event triggered we can have a listener in the component performing some action

Tag cloud skipping redraw if data array is empty

I'm submitting a ... (check one with "x")

[X ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior

I have a tag cloud that I have updated with some "stuff". In my use case, this is dynamic data and updates in real time. If I set data to an array with elements in it, then clear out the elements at a later time, redraw is skipped leaving all my old / stale data still visible in the component.

relevant lines of code

......
  reDraw(changes?: SimpleChanges) {
    this.dataChanges.emit(changes);
    this._alreadyPlacedWords = [];

    // check if data is not null or empty
    if (!this.data) {
      console.error('angular-tag-cloud: No data passed. Please pass an Array of CloudData');
      return;
    }
    if (this.data.length === 0) {
      console.log('angular-tag-cloud: Empty dataset');
      return;
    }
.......

Expected behavior

If i update data array and it happens to be empty now, where before there was data, I would expect the tag cloud to render with nothing in it.

Reproduction of the problem

You can for this template which already includes some example code: https://stackblitz.com/edit/angular-sjqdjc

What is the motivation / use case for changing the behavior?

Real time data visualization where empty data is acceptable and expected to happen at times.

Please tell us about your environment:

  • NodeJS version: x.x.x
  • NPM version version: x.x.x
  • Angular version: 5.x.x
  • Angular-CLI version: 1.x.x
  • angular-tag-cloud-module version: 2.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
  • Language: [all | TypeScript X.X | ES6/7 | ES5]

allow specifying a specific word position

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x] feature request
[ ] support request => Please do not submit support request here

Current behavior

Expected behavior

Reproduction of the problem

You can for this template which already includes some example code: https://stackblitz.com/edit/angular-tag-cloud-module

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • NodeJS version: x.x.x
  • NPM version version: x.x.x
  • Angular version: 8.x.x
  • Angular-CLI version: 8.x.x
  • angular-tag-cloud-module version: 3.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

ExpressionChangedAfterItHasBeenCheckedError occurring on Angular 5 inside the *ngFor

we are trying to create dynamic tag cloud inside the *ngFor in Angular 5. Initially we have empty object in the for loop after that we changing the empty value into object. We are getting the below error in th console.

ERROR Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: ''. Current value: '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]'.

It does means once we declared the value we are not able to change it. Is it true?

If False then how would can dynamically change the values.

Support Angular 8

Trying to update an Angular 7 project to Angular 8, you get an incompatible peer dependencies error:

Package "angular-tag-cloud-module" has an incompatible peer dependency to "zone.js" (requires "^0.8.26", would install "0.9.1").

Words aligning on top of each other

I'm submitting a ... (check one with "x")

[X] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
afbeelding

Expected behavior
Words not aligning on top of each other for visability

Reproduction of the problem

  1. Use an old Angular 6 project
  2. Get the clouddata from an API call

What is the motivation / use case for changing the behavior?
The text isn't readable when more will be added

Please tell us about your environment:

Intellij, Windows 11

  • NodeJS version: x.x.x
    12.x.x

  • NPM version version: x.x.x
    6.14.16

  • Angular version: 8.x.x
    6.1.10

  • Angular-CLI version: 8.x.x
    1.7.4

  • angular-tag-cloud-module version: 3.x.x
    3.8.2

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Firefox

Feature request: option to draw clouds not randomized

I'm submitting a ...

[ ] bug report => search github for a similar issue or PR before submitting
[X ] feature request
[ ] support request => Please do not submit support request here

Current behavior
The layout of the words in the wordcloud is randomized, so when a wordcloud with the same terms is redrawn, the positions of the words change.

Expected behavior
I would like to have the option to draw non-randomized clouds. It appears to be achievable by adjusting drawWord in tag-cloud.component.ts:

drawWord(index: number, word: CloudData) { // Define the ID attribute of the span that will wrap the word let angle = 6.28 * Math.random(), radius = 0.0, weight = 5, wordSpan: HTMLElement;

Tag Cloud isn't responsive

I'm submitting a ...

[ ] bug report => search github for a similar issue or PR before submitting
[ x ] feature request
[ ] support request => Please do not submit support request here

Current behavior

When its parent container's width changes, the tag cloud doesn't update its size.

Expected behavior

It should resize itself or there should be a way to manually trigger a redraw.

What is the motivation / use case for changing the behavior?

I just need my app to be responsive.

  • Angular version: 5.2.0
  • Angular-CLI version: 1.6.7
  • angular-tag-cloud-module version: 2.4.x
  • Browser: all

Null pointer error when options change but data does not

In our case we have a resize handler that tries to directly set the width and height values in the options object but ngOnChanges looks at the data object whenever it is called. The top of the stack trace is as follows:

ERROR TypeError: changes.data is undefined
Stack trace:
TagCloudComponent.prototype.ngOnChanges@http://localhost:4200/vendor.bundle.js:105457:9
checkAndUpdateDirectiveInline@http://localhost:4200/vendor.bundle.js:10968:9
checkAndUpdateNodeInline@http://localhost:4200/vendor.bundle.js:12349:17
checkAndUpdateNode@http://localhost:4200/vendor.bundle.js:12317:16
debugCheckAndUpdateNode@http://localhost:4200/vendor.bundle.js:12946:38
debugCheckDirectivesFn@http://localhost:4200/vendor.bundle.js:12887:13
View_WidgetTagCloudComponent_0/<@ng:///AppModule/WidgetTagCloudComponent.ngfactory.js:62:5

Looking at the source code:

ngOnChanges(changes: SimpleChanges) {
this.dataArr = changes['data'].currentValue; // this line needs to check for undefined before accessing currentValue

let cloud elements specify html content

The cloud should accepts inputs with a specified html-object. In that case the link-object will be ignored (a you can set it in the given object for html).
For Example:

data = [
  {
    text: 'My Text for this item',
    weight: 10,
    link: 'http://google.de'
    html: {
      element: 'span',
      class: 'my-class my-class-2',
      id: 'custom-el-html',
      attr1: null,
      attr2: 'myValue',
      // ...
    }
  },
  // ...
]

should produce something like this:

<a href="http://google.de">
  <span class="my-class my-class-2"
        id="custom-el-html"
        attr1
        attr2="myValue">
    My Text for this item
  </span>
</a>

infiniteloop issue with Angular 8

Following code is causing an infinite loop

while (this.hitTest(wordSpan)) {
      radius += this.options.step;
      angle += (index % 2 === 0 ? 1 : -1) * this.options.step;

      left = this.options.center.x - (width / 2.0) + (radius * Math.cos(angle)) * this.options.aspectRatio;
      top = this.options.center.y + radius * Math.sin(angle) - (height / 2.0);

      wordStyle.left = left + 'px';
      wordStyle.top = top + 'px';
    }

Angular - 8.0.2
Mac OS - 10.13.4
npm - v6.9.0
node - v10.16.3

Is there a way to change the size and location of tooltip?

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here

Current behavior
tooltip font size is same as word font size, but it is too big and will be blocked if the words are near the edge of the block.

Expected behavior
Be able to change tooltip's size and location

expose alreadyPlacedWords attribute

Thanks for this awesome library! The documentation is very good and its really fun to use! 🤩

Summary

The alreadyPlacedWords attribute is currently set to private which prevents to place words in fixed positions dynamically.

Details

In my current usecase I keep getting new data for the tagcloud which causes the cloud to completely rerender. It would be nice to be able to have alreadyPlacedWords in fixed positions so that they are not redrawn on changes. Only the new words should be placed around the existing ones.

Snippet

Component

  ngOnChanges(changes: SimpleChanges) {
    if (changes.hasOwnProperty('quiz')) {
      // load results
      const currentList = this.quiz.voteOptions[0].wordcloudList || {};
      const currentListLength = Object.keys(currentList).length;
      if (currentListLength > 0) {
        const data: CloudData[] = [];
        const maxCount = Math.max(...Object.values(currentList));
        Object.entries(currentList).map((entry, index) => {
          let [value, count] = entry;
          value = value.toLowerCase();
          data.push({
            text: value,
            weight: this.getWeight(count, maxCount),
            color: this.getColor(index),
            rotate: index % 3 === 0 ? 90 : 0
          });
        });
        this.wordcloudDataSubject.next(this.data);
      }
    }
  }

Template

    <angular-tag-cloud
      #wordCloudComponent
      *ngIf="data.length > 0; else wordcloudPlaceholder"
      [data]="wordCloudData$ | async"
      [width]="wordCloudOptions.width"
      [strict]="wordCloudOptions.strict"
      [realignOnResize]="wordCloudOptions.realignOnResize"
      [overflow]="wordCloudOptions.overflow"
      [delay]="5"
      >
    </angular-tag-cloud>

Critical Issue : JS execution infinite loop that crashes browser tab

I'm submitting a ... (check one with "x")

[x ] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
Critical Issue : (infinite JS execution loop, breaks browser)

If we add a div outside of <angular-tag-cloud></angular-tag-cloud> with display = none, one of the for loops mentioned in belw file fails to exit :

File = projects/angular-tag-cloud-module/src/lib/tag-cloud.component.ts
Line Number = 289

From what it looks like, the function "overlapping" always returns true because the div has a width and height equal to zero (0).

Function in current state (without fix):
`
private overlapping(e1: HTMLElement, e2: HTMLElement) {
const rect1 = e1.getBoundingClientRect();
const rect2 = e2.getBoundingClientRect();

const overlap = !(
  rect1.right < rect2.left ||
  rect1.left > rect2.right ||
  rect1.bottom < rect2.top ||
  rect1.top > rect2.bottom
);
return overlap;

}
`

Suggested fix :
`
private overlapping(e1: HTMLElement, e2: HTMLElement) {
const rect1 = e1.getBoundingClientRect();
const rect2 = e2.getBoundingClientRect();

const overlap = !(
  rect1.right < rect2.left ||
  rect1.left > rect2.right ||
  rect1.bottom < rect2.top ||
  rect1.top > rect2.bottom
);
 return overlap && rect1.clientWidth > 0 && rect2.clientHeight > 0;

}
`

Expected behavior
Even if user add display none property to outside world ( from the point of view of the tag usage ) the library should not get stuck in infinite loop and avoid impact directly on the JS execution thread. Whenever possible try to have retry mechanism in the loops or have a full proof exit mechanism.

Reproduction of the problem

  1. Add a div outside of :
    <angular-tag-cloud></angular-tag-cloud>

  2. give it a display property of "none"

What is the motivation / use case for changing the behavior?
While using media queries ( because we needed to hide the tile for small screens ), we added a display property none to the outside tag whenever it met the screen width. The library code blocked the JS execution in an infinite loop causing the application to crash.

Please tell us about your environment:
It is OS Independent Issue

  • NodeJS version: all
    Independent on node js version
    Screenshot from 2023-06-06 21 56 29

  • NPM version version: 8.19.2
    Npm version independent issue

  • Angular version: 9.0.6
    Independent on angular version issue is with library

  • Angular-CLI version: 9.0.6

  • angular-tag-cloud-module version: 3.8.1
    Still an issue with the latest version ? - Yes

  • Browser:
    All browsers

IE11 doesn't support childNode.remove()

I'm submitting a ... (check one with "x")
[ x] bug report => search github for a similar issue or PR before submitting

Current behavior
In IE11 if the container is too small and it tries to remove words that don't fit it will blow up because IE11 doesn't support childNode.remove()

Expected behavior
It doesn't blow up

Reproduction of the problem
Create a smallish word cloud with 25 words so and set overflow to false

What is the motivation / use case for changing the behavior?
You should support IE11 and add the polyfill https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove

zoomOnHover not working

Hi!
I'm using angular-tag-cloud-module version 4.2.0 and zoomOnHover option is not working.
That’s my html
image
and the component is this one
image

I saw the documentation and I don’t understand why is not working. Thanks for your help

Prod-mode build generates TagCloudModule error

Hi.

I'm trying to generate a prod mode build, and I'm getting the following error through ngc:

Error: Unexpected value 'TagCloudModule in (...)/node_modules/angular-tag-cloud-module/src/app/tag-cloud-module/tag-cloud.module.d.ts' imported by the module 'AppModule in (...)/src/app/app.module.ts'. Please add a @NgModule annotation.

Do you know what this could mean? I don't think it's an error with my project, I think it's with your library. Tried to search google but, as it seens, this error can have a lot of causes.

node -v
v8.9.3
npm -v
5.6.0
"dependencies": {
    "@angular/animations": "5.0.3",
    "@angular/common": "5.0.3",
    "@angular/compiler": "5.0.3",
    "@angular/compiler-cli": "5.0.3",
    "@angular/core": "5.0.3",
    "@angular/forms": "5.0.3",
    "@angular/http": "5.0.3",
    "@angular/platform-browser": "5.0.3",
    "@angular/platform-browser-dynamic": "5.0.3",
    "@angular/platform-server": "5.0.3",
    "@angular/router": "5.0.3"
},
"devDependencies": {
    "@ionic/app-scripts": "3.1.2",
    "ionic": "3.19.0",
    "typescript": "2.6.1"
}

Can't set color of undefined

Trying to use this package in my Angular 2 / bootstrap app (built with webpack if it makes a difference). I am unable to pass in a color value into cloudData as it says

Can't set color on undefined

getting object is possibly undefined error on clicked property

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
When I used (clicked) property with angular-tag-cloud HTML template it gave me error i.e.
error TS2532: Object is possibly 'undefined'.
<angular-tag-cloud [config]="wordOptions" [data]="card.answerData" (clicked)="wordClicked($event)"></angular-tag-cloud>

Expected behavior
It should have directly accepted my click function without any error.

Reproduction of the problem

It is working fine if I try it on here code: https://stackblitz.com/edit/angular-tag-cloud-module

What is the motivation / use case for changing the behavior?
Easier integration of click event

Please tell us about your environment:
IDE - VS Code
OS - Windows

  • NodeJS version: 14

  • Angular version: 12

  • Angular-CLI version: 12
  • angular-tag-cloud-module version: 6.0.0
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

P.S. I was able to fix it by changed strict to false in my tsconfig.js file compilerOptions
also If I changed the clicked?: EventEmitter<CloudData>; to clicked: EventEmitter<CloudData>; in TagCloudComponent class the error was gone.

The browser lags after several data updates

I'm submitting a ... (check one with "x")

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here

Current behavior
When updating the data frequently (total replace, once per second) the browser starts lagging after ~60 updates. This happens because all the old nodes still exist in memory in alreadyPlacedWords, and you can see the node count going higher and higher, thus lagging the browser.

Expected behavior
It should not lag

Reproduction of the problem
Update with random data in an interval, even the interval starts lagging

What is the motivation / use case for changing the behavior?
It should not lag if you update the data, I'm extracting metadata from a video and showing them real time.

Please tell us about your environment:
MacOS 10.13

  • NodeJS version: x.x.x
    9.5.0

  • NPM version version: x.x.x
    5.6.0

  • Angular version: 5.x.x
    5.2.0

  • Angular-CLI version: 1.x.x
    1.7.1

  • angular-tag-cloud-module version: 2.x.x
    2.0.0

  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
    Chrome 66

Add custom css guideline

There should be a guideline which describes how to apply a custom css style for the component (README.md, Wiki, etc.)

View is not reloaded if data changes

I use Observables to asynchronously fetch data for the tag cloud. The cloud is not refreshed when the data changes, altough the model gets the new data.
I would recommend implementing OnChanges to refresh the view when the input is changed.

Angular tag cloud responsive height as similar as width and overflow

I'm submitting a ... (check one with "x")

[ ] bug report => search github for a similar issue or PR before submitting
[x ] feature request
[ ] support request => Please do not submit support request here

Current behavior

Expected behavior

Reproduction of the problem

You can for this template which already includes some example code: https://stackblitz.com/edit/angular-tag-cloud-module

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • NodeJS version: x.x.x
  • NPM version version: x.x.x
  • Angular version: 8.x.x
  • Angular-CLI version: 8.x.x
  • angular-tag-cloud-module version: 3.x.x
  • Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Upgrade to Angular 5

Currently getting warnings when using the component under Angular 5. Would be nice to have a Angular 5 compliant release

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.