Skip to content

Commit b47427b

Browse files
author
tenormis
committed
Support the use of "tag" type documents to declare relationships between tags.
1 parent b67074b commit b47427b

File tree

1 file changed

+22
-12
lines changed
  • packages/foam-vscode/static/dataviz

1 file changed

+22
-12
lines changed

packages/foam-vscode/static/dataviz/graph.js

+22-12
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const initGUI = () => {
1919
if (!nodeTypeFilterControllers.has(type)) {
2020
const ctrl = nodeTypeFilterFolder
2121
.add(m.showNodesOfType, type)
22-
.onFinishChange(function() {
22+
.onFinishChange(function () {
2323
Actions.updateFilters();
2424
});
2525
ctrl.domElement.previousSibling.style.color = getNodeTypeColor(
@@ -249,23 +249,33 @@ function initDataviz(channel) {
249249
}
250250

251251
function augmentGraphInfo(graph) {
252+
const tagNodes = {};
252253
Object.values(graph.nodeInfo).forEach(node => {
254+
if (node.type === 'tag') {
255+
tagNodes[node.title] = node;
256+
}
253257
node.neighbors = [];
254258
node.links = [];
259+
});
260+
Object.values(graph.nodeInfo).forEach(node => {
255261
if (node.tags && node.tags.length > 0) {
256262
node.tags.forEach(tag => {
257-
const tagNode = {
258-
id: tag.label,
259-
title: tag.label,
260-
type: 'tag',
261-
properties: {},
262-
neighbors: [],
263-
links: [],
264-
};
265-
graph.nodeInfo[tag.label] = tagNode;
263+
let tagNode = tagNodes[tag.label];
264+
if (!tagNode) {
265+
tagNode = {
266+
id: tag.label,
267+
title: tag.label,
268+
type: 'tag',
269+
properties: {},
270+
neighbors: [],
271+
links: [],
272+
};
273+
graph.nodeInfo[tag.label] = tagNode;
274+
tagNodes[tag.label] = tagNode;
275+
}
266276
graph.links.push({
267-
source: tagNode.id,
268-
target: node.id,
277+
source: node.id,
278+
target: tagNode.id,
269279
});
270280
});
271281
}

0 commit comments

Comments
 (0)