graph enhancements

This commit is contained in:
Utsob Roy 2023-02-14 15:07:13 +06:00
parent 862a6a5dcd
commit 353e2094b6
3 changed files with 112 additions and 72 deletions

View File

@ -50,15 +50,17 @@
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();
let hoverNode = null;
const color = getCssVar("--text-accent");
const mutedColor = getCssVar("--text-faint");
let Graph = ForceGraph()
(document.getElementById(id))
(el)
.graphData(graphData)
.nodeId('id')
.nodeLabel('title')
@ -138,7 +140,7 @@
function fetchGraphData() {
fetch('/graph.json').then(res => res.json()).then(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 = 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;
@ -169,7 +171,7 @@
g.classList.add('show');
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>';
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) => {
g.classList.remove('show');
window.fullGraph._destructor();
@ -180,8 +182,20 @@
}
document.getElementById('graph-full-btn').addEventListener('click', (evt) => {
if (!fullGraph) {
document.getElementById('graph-fs-btn').addEventListener('click', (evt) => {
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();
}
});

View File

@ -19,7 +19,10 @@
</div>
<span id="depth-display"></span>
</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 id="link-graph"></div>

View File

@ -15,16 +15,15 @@ body {
margin-top: 90px;
position: relative;
@media(max-width: 800px) {
@media (max-width: 800px) {
margin-top: 75px;
}
}
.external-link {
background-position: center right;
background-repeat: no-repeat;
background-image: linear-gradient(transparent, transparent), url('/img/outgoing.svg');
background-image: linear-gradient(transparent, transparent), url("/img/outgoing.svg");
background-size: 13px;
padding-right: 16px;
background-position-y: 4px;
@ -62,6 +61,33 @@ ul.task-list {
display: flex;
z-index: 3;
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 {
@ -91,7 +117,7 @@ ul.task-list {
font-size: 1rem;
max-height: 220px;
overflow-y: auto;
margin-bottom:10px;
margin-bottom: 10px;
border-left: 1px solid var(--text-accent);
ul {
list-style-type: none;
@ -100,19 +126,19 @@ ul.task-list {
margin-bottom: 0;
}
ul:not(:first-child) {
margin-bottom:3px;
margin-bottom: 3px;
}
li{
li {
padding-top: 4px;
&::before{
content: '# ' !important;
&::before {
content: "# " !important;
color: var(--text-accent);
font-size: 0.8rem;
}
a{
a {
text-decoration: none;
&:hover{
&:hover {
text-decoration: underline;
}
}
@ -149,7 +175,7 @@ ul.task-list {
border-left: 1px solid var(--text-accent);
max-height: 200px;
overflow-y: auto;
overflow-x:hidden;
overflow-x: hidden;
}
.backlink-card {
@ -164,13 +190,12 @@ ul.task-list {
}
}
.no-backlinks-message{
.no-backlinks-message {
font-size: 0.8rem;
color: var(--text-normal);
}
.graph {
.graph-title-container {
display: flex;
justify-content: flex-end;
@ -195,9 +220,7 @@ ul.task-list {
width: fit-content;
}
@media(max-width: 1400px) {
@media (max-width: 1400px) {
#link-graph {
border-radius: 0 10px 10px 10px;
}
@ -213,7 +236,7 @@ ul.task-list {
justify-content: space-between;
}
.sidebar-container{
.sidebar-container {
display: flex;
flex-direction: row;
justify-content: space-between;
@ -221,7 +244,7 @@ ul.task-list {
.graph {
flex: 1;
.graph-title-container{
.graph-title-container {
justify-content: flex-start;
}
}
@ -230,8 +253,8 @@ ul.task-list {
display: none;
}
}
@media(max-width: 800px) {
.sidebar-container{
@media (max-width: 800px) {
.sidebar-container {
display: flex;
flex-direction: column-reverse;
}
@ -252,7 +275,7 @@ ul.task-list {
h1 {
font-size: 32px !important;
}
@media(max-width: 800px) {
@media (max-width: 800px) {
h1 {
display: none;
}
@ -269,7 +292,7 @@ ul.task-list {
justify-content: flex-end;
margin-bottom: -60px;
@media(max-width: 800px) {
@media (max-width: 800px) {
justify-content: center;
}
@ -290,11 +313,11 @@ ul.task-list {
display: flex;
justify-content: space-between;
align-items: center;
@media(max-width: 1400px) {
@media (max-width: 1400px) {
position: fixed;
}
@media(max-width: 800px) {
@media (max-width: 800px) {
h1 {
font-size: 18px !important;
}
@ -307,8 +330,7 @@ ul.task-list {
}
.search-button {
@media(max-width: 800px) {
@media (max-width: 800px) {
min-width: 36px;
margin: 10px 25px 10px 25px;
}
@ -317,7 +339,7 @@ ul.task-list {
.search-text {
display: flex;
justify-content: center;
@media(max-width: 800px){
@media (max-width: 800px) {
display: none;
}
}
@ -325,7 +347,7 @@ ul.task-list {
.notelink {
padding: 5px 0 5px 25px;
a{
a {
&:hover {
text-decoration: underline !important;
}
@ -361,10 +383,9 @@ ul.task-list {
right: 0;
left: 0;
bottom: 0;
z-index: 5
z-index: 5;
}
.search-container {
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
@ -400,7 +421,6 @@ ul.task-list {
font-size: 2rem;
background-color: var(--background-primary);
color: var(--text-primary);
}
.search-box input:focus {
@ -425,7 +445,7 @@ ul.task-list {
font-size: 1.2rem;
cursor: pointer;
&.active{
&.active {
border: 2px solid var(--text-accent);
}
}
@ -459,25 +479,21 @@ ul.task-list {
border: 1px solid var(--text-normal);
cursor: pointer;
>span {
> span {
padding: 3px 3px 3px 10px;
}
>i {
> i {
margin-left: 10px;
}
&:hover {
border: 1px solid var(--text-accent);
}
}
.search-keys {
@media(max-width: 800px) {
@media (max-width: 800px) {
display: none;
}
}
@ -491,7 +507,7 @@ ul.task-list {
padding: 0;
}
.callout-fold{
.callout-fold {
cursor: pointer;
}
@ -529,8 +545,6 @@ ul.task-list {
margin-right: -10px;
}
// Graph Controls
.graph-title-container {
position: relative;
@ -540,15 +554,20 @@ ul.task-list {
position: fixed;
top: 50%;
left: 50%;
height: 60vh;
width: 60vw;
min-height: 400px;
min-width: 400px;
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);
#full-graph-container {
width: 100%;
height: 100%;
}
#full-graph-close {
position: absolute;
top: 10px;
@ -580,6 +599,10 @@ ul.task-list {
color: var(--text-accent);
z-index: 9;
i {
cursor: pointer;
}
.depth-control {
display: flex;
flex-direction: row;
@ -616,7 +639,7 @@ ul.task-list {
}
}
input[type=range]::-webkit-slider-thumb {
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
margin-top: -10px;
}