Skip to content

Commit

Permalink
fix: fix draw random issue
Browse files Browse the repository at this point in the history
  • Loading branch information
phodal committed Mar 5, 2021
1 parent 79bd3db commit 634cb09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
25 changes: 4 additions & 21 deletions web/public/js/graph/git/file-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ function renderCodeExplorer(freedom, data, elementId) {
let width = GraphConfig.width - margin.left - margin.right;
let height = GraphConfig.width - margin.top - margin.bottom;

let ellipse = d3
.range(100)
.map(i => [
(width * (1 + 0.99 * Math.cos((i / 50) * Math.PI))) / 2,
(height * (1 + 0.99 * Math.sin((i / 50) * Math.PI))) / 2
])

const rootNode = d3.hierarchy(data); // .sum(d => d.value);
rootNode.descendants().forEach((node) => {
node.data.hierarchNode = node;
Expand All @@ -31,37 +24,27 @@ function renderCodeExplorer(freedom, data, elementId) {
const labels = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");
const pop_labels = svg.append("g").attr("transform", "translate(" + margin.left + "," + margin.top + ")");

let seed = new Math.seedrandom(20);
let voronoiTreeMap = d3.voronoiTreemap()
.prng(seed)
.clip(ellipse);

voronoi.selectAll('path')
.data(allNodes)
.enter()
.append('path')
.attr('d', d => `${d3.line()(d.data.layout.polygon)}z`)
.style('fill', d => d.parent ? d.parent.color : d.color)
.attr("stroke", "#F5F5F2")
// .attr("stroke-width", 0)
// .style('fill-opacity', d => d.depth === 2 ? 1 : 0)
// .attr('pointer-events', d => d.depth === 2 ? 'all' : 'none')
.on('mouseenter', d => {
let label = labels.select(`.label-${d.id}`);
label.attr('opacity', 1)
let pop_label = pop_labels.select(`.label-${d.id}`);
pop_label.attr('opacity', 1)
})
.on('mouseleave', d => {
// let label = labels.select(`.label-${d.id}`);
// label.attr('opacity', d => d.data.value > 130000000 ? 1 : 0)
// let pop_label = pop_labels.select(`.label-${d.id}`);
// pop_label.attr('opacity', d => d.data.value > 130000000 ? 1 : 0)

})
.transition()
.duration(1000)
.attr("stroke-width", d => 7 - d.depth * 2.8)
// .style('fill', d => d.color);
.attr("stroke-width", d => {
return d.depth < 4 ? 4 - d.depth : 1;
})

labels.selectAll('text')
.data(allNodes)
Expand Down
2 changes: 2 additions & 0 deletions web/public/js/plugins/code-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ function calculateVoronoi(
let bestPolygons = undefined;
while (!simulationLoopEnded) {

let seed = new Math.seedrandom(20);
console.log(node.children);
var simulation = d3.voronoiMapSimulation(node.children)
.maxIterationCount(MAX_ITERATION_COUNT)
.minWeightRatio(MIN_WEIGHT_RATIO)
.weight((d) => d.value)
.prng(seed)
.clip(clipPolygon)
.stop();

Expand Down

0 comments on commit 634cb09

Please sign in to comment.