mirror of
https://git.alemi.dev/fedicharter.git
synced 2024-11-12 20:09:21 +01:00
feat: added mass and scale
This commit is contained in:
parent
e1e80a717d
commit
48195cdeb3
2 changed files with 8 additions and 6 deletions
7
dist/index.html
vendored
7
dist/index.html
vendored
|
@ -47,8 +47,8 @@
|
|||
'#05979A',
|
||||
]
|
||||
for (const i in graph.nodes) {
|
||||
if (graph.nodes[i].label === domain) graph.nodes[i].color = '#BF616A';
|
||||
else graph.nodes[i].color = palette[Math.floor(Math.random() * palette.length)];;
|
||||
if (graph.nodes[i].label === domain) { graph.nodes[i].color = '#BF616A' }
|
||||
else { graph.nodes[i].color = palette[Math.floor(Math.random() * palette.length)] }
|
||||
}
|
||||
|
||||
const nodes = new vis.DataSet(graph.nodes);
|
||||
|
@ -60,9 +60,8 @@
|
|||
nodes: nodes,
|
||||
edges: edges,
|
||||
};
|
||||
const options = { edges: { dashes: true, arrows: 'to' }, nodes: { mass: 2, color: "#bf616a", shape: "box" }};
|
||||
const options = { edges: { dashes: true, arrows: 'to' }, nodes: { color: "#bf616a", shape: "box", scaling: { min: 1, max: 500, label: { enabled: true, min: 14, max: 56 }}}};
|
||||
const network = new vis.Network(container, data, options);
|
||||
document.getElementById("loader").remove();
|
||||
}))
|
||||
</script>
|
||||
</body>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::{HashSet, HashMap}, sync::Arc};
|
||||
use std::{collections::HashMap, sync::Arc};
|
||||
|
||||
use serde::Serialize;
|
||||
use tokio::sync::{mpsc, RwLock};
|
||||
|
@ -38,7 +38,7 @@ impl MapCollector {
|
|||
for (i, node) in nodes_domains.iter().enumerate() {
|
||||
nodes_map.insert(
|
||||
node.domain.clone(),
|
||||
Node { id: i, label: node.domain.clone(), title: node.name.clone(), value: 1 }
|
||||
Node { id: i, label: node.domain.clone(), title: node.name.clone(), value: 1, mass: 1. }
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,7 @@ impl MapCollector {
|
|||
let from = {
|
||||
if let Some(node) = nodes_map.get_mut(&vertex.from) {
|
||||
node.value += 1;
|
||||
node.mass += 0.1;
|
||||
node.id
|
||||
} else {
|
||||
tracing::warn!("vertex from nonexisting node {}", vertex.from);
|
||||
|
@ -56,6 +57,7 @@ impl MapCollector {
|
|||
let to = {
|
||||
if let Some(node) = nodes_map.get_mut(&vertex.to) {
|
||||
node.value += 10;
|
||||
node.mass += 1.;
|
||||
node.id
|
||||
} else {
|
||||
tracing::warn!("vertex to nonexisting node {}", vertex.to);
|
||||
|
@ -120,6 +122,7 @@ pub struct Node {
|
|||
pub id: usize,
|
||||
pub label: String,
|
||||
pub value: usize,
|
||||
pub mass: f32,
|
||||
pub title: String,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue