mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-06 20:55:21 +00:00
some enhancements
This commit is contained in:
parent
6edc732dcc
commit
7994a93015
@ -49,13 +49,17 @@
|
|||||||
|
|
||||||
var Graph;
|
var Graph;
|
||||||
|
|
||||||
function renderGraph(graphData, id, width, height) {
|
function renderGraph(graphData, id, width, height, delay) {
|
||||||
let Graph = ForceGraph()
|
let Graph = ForceGraph()
|
||||||
(document.getElementById(id))
|
(document.getElementById(id))
|
||||||
.graphData(graphData)
|
.graphData(graphData)
|
||||||
.nodeId('id')
|
.nodeId('id')
|
||||||
.nodeLabel('title')
|
.nodeLabel('title')
|
||||||
.linkSource('source')
|
.linkSource('source')
|
||||||
|
.linkTarget('target')
|
||||||
|
.d3AlphaDecay(0.10)
|
||||||
|
.width(width)
|
||||||
|
.height(height)
|
||||||
.linkDirectionalArrowLength(2)
|
.linkDirectionalArrowLength(2)
|
||||||
.linkDirectionalArrowRelPos(0.5)
|
.linkDirectionalArrowRelPos(0.5)
|
||||||
.nodeCanvasObject((node, ctx) => {
|
.nodeCanvasObject((node, ctx) => {
|
||||||
@ -79,8 +83,10 @@
|
|||||||
.linkColor(() => getCssVar("--text-muted") || getCssVar("--text-normal"))
|
.linkColor(() => getCssVar("--text-muted") || getCssVar("--text-normal"))
|
||||||
.onNodeClick(node => {
|
.onNodeClick(node => {
|
||||||
window.location = node.url;
|
window.location = node.url;
|
||||||
})
|
});
|
||||||
.linkTarget('target').width(width).height(height);
|
setTimeout(() => {
|
||||||
|
Graph.zoomToFit(5, 75);
|
||||||
|
}, delay);
|
||||||
return Graph;
|
return Graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,7 +108,7 @@
|
|||||||
Graph._destructor();
|
Graph._destructor();
|
||||||
Graph = null;
|
Graph = null;
|
||||||
}
|
}
|
||||||
renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 330, 330);
|
renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 330, 330, 1);
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fullGraph = null;
|
window.fullGraph = null;
|
||||||
@ -118,8 +124,7 @@
|
|||||||
g.classList.add('show');
|
g.classList.add('show');
|
||||||
document.body.appendChild(g);
|
document.body.appendChild(g);
|
||||||
g.innerHTML = '<i class="fa fa-times" id="full-graph-close" aria-hidden="true"></i><div id="full-graph-container"></div>';
|
g.innerHTML = '<i class="fa fa-times" id="full-graph-close" aria-hidden="true"></i><div id="full-graph-container"></div>';
|
||||||
|
window.fullGraph = renderGraph(graphData, "full-graph-container", g.offsetWidth, g.offsetHeight, 200);
|
||||||
window.fullGraph = renderGraph(graphData, "full-graph-container", g.offsetWidth, g.offsetHeight);
|
|
||||||
document.getElementById('full-graph-close').addEventListener('click', (evt) => {
|
document.getElementById('full-graph-close').addEventListener('click', (evt) => {
|
||||||
g.classList.remove('show');
|
g.classList.remove('show');
|
||||||
window.fullGraph._destructor();
|
window.fullGraph._destructor();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user