mirror of
https://github.com/tcsenpai/obsidiangarden_netlify.git
synced 2025-06-07 13:15:20 +00:00
graph enhancements
This commit is contained in:
parent
cfe44308d0
commit
f291e37b05
@ -50,15 +50,17 @@
|
|||||||
|
|
||||||
var Graph;
|
var Graph;
|
||||||
|
|
||||||
function renderGraph(graphData, id, width, height, delay) {
|
function renderGraph(graphData, id, delay) {
|
||||||
|
const el = document.getElementById(id);
|
||||||
|
width = el.offsetWidth;
|
||||||
|
height = el.offsetHeight;
|
||||||
const highlightNodes = new Set();
|
const highlightNodes = new Set();
|
||||||
let hoverNode = null;
|
let hoverNode = null;
|
||||||
const color = getCssVar("--text-accent");
|
const color = getCssVar("--text-accent");
|
||||||
const mutedColor = getCssVar("--text-faint");
|
const mutedColor = getCssVar("--text-faint");
|
||||||
|
|
||||||
let Graph = ForceGraph()
|
let Graph = ForceGraph()
|
||||||
(document.getElementById(id))
|
(el)
|
||||||
.graphData(graphData)
|
.graphData(graphData)
|
||||||
.nodeId('id')
|
.nodeId('id')
|
||||||
.nodeLabel('title')
|
.nodeLabel('title')
|
||||||
@ -138,7 +140,7 @@
|
|||||||
function fetchGraphData() {
|
function fetchGraphData() {
|
||||||
fetch('/graph.json').then(res => res.json()).then(data => {
|
fetch('/graph.json').then(res => res.json()).then(data => {
|
||||||
window.graphData = data;
|
window.graphData = data;
|
||||||
Graph = renderGraph(filterToDepth(JSON.parse(JSON.stringify(data))), "link-graph", 320, 320, 1);
|
Graph = renderGraph(filterToDepth(JSON.parse(JSON.stringify(data))), "link-graph", 1);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +155,7 @@
|
|||||||
Graph._destructor();
|
Graph._destructor();
|
||||||
Graph = null;
|
Graph = null;
|
||||||
}
|
}
|
||||||
renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 320, 320, 1);
|
renderGraph(filterToDepth(JSON.parse(JSON.stringify(window.graphData))), "link-graph", 1);
|
||||||
})
|
})
|
||||||
|
|
||||||
window.fullGraph = null;
|
window.fullGraph = null;
|
||||||
@ -169,7 +171,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", 200);
|
||||||
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();
|
||||||
@ -180,8 +182,20 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('graph-full-btn').addEventListener('click', (evt) => {
|
document.getElementById('graph-fs-btn').addEventListener('click', (evt) => {
|
||||||
if (!fullGraph) {
|
const el = document.querySelector('.graph');
|
||||||
|
if (el.classList.contains('graph-fs')) {
|
||||||
|
el.classList.remove('graph-fs');
|
||||||
|
Graph.width(el.offsetWidth).height(el.offsetHeight);
|
||||||
|
} else {
|
||||||
|
el.classList.add('graph-fs');
|
||||||
|
Graph.width(el.offsetWidth).height(el.offsetHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('global-graph-btn').addEventListener('click', (evt) => {
|
||||||
|
if (!window.fullGraph) {
|
||||||
renderFullGraph();
|
renderFullGraph();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<span id="depth-display"></span>
|
<span id="depth-display"></span>
|
||||||
</div>
|
</div>
|
||||||
<i class="fa fa-arrows-alt" id="graph-full-btn" aria-hidden="true"></i>
|
<div class="ctrl-right">
|
||||||
|
<i class="fa fa-globe" id="global-graph-btn" aria-hidden="true"></i>
|
||||||
|
<i class="fa fa-arrows-alt" id="graph-fs-btn" aria-hidden="true"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="link-graph"></div>
|
<div id="link-graph"></div>
|
||||||
|
@ -65,6 +65,33 @@ ul.task-list {
|
|||||||
display: flex;
|
display: flex;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
max-width: 350px;
|
max-width: 350px;
|
||||||
|
|
||||||
|
.graph {
|
||||||
|
width: 320px;
|
||||||
|
height: 320px;
|
||||||
|
|
||||||
|
#link-graph {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.graph-fs {
|
||||||
|
position: fixed;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
height: calc(100vmin - 100px);
|
||||||
|
width: calc(100vmin - 100px);
|
||||||
|
min-height: 350px;
|
||||||
|
min-width: 350px;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
z-index: 9999;
|
||||||
|
display: none;
|
||||||
|
background-color: var(--background-secondary);
|
||||||
|
|
||||||
|
.graph-title {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.expand-line {
|
.expand-line {
|
||||||
@ -531,15 +558,20 @@ ul.task-list {
|
|||||||
position: fixed;
|
position: fixed;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
height: 60vh;
|
height: calc(100vmin - 100px);
|
||||||
width: 60vw;
|
width: calc(100vmin - 100px);
|
||||||
min-height: 400px;
|
min-height: 350px;
|
||||||
min-width: 400px;
|
min-width: 350px;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
z-index: 9999;
|
z-index: 9999;
|
||||||
display: none;
|
display: none;
|
||||||
background-color: var(--background-secondary);
|
background-color: var(--background-secondary);
|
||||||
|
|
||||||
|
#full-graph-container {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
#full-graph-close {
|
#full-graph-close {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
@ -571,6 +603,10 @@ ul.task-list {
|
|||||||
color: var(--text-accent);
|
color: var(--text-accent);
|
||||||
z-index: 9;
|
z-index: 9;
|
||||||
|
|
||||||
|
i {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.depth-control {
|
.depth-control {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user