Browse Source

Released version 0.1.0

gh-pages
josdejong 11 years ago
parent
commit
81c0c4329b
12 changed files with 2518 additions and 1147 deletions
  1. +0
    -207
      css/style.css.bak
  2. +0
    -4
      docs/css/prettify.css
  3. +682
    -2
      docs/dataset.html
  4. +222
    -0
      docs/dataview.html
  5. +16
    -38
      docs/graph.html
  6. BIN
      docs/img/vis_overview.odg
  7. BIN
      docs/img/vis_overview.png
  8. +173
    -5
      docs/index.html
  9. +100
    -24
      docs/timeline.html
  10. +7
    -12
      index.html
  11. +1311
    -848
      vis.js
  12. +7
    -7
      vis.min.js

+ 0
- 207
css/style.css.bak View File

@ -1,207 +0,0 @@
html, body {
font-family: arial;
font-size: 11pt;
color: #4D4D4D;
line-height: 1.7em;
padding: 0px;
margin: 0px;
width: 100%;
height: 100%;
}
body {
overflow-y: scroll;
}
#container {
margin: 0 auto;
width: 900px;
/* TODO: cleanup
height: 100%;
*/
}
#menu {
width: 150px;
float: left;
text-align: right;
/* TODO: cleanup
height: 100%;
position: fixed;
overflow-x: hidden;
overflow-y: auto;
*/
}
#menu-inner {
padding: 70px 20px 0px 0px;
}
#contents {
/* TODO: cleanup
margin-left: 150px;
*/
padding: 50px 25px;
width: 700px;
float: left;
}
h2 {
padding-top: 20px;
padding-bottom: 10px;
border-bottom: 1px solid #a0c0f0;
color: #2B7CE9;
}
a {
color: #2B7CE9;
text-decoration: none;
}
a:visited {
color: #2E60A4;
}
a:hover {
color: red;
text-decoration: underline;
}
/*
ul.nav {
text-decoration: none;
text-transform: uppercase;
margin-bottom: 30px;
padding-left: 0px;
}
li.nav {
list-style: none;
}
ul li.nav {
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 11pt;
color: #2B7CE9;
margin-top: 5px;
}
ul li ul li.nav {
text-decoration: none;
text-transform: none;
font-weight: normal;
font-size: 11pt;
color: #4D4D4D;
}
*/
div.nav ul {
text-decoration: none;
text-transform: uppercase;
margin-bottom: 30px;
padding-left: 0px;
}
li.nav {
}
div.nav ul li {
text-decoration: none;
text-transform: uppercase;
font-weight: bold;
font-size: 11pt;
color: #2B7CE9;
list-style: none;
margin-top: 5px;
}
div.nav ul li ul li {
text-decoration: none;
text-transform: none;
font-weight: normal;
font-size: 11pt;
color: #4D4D4D;
list-style: none;
}
a.nav {
color: #4D4D4D;
}
a.nav:hover {
color: #2B7CE9;
}
table.example {
border-collapse: collapse;
}
th.example {
font-weight: normal;
border: 1px solid lightgray;
background-color: #E5E5E5;
text-align: left;
vertical-align: top;
padding: 5px;
}
td.example {
border: 1px solid lightgray;
padding: 5px;
}
pre {
line-height: 1.5em;
font-size: 10pt;
overflow-x: auto;
background-color: #F5F5F5;
border: 1px solid lightgray;
padding: 5px;
}
pre.example {
background-color: transparent;
border: none;
padding: 0px;
margin: 0px;
}
div.lastupdate {
font-size: 75%;
margin-top: 40px;
border-top: 1px solid #a0c0f0;
color: #2B7CE9;
}
img {
border: none;
}
img.thumb {
border: 1px solid #a0c0f0;
width: 120px;
height: 60px;
}
img.thumb:hover {
border-color: #2E60A4;
}
#forkme {
position: fixed;
top: 0;
right: 0;
border: 0;
}

+ 0
- 4
docs/css/prettify.css View File

@ -16,16 +16,12 @@
pre.prettyprint {
border: 1px solid lightgray;
box-sizing: border-box;
-moz-box-sizing: border-box;
background-color: #fcfcfc;
padding: 5px;
font-size: 10pt;
line-height: 1.5em;
font-family: monospace;
overflow-x: auto;
width: 100%;
}
ol.linenums {

+ 682
- 2
docs/dataset.html View File

@ -11,12 +11,692 @@
<script type="text/javascript" src="lib/prettify/prettify.js"></script>
</head>
<body>
<body onload="prettyPrint();">
<div id="container">
<h1>DataSet documentation</h1>
<p>coming soon...</p>
<h2 id="Contents">Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Example">Example</a></li>
<li><a href="#Construction">Construction</a></li>
<li><a href="#Data_Manipulation">Data Manipulation</a></li>
<li><a href="#Data_Filtering">Data Filtering</a></li>
<li><a href="#Data_Formatting">Data Formatting</a></li>
<li><a href="#Subscriptions">Subscriptions</a></li>
<li><a href="#Data_Policy">Data Policy</a></li>
</ul>
<h2 id="Overview">Overview</h2>
<p>
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.
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.
</p>
<h2 id="Example">Example</h2>
<p>
The following example shows how to use a DataSet.
</p>
<pre class="prettyprint lang-js">
// create a DataSet
var options = {};
var data = new vis.DataSet(options);
// add items
// note that the data items can contain different properties and data formats
data.add([
{id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
{id: 2, text: 'item 2', date: '2013-06-23', group: 2},
{id: 3, text: 'item 3', date: '2013-06-25', group: 2},
{id: 4, text: 'item 4'}
]);
// subscribe to any change in the DataSet
data.subscribe('*', function (event, params, senderId) {
console.log('event', event, params);
});
// update an existing item
data.update({id: 2, group: 1});
// remove an item
data.remove(4);
// get all ids
var ids = data.getIds();
console.log('ids', ids);
// get a specific item
var item1 = data.get(1);
console.log('item1', item1);
// retrieve a filtered subset of the data
var items = data.get({
filter: function (item) {
return item.group == 1;
}
});
console.log('filtered items', items);
// retrieve formatted items
var items = data.get({
fields: ['id', 'date'],
convert: {
date: 'ISODate'
}
});
console.log('formatted items', items);
</pre>
<h2 id="Construction">Construction</h2>
<p>
A DataSet can be constructed as:
</p>
<pre class="prettyprint lang-js">
var data = new vis.DataSet(options)
</pre>
<p>
After construction, data can be added to the DataSet using the methods
<code>add</code> and <code>update</code>, as described in section
<a href="#Data_Manipulation">Data Manipulation</a>.
</p>
<p>
The parameter <code>options</code> is optional and is an object which can
contain the following properties:
</p>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default value</th>
<th>Description</th>
</tr>
<tr>
<td>fieldId</td>
<td>String</td>
<td>"id"</td>
<td>
The name of the field containing the id of the items.
When data is fetched from a server which uses some specific
field to identify items, this field name can be specified
in the DataSet using the option <code>fieldId</code>.
For example <a href="http://couchdb.apache.org/"
target="_blank">CouchDB</a> uses the field
<code>"_id"</code> to identify documents.
</td>
</tr>
<tr>
<td>convert</td>
<td>Object.&lt;String,&nbsp;String&gt;</td>
<td>none</td>
<td>
An object containing field names as key, and data types as
value. By default, the type of the properties of items are left
unchanged. Item properties can be normalized by specifying a
field type. This is useful for example to automatically convert
stringified dates coming from a server into JavaScript Date
objects. The available data types are listed in section
<a href="#Data_Types">Data Types</a>.
</td>
</tr>
</table>
<h2 id="Data_Manipulation">Data Manipulation</h2>
<p>
The data in a DataSet can be manipulated using the methods
<a href="#Add"><code>add</code></a>,
<a href="#Update"><code>update</code></a>,
and <a href="#Remove"><code>remove</code></a>.
The DataSet can be emptied using the method
<a href="#Clear"><code>clear</code></a>.
</p>
<pre class="prettyprint lang-js">
// create a DataSet
var data = new vis.DataSet();
// add items
data.add([
{id: 1, text: 'item 1'},
{id: 2, text: 'item 2'},
{id: 3, text: 'item 3'}
]);
// update an item
data.update({id: 2, text: 'item 2 (updated)'});
// remove an item
data.remove(3);
</pre>
<h3 id="Add">Add</h3>
<p>
Add a data item or an array with items.
</p>
Syntax:
<pre class="prettyprint lang-js">var addedIds = DataSet.add(data [, senderId])</pre>
The argument <code>data</code> can contain:
<ul>
<li>
An <code>Object</code> containing a single item to be
added. The item must contain an id.
</li>
<li>
An <code>Array</code> or
<code>google.visualization.DataTable</code> containing
a list with items to be added. Each item must contain
an id.
</li>
</ul>
<p>
After the items are added to the DataSet, the DataSet will
trigger an event <code>add</code>. When a <code>senderId</code>
is provided, this id will be passed with the triggered
event to all subscribers.
</p>
<p>
The method will throw an Error when an item with the same id
as any of the added items already exists.
</p>
<h3 id="Update">Update</h3>
<p>
Update a data item or an array with items.
</p>
Syntax:
<pre class="prettyprint lang-js">var updatedIds = DataSet.update(data [, senderId])</pre>
The argument <code>data</code> can contain:
<ul>
<li>
An <code>Object</code> containing a single item to be
updated. The item must contain an id.
</li>
<li>
An <code>Array</code> or
<code>google.visualization.DataTable</code> containing
a list with items to be updated. Each item must contain
an id.
</li>
</ul>
<p>
The provided properties will be merged in the existing item.
When an item does not exist, it will be created.
</p>
<p>
After the items are updated, the DataSet will
trigger an event <code>add</code> for the added items, and
an event <code>update</code>. When a <code>senderId</code>
is provided, this id will be passed with the triggered
event to all subscribers.
</p>
<h3 id="Remove">Remove</h3>
<p>
Remove a data item or an array with items.
</p>
Syntax:
<pre class="prettyprint lang-js">var removedIds = DataSet.remove(id [, senderId])</pre>
<p>
The argument <code>id</code> can be:
</p>
<ul>
<li>
A <code>Number</code> or <code>String</code> containing the id
of a single item to be removed.
</li>
<li>
An <code>Object</code> containing the item to be deleted.
The item will be deleted by its id.
</li>
<li>
An Array containing ids or items to be removed.
</li>
</ul>
<p>
The method ignores removal of non-existing items, and returns an array
containing the ids of the items which are actually removed from the
DataSet.
</p>
<p>
After the items are removed, the DataSet will
trigger an event <code>remove</code> for the removed items.
When a <code>senderId</code> is provided, this id will be passed with
the triggered event to all subscribers.
</p>
<h3 id="Clear">Clear</h3>
<p>
Clear the complete DataSet.
</p>
Syntax:
<pre class="prettyprint lang-js">var removedIds = DataSet.clear([senderId])</pre>
<p>
After the items are removed, the DataSet will
trigger an event <code>remove</code> for all removed items.
When a <code>senderId</code> is provided, this id will be passed with
the triggered event to all subscribers.
</p>
<h2 id="Data_Filtering">Data Filtering</h2>
<p>
Data can be retrieved from the DataSet using the method <code>get</code>.
This method can return a single item or a list with items.
</p>
<p>A single item can be retrieved by its id:</p>
<pre class="prettyprint lang-js">
var item1 = dataset.get(1);
</pre>
<p>A selection of items can be retrieved by providing an array with ids:</p>
<pre class="prettyprint lang-js">
var items = dataset.get([1, 3, 4]); // retrieve items 1, 3, and 4
</pre>
<p>All items can be retrieved by simply calling <code>get</code> without
specifying an id:</p>
<pre class="prettyprint lang-js">
var items = dataset.get(); // retrieve all items
</pre>
<p>
Items can be filtered on specific properties by providing a filter
function. A filter function is executed for each of the items in the
DataSet, and is called with the item as parameter. The function must
return a boolean. All items for which the filter function returns
true will be emitted.
</p>
<pre class="prettyprint lang-js">
// retrieve all items having a property group with value 2
var group2 = dataset.get({
filter: function (item) {
return (item.group == 2);
}
});
// retrieve all items having a property balance with a value above zero
var positiveBalance = dataset.get({
filter: function (item) {
return (item.balance > 0);
}
});
</pre>
<h2 id="Data_Formatting">Data Formatting</h2>
<p>
The DataSet contains functionality to format data retrieved via the
method <code>get</code>. The method <code>get</code> has the following
syntax:
</p>
<pre class="prettyprint lang-js">
var item = DataSet.get(id, options); // retrieve a single item
var items = DataSet.get(ids, options); // retrieve a selection of items
var items = DataSet.get(options); // retrieve all items or a filtered set
</pre>
<p>
Where <code>options</code> is an Object which can have the following
properties:
</p>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>fields</td>
<td>String[&nbsp;]</td>
<td>
An array with field names.
By default, all properties of the items are emitted.
When <code>fields</code> is defined, only the properties
whose name is specified in <code>fields</code> will be included
in the returned items.
</td>
</tr>
<tr>
<td>convert</td>
<td>Object.&lt;String,&nbsp;String&gt;</td>
<td>
An object containing field names as key, and data types as value.
By default, the type of the properties of an item are left
unchanged. When a field type is specified, this field in the
items will be converted to the specified type. This can be used
for example to convert ISO strings containing a date to a
JavaScript Date object, or convert strings to numbers or vice
versa. The available data types are listed in section
<a href="#Data_Types">Data Types</a>.
</td>
</tr>
<tr>
<td>filter</td>
<td>function</td>
<td>Items can be filtered on specific properties by providing a filter
function. A filter function is executed for each of the items in the
DataSet, and is called with the item as parameter. The function must
return a boolean. All items for which the filter function returns
true will be emitted.
See section <a href="#Data_Filtering">Data Filtering</a>.</td>
</tr>
</table>
<p>
The following example demonstrates formatting properties and filtering
properties from items.
</p>
<pre class="prettyprint lang-js">
// create a DataSet
var data = new vis.DataSet();
data.add([
{id: 1, text: 'item 1', date: '2013-06-20', group: 1, first: true},
{id: 2, text: 'item 2', date: '2013-06-23', group: 2},
{id: 3, text: 'item 3', date: '2013-06-25', group: 2},
{id: 4, text: 'item 4'}
]);
// retrieve formatted items
var items = data.get({
fields: ['id', 'date', 'group'], // output the specified fields only
convert: {
date: 'Date', // convert the date fields to Date objects
group: 'String' // convert the group fields to Strings
}
});
</pre>
<h3 id="Data_Types">Data Types</h3>
<p>
DataSet supports the following data types:
</p>
<table style="width: 100%">
<tr>
<th>Name</th>
<th>Description</th>
<th>Examples</th>
</tr>
<tr>
<td>Boolean</td>
<td>A JavaScript Boolean</td>
<td>
<code>true</code><br>
<code>false</code>
</td>
</tr>
<tr>
<td>Number</td>
<td>A JavaScript Number</td>
<td>
<code>32</code><br>
<code>2.4</code>
</td>
</tr>
<tr>
<td>String</td>
<td>A JavaScript String</td>
<td>
<code>"hello world"</code><br>
<code>"2013-06-28"</code>
</td>
</tr>
<tr>
<td>Date</td>
<td>A JavaScript Date object</td>
<td>
<code>new Date()</code><br>
<code>new Date(2013, 5, 28)</code><br>
<code>new Date(1372370400000)</code>
</td>
</tr>
<tr>
<td>Moment</td>
<td>A Moment object, created with
<a href="http://momentjs.com/" target="_blank">moment.js</a></td>
<td>
<code>moment()</code><br>
<code>moment('2013-06-28')</code>
</td>
</tr>
<tr>
<td>ISODate</td>
<td>A string containing an ISO Date</td>
<td>
<code>new Date().toISOString()</code><br>
<code>"2013-06-27T22:00:00.000Z"</code>
</td>
</tr>
<tr>
<td>ASPDate</td>
<td>A string containing an ASP Date</td>
<td>
<code>"/Date(1372370400000)/"</code><br>
<code>"/Date(1198908717056-0700)/"</code>
</td>
</tr>
</table>
<h2 id="Subscriptions">Subscriptions</h2>
<p>
One can subscribe on changes in a DataSet.
A subscription can be created using the method <code>subscribe</code>,
and removed with <code>unsubscribe</code>.
</p>
<pre class="prettyprint lang-js">
// create a DataSet
var data = new vis.DataSet();
// subscribe to any change in the DataSet
data.subscribe('*', function (event, params, senderId) {
console.log('event:', event, 'params:', params, 'senderId:', senderId);
});
// add an item
data.add({id: 1, text: 'item 1'}); // triggers an 'add' event
data.update({id: 1, text: 'item 1 (updated)'}); // triggers an 'update' event
data.remove(1); // triggers an 'remove' event
</pre>
<h3 id="Subscribe">Subscribe</h3>
<p>
Subscribe to an event.
</p>
Syntax:
<pre class="prettyprint lang-js">DataSet.subscribe(event, callback)</pre>
Where:
<ul>
<li>
<code>event</code> is a String containing any of the events listed
in section <a href="#Events">Events</a>.
</li>
<li>
<code>callback</code> is a callback function which will be called
each time the event occurs. The callback function is described in
section <a href="#Callback">Callback</a>.
</li>
</ul>
<h3 id="Unsubscribe">Unsubscribe</h3>
<p>
Unsubscribe from an event.
</p>
Syntax:
<pre class="prettyprint lang-js">DataSet.unsubscribe(event, callback)</pre>
Where <code>event</code> and <code>callback</code> correspond with the
parameters used to <a href="#Subscribe">subscribe</a> to the event.
<h3 id="Events">Events</h3>
<p>
The following events are available for subscription:
</p>
<table>
<tr>
<th>Event</th>
<th>Description</th>
</tr>
<tr>
<td>add</td>
<td>
The <code>add</code> event is triggered when an item
or a set of items is added, or when an item is updated while
not yet existing.
</td>
</tr>
<tr>
<td>update</td>
<td>
The <code>update</code> event is triggered when an existing item
or a set of existing items is updated.
</td>
</tr>
<tr>
<td>remove</td>
<td>
The <code>remove</code> event is triggered when an item
or a set of items is removed.
</td>
</tr>
<tr>
<td>*</td>
<td>
The <code>*</code> event is triggered when any of the events
<code>add</code>, <code>update</code>, and <code>remove</code>
occurs.
</td>
</tr>
</table>
<h3 id="Callback">Callback</h3>
<p>
The callback functions of subscribers are called with the following
parameters:
</p>
<pre class="prettyprint lang-js">
function (event, params, senderId) {
// handle the event
});
</pre>
<p>
where the parameters are defined as
</p>
<table>
<tr>
<th>Parameter</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>event</td>
<td>String</td>
<td>
Any of the available events: <code>add</code>,
<code>update</code>, or <code>remove</code>.
</td>
</tr>
<tr>
<td>params</td>
<td>Object&nbsp;|&nbsp;null</td>
<td>
Optional parameters providing more information on the event.
In case of the events <code>add</code>,
<code>update</code>, and <code>remove</code>,
<code>params</code> is always an object containing a property
items, which contains an array with the ids of the affected
items.
</td>
</tr>
<tr>
<td>senderId</td>
<td>String&nbsp;|&nbsp;Number</td>
<td>
An senderId, optionally provided by the application code
which triggered the event. If senderId is not provided, the
argument will be <code>null</code>.
</td>
</tr>
</table>
<h2 id="Data_Policy">Data Policy</h2>
<p>
All code and data is processed and rendered in the browser.
No data is sent to any server.
</p>
</div>
</body>

+ 222
- 0
docs/dataview.html View File

@ -0,0 +1,222 @@
<!doctype html>
<html>
<head>
<title>vis.js | DataView documentation</title>
<link rel='stylesheet' href='css/style.css' type='text/css' />
<link href="css/prettify.css" type="text/css" rel="stylesheet" />
<link href='css/style.css' type='text/css' rel='stylesheet'>
<script type="text/javascript" src="lib/prettify/prettify.js"></script>
</head>
<body onload="prettyPrint();">
<div id="container">
<h1>DataView documentation</h1>
<h2 id="Contents">Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Example">Example</a></li>
<li><a href="#Construction">Construction</a></li>
<li><a href="#Getting_Data">Getting Data</a></li>
<li><a href="#Subscriptions">Subscriptions</a></li>
<li><a href="#Data_Policy">Data Policy</a></li>
</ul>
<h2 id="Overview">Overview</h2>
<p>
A DataView offers a filtered and/or formatted view on a
<a href="dataset.html">DataSet</a>.
One can subscribe on changes in a DataView, and easily get filtered or
formatted data without having to specify filters and field types all
the time.
</p>
<h2 id="Example">Example</h2>
<p>
The following example shows how to use a DataView.
</p>
<pre class="prettyprint lang-js">
// create a DataSet
var data = new vis.DataSet();
data.add([
{id: 1, text: 'item 1', date: new Date(2013, 6, 20), group: 1, first: true},
{id: 2, text: 'item 2', date: '2013-06-23', group: 2},
{id: 3, text: 'item 3', date: '2013-06-25', group: 2},
{id: 4, text: 'item 4'}
]);
// create a DataView
// the view will only contain items having a property group with value 1,
// and will only output fields id, text, and date.
var view = new vis.DataView(data, {
filter: function (item) {
return (item.group == 1);
},
fields: ['id', 'text', 'date']
});
// subscribe to any change in the DataView
view.subscribe('*', function (event, params, senderId) {
console.log('event', event, params);
});
// update an item in the data set
data.update({id: 2, group: 1});
// get all ids in the view
var ids = view.getIds();
console.log('ids', ids); // will output [1, 2]
// get all items in the view
var items = view.get();
</pre>
<h2 id="Construction">Construction</h2>
<p>
A DataView can be constructed as:
</p>
<pre class="prettyprint lang-js">
var data = new vis.DataView(dataset, options)
</pre>
<p>
where:
</p>
<ul>
<li>
<code>dataset</code> is a DataSet or DataView.
</li>
<li>
<code>options</code> is an object which can
contain the following properties. Note that these properties
are exactly the same as the properties available in methods
<code>DataSet.get</code> and <code>DataView.get</code>.
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>convert</td>
<td>Object.&lt;String,&nbsp;String&gt;</td>
<td>
An object containing field names as key, and data types as value.
By default, the type of the properties of an item are left
unchanged. When a field type is specified, this field in the
items will be converted to the specified type. This can be used
for example to convert ISO strings containing a date to a
JavaScript Date object, or convert strings to numbers or vice
versa. The available data types are listed in section
<a href="dataset.html#Data_Types">Data Types</a>.
</td>
</tr>
<tr>
<td>fields</td>
<td>String[&nbsp;]</td>
<td>
An array with field names.
By default, all properties of the items are emitted.
When <code>fields</code> is defined, only the properties
whose name is specified in <code>fields</code> will be included
in the returned items.
</td>
</tr>
<tr>
<td>filter</td>
<td>function</td>
<td>Items can be filtered on specific properties by providing a filter
function. A filter function is executed for each of the items in the
DataSet, and is called with the item as parameter. The function must
return a boolean. All items for which the filter function returns
true will be emitted.
See also section <a href="dataset.html#Data_Filtering">Data Filtering</a>.</td>
</tr>
</table>
</li>
</ul>
<h2 id="Getting_Data">Getting Data</h2>
<p>
Data of the DataView can be retrieved using the method <code>get</code>.
</p>
<pre class="prettyprint lang-js">
var items = view.get();
</pre>
<p>
Data of a DataView can be filtered and formatted again, in exactly the
same way as in a DataSet. See sections
<a href="dataset.html#Data_Filtering">Data Filtering</a> and
<a href="dataset.html#Data_Formatting">Data Formatting</a> for more
information.
</p>
<pre class="prettyprint lang-js">
var items = view.get({
fields: ['id', 'score'],
filter: function (item) {
return (item.score > 50);
}
});
</pre>
<h2 id="Subscriptions">Subscriptions</h2>
<p>
One can subscribe on changes in the DataView. Subscription works exactly
the same as for DataSets. See the documentation on
<a href="dataset.html#Subscriptions">subscriptions in a DataSet</a>
for more information.
</p>
<pre class="prettyprint lang-js">
// create a DataSet and a view on the data set
var data = new vis.DataSet();
var view = new vis.DataView({
filter: function (item) {
return (item.group == 2);
}
});
// subscribe to any change in the DataView
view.subscribe('*', function (event, params, senderId) {
console.log('event:', event, 'params:', params, 'senderId:', senderId);
});
// add, update, and remove data in the DataSet...
</pre>
<h2 id="Data_Policy">Data Policy</h2>
<p>
All code and data is processed and rendered in the browser.
No data is sent to any server.
</p>
</div>
</body>
</html>

+ 16
- 38
docs/graph.html View File

@ -15,22 +15,6 @@
<h1>Graph documentation</h1>
<table>
<tr>
<td>Author</td>
<td>Jos de Jong, <a href="http://www.almende.com" target="_blank">Almende B.V.</a></td>
</tr>
<tr>
<td>Webpage</td>
<td><a href="http://visjs.org" target="_blank">http://visjs.org</a></td>
</tr>
<tr>
<td>License</td>
<td> <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a></td>
</tr>
</table>
<h2><a name="Contents"></a>Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
@ -1039,10 +1023,10 @@ var nodes = [
<tr>
<td>getSelection()</td>
<td>Array of selection elements</td>
<td>Standard <code>getSelection()</code> implementation.
Returns an array with one or multiple selections. Each selection contains
the property <code>row</code>. The selections are not ordered.
<td>Array of ids</td>
<td>Returns an array with the ids of the selected nodes.
Returns an empty array if no nodes are selected.
The selections are not ordered.
</td>
</tr>
@ -1055,10 +1039,11 @@ var nodes = [
<tr>
<td>setSelection(selection)</td>
<td>none</td>
<td>Standard <code>setSelection(selection)</code> implementation.
<code>selection</code> is an array with selection elements. The visualization
accepts one or multiple selection elements, which must have the property <code>row</code>.
Example usage: <code>graph.setSelection([{"row": 3}]);</code>.
<td>Select nodes.
<code>selection</code> is an array with ids of nodes to be selected.
The array <code>selection</code> can contain zero or multiple ids.
Example usage: <code>graph.setSelection([3, 5]);</code> will select
nodes with id 3 and 5.
</td>
</tr>
@ -1083,18 +1068,11 @@ var nodes = [
</p>
<pre class="prettyprint lang-js">
function onselect() {
var sel = graph.getSelection();
var info = 'selected row(s): ';
for (var i = 0; i &lt; sel.length; i++) {
info += sel[i].row + ' ';
}
alert(info);
function onSelect() {
alert('selected nodes: ' + graph.getSelection());
}
vis.events.addListener(graph, 'select', onselect);
vis.events.addListener(graph, 'select', onSelect);
</pre>
<p>
@ -1117,9 +1095,8 @@ vis.events.addListener(graph, 'select', onselect);
<td>Fired after the user selects or unselects a node by clicking it,
or when selecting a number of nodes by dragging a selection area
around them. Not fired when the method <code>setSelection</code>
is executed. The corresponding rows in the Array are selected.
<br>
The selected rows can be retrieved via the method <code>getSelection</code>.
is executed. The ids of the selected nodes can be retrieved via the
method <code>getSelection</code>.
</td>
<td>none</td>
</tr>
@ -1128,7 +1105,8 @@ vis.events.addListener(graph, 'select', onselect);
<h2 id="Data_Policy">Data Policy</h2>
<p>
All code and data are processed and rendered in the browser. No data is sent to any server.
All code and data is processed and rendered in the browser.
No data is sent to any server.
</p>
</div>

BIN
docs/img/vis_overview.odg View File


BIN
docs/img/vis_overview.png View File

Before After
Width: 960  |  Height: 912  |  Size: 64 KiB

+ 173
- 5
docs/index.html View File

@ -11,19 +11,187 @@
<script type="text/javascript" src="lib/prettify/prettify.js"></script>
</head>
<body>
<body onload="prettyPrint();">
<div id="container">
<h1>vis.js documentation</h1>
<p>Vis.js contains the following components:</p>
<p>
Vis.js is a dynamic, browser based visualization library.
The library is designed to be easy to use, handle large amounts
of dynamic data, and enable manipulation of the data.
</p>
<p>
The library is developed by
<a href="http://almende.com" target="_blank">Almende B.V.</a>
</p>
<h2 id="Components">Components</h2>
<p>
Vis.js contains of the following components:
</p>
<ul>
<li><a href="dataset.html">DataSet</a></li>
<li><a href="graph.html">Graph</a></li>
<li><a href="timeline.html">Timeline</a></li>
<li>
<a href="dataset.html"><b>DataSet</b></a>.
A flexible key/value based data set.
Add, update, and remove items. Subscribe on changes in the data set.
A DataSet can filter and order items, and convert fields of items.
</li>
<li>
<a href="dataview.html"><b>DataView</b></a>.
A filtered and/or formatted view on a DataSet.
</li>
<li>
<a href="graph.html"><b>Graph</b></a>.
Display a graph or network with nodes and edges.
</li>
<li>
<a href="timeline.html"><b>Timeline</b></a>.
Display different types of data on a timeline. The timeline and the
items on the timeline can be interactively moved, zoomed, and
manipulated.
</li>
</ul>
<h2 id="Install">Install</h2>
<h3>npm</h3>
<pre class="prettyprint">
npm install vis
</pre>
<h3>bower</h3>
<pre class="prettyprint">
bower install vis
</pre>
<h3>download</h3>
Download the library from the website:
<a href="http://visjs.org" target="_blank">http://visjs.org</a>.
<h2 id="Load">Load</h2>
<p>
To use a component, include the javascript file of vis in your web page:
</p>
<pre class="prettyprint lang-html">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script src="components/vis/vis.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;script type="text/javascript"&gt;
// ... load a visualization
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>
or load vis.js using require.js:
</p>
<pre class="prettyprint lang-js">
require.config({
paths: {
vis: 'path/to/vis',
}
});
require(['vis'], function (math) {
// ... load a visualization
});
</pre>
<p>
A timeline can be instantiated as follows. Other components can be
created in a similar way.
</p>
<pre class="prettyprint lang-js">
var timeline = new vis.Timeline(container, data, options);
</pre>
<p>
Where <code>container</code> is an HTML element, <code>data</code> is
an Array with data or a DataSet, and <code>options</code> is an optional
object with configuration options for the component.
</p>
<h2 id="Use">Use</h2>
<p>
A basic example on using a Timeline is shown below. More examples can be
found in the <a href="https://github.com/almende/vis/tree/master/examples"
target="_blank">examples directory</a> of the project.
</p>
<pre class="prettyprint lang-html">
&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Timeline basic demo&lt;/title&gt;
&lt;script src="components/vis/vis.js"&gt;&lt;/script&gt;
&lt;style type="text/css"&gt;
body, html {
font-family: sans-serif;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id="visualization"&gt;&lt;/div&gt;
&lt;script type="text/javascript"&gt;
var container = document.getElementById('visualization');
var data = [
{id: 1, content: 'item 1', start: '2013-04-20'},
{id: 2, content: 'item 2', start: '2013-04-14'},
{id: 3, content: 'item 3', start: '2013-04-18'},
{id: 4, content: 'item 4', start: '2013-04-16', end: '2013-04-19'},
{id: 5, content: 'item 5', start: '2013-04-25'},
{id: 6, content: 'item 6', start: '2013-04-27'}
];
var options = {};
var timeline = new vis.Timeline(container, data, options);
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<h2 id="license">License</h2>
<p>
Copyright (C) 2010-2013 Almende B.V.
</p>
<p>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
</p>
<p>
<a href="http://www.apache.org/licenses/LICENSE-2.0"
target="_blank">http://www.apache.org/licenses/LICENSE-2.0</a>
</p>
<p>
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</p>
</div>
</body>
</html>

+ 100
- 24
docs/timeline.html View File

@ -14,29 +14,18 @@
<h1>Timeline documentation</h1>
<table>
<tr>
<td>Author</td>
<td>Jos de Jong, <a href="http://www.almende.com" target="_blank">Almende B.V.</a></td>
</tr>
<tr>
<td>Webpage</td>
<td><a href="http://visjs.org" target="_blank">http://visjs.org</a></td>
</tr>
<tr>
<td>License</td>
<td> <a href="http://www.apache.org/licenses/LICENSE-2.0" target="_blank">Apache License, Version 2.0</a></td>
</tr>
</table>
<h2 id="Contents">Contents</h2>
<ul>
<li><a href="#Overview">Overview</a></li>
<li><a href="#Example">Example</a></li>
<li><a href="#Loading">Loading</a></li>
<li><a href="#Data_Format">Data Format</a></li>
<li><a href="#Data_Format">Data Format</a>
<ul>
<li><a href="#items">Items</a></li>
<li><a href="#groups">Groups</a></li>
</ul>
</li>
<li><a href="#Configuration_Options">Configuration Options</a></li>
<li><a href="#Methods">Methods</a></li>
<li><a href="#Styles">Styles</a></li>
@ -125,6 +114,16 @@ The constructor accepts three parameters:
<h2 id="Data_Format">Data Format</h2>
<p>
The timeline can be provided with two types of data:
</p>
<ul>
<li><a href="#items">Items</a> containing a set of items to be displayed in time.</li>
<li><a href="#groups">Groups</a> containing a set of groups used to group items
together.</li>
</ul>
<h3 id="items">Items</h3>
<p>
The Timeline uses regular Arrays and Objects as data format.
Data items can contain the properties <code>start</code>,
@ -150,8 +149,6 @@ var items = [
]);
</pre>
<h3>Properties</h3>
<p>
The item properties are defined as:
</p>
@ -163,6 +160,14 @@ var items = [
<th>Required</th>
<th>Description</th>
</tr>
<tr>
<td>id</td>
<td>String | Number</td>
<td>no</td>
<td>An id for the item. Using an id is not required but highly
recommended. An id is needed when dynamically adding, updating,
and removing items in a DataSet.</td>
</tr>
<tr>
<td>start</td>
<td>Date</td>
@ -205,7 +210,7 @@ var items = [
<td>String</td>
<td>no</td>
<td>This field is optional. A className can be used to give items
and individual css style. For example, when an item has className
an individual css style. For example, when an item has className
'red', one can define a css style
<code>
.red {
@ -219,6 +224,76 @@ var items = [
</tr>
</table>
<h3 id="groups">Groups</h3>
<p>
Like the items, groups are regular JavaScript Arrays and Objects.
Using groups, items can be grouped together.
Items are filtered per group, and displayed as
Group items can contain the properties <code>id</code>,
<code>content</code>, and <code>className</code> (optional).
</p>
<p>
Groups can be applied to a timeline using the method <code>setGroups</code>.
A table with groups can be created like:
</p>
<pre class="prettyprint lang-js">
var groups = [
{
id: 1,
content: 'Group 1'
// Optional: a field 'className'
}
// more groups...
]);
</pre>
<p>
Groups can have the following properties:
</p>
<table>
<tr>
<th>Name</th>
<th>Type</th>
<th>Required</th>
<th>Description</th>
</tr>
<tr>
<td>id</td>
<td>String | Number</td>
<td>yes</td>
<td>An id for the group. The group will display all items having a
property <code>group</code> which matches the <code>id</code>
of the group.</td>
</tr>
<tr>
<td>content</td>
<td>String</td>
<td>yes</td>
<td>The contents of the group. This can be plain text or html code.</td>
</tr>
<tr>
<td>className</td>
<td>String</td>
<td>no</td>
<td>This field is optional. A className can be used to give groups
an individual css style. For example, when a group has className
'red', one can define a css style
<code>
.red {
color: red;
}
</code>.
More details on how to style groups can be found in the section
<a href="#Styles">Styles</a>.
</td>
</tr>
</table>
<h2 id="Configuration_Options">Configuration Options</h2>
@ -433,16 +508,16 @@ var options = {
<th>Return Type</th>
<th>Description</th>
</tr>
<!-- TODO: document groups as soon as implemented
<tr>
<td>setGroups(groups)</td>
<td>none</td>
<td>Set a data set with groups for the Timeline.
<code>groups</code> can be an Array with Objects,
a DataSet, or a DataView.
a DataSet, or a DataView. For each of the groups, the items of the
timeline are filtered on the property <code>group</code>, which
must correspond with the id of the group.
</td>
</tr>
-->
<tr>
<td>setItems(items)</td>
<td>none</td>
@ -484,7 +559,8 @@ var options = {
<h2 id="Data_Policy">Data Policy</h2>
<p>
All code and data are processed and rendered in the browser. No data is sent to any server.
All code and data is processed and rendered in the browser.
No data is sent to any server.
</p>
</div>

+ 7
- 12
index.html View File

@ -28,7 +28,7 @@
<li><a href="#install">Install</a></li>
<li><a href="#example">Example</a></li>
<li><a href="#gallery">Gallery</a></li>
<li><a href="#docs">Docs</a></li>
<li><a href="docs/index.html" target="_blank">Docs</a></li>
<li><a href="#license">License</a></li>
</ul>
</div>
@ -67,19 +67,19 @@ bower install vis
<tr>
<td>
<a href="vis.js" target="_blank">Development
(version <span class="version">0.0.9</span>)</a>
(version <span class="version">0.1.0</span>)</a>
</td>
<td>
<span id="development-size">372 kB</span>, uncompressed with comments
<span id="development-size">384 kB</span>, uncompressed with comments
</td>
</tr>
<tr>
<td>
<a href="vis.min.js" target="_blank">Production
(version <span class="version">0.0.9</span>)</a>
(version <span class="version">0.1.0</span>)</a>
</td>
<td>
<span id="production-size">33 kB</span>, minified and gzipped
<span id="production-size">34 kB</span>, minified and gzipped
</td>
</tr>
</table>
@ -275,14 +275,9 @@ bower install vis
<h2 id="docs">Docs</h2>
<p>
The following documentation is available:
Documentation is available here:
<a href="docs/index.html" target="_blank">Documentation</a>
</p>
<ul>
<li><a href="https://github.com/almende/vis#readme" target="_blank">Introduction</a></li>
<li><a href="docs/dataset.html" target="_blank">DataSet</a></li>
<li><a href="docs/graph.html" target="_blank">Graph</a></li>
<li><a href="docs/timeline.html" target="_blank">Timeline</a></li>
</ul>
<h2 id="license">License</h2>

+ 1311
- 848
vis.js
File diff suppressed because it is too large
View File


+ 7
- 7
vis.min.js
File diff suppressed because it is too large
View File


Loading…
Cancel
Save