Skip to content

Build your personal knowledge base with Trilium Notes

excludeFromTreeMap generalized to excludeFromNoteMap

zadama1ca538106be
diff --git a/db/migrations/0184__add_excludeFromTreeMap_to_journal.js b/db/migrations/0184__add_excludeFromNoteMap_to_journal.js
similarity index 85%
rename from db/migrations/0184__add_excludeFromTreeMap_to_journal.js
rename to db/migrations/0184__add_excludeFromNoteMap_to_journal.js
index 71cd5b799a..1cc602960f 100644
--- a/db/migrations/0184__add_excludeFromTreeMap_to_journal.js
+++ b/db/migrations/0184__add_excludeFromNoteMap_to_journal.js
@@ -8,7 +8,7 @@ module.exports = () => {
for (const note of Object.values(becca.notes)) {
if (note.hasLabel('calendarRoot')) {
- note.addLabel('excludeFromTreeMap', "", true);
+ note.addLabel('excludeFromNoteMap', "", true);
}
}
});
diff --git a/src/public/app/widgets/note_map.js b/src/public/app/widgets/note_map.js
index 0c02fe7c22..bd7f7d1a8a 100644
--- a/src/public/app/widgets/note_map.js
+++ b/src/public/app/widgets/note_map.js
@@ -119,11 +119,15 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
let mapRootNoteId = this.getMapRootNoteId();
const data = await this.loadNotesAndRelations(mapRootNoteId);
+
const nodeLinkRatio = data.nodes.length / data.links.length;
+ const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
+ const charge = -20 / magnifiedRatio;
+ const boundedCharge = Math.min(-3, charge);
this.graph.d3Force('link').distance(40);
this.graph.d3Force('center').strength(0.2);
- this.graph.d3Force('charge').strength(-20 / Math.pow(nodeLinkRatio, 1.5));
+ this.graph.d3Force('charge').strength(boundedCharge);
this.graph.d3Force('charge').distanceMax(1000);
this.renderData(data);
diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.js
index be384c839d..433cb6791e 100644
--- a/src/routes/api/note_map.js
+++ b/src/routes/api/note_map.js
@@ -26,10 +26,14 @@ function buildDescendantCountMap() {
function getLinkMap(req) {
const mapRootNote = becca.getNote(req.params.noteId);
+ // if the map root itself has ignore (journal typically) then there wouldn't be anything to display so
+ // we'll just ignore it
+ const ignoreExcludeFromNoteMap = mapRootNote.hasLabel('excludeFromNoteMap');
const noteIds = new Set();
const notes = mapRootNote.getSubtreeNotes(false)
+ .filter(note => ignoreExcludeFromNoteMap || !note.hasLabel('excludeFromNoteMap'))
.map(note => [
note.noteId,
note.isContentAvailable() ? note.title : '[protected]',
@@ -72,11 +76,11 @@ function getTreeMap(req) {
const mapRootNote = becca.getNote(req.params.noteId);
// if the map root itself has ignore (journal typically) then there wouldn't be anything to display so
// we'll just ignore it
- const ignoreExcludeFromTreeMap = mapRootNote.hasLabel('excludeFromTreeMap');
+ const ignoreExcludeFromNoteMap = mapRootNote.hasLabel('excludeFromNoteMap');
const noteIds = new Set();
const notes = mapRootNote.getSubtreeNotes(false)
- .filter(note => ignoreExcludeFromTreeMap || !note.hasLabel('excludeFromTreeMap'))
+ .filter(note => ignoreExcludeFromNoteMap || !note.hasLabel('excludeFromNoteMap'))
.filter(note => {
if (note.type !== 'image' || note.getChildNotes().length > 0) {
return true;
diff --git a/src/services/attributes.js b/src/services/attributes.js
index 4302647569..b646af7f14 100644
--- a/src/services/attributes.js
+++ b/src/services/attributes.js
@@ -47,7 +47,7 @@ const BUILTIN_ATTRIBUTES = [
{ type: 'label', name: 'pageSize' },
{ type: 'label', name: 'viewType' },
{ type: 'label', name: 'mapRootNoteId' },
- { type: 'label', name: 'excludeFromTreeMap' },
+ { type: 'label', name: 'excludeFromNoteMap' },
// relation names
{ type: 'relation', name: 'runOnNoteCreation', isDangerous: true },