mirror of https://gitee.com/bigwinds/arangodb
The graphviewer will now start with a random vertex
This commit is contained in:
parent
4d1357c465
commit
97309a837b
|
@ -188,6 +188,14 @@ function GharialAdapter(nodes, edges, viewer, config) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
result = result[0];
|
result = result[0];
|
||||||
|
if (result.length === 0) {
|
||||||
|
if (callback) {
|
||||||
|
callback({
|
||||||
|
errorCode: 404
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
var inserted = {},
|
var inserted = {},
|
||||||
n = absAdapter.insertNode(result[0].vertex),
|
n = absAdapter.insertNode(result[0].vertex),
|
||||||
oldLength = nodes.length;
|
oldLength = nodes.length;
|
||||||
|
|
|
@ -208,6 +208,20 @@ function GraphViewer(svg, width, height, adapterConfig, config) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.loadGraphWithRandomStart = function(callback) {
|
||||||
|
adapter.loadRandomNode(function (node) {
|
||||||
|
if (node.errorCode) {
|
||||||
|
callback(node);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
node._expanded = true;
|
||||||
|
self.start();
|
||||||
|
if (_.isFunction(callback)) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
this.loadGraphWithAttributeValue = function(attribute, value, callback) {
|
this.loadGraphWithAttributeValue = function(attribute, value, callback) {
|
||||||
adapter.loadInitialNodeByAttributeValue(attribute, value, function (node) {
|
adapter.loadInitialNodeByAttributeValue(attribute, value, function (node) {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
/*global document, $, _ */
|
/*global document, $, _ */
|
||||||
/*global EventDispatcherControls, NodeShaperControls, EdgeShaperControls */
|
/*global EventDispatcherControls, NodeShaperControls, EdgeShaperControls */
|
||||||
/*global LayouterControls, GharialAdapterControls*/
|
/*global LayouterControls, GharialAdapterControls*/
|
||||||
/*global GraphViewer, d3, window*/
|
/*global GraphViewer, d3, window, alert*/
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief Graph functionality
|
/// @brief Graph functionality
|
||||||
///
|
///
|
||||||
|
@ -448,7 +448,15 @@ function GraphViewerUI(container, adapterConfig, optWidth, optHeight, viewerConf
|
||||||
createColourList();
|
createColourList();
|
||||||
|
|
||||||
if (startNode) {
|
if (startNode) {
|
||||||
graphViewer.loadGraph(startNode);
|
if (typeof startNode === "string") {
|
||||||
|
graphViewer.loadGraph(startNode);
|
||||||
|
} else {
|
||||||
|
graphViewer.loadGraphWithRandomStart(function(node) {
|
||||||
|
if (node && node.errorCode) {
|
||||||
|
alert("Sorry your graph seems to be empty");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.changeWidth = function(w) {
|
this.changeWidth = function(w) {
|
||||||
|
|
|
@ -25,12 +25,11 @@
|
||||||
var adapterConfig = {
|
var adapterConfig = {
|
||||||
type: "gharial",
|
type: "gharial",
|
||||||
graphName: name,
|
graphName: name,
|
||||||
graph: name,
|
|
||||||
baseUrl: require("internal").arango.databasePrefix("/")
|
baseUrl: require("internal").arango.databasePrefix("/")
|
||||||
};
|
};
|
||||||
var width = $("#content").width() - 75;
|
var width = $("#content").width() - 75;
|
||||||
$("#content").html("");
|
$("#content").html("");
|
||||||
this.ui = new GraphViewerUI($("#content")[0], adapterConfig, width, 680, {});
|
this.ui = new GraphViewerUI($("#content")[0], adapterConfig, width, 680, {}, true);
|
||||||
},
|
},
|
||||||
|
|
||||||
addNewGraph: function(e) {
|
addNewGraph: function(e) {
|
||||||
|
|
Loading…
Reference in New Issue