Skip to content

Commit

Permalink
feat(explorer): add lost popoed lables
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 5, 2021
1 parent 61bf0e3 commit 6c94ba4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
30 changes: 21 additions & 9 deletions web/public/js/graph/git/file-explorer.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
function renderCodeExplorer(freedom, data, elementId) {
let margin = {top: 20, right: 20, bottom: 50, left: 50};
let width = GraphConfig.width - margin.left - margin.right;
let height = GraphConfig.width - margin.top - margin.bottom;

const rootNode = d3.hierarchy(data); // .sum(d => d.value);
const rootNode = d3.hierarchy(data);
rootNode.descendants().forEach((node) => {
node.data.hierarchNode = node;
});
Expand Down Expand Up @@ -76,7 +73,7 @@ function renderCodeExplorer(freedom, data, elementId) {
})

labels.selectAll('text')
.data(allNodes.filter(d => d.depth === 2))
.data(allNodes)
.enter()
.append('text')
.attr('class', d => `label-${d.id}`)
Expand All @@ -86,14 +83,29 @@ function renderCodeExplorer(freedom, data, elementId) {
})
.text(d => {
if (d.data.data) {
return d.data.path + ":" + d.data.data.git.details.length
return d.data.name + ":" + d.data.data.git.details.length
}
return d.data.path;
return d.data.name;
})
.attr('opacity', function (d) {
.attr('cursor', 'default')
.attr('pointer-events', 'none')
.attr('fill', 'white')

pop_labels.selectAll('text')
.data(allNodes)
.enter()
.append('text')
.attr('class', d => {
`label-${d.id}`
})
.attr("transform", d => {
return "translate(" + [d.data.layout.center[0], d.data.layout.center[1] + 6] + ")"
})
.attr('text-anchor', 'middle')
.text(d => d.data.value)
.attr('opacity', 0)
.attr('cursor', 'default')
.attr('pointer-events', 'none')
.attr('fill', 'white')
.attr('fill', 'black')
.style('font-size', '12px');
}
1 change: 1 addition & 0 deletions web/public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ d3.json("data/struct.json").then(function (data) {
});

d3.json("data/git-file-history.json").then(function (data) {
data.width = GraphConfig.width;
let layout = calculateCodeLayout(data);

d3.csv("fake/freedom_clean.csv").then(json => {
Expand Down

0 comments on commit 6c94ba4

Please sign in to comment.