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 71cd5b799..1cc602960 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 0c02fe7c2..bd7f7d1a8 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 be384c839..433cb6791 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 430264756..b646af7f1 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 },