Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Testnet #197

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 1 addition & 15 deletions src/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,9 @@ angular.element(document).ready(function() {
angular.module('ripplecharts', [
'templates-app',
'templates-common',
'ripplecharts.landing',
'ripplecharts.markets',
'ripplecharts.manage-currencies',
'ripplecharts.manage-gateways',
'ripplecharts.multimarkets',
'ripplecharts.activeAccounts',
'ripplecharts.trade-volume',
'ripplecharts.graph',
'ripplecharts.accounts',
'ripplecharts.transactions',
'ripplecharts.value',
'ripplecharts.history',
'ripplecharts.metrics',
'ripplecharts.topology',
'ripplecharts.validators',
'ripplecharts.validator',
'ripplecharts.xrp-markets',
'ui.state',
'ui.route',
'snap',
Expand All @@ -207,7 +193,7 @@ angular.element(document).ready(function() {
'versionsGraph'
])
.config(function myAppConfig($urlRouterProvider) {
$urlRouterProvider.otherwise('/')
$urlRouterProvider.otherwise('/graph')
})
.run(function($window, $rootScope) {
if (typeof navigator.onLine !== 'undefined') {
Expand Down
2 changes: 1 addition & 1 deletion src/app/graph/graph.less
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
.graph #information {
background-color:rgba(255,255,255,.9);
position:absolute;
top:710px;
top:100px;
width:100%;
border: 1px solid #c8c8c8;
margin-left:-1px;
Expand Down
8 changes: 4 additions & 4 deletions src/app/graph/graph.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<div class="topbar">
<div class="centered">
<input id="focus" type="text"/>
<div id="currencySelect">
<!-- <div id="currencySelect">
<select id="currency">
<option value="XRP">All Currencies</option>
<option value="USD">USD - U.S. Dollars</option>
Expand All @@ -44,15 +44,15 @@
<option value="___">Other</option>
</select>
<input type="text" id="otherCurrency" value="other" class="sbSelector sbHolder" />
</div>
</div> -->
<input id="searchButton" type="button" value="Go"/>
</div>
</div>

<div class="zoom">
<!-- <div class="zoom">
<input type="button" id="zoomOutButton" value="&ndash;"/>
<input type="button" id="zoomInButton" value="+" disabled="disabled"/>
</div>
</div> -->

<div class="light large loading" style="color:#aaa; position:absolute; width:100%; top:300px; line-height:50px; text-align:center;">
<img class="loader" src="assets/images/rippleThrobber.png" style="vertical-align: middle;"/>
Expand Down
159 changes: 80 additions & 79 deletions src/common/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,8 @@ networkGraph = function (nameService) {
zoomLevel = 1;
translationX = 0;
translationY = 0;
panAndZoom();
$("#zoomInButton").attr("disabled","disabled");
// panAndZoom();
// $("#zoomInButton").attr("disabled","disabled");

svg.select("g#nodeGroup").selectAll("circle.node").data([]).exit().remove();
svg.select("g#linkGroup").selectAll("line") .data([]).exit().remove();
Expand Down Expand Up @@ -951,19 +951,19 @@ networkGraph = function (nameService) {


if (trustLine.limit !== 0) {
link={};
link.source = nodes[nodeMap[ origin ]];
link.target = node;
link.value = trustLine.limit;
goon(link);
// link={};
// link.source = nodes[nodeMap[ origin ]];
// link.target = node;
// link.value = trustLine.limit;
// goon(link);
}

if (trustLine.limit_peer !== 0) {
link = {};
link.target = nodes[nodeMap[ origin ]];
link.source = node;
link.value = trustLine.limit_peer;
goon(link);
// link = {};
// link.target = nodes[nodeMap[ origin ]];
// link.source = node;
// link.value = trustLine.limit_peer;
// goon(link);
}
}

Expand Down Expand Up @@ -1027,7 +1027,7 @@ networkGraph = function (nameService) {
function redraw() {
translationX += d3.event.dx;
translationY += d3.event.dy;
panAndZoom();
// panAndZoom();
}


Expand All @@ -1040,7 +1040,7 @@ networkGraph = function (nameService) {
panOffset[0] -= (w/8 * zoomLevel);
panOffset[1] -= (hh/8 * zoomLevel);
zoomLevel *= 0.75;
panAndZoom();
// panAndZoom();
}

function zoomIn() {
Expand All @@ -1053,7 +1053,7 @@ networkGraph = function (nameService) {
translationY -= (hh/8 * zoomLevel);
panOffset[0] += (w/8 * zoomLevel);
panOffset[1] += (hh/8 * zoomLevel);
panAndZoom();
// panAndZoom();
}

function panAndZoom() {
Expand Down Expand Up @@ -1109,10 +1109,10 @@ networkGraph = function (nameService) {
}


var haloGroup = svg.append("g").attr("id","haloGroup");
var linkGroup = svg.append("g").attr("id","linkGroup");
var arrowheadGroup = svg.append("g").attr("id","arrowheadGroup");
var nodeGroup = svg.append("g").attr("id","nodeGroup");
// var haloGroup = svg.append("g").attr("id","haloGroup");
// var linkGroup = svg.append("g").attr("id","linkGroup");
// var arrowheadGroup = svg.append("g").attr("id","arrowheadGroup");
// var nodeGroup = svg.append("g").attr("id","nodeGroup");

function nodeRadius(accountNode) {
var bal = currentCurrencyBalance(accountNode);
Expand All @@ -1130,17 +1130,18 @@ networkGraph = function (nameService) {
return 14 + Math.pow(Math.log(Math.abs(bal) + 1), 3) / 2000;
}

var force = d3.layout.force()
.size([(window.innerWidth > 0) ? window.innerWidth : screen.width, 710]) //w
.linkDistance(80)
.linkStrength(function(d) {
if (currentCurrency == "XRP" || currentCurrency == d.currency) {
return d.strength * 0.25;
} else {
return 0;
}
}).friction(0.5)
.charge(-1500).nodes([]).links([]).start();
// //disable force graph
// var force = d3.layout.force()
// .size([(window.innerWidth > 0) ? window.innerWidth : screen.width, 710]) //w
// .linkDistance(80)
// .linkStrength(function(d) {
// if (currentCurrency == "XRP" || currentCurrency == d.currency) {
// return d.strength * 0.25;
// } else {
// return 0;
// }
// }).friction(0.5)
// .charge(-1500).nodes([]).links([]).start();



Expand Down Expand Up @@ -1221,15 +1222,15 @@ networkGraph = function (nameService) {
function lightenAddress(address) {
if (typeof degreeMap[address] != "undefined") {
var colorDegree = Math.min(degreeMap[address], 3);
var cur = findCur(force.nodes()[nodeMap[address]]);
nodeGroup.select("#_"+address).style("fill", "url(#gradient"+cur+(colorDegree+1)+")").style("stroke-width", 2).style("stroke", "#fc0" );
// var cur = findCur(force.nodes()[nodeMap[address]]);
// nodeGroup.select("#_"+address).style("fill", "url(#gradient"+cur+(colorDegree+1)+")").style("stroke-width", 2).style("stroke", "#fc0" );
}
}
function darkenAddress(address) {
if (typeof degreeMap[address] != "undefined") {
var colorDegree = Math.min(degreeMap[address], 3);
var cur = findCur(force.nodes()[nodeMap[address]]);
nodeGroup.select("#_"+address).style("fill", "url(#gradient"+cur+(colorDegree)+")").style("stroke-width", (colorDegree===0?5:0.5)).style("stroke", function(d){var cur = findCur(d); return borderColor(cur,colorDegree);} );
// var cur = findCur(force.nodes()[nodeMap[address]]);
// nodeGroup.select("#_"+address).style("fill", "url(#gradient"+cur+(colorDegree)+")").style("stroke-width", (colorDegree===0?5:0.5)).style("stroke", function(d){var cur = findCur(d); return borderColor(cur,colorDegree);} );
}
}

Expand Down Expand Up @@ -1492,15 +1493,15 @@ networkGraph = function (nameService) {
var lastNodeTouched = "";

function stopExpandResume(d) {
force.stop();
// force.stop();
$('#focus').val(d.account.Account);
expandNode(d.account.Account);
setTimeout(force.resume,500);
// setTimeout(force.resume,500);
}

function addNodes(degree) {

force.nodes(nodes).links(le_links);
// force.nodes(nodes).links(le_links);
var timer;
var colorDegree = Math.min(degree, 3);
var node = svg.select("g#nodeGroup").selectAll("circle.node").data(nodes)
Expand All @@ -1519,15 +1520,15 @@ function addNodes(degree) {
.on("click", stopExpandResume );
colorNodes(node, colorDegree);
node.append("svg:title").text( function(d) { return d.account.Account;} );
node.call(force.drag);
// node.call(force.drag);



var link = svg.select("g#linkGroup").selectAll("line.static").data(force.links())
.enter().append("svg:line")
.attr("class","static")
.style("opacity",function(d) { return d.opacity ? d.opacity:1})
.attr("stroke-width", linkOrNot);
// var link = svg.select("g#linkGroup").selectAll("line.static").data(force.links())
// .enter().append("svg:line")
// .attr("class","static")
// .style("opacity",function(d) { return d.opacity ? d.opacity:1})
// .attr("stroke-width", linkOrNot);


function arrowheadPath(radius, theta) {
Expand All @@ -1539,13 +1540,13 @@ function addNodes(degree) {
rCosTheta+" "+(-rSinTheta)+" z";
}

var arrowhead = svg.select("g#arrowheadGroup")
.selectAll("path.arrowhead")
.data(force.links())
.enter().append("svg:path")
.attr("class", "arrowhead");
// var arrowhead = svg.select("g#arrowheadGroup")
// .selectAll("path.arrowhead")
// .data(force.links())
// .enter().append("svg:path")
// .attr("class", "arrowhead");

arrowhead = setArrowheads(arrowhead);
// arrowhead = setArrowheads(arrowhead);

function euclidean(pointA, pointB) {
return Math.sqrt(Math.pow(pointA.x-pointB.x,2)
Expand Down Expand Up @@ -1595,31 +1596,31 @@ function addNodes(degree) {
.attr("cy", function(d) { return d.y; })
.attr("r", function(d){ return HALO_MARGIN+nodeRadius(d);} );

force.start();
// force.start();





force.on("tick", function(e) {
var node = svg.selectAll("circle.node");
var halo = svg.selectAll("circle.halo");
var arrowhead = svg.selectAll("path.arrowhead");
var link = svg.selectAll("line");
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
link.attr("x1", function(d) {return d.source.x;})
.attr("y1", function(d) {return d.source.y;})
.attr("x2", function(d) {return d.target.x;})
.attr("y2", function(d) {return d.target.y;});
halo.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
setArrowheads(arrowhead);
});
// force.on("tick", function(e) {
// var node = svg.selectAll("circle.node");
// var halo = svg.selectAll("circle.halo");
// var arrowhead = svg.selectAll("path.arrowhead");
// var link = svg.selectAll("line");
// node.attr("cx", function(d) { return d.x; })
// .attr("cy", function(d) { return d.y; });
// link.attr("x1", function(d) {return d.source.x;})
// .attr("y1", function(d) {return d.source.y;})
// .attr("x2", function(d) {return d.target.x;})
// .attr("y2", function(d) {return d.target.y;});
// halo.attr("cx", function(d) { return d.x; })
// .attr("cy", function(d) { return d.y; });
// setArrowheads(arrowhead);
// });

force.drag().on("dragstart", function(){
d3.event.sourceEvent.stopPropagation(); // silence other listeners
});
// force.drag().on("dragstart", function(){
// d3.event.sourceEvent.stopPropagation(); // silence other listeners
// });
}

function refocus(focus, erase, noExpand) {
Expand Down Expand Up @@ -2174,7 +2175,7 @@ function changeCurrency(newCurrency) {
updated.attr("r", nodeRadius );
svg.select("g#haloGroup").selectAll("circle.halo").attr("r", function(d){return HALO_MARGIN+nodeRadius(d);} );
svg.select("g#linkGroup").selectAll("line.static").attr("stroke-width", linkOrNot);
force.start();
// force.start();
}
}

Expand Down Expand Up @@ -2251,8 +2252,8 @@ window.onhashchange = function(){
changeMode('individual',senderAddress);
});

$('#zoomInButton').click(zoomIn);
$('#zoomOutButton').click(zoomOut);
// $('#zoomInButton').click(zoomIn);
// $('#zoomOutButton').click(zoomOut);
$('#currency').change(function(){
changeCurrency(this.value);
});
Expand All @@ -2265,18 +2266,18 @@ window.onhashchange = function(){
//translationX = parseInt(svg.style("width"),10)/4;
//translationY = parseInt(svg.style("height"),10)/4;
translationX = translationY = 0;
panAndZoom();
// panAndZoom();
}

addResizeListener($('#visualization').get(0), resizeGraph);

this.suspend = function() {
force.nodes([]).links([]).stop();
svg.html('');
clearInterval(requestRepetitionInterval);
remote.connection.removeListener('transaction', handleTransaction);
remote.removeListener('ledger', handleLedger);
}
// this.suspend = function() {
// force.nodes([]).links([]).stop();
// svg.html('');
// clearInterval(requestRepetitionInterval);
// remote.connection.removeListener('transaction', handleTransaction);
// remote.removeListener('ledger', handleLedger);
// }

remote.connection.on('transaction', handleTransaction);
remote.on('ledger', handleLedger);
Expand Down
Loading