Skip to content

Commit

Permalink
fix: fix lost links issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 3, 2021
1 parent 90964e3 commit 1186c2b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ <h2>Commits Tree</h2>
<div id="commits-tree"></div>

<script src="public/js/libs/d3.min.js"></script>
<script src="public/js/libs/d3-force.v2.min.js"></script>

<script src="public/js/graph-config.js"></script>

Expand Down
12 changes: 6 additions & 6 deletions web/public/js/graph/cloc/code-flower.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
function renderCodeFlower(data, selector) {
data = {
links: [
nodes: [
{"id": "Myriel", "group": 1},
{"id": "CountessdeLo", "group": 1},
{"id": "Geborand", "group": 1},
{"id": "Champtercier", "group": 1},
],
nodes: [
links: [
{"source": "CountessdeLo", "target": "Myriel", "value": 1},
{"source": "Geborand", "target": "Myriel", "value": 1},
{"source": "Champtercier", "target": "Myriel", "value": 1},
Expand All @@ -16,14 +16,14 @@ function renderCodeFlower(data, selector) {
let w = GraphConfig.width;
let h = GraphConfig.height;

const links = data.links;
const nodes = data.nodes;
const links = data.links.map(d => Object.create(d));
const nodes = data.nodes.map(d => Object.create(d));

d3.select(selector).selectAll("svg").remove();
const svg = d3.select(selector).append("svg").attr("viewBox", [0, 0, w, h]);

const simulation = d3.forceSimulation(nodes)
.force("link", d3.forceLink().id(d => d.id))
.force("link", d3.forceLink(links).id(d => d.id))
.force("charge", d3.forceManyBody())
.force("center", d3.forceCenter(w / 2, h / 2));

Expand All @@ -48,7 +48,7 @@ function renderCodeFlower(data, selector) {
.join("circle")
.attr("r", 5)
.attr("fill", color)
.call(drag(simulation));
.call(drag(simulation))

node.append("title")
.text(d => d.id);
Expand Down

0 comments on commit 1186c2b

Please sign in to comment.