Skip to content

Commit 14c4a10

Browse files
committed
added dot and gephi parser to docs, need to include examples in the docs everywhere. Added working example code at the top of the docs and link to example 1
1 parent d9a6b41 commit 14c4a10

22 files changed

+313
-186
lines changed

dist/vis.js

+34-31
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ return /******/ (function(modules) { // webpackBootstrap
143143
dotparser: __webpack_require__(38),
144144
gephiParser: __webpack_require__(39)
145145
};
146+
exports.network.convertDot = function (input) {
147+
return exports.network.dotparser.DOTToGraph(input);
148+
};
149+
exports.network.convertGephi = function (input, options) {
150+
return exports.network.gephiParser.parseGephi(input, options);
151+
};
146152

147153
// Deprecated since v3.0.0
148154
exports.Graph = function () {
@@ -6451,8 +6457,7 @@ return /******/ (function(modules) { // webpackBootstrap
64516457
// validate options
64526458
var errorFound = Validator.validate(options, allOptions);
64536459
if (errorFound === true) {
6454-
options = {};
6455-
console.log('%cErrors have been found in the supplied options object. None of the options will be used.', printStyle);
6460+
console.log('%cErrors have been found in the supplied options object.', printStyle);
64566461
}
64576462

64586463
Core.prototype.setOptions.call(this, options);
@@ -15620,15 +15625,15 @@ return /******/ (function(modules) { // webpackBootstrap
1562015625

1562115626
var _modulesManipulationSystem2 = _interopRequireDefault(_modulesManipulationSystem);
1562215627

15623-
var _modulesConfigurationSystem = __webpack_require__(45);
15628+
var _sharedConfigurationSystem = __webpack_require__(45);
1562415629

15625-
var _modulesConfigurationSystem2 = _interopRequireDefault(_modulesConfigurationSystem);
15630+
var _sharedConfigurationSystem2 = _interopRequireDefault(_sharedConfigurationSystem);
1562615631

15627-
var _modulesValidator = __webpack_require__(46);
15632+
var _sharedValidator = __webpack_require__(46);
1562815633

15629-
var _modulesValidator2 = _interopRequireDefault(_modulesValidator);
15634+
var _sharedValidator2 = _interopRequireDefault(_sharedValidator);
1563015635

15631-
var _modulesComponentsAllOptionsJs = __webpack_require__(65);
15636+
var _optionsJs = __webpack_require__(65);
1563215637

1563315638
// Load custom shapes into CanvasRenderingContext2D
1563415639
__webpack_require__(66);
@@ -15738,7 +15743,7 @@ return /******/ (function(modules) { // webpackBootstrap
1573815743
this.canvas._create();
1573915744

1574015745
// setup configuration system
15741-
this.configurationSystem = new _modulesConfigurationSystem2['default'](this, this.body.container, _modulesComponentsAllOptionsJs.configureOptions, this.canvas.pixelRatio);
15746+
this.configurationSystem = new _sharedConfigurationSystem2['default'](this, this.body.container, _optionsJs.configureOptions, this.canvas.pixelRatio);
1574215747

1574315748
// apply options
1574415749
this.setOptions(options);
@@ -15757,10 +15762,9 @@ return /******/ (function(modules) { // webpackBootstrap
1575715762
Network.prototype.setOptions = function (options) {
1575815763
if (options !== undefined) {
1575915764

15760-
var errorFound = _modulesValidator2['default'].validate(options, _modulesComponentsAllOptionsJs.allOptions);
15765+
var errorFound = _sharedValidator2['default'].validate(options, _optionsJs.allOptions);
1576115766
if (errorFound === true) {
15762-
options = {};
15763-
console.log('%cErrors have been found in the supplied options object. None of the options will be used.', _modulesValidator.printStyle);
15767+
console.log('%cErrors have been found in the supplied options object.', _sharedValidator.printStyle);
1576415768
}
1576515769

1576615770
// copy the global fields over
@@ -15914,19 +15918,17 @@ return /******/ (function(modules) { // webpackBootstrap
1591415918
this.setOptions(data && data.options);
1591515919
// set all data
1591615920
if (data && data.dot) {
15921+
console.log('The dot property has been depricated. Please use the static convertDot method to convert DOT into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertDot(dotString);');
1591715922
// parse DOT file
15918-
if (data && data.dot) {
15919-
var dotData = dotparser.DOTToGraph(data.dot);
15920-
this.setData(dotData);
15921-
return;
15922-
}
15923+
var dotData = dotparser.DOTToGraph(data.dot);
15924+
this.setData(dotData);
15925+
return;
1592315926
} else if (data && data.gephi) {
1592415927
// parse DOT file
15925-
if (data && data.gephi) {
15926-
var gephiData = gephiParser.parseGephi(data.gephi);
15927-
this.setData(gephiData);
15928-
return;
15929-
}
15928+
console.log('The gephi property has been depricated. Please use the static convertGephi method to convert gephi into vis.network format and use the normal data format with nodes and edges. This converter is used like this: var data = vis.network.convertGephi(gephiJson);');
15929+
var gephiData = gephiParser.parseGephi(data.gephi);
15930+
this.setData(gephiData);
15931+
return;
1593015932
} else {
1593115933
this.nodesHandler.setData(data && data.nodes, true);
1593215934
this.edgesHandler.setData(data && data.edges, true);
@@ -17062,7 +17064,7 @@ return /******/ (function(modules) { // webpackBootstrap
1706217064
var nodes = [];
1706317065
var options = {
1706417066
edges: {
17065-
inheritColor: true
17067+
inheritColor: false
1706617068
},
1706717069
nodes: {
1706817070
fixed: false,
@@ -17071,9 +17073,9 @@ return /******/ (function(modules) { // webpackBootstrap
1707117073
};
1707217074

1707317075
if (options !== undefined) {
17074-
options.nodes['fixed'] = optionsObj.fixed !== undefined ? options.fixed : false;
17076+
options.nodes['fixed'] = optionsObj.fixed !== undefined ? options.fixed : true;
1707517077
options.nodes['parseColor'] = optionsObj.parseColor !== undefined ? options.parseColor : false;
17076-
options.edges['inheritColor'] = optionsObj.inheritColor !== undefined ? options.inheritColor : true;
17078+
options.edges['inheritColor'] = optionsObj.inheritColor !== undefined ? options.inheritColor : false;
1707717079
}
1707817080

1707917081
var gEdges = gephiJSON.edges;
@@ -17087,8 +17089,9 @@ return /******/ (function(modules) { // webpackBootstrap
1708717089
edge['attributes'] = gEdge.attributes;
1708817090
// edge['value'] = gEdge.attributes !== undefined ? gEdge.attributes.Weight : undefined;
1708917091
// edge['width'] = edge['value'] !== undefined ? undefined : edgegEdge.size;
17090-
edge['color'] = gEdge.color;
17091-
edge['inheritColor'] = edge['color'] !== undefined ? false : options.inheritColor;
17092+
if (gEdge.color && options.inheritColor === false) {
17093+
edge['color'] = gEdge.color;
17094+
}
1709217095
edges.push(edge);
1709317096
}
1709417097

@@ -18515,9 +18518,9 @@ return /******/ (function(modules) { // webpackBootstrap
1851518518

1851618519
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
1851718520

18518-
var _componentsColorPicker = __webpack_require__(72);
18521+
var _networkModulesComponentsColorPicker = __webpack_require__(72);
1851918522

18520-
var _componentsColorPicker2 = _interopRequireDefault(_componentsColorPicker);
18523+
var _networkModulesComponentsColorPicker2 = _interopRequireDefault(_networkModulesComponentsColorPicker);
1852118524

1852218525
var util = __webpack_require__(1);
1852318526

@@ -18557,7 +18560,7 @@ return /******/ (function(modules) { // webpackBootstrap
1855718560
this.configureOptions = configureOptions;
1855818561
this.moduleOptions = {};
1855918562
this.domElements = [];
18560-
this.colorPicker = new _componentsColorPicker2['default'](pixelRatio);
18563+
this.colorPicker = new _networkModulesComponentsColorPicker2['default'](pixelRatio);
1856118564
this.wrapper;
1856218565
}
1856318566

@@ -34192,9 +34195,9 @@ return /******/ (function(modules) { // webpackBootstrap
3419234195

3419334196
var _nodesShapesTriangleDown2 = _interopRequireDefault(_nodesShapesTriangleDown);
3419434197

34195-
var _Validator = __webpack_require__(46);
34198+
var _sharedValidator = __webpack_require__(46);
3419634199

34197-
var _Validator2 = _interopRequireDefault(_Validator);
34200+
var _sharedValidator2 = _interopRequireDefault(_sharedValidator);
3419834201

3419934202
var util = __webpack_require__(1);
3420034203

dist/vis.map

+1-1
Large diffs are not rendered by default.

dist/vis.min.js

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/js/toggleTable.js

+17-25
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,25 @@ function toggleTable(tableId, parent, clickedRow) {
5757
}
5858
}
5959

60-
function toggleTab(showTabId, showDOMid, hideTabId, hideDOMid, hideTabId2, hideDOMid2) {
61-
if (hideTabId2 !== undefined) {
62-
document.getElementById(hideTabId2).className = '';
63-
document.getElementById(hideDOMid2).className = document.getElementById(hideDOMid2).className.replace(' hidden','');
64-
document.getElementById(hideDOMid2).className += ' hidden';
65-
}
66-
67-
if (hideTabId !== undefined) {
68-
document.getElementById(hideTabId).className = '';
69-
document.getElementById(hideDOMid).className = document.getElementById(hideDOMid).className.replace(' hidden','');
70-
document.getElementById(hideDOMid).className += ' hidden';
60+
function toggleTab(tabThis) {
61+
var parentNode = tabThis.parentNode;
62+
var active = tabThis.className.indexOf('active') !== -1;
63+
for (var i = 0; i < parentNode.children.length; i++) {
64+
var child = parentNode.children[i];
65+
var targetNodeId = child.getAttribute('targetNode');
66+
if (targetNodeId) {
67+
var targetNode = document.getElementById(child.getAttribute('targetNode'));
68+
targetNode.className = targetNode.className.replace(' hidden', '').replace('hidden', '') + ' hidden';
69+
}
70+
child.className = child.className.replace(' active','').replace('active','');
7171
}
7272

73-
document.getElementById(showTabId).className = 'active';
74-
document.getElementById(showDOMid).className = document.getElementById(showDOMid).className.replace(' hidden','');
75-
}
76-
77-
78-
function hideOptions(hideTabId1, hidePreId1, hideTabId2, hidePreId2) {
79-
document.getElementById(hideTabId1).className = '';
80-
document.getElementById(hidePreId1).className = document.getElementById(hidePreId1).className.replace(' hidden','');
81-
document.getElementById(hidePreId1).className += ' hidden';
82-
83-
if (hideTabId2 !== undefined) {
84-
document.getElementById(hideTabId2).className = '';
85-
document.getElementById(hidePreId2).className = document.getElementById(hidePreId2).className.replace(' hidden','');
86-
document.getElementById(hidePreId2).className += ' hidden';
73+
// activate the tab
74+
tabThis.className += ' active';
75+
var ownTargetNodeId = tabThis.getAttribute('targetNode');
76+
if (ownTargetNodeId) {
77+
var ownTargetNode = document.getElementById(ownTargetNodeId);
78+
ownTargetNode.className = ownTargetNode.className.replace(' hidden','').replace('hidden','');
8779
}
8880

8981
}

docs/network.html

-77
Original file line numberDiff line numberDiff line change
@@ -484,83 +484,6 @@ <h3 id="DOT_language">DOT language</h3>
484484

485485
<h3 id="Gephi_import">Gephi import (JSON)</h3>
486486

487-
<p>
488-
network can import data straight from an exported json file from gephi. You can get the JSON exporter here:
489-
<a href="https://marketplace.gephi.org/plugin/json-exporter/" target="_blank">https://marketplace.gephi.org/plugin/json-exporter/</a>.
490-
An example exists showing how to get a JSON file into Vis: <a href="../examples/network/30_importing_from_gephi.html">30_importing_from_gephi</a>.
491-
</p>
492-
493-
<p>
494-
Example usage:
495-
</p>
496-
497-
<pre class="prettyprint lang-js">
498-
// load the JSON file containing the Gephi network.
499-
var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
500-
501-
// create a data object with the gephi key:
502-
var data = {
503-
gephi: gephiJSON
504-
};
505-
506-
// create a network
507-
var network = new vis.Network(container, data);
508-
</pre>
509-
Alternatively you can use the parser manually:
510-
<pre class="prettyprint lang-js">
511-
// load the JSON file containing the Gephi network.
512-
var gephiJSON = loadJSON("./data/WorldCup2014.json"); // code in example 30
513-
514-
// parse the gephi file to receive an object
515-
// containing nodes and edges in vis format.
516-
var parsed = vis.network.gephiParser.parseGephi(gephiJSON);
517-
518-
// provide data in the normal fashion
519-
var data = {
520-
nodes: parsed.nodes,
521-
edged: parsed.edges
522-
};
523-
524-
// create a network
525-
var network = new vis.Network(container, data);
526-
</pre>
527-
528-
<h4>Gephi parser options</h4>
529-
530-
There are a few options you can use to tell Vis what to do with the data from Gephi.
531-
532-
<pre class="prettyprint lang-js">
533-
var parserOptions = {
534-
allowedToMove: false,
535-
parseColor: false
536-
}
537-
var parsed = vis.network.gephiParser.parseGephi(gephiJSON, parserOptions);
538-
</pre>
539-
<table>
540-
<tr>
541-
<th>Name</th>
542-
<th>Type</th>
543-
<th>Default</th>
544-
<th>Description</th>
545-
</tr>
546-
547-
<tr>
548-
<td>allowedToMove</td>
549-
<td>Boolean</td>
550-
<td>false</td>
551-
<td>
552-
If true, the nodes will move according to the physics model after import. If false, the nodes do not move at all.
553-
</td>
554-
</tr>
555-
<tr>
556-
<td>parseColor</td>
557-
<td>Boolean</td>
558-
<td>false</td>
559-
<td>
560-
If true, the color will be parsed by the vis parser, generating extra colors for the borders, highlighs and hover. If false, the node will be the supplied color.
561-
</td>
562-
</tr>
563-
</table>
564487

565488
<h2 id="Configuration_options">Configuration options</h2>
566489

docs/network/configure.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ <h3>Options</h3>
8989
<p>The options for the canvas have to be contained in an object titled 'configure'.</p>
9090
<p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
9191
<ul class="nav nav-tabs">
92-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions','shortTab','shortOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
93-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions','shortTab','shortOptions');" id="fullTab"><a href="#">full options</a></li>
94-
<li role="presentation" onclick="toggleTab('shortTab','shortOptions','fullTab','fullOptions');" id="shortTab"><a href="#">shorthand options</a></li>
92+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
93+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
94+
<li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
9595
</ul>
9696
<br>
9797
<pre class="prettyprint lang-js options top hidden" id="fullOptions">

docs/network/edges.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ <h3>Options</h3>
9494
</p>
9595
<p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
9696
<ul class="nav nav-tabs">
97-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions','shortTab','shortOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
98-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions','shortTab','shortOptions');" id="fullTab"><a href="#">full options</a></li>
99-
<li role="presentation" onclick="toggleTab('shortTab','shortOptions','fullTab','fullOptions');" id="shortTab"><a href="#">shorthand options</a></li>
97+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
98+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
99+
<li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
100100
</ul>
101101
<br>
102102
<pre class="prettyprint lang-js options top hidden" id="fullOptions">

docs/network/groups.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ <h3>Options</h3>
8888
<p>The options for the canvas have to be contained in an object titled 'groups'.</p>
8989
<p>Click on the options shown to show how these options are supposed to be used.</p>
9090
<ul class="nav nav-tabs">
91-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
92-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions');" id="fullTab"><a href="#">options shown</a></li>
91+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
92+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">options shown</a></li>
9393
</ul>
9494
<br>
9595
<pre class="prettyprint lang-js options hidden" id="fullOptions">

docs/network/interaction.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ <h3>Options</h3>
7575
<p>The options for the interaction module have to be contained in an object titled 'interaction'.</p>
7676
<p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
7777
<ul class="nav nav-tabs">
78-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions','shortTab','shortOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
79-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions','shortTab','shortOptions');" id="fullTab"><a href="#">full options</a></li>
80-
<li role="presentation" onclick="toggleTab('shortTab','shortOptions','fullTab','fullOptions');" id="shortTab"><a href="#">shorthand options</a></li>
78+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
79+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
80+
<li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
8181
</ul>
8282
<br>
8383
<pre class="prettyprint lang-js options top hidden" id="fullOptions">

docs/network/layout.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ <h3>Options</h3>
7676
<p>The options for the layout module have to be contained in an object titled 'layout'.</p>
7777
<p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
7878
<ul class="nav nav-tabs">
79-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions','shortTab','shortOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
80-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions','shortTab','shortOptions');" id="fullTab"><a href="#">full options</a></li>
81-
<li role="presentation" onclick="toggleTab('shortTab','shortOptions','fullTab','fullOptions');" id="shortTab"><a href="#">shorthand options</a></li>
79+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
80+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
81+
<li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
8282
</ul>
8383
<br>
8484
<pre class="prettyprint lang-js options top hidden" id="fullOptions">

docs/network/manipulation.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ <h3>Options</h3>
7575
<p>The options for the manipulation module have to be contained in an object titled 'manipulation'.</p>
7676
<p>Click on the full options or shorthand options to show how these options are supposed to be used.</p>
7777
<ul class="nav nav-tabs">
78-
<li role="presentation" class="active" onclick="hideOptions('fullTab','fullOptions','shortTab','shortOptions');" id="hiddenTab"><a href="#">options hidden</a></li>
79-
<li role="presentation" onclick="toggleTab('fullTab','fullOptions','shortTab','shortOptions');" id="fullTab"><a href="#">full options</a></li>
80-
<li role="presentation" onclick="toggleTab('shortTab','shortOptions','fullTab','fullOptions');" id="shortTab"><a href="#">shorthand options</a></li>
78+
<li role="presentation" class="active" onclick="toggleTab(this)"><a href="#">options hidden</a></li>
79+
<li role="presentation" onclick="toggleTab(this);" targetNode="fullOptions"><a href="#">full options</a></li>
80+
<li role="presentation" onclick="toggleTab(this);" targetNode="shortOptions"><a href="#">shorthand options</a></li>
8181
</ul>
8282
<br>
8383
<pre class="prettyprint lang-js options top hidden" id="fullOptions">

0 commit comments

Comments
 (0)