{"id":20389170,"url":"https://github.com/daidr/node-wordcloud","last_synced_at":"2025-04-12T10:51:45.281Z","repository":{"id":57863655,"uuid":"528073673","full_name":"daidr/node-wordcloud","owner":"daidr","description":"Tag cloud presentation for NodeJS (Based on wordcloud2.js)","archived":false,"fork":false,"pushed_at":"2022-08-26T14:20:19.000Z","size":22,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T19:29:49.009Z","etag":null,"topics":["nodejs","tagcloud","wordcloud"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daidr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-23T16:26:02.000Z","updated_at":"2024-10-30T03:11:57.000Z","dependencies_parsed_at":"2023-01-16T19:00:39.049Z","dependency_job_id":null,"html_url":"https://github.com/daidr/node-wordcloud","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fnode-wordcloud","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fnode-wordcloud/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fnode-wordcloud/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daidr%2Fnode-wordcloud/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daidr","download_url":"https://codeload.github.com/daidr/node-wordcloud/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248557844,"owners_count":21124165,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nodejs","tagcloud","wordcloud"],"created_at":"2024-11-15T03:16:06.359Z","updated_at":"2025-04-12T10:51:45.258Z","avatar_url":"https://github.com/daidr.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# node-wordcloud ![npm version](https://img.shields.io/npm/v/node-wordcloud.svg) \n\nTag cloud presentation for NodeJS (Based on [wordcloud2.js](https://github.com/timdream/wordcloud2.js))\n\n\n\n## Installation\n\n```bash\nnpm install node-wordcloud\n```\n\n## Usage\n\n```javascript\nconst { createCanvas } = require('canvas');\nconst WordCloud = require('node-wordcloud')();\n\nconst canvas = createCanvas(500, 500);\n\n// Array of words [text: String, weight: Number][]\n// The weight of word isn't the absolute size of word, the real size will be automatically calculated based on options.sizeRange\nconst list = [['word', 150], ['hello', 140], ['world', 130], ['test', 90]];\n\nconst wordcloud = WordCloud(canvas, { list });\n\n// you should call draw() to draw the wordcloud manually\nwordcloud.draw();\n\nconst buffer = canvas.toBuffer();\n\n// you can use the wordcloud.updateList() to update the word list\n// wordcloud.updateList([['word', 150], ['hello', 140], ['world', 130], ['test', 90]]);\n// wordcloud.draw();\n```\n\n## Example\n\nSee [example](./example) folder for more examples.\n\n## Options\n\nSupport most of options of [wordcloud2.js](https://github.com/timdream/wordcloud2.js), except for:\n\n- `clearCanvas`\n- `weightFactor`\n- `wait`\n- `minRotation`\n- `maxRotation`\n- `classes`\n- `hover`\n- `click`\n\nAlso we added some options:\n\n```diff\n+ {\n+     sizeRange: [16, 68], \n+     rotationRange: [-70, 70],\n+ }\n```\n\n## API\n\nWe remove the support for generating word cloud in svg format, because some canvas implementation already allow to generate svg directly (such as [node-canvas](https://github.com/Automattic/node-canvas)).\n\nThis module will not draw word cloud automatically, you need to call `wordcloud.draw()` to draw word cloud. See example for more details.\n\nYou can use `wordcloud.updateList(list: Array\u003c[text: String, weight: Number]\u003e)` to update word list. See example for more details.\n\nIn `wordcloud2.js`, you can import module by `const WordCloud = require('wordcloud2')`, but in node-wordcloud, it will be `const WordCloud = require('node-wordcloud')()`, you can choose the canvas implementation you want to use by passing `createCanvas` function, here here some examples:\n\n```javascript\n// use node-canvas default\nconst WordCloud = require('node-wordcloud')();\n\n// use node-canvas\nconst { createCanvas } = require('canvas');\nconst WordCloud = require('node-wordcloud')(createCanvas);\n\n// use skia-canvas\nconst { Canvas } = require('skia-canvas');\nconst WordCloud = require('node-wordcloud')((w, h) =\u003e new Canvas(w, h));\n\n// etc.\n```\n\n## LICENSE\n\nMIT License","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidr%2Fnode-wordcloud","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaidr%2Fnode-wordcloud","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaidr%2Fnode-wordcloud/lists"}