Skip to content

Commit

Permalink
Report edges initialization progress
Browse files Browse the repository at this point in the history
  • Loading branch information
anvaka committed Aug 27, 2015
1 parent a030ab7 commit 8963ba7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ is smaller than 10k nodes, consider using [ngraph.pixel](https://github.com/anva
or [VivaGraph](https://github.com/anvaka/VivaGraphJS) both should
be able to provide interactive layout.

If you have an interesting graph but don't have javascript experience,
If you have an interesting graph but don't have JavaScript experience,
please feel free to reach out to me and I'll try to make visualization
for you (my email is `[email protected]`).

Expand Down
2 changes: 1 addition & 1 deletion src/galaxy/loadingIndicator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function loadingIndicator(x) {
}

function updateLoadingIndicator(progress) {
loadingMessage = `${progress.name}: ${progress.file} - ${progress.completed}`;
loadingMessage = `${progress.message} - ${progress.completed}`;
x.forceUpdate();
}
}
26 changes: 19 additions & 7 deletions src/galaxy/service/graphLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default loadGraph;
* @param {string} name of the graph to be downloaded
* @param {progressCallback} progress notifies when download progress event is
* received
* @param {completeCallback} complete notifies when all graph files are downloaed
* @param {completeCallback} complete notifies when all graph files are downloaded
*
*/
function loadGraph(name, progress) {
Expand Down Expand Up @@ -69,8 +69,8 @@ function loadGraph(name, progress) {
manifest = response;
var version = getFromAppConfig(manifest) || manifest.last;
if (manifest.endpoint) {
// the endpoint is overriden. Since we trust manifest endpoint, we also
// trust overidden endpoint:
// the endpoint is overridden. Since we trust manifest endpoint, we also
// trust overridden endpoint:
galaxyEndpoint = manifest.endpoint;
} else {
galaxyEndpoint = manifestEndpoint;
Expand All @@ -86,7 +86,7 @@ function loadGraph(name, progress) {
// default to the last version:
if (!approvedVersions || !appConfigVersion) return;

// If this version is whitelised, let it through:
// If this version is whitelisted, let it through:
if (approvedVersions.indexOf(appConfigVersion) >= 0) {
return appConfigVersion;
}
Expand Down Expand Up @@ -119,8 +119,10 @@ function loadGraph(name, progress) {
var links = new Int32Array(buffer);
var lastArray = [];
outLinks[0] = lastArray;
// TODO: Report progress?
var srcIndex;
var processed = 0;
var total = links.length;

asyncFor(links, processLink, reportBack);
var deffered = defer();

Expand All @@ -137,6 +139,17 @@ function loadGraph(name, progress) {
inLinks[toNode].push(srcIndex);
}
}
processed += 1;
if (processed % 10000 === 0) {
reportLinkProgress(processed / total);
}
}

function reportLinkProgress(percent) {
progress({
message: name + ': initializing edges ',
completed: Math.round(percent * 100) + '%'
});
}

function reportBack() {
Expand All @@ -162,8 +175,7 @@ function loadGraph(name, progress) {
function reportProgress(name, file) {
return function(e) {
progress({
name: name,
file: file,
message: name + ': downloading ' + file,
completed: Math.round(e.percent * 100) + '%'
});
};
Expand Down

0 comments on commit 8963ba7

Please sign in to comment.