Skip to content

Commit

Permalink
fix(Vis View): 🐛 Force Directed Graph: Colour reset to defaultNodeCol…
Browse files Browse the repository at this point in the history
…our when setting new nodeToGetTo
  • Loading branch information
SkepticMystic committed Aug 15, 2021
1 parent dd25319 commit dd1d41e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Visualisations/ForceDirectedG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,24 @@ export const forceDirectedG = (
let pathsFromNodeToGetTo = graphlib.alg.dijkstra(graph, nodeToGetTo);
console.timeEnd("Find all paths");

const nodeColour = getComputedStyle(document.body).getPropertyValue(
const defaultNodeColour = getComputedStyle(document.body).getPropertyValue(
"--text-accent"
);
const colourChange = d3
let currNodeColour = defaultNodeColour;

const colourChangeInput = d3
.select(".d3-graph")
.append("input")
.attr("type", "color")
// Doesn't seem to work...
.attr("value", nodeColour);
.attr("type", "color");

colourChange.on("change", function changeColor(el) {
const colour = el.target.value;
colourChangeInput.on("change", function changeColor(el) {
currNodeColour = el.target.value;
node
.transition()
.duration(300)
.style("fill", (d) => {
if (d.index === currNodeIndex) return;
return colour;
return currNodeColour;
});
});

Expand Down Expand Up @@ -156,7 +156,7 @@ export const forceDirectedG = (
if (nameFromIndex(d) === currFile.basename) {
return "#ffffff";
} else {
return nodeColour;
return currNodeColour;
}
})
.call(drag(simulation));
Expand All @@ -179,7 +179,7 @@ export const forceDirectedG = (
node.style("fill", (n) => {
if (n.name === nodeToGetTo) {
return "#ff0000";
}
} else return currNodeColour;
});

pathsFromNodeToGetTo = graphlib.alg.dijkstra(graph, nodeToGetTo);
Expand Down Expand Up @@ -247,7 +247,7 @@ export const forceDirectedG = (
path.includes(nameFromIndex(link.source)) &&
path.includes(nameFromIndex(link.target))
)
return nodeColour;
return currNodeColour;
})
.style("opacity", function (link) {
if (
Expand Down

0 comments on commit dd1d41e

Please sign in to comment.