Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/foam-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,7 @@
"default": false,
"description": "Whether to open the graph on startup."
}

}
},
"keybindings": [
Expand Down
14 changes: 8 additions & 6 deletions packages/foam-vscode/src/features/panels/dataviz.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ export default async function activate(
) {
let panel: vscode.WebviewPanel | undefined = undefined;
vscode.workspace.onDidChangeConfiguration(event => {
if (event.affectsConfiguration('foam.graph.style')) {
const style = getGraphStyle();
panel.webview.postMessage({
type: 'didUpdateStyle',
payload: style,
});
if (panel) {
if (event.affectsConfiguration('foam.graph.style')) {
const style = getGraphStyle();
panel.webview.postMessage({
type: 'didUpdateStyle',
payload: style,
});
}
}
});

Expand Down
8 changes: 0 additions & 8 deletions packages/foam-vscode/static/dataviz/graph.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ body {
overflow: hidden;
}

.dg .c {
width: 10%;
}

.dg .property-name {
width: 90%;
}

.vscode-light .dg.main.taller-than-window .close-button {
border-top: 1px solid #ddd;
}
Expand Down
29 changes: 28 additions & 1 deletion packages/foam-vscode/static/dataviz/graph.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
const CONTAINER_ID = 'graph';

let nodeFontSizeController = null;
const initGUI = () => {
const gui = new dat.gui.GUI();
const nodeTypeFilterFolder = gui.addFolder('Filter by type');
const nodeTypeFilterControllers = new Map();
const appearanceFolder = gui.addFolder('Appearance');

appearanceFolder
.add(model, 'textFade', 0, 5)
.step(0.1)
.name('Text Fade')
.onFinishChange(v => {
const invertedValue = 5 - v;
getNodeLabelOpacity.domain([invertedValue, invertedValue + 0.8]);
});

nodeFontSizeController = appearanceFolder
.add(model, 'nodeFontSizeMultiplier', 0.5, 3)
.step(0.1)
.name('Node Font Size');

return {
/**
Expand Down Expand Up @@ -91,6 +107,8 @@ let model = {
note: true,
tag: true,
},
textFade: 1.2,
nodeFontSizeMultiplier: 1,
};

const graph = ForceGraph();
Expand Down Expand Up @@ -216,7 +234,7 @@ function initDataviz(channel) {
}
const size = getNodeSize(info.neighbors.length);
const { fill, border } = getNodeColor(node.id, model);
const fontSize = model.style.fontSize / globalScale;
const fontSize = (model.style.fontSize * model.nodeFontSizeMultiplier) / globalScale;
const nodeState = getNodeState(node.id, model);
const textColor = fill.copy({
opacity:
Expand Down Expand Up @@ -577,6 +595,15 @@ try {
const style = message.payload;
Actions.updateStyle(style);
break;
case 'didUpdateNodeFontSizeMultiplier':
const multiplier = message.payload;
if (typeof multiplier === 'number') {
model.nodeFontSizeMultiplier = multiplier;
if (nodeFontSizeController) {
nodeFontSizeController.updateDisplay();
}
}
break;
}
});
} catch {
Expand Down