Install browserify globally via `[sudo] npm install -g browserify`, then create a custom bundle like:
Then create a custom bundle using browserify, like:
browserify custom.js -t babelify -o vis-custom.js -s vis
$ browserify custom.js -t babelify -o vis-custom.js -s vis
This will generate a custom bundle *vis-custom.js*, which exposes the namespace `vis` containing only `DataSet` and `Timeline`. The generated bundle can be minified with uglifyjs (installed globally with `[sudo] npm install -g uglify-js`):
This will generate a custom bundle *vis-custom.js*, which exposes the namespace `vis` containing only `DataSet` and `Timeline`. The generated bundle can be minified using uglifyjs:
uglifyjs vis-custom.js -o vis-custom.min.js
$ uglifyjs vis-custom.js -o vis-custom.min.js
The custom bundle can now be loaded like:
@ -204,11 +217,11 @@ The custom bundle can now be loaded like:
The default bundle `vis.js` is standalone and includes external dependencies such as hammer.js and moment.js. When these libraries are already loaded by the application, vis.js does not need to include these dependencies itself too. To build a custom bundle of vis.js excluding moment.js and hammer.js, run browserify in the root of the project:
browserify index.js -t babelify -o vis-custom.js -s vis -x moment -x hammerjs
$ browserify index.js -t babelify -o vis-custom.js -s vis -x moment -x hammerjs
This will generate a custom bundle *vis-custom.js*, which exposes the namespace `vis`, and has moment and hammerjs excluded. The generated bundle can be minified with uglifyjs:
uglifyjs vis-custom.js -o vis-custom.min.js
$ uglifyjs vis-custom.js -o vis-custom.min.js
The custom bundle can now be loaded as:
@ -254,12 +267,12 @@ var timeline = new Timeline(container, data, options);
Install the application dependencies via npm:
npm install vis moment
$ npm install vis moment
The application can be bundled and minified:
browserify app.js -o app-bundle.js -t babelify
uglifyjs app-bundle.js -o app-bundle.min.js
$ browserify app.js -o app-bundle.js -t babelify
$ uglifyjs app-bundle.js -o app-bundle.min.js
And loaded into a webpage:
@ -282,11 +295,11 @@ And loaded into a webpage:
To test the library, install the project dependencies once:
Vis.js comes with a flexible DataSet, which can be used to hold and
manipulate unstructured data and listen for changes in the data.
The DataSet is key/value based. Data items can be added, updated and
removed from the DatSet, and one can subscribe to changes in the DataSet.
removed from the DataSet, and one can subscribe to changes in the DataSet.
The data in the DataSet can be filtered and ordered, and fields (like
dates) can be converted to a specific type. Data can be normalized when
appending it to the DataSet as well.
@ -312,7 +312,7 @@ var data = new vis.DataSet([data] [, options])
<td>Object | Array</td>
<td>
Get a single item, multiple items, or all items from the DataSet.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>. When no item is found, <code>null</code> is returned when a single item was requested, and and empty Array is returned in case of multiple id's.
</td>
</tr>
@ -598,9 +598,9 @@ function (event, properties, senderId) {
<code>update</code>, and <code>remove</code>,
<code>properties</code> is always an object containing a property
<code>items</code>, which contains an array with the ids of the affected
items. The <code>update</code> event has an extra field <code>data</code>
containing the original data of the updated items, i.e. the gives the
changed fields of the changed items.
items. The <code>update</code> event has an extra field <code>oldData</code>
containing the original data of the updated items, and a field <code>data</code>
containing the changes: the properties of the items that are being updated.
</td>
</tr>
<tr>
@ -1020,4 +1020,4 @@ var positiveBalance = dataset.get({
@ -248,7 +248,7 @@ var data = new vis.DataView(dataset, options)
<td>Object | Array</td>
<td>
Get a single item, multiple items, or all items from the DataView.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>.
Usage examples can be found in section <ahref="#Getting_Data">Getting Data</a>, and the available <code>options</code> are described in section <ahref="#Data_Selection">Data Selection</a>. When no item is found, <code>null</code> is returned when a single item was requested, and and empty Array is returned in case of multiple id's.
Graph2d can load data from an <code>Array</code>, a <code>DataSet</code> (offering 2 way data binding), or a <code>DataView</code> (offering one way data binding).
Objects are added to this DataSet by using the <code>add()</code> function.
Data points must have properties <code>x</code>, <code>y</code>, and <code>z</code>,
and can optionally have a property <code>style</code> and <code>filter</code>.
<td>If two datapoints of a barchart overlap, they are drawn over eachother by default. If sideBySide is set to true, they will be drawn side by side.
<td>If two datapoints of a barchart overlap, they are drawn over eachother by default. If sideBySide is set to true, they will be drawn side by side, within the same width as a single bar..
See <ahref="../../examples/graph2d/10_barsSideBySide.html">example 10</a> for more information.
When using groups, see <ahref="../../examples/graph2d/11_barsSideBySideGroups.html">example 11</a>.
<td>The minimum width of the bars in pixels: by default the bars get smaller while zooming out to prevent overlap, this value is the minimum width of the bar. Default behavior (when minWidth is not set) is 10% of the bar width.</td>
<td>If stack is enabled, the graphs will be stacked upon eachother when applicable. This currently only works with bar graphs but linegraph support is being worked on.</td>
<td>If stack is enabled, the graphs will be stacked upon each-other when applicable. A group can opt-out of stacking through the "excludeFromStacking" option.</td>
<td>Exactly the same as the to object but with an arrowhead at the from node of the edge.</td>
</tr>
<tr>
<tdclass="indent">arrowStrikethrough</td>
<td>Boolean</td>
<td><code>true</code></td>
<td>When false, the edge stops at the arrow. This can be useful if you have thick lines and you want the arrow to end in a point. Middle arrows are not affected by this.</td>
section below</a> for more explaination on how to customize this.
<td>When a Network is configured to be <code>clickToUse</code>, it will react to mouse and touch events only when active. When active, a blue shadow border is displayed around the Network. The network is set active by clicking on it, and is changed to inactive again by clicking outside the Network or by pressing the ESC key.
</td>
</tr>
<tr><tdid="event_configure">configure</td>
<td>Object</td>
<td>Object</td>
<tdhref="./configure.html">All options in this object are explained in the configure module.</a>
<td>All options in this object are explained in the <ahref="./configure.html">configure module</a>.
</td>
</tr>
<tr><tdid="event_edges">edges</td>
<td>Object</td>
<td>Object</td>
<tdhref="./edges.html">All options in this object are explained in the edges module.</a>
<td>All options in this object are explained in the <ahref="./edges.html">edges module</a>.
</td>
</tr>
<tr><tdid="event_nodes">nodes</td>
<td>Object</td>
<td>Object</td>
<tdhref="./nodes.html">All options in this object are explained in the nodes module.</a>
<td>All options in this object are explained in the <ahref="./nodes.html">nodes module</a>.
</td>
</tr>
<tr><tdid="event_groups">groups</td>
<td>Object</td>
<td>Object</td>
<tdhref="./groups.html">All options in this object are explained in the groups module.</a>
<td>All options in this object are explained in the <ahref="./groups.html">groups module</a>.
</td>
</tr>
<tr><tdid="event_layout">layout</td>
<td>Object</td>
<td>Object</td>
<tdhref="./layout.html">All options in this object are explained in the layout module.</a>
<td>All options in this object are explained in the <ahref="./layout.html">layout module</a>.
</td>
</tr>
<tr><tdid="event_interaction">interaction</td>
<td>Object</td>
<td>Object</td>
<tdhref="./interaction.html">All options in this object are explained in the interaction module.</a>
<td>All options in this object are explained in the <ahref="./interaction.html">interaction module</a>.
</td>
</tr>
<tr><tdid="event_manipulation">manipulation</td>
<td>Object</td>
<td>Object</td>
<tdhref="./manipulation.html">All options in this object are explained in the manipulation module.</a>
<td>All options in this object are explained in the <ahref="./manipulation.html">manipulation module</a>.
</td>
</tr>
<tr><tdid="event_physics">physics</td>
<td>Object</td>
<td>Object</td>
<tdhref="./physics.html">All options in this object are explained in the physics module.</a>
<td>All options in this object are explained in the <ahref="./physics.html">physics module</a>.
</td>
</tr>
</table>
@ -944,6 +940,28 @@ function releaseFunction (clusterPosition, containedNodesPositions) {
before selecting its own objects. <i>Does not fire events</i>.
<trclass='toggle collapsible'onclick="toggleTable('optionTable','hierarchical', this);"><td><spanparent="repulsion"class="right-caret"></span> hierarchical</td><td>Object or Boolean</td><td><code>Object</code></td><td>When true, the layout engine positions the nodes in a hierarchical fashion using default settings. For customization you can supply an object.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.enabled</td><td>Boolean</td><td><code>false</code></td><td>Toggle the usage of the hierarchical layout system. If this option is not defined, it is set to true if any of the properties in this object are defined.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.levelSeparation</td><td>Number</td><td><code>150</code></td><td>The distance between the different levels.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.nodeSpacing</td><td>Number</td><td><code>100</code></td><td>Minimum distance between nodes on the free axis. This is only for the initial layout. If you enable physics, the node distance there will be the effective node distance.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.treeSpacing</td><td>Number</td><td><code>200</code></td><td>Distance between different trees (independent networks). This is only for the initial layout. If you enable physics, the repulsion model will denote the distance between the trees.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.blockShifting</td><td>Boolean</td><td><code>true</code></td><td>Method for reducing whitespace. Can be used alone or together with edge minimization. Each node will check for whitespace and will shift
it's branch along with it for as far as it can, respecting the nodeSpacing on any level. This is mainly for the initial layout. If you enable physics, they layout will be determined by the physics. This will greatly speed up the stabilization time though!</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.edgeMinimization</td><td>Boolean</td><td><code>true</code></td><td>Method for reducing whitespace. Can be used alone or together with block shifting. Enabling block shifting will usually speed up the layout process.
Each node will try to move along its free axis to reduce the total length of it's edges. This is mainly for the initial layout. If you enable physics, they layout will be determined by the physics. This will greatly speed up the stabilization time though!</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.parentCentralization</td><td>Boolean</td><td><code>true</code></td><td>When true, the parents nodes will be centered again after the the layout algorithm has been finished.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.direction</td><td>String</td><td><code>'UD'</code></td><td>The direction of the hierarchical layout. The available options are: <code>UD, DU, LR, RL</code>. To simplify: up-down, down-up, left-right, right-left.</td></tr>
<trparent="hierarchical"class="hidden"><tdclass="indent">hierarchical.sortMethod</td><td>String</td><td><code>'hubsize'</code></td><td>The algorithm used to ascertain the levels of the nodes based on the data. The possible options are: <code>hubsize, directed</code>. <br><br>
Hubsize takes the nodes with the most edges and puts them at the top. From that the rest of the hierarchy is evaluated. <br><br>
<td>This property only applies to the <code>image</code> and <code>circularImage</code> shapes. When true, the image is resampled when scaled down, resulting in a nicer image at the cost of computional time.</i>
This example shows a user-defined hierarchical layout. If the user defines levels for nodes but does not do so for all nodes, an alert will show up and hierarchical layout will be disabled. Either all or none can be defined.
This example shows a user-defined hierarchical layout. If the user defines levels for nodes but does not do so for
all nodes, an alert will show up and hierarchical layout will be disabled. Either all or none can be defined.
If the smooth curves appear to be inverted, the direction of the edge is not in the same direction as the network.
</div>
<p>
<inputtype="button"id="btn-UD"value="Up-Down">
<inputtype="button"id="btn-DU"value="Down-Up">
<inputtype="button"id="btn-LR"value="Left-Right">
<inputtype="button"id="btn-RL"value="Right-Left">
<inputtype="hidden"id='direction'value="UD">
<inputtype="button"id="btn-UD"value="Up-Down">
<inputtype="button"id="btn-DU"value="Down-Up">
<inputtype="button"id="btn-LR"value="Left-Right">
<inputtype="button"id="btn-RL"value="Right-Left">
<inputtype="hidden"id='direction'value="UD">
</p>
<divid="mynetwork"></div>
@ -123,22 +128,22 @@
<scriptlanguage="JavaScript">
var directionInput = document.getElementById("direction");
<td>Minimum distance between nodes on the free axis.</td>
</tr>
<tr>
<td><code>treeSpacing</code></td>
<td>Distance between different trees (independent networks).</td>
</tr>
<tr>
<td><code>blockShifting</code></td>
<td>Method for reducing whitespace. Can be used alone or together with edge minimization. Each node will check for whitespace and will shift
it's branch along with it for as far as it can, respecting the nodeSpacing on any level.</td>
</tr>
<tr>
<td><code>edgeMinimization</code></td>
<td>Method for reducing whitespace. Can be used alone or together with block shifting. Enabling block shifting will usually speed up the layout process.
Each node will try to move along its free axis to reduce the total length of it's edges.</td>
</tr>
<tr>
<td><code>parentCentralization</code></td>
<td>When true, the parents nodes will be centered again after the the layout algorithm has been finished.</td>
</tr>
</table>
<br/><br/>
Play with the settings below the network and see how the layout changes!
<divid="network"></div>
<script>
var data = {
nodes: nodes,
edges: edges
};
// create a network
var container = document.getElementById('network');
var options = {
layout: {
hierarchical: {
direction: "UD",
sortMethod: "directed"
}
},
interaction: {dragNodes :false},
physics: {
enabled: false
},
configure: {
filter: function (option, path) {
if (path.indexOf('hierarchical') !== -1) {
return true;
}
return false;
},
showButton:false
}
};
var network = new vis.Network(container, data, options);
You can also supply a custom filter function or filter string. You can press the generate options button below to have an options object printed. You can then use
this in the network.
</p>
<p><b>Note:</b> The configurator is recreated in the dom tree on input change. This may cause undesired scrolls in your application. In order to avoid this, explicitly set the height of the configurator (see this example's source code).
// TODO: remove deprecated property 'data' some day
//Object.defineProperty(props, 'data', {
// 'get': (function() {
// console.warn('Property data is deprecated. Use DataSet.get(ids) to retrieve the new data, use the oldData property on this object to get the old data');
// return updatedData;
// }).bind(this)
//});
this._trigger('update',props,senderId);
}
returnaddedIds.concat(updatedIds);
@ -340,13 +355,13 @@ DataSet.prototype.get = function (args) {
// put the weights for the edges in. This assumes unidirectionality.
for(leti=0;i<edgesArray.length;i++){
letedge=edges[edgesArray[i]];
D_matrix[edge.fromId][edge.toId]=1;
D_matrix[edge.toId][edge.fromId]=1;
// edge has to be connected if it counts to the distances. If it is connected to inner clusters it will crash so we also check if it is in the D_matrix
// draw a rectangle to form the border around. This rectangle is filled so the opacity of a picture (in future vis releases?) can be used to tint the image
ctx.rect(this.left-0.5*ctx.lineWidth,
this.top-0.5*ctx.lineWidth,
this.width+ctx.lineWidth,
this.height+ctx.lineWidth);
ctx.fill();
//draw dashed border if enabled, save and restore is required for firefox not to crash on unix.
ctx.save();
// if borders are zero width, they will be drawn with width 1 by default. This prevents that
if(borderWidth>0){
this.enableBorderDashes(ctx);
//draw the border
ctx.stroke();
//disable dashed border for other elements
this.disableBorderDashes(ctx);
}
ctx.restore();
ctx.closePath();
}
this._drawImageAtPosition(ctx);
this._drawImageLabel(ctx,x,y,selected||hover);
@ -42,12 +78,7 @@ class Image extends CircleImageBase {