Skip to content

Commit

Permalink
- add support for ignoring words and stopwords(closes #1)
Browse files Browse the repository at this point in the history
- add a wordcloud for the entire vault(closes #2)
- add the ability to add dataview query(only tagcloud for now)
- expose more options of underlining word cloud renderer
- improved readme
  • Loading branch information
joethei committed Jan 31, 2022
1 parent 0c3027d commit 99dae55
Show file tree
Hide file tree
Showing 8 changed files with 341 additions and 48 deletions.
6 changes: 3 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
],
"parserOptions": {
"sourceType": "module"
},
Expand All @@ -19,5 +19,5 @@
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}
}
}
70 changes: 57 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,66 @@ Plugin for [Obsidian](https://obsidian.md)
[![libera manifesto](https://img.shields.io/badge/libera-manifesto-lightgrey.svg)](https://liberamanifesto.com)
---

![](https://i.joethei.space/Obsidian_XQP86CLUkB.png)


With this plugin you can create a tag or word cloud in your notes.

To do this create a codeblock named either `tagcloud` or `wordcloud`.
A tagcloud displays all tags in your vault,
the wordcloud displays all words in the note the codeblock has been created in.
To do this create a [codeblock](https://help.obsidian.md/How+to/Format+your+notes#Code+blocks) with the language set to either `tagcloud` or `wordcloud`.

You can configure your cloud using a [YAML](https://learnxinyminutes.com/docs/yaml/) syntax.

## Tag Cloud
![](https://i.joethei.space/9URSIqXbEs.png)

Displays all tags that fit your selection.

### Options

| **Name** | **Description** | **Possible Values** |
|----------|----------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|
| query | Requires [Dataview](https://github.com/blacksmithgu/obsidian-dataview), requires `source` to be set to `query` | A valid [Dataview Source](https://blacksmithgu.github.io/obsidian-dataview/query/sources/) |

## Word Cloud

![](https://i.joethei.space/7WCqI74ca8.png)
a wordcloud displays all words in your vault/note.


### Options

| **Name** | **Description** | **Possible Values** | **Default** |
|-----------|-----------------------------------------------------------------------------------------------------------------|---------------------|-------------|
| stopwords | Remove all [stopwords](https://www.opinosis-analytics.com/knowledge-base/stop-words-explained/) from the result | `true`/ `false` | `true` |

> ⚠ Word distribution will only be calculated when loading a vault and by running the `Recalculate Word Distribution` command.
## General Options
The following options are supported for both the tag & word cloud.

| **Name** | **Description** | **Possible Values** | **Default** |
|-------------|-------------------------------------------------|-----------------------------------------------------------------------------------------------|----------------------------------------|
| shape | What shape to draw | `circle`, `cardioid`, `diamond`, `square`, `triangle-forward`, `triangle`, `pentagon`, `star` | `circle` |
| source | where are the tags/words coming from? | `file`, `vault`, `query`(only supported in tagcloud) | `vault` |
| weight | factor by wich the size of a word is multiplied | any number | `2` |
| background | Background color | a hexadecimal RGB value | background color from the chosen theme |
| width | Width of canvas | any valid [CSS unit](https://developer.mozilla.org/docs/Web/CSS/length) | line width |
| height | Height of canvas | any valid [CSS unit](https://developer.mozilla.org/docs/Web/CSS/length) | `width / 2` |
| fontFamily | font used to display | any valid [font-family](https://developer.mozilla.org/docs/Web/CSS/font-family) | |
| fontWeight | font weight | `normal`, `bold`, or a number | `normal` |
| minFontSize | minumum font size | any number | `0` |
| minRotation | the minimum rotation the text should rotate | number (in rad) | `- pi / 2` |
| maxRotation | the maximum rotation the text should rotate | number (in rad) | `pi / 2` |
| ellipticity | degree of 'flatness' | number | `0.65` |
| shuffle | produce a different looking result each time? | `true`/`false` | `true` |
| rotateRatio | Rotation Probability | Number as percentage (so 1.0 is 100%) | `0.1` |

---
# Credits

- Built using [wordcloud2.js](https://github.com/timdream/wordcloud2.js)
- and [stopword](https://github.com/fergiemcdowall/stopword)
- as well as the [Dataview](https://github.com/blacksmithgu/obsidian-dataview) API
- With help from the code of [Tag Wrangler](https://github.com/pjeby/tag-wrangler)
- Some Code taken from the [Word Count Dashboard for Dataview](https://gist.github.com/chrisgrieser/ac16a80cdd9e8e0e84606cc24e35ad99)


The following options are supported:

| **Name** | **Description** | **Possible Values** | **Default** |
|------------|-------------------------------------------------|-------------------------------------------------------------------------------|----------------------------------------|
| shape | What shape to draw | circle, cardioid, diamond, square, triangle-forward, triange, pentagon, star | circle |
| weight | factor by wich the size of a word is multiplied | number | 2 |
| background | Background color | a hexadecimal RGB value | background color from the chosen theme |
| width | Width of canvas | any valid [CSS unit](https://developer.mozilla.org/en-US/docs/Web/CSS/length) | line width |
| height | Height of canvas | any valid [CSS unit](https://developer.mozilla.org/en-US/docs/Web/CSS/length) | width / 2 |
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "tag-word-cloud",
"name": "Tag & Word Cloud",
"version": "1.0.1",
"version": "1.1.0",
"minAppVersion": "0.12.0",
"description": "Show a cloud of your tags/words in a note",
"author": "Johannes Theiner",
Expand Down
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "obsidian-tag-cloud",
"version": "1.0.1",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"version": "1.1.0",
"description": "Show a cloud of your tags/words in a note",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
Expand All @@ -23,6 +23,9 @@
"tslib": "2.3.1",
"typescript": "4.4.4",
"wordcloud": "^1.2.2",
"@types/wordcloud": "^1.1.3"
"@types/wordcloud": "^1.1.3",
"stopword": "^1.0.11",
"@types/stopword": "^1.0.2",
"obsidian-dataview": "^0.4.22"
}
}
Loading

0 comments on commit 99dae55

Please sign in to comment.