@ -0,0 +1,859 @@ | |||
<html> | |||
<head> | |||
<title>vis.js | Graph2d documentation</title> | |||
<style> | |||
td.greenField { | |||
background-color: #c9ffc7; | |||
} | |||
</style> | |||
<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>Graph2d documentation</h1> | |||
<h2 id="Overview">Overview</h2> | |||
<p> | |||
Graph2d is an interactive visualization chart to draw data in a 2D graph. | |||
You can freely move and zoom in the graph by dragging and scrolling in the | |||
window. | |||
</p> | |||
<p> | |||
Graph2d uses HTML DOM and SVG for rendering. This allows for flexible | |||
customization using css styling. | |||
</p> | |||
<h2 id="Contents">Contents</h2> | |||
<ul> | |||
<li><a href="#Overview">Overview</a></li> | |||
<li><a href="#Loading">Loading</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> | |||
<ul> | |||
<li><a href="#graph2dOptions">Graph2d options</a></li> | |||
<li><a href="#timelineOptions">Timeline options</a></li> | |||
</ul> | |||
</li> | |||
<li><a href="#Methods">Methods</a></li> | |||
<li><a href="#Events">Events</a></li> | |||
<li><a href="#Data_Policy">Data Policy</a></li> | |||
</ul> | |||
<h2 id="Example">Example</h2> | |||
<p> | |||
The following code shows how to create a Graph2d and provide it with data. | |||
More examples can be found in the <a href="../examples">examples</a> directory. | |||
</p> | |||
<pre class="prettyprint lang-html"> | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Basic Example</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options); | |||
</script> | |||
</body> | |||
</html> | |||
</pre> | |||
<h2 id="Loading">Loading</h2> | |||
<p> | |||
The class name of the Graph2d is <code>vis.Graph2d</code>. | |||
When constructing a Graph2d, an HTML DOM container must be provided to attach | |||
the graph to. Optionally, data an options can be provided. | |||
Data is a vis <code>DataSet</code> or an <code>Array</code>, described in | |||
section <a href="#Data_Format">Data Format</a>. | |||
Options is a name-value map in the JSON format. The available options | |||
are described in section <a href="#Configuration_Options">Configuration Options</a>. | |||
Groups is a vis <code>DataSet</code> containing groups. The available options and the method of construction | |||
are described in section <a href="#Group_Options">Data Format</a>. | |||
</p> | |||
<pre class="prettyprint lang-js">var graph = new vis.Graph2d(container [, data] [, options] [,groups]);</pre> | |||
<p> | |||
Data, options and groups can be set or changed later on using the functions | |||
<code>Graph2d.setData(data)</code>, <code>Graph2d.setOptions(options)</code> and <code>Graph2d.setGroups(groups)</code>. | |||
</p> | |||
<h2 id="Data_Format">Data Format</h2> | |||
<p> | |||
Graph2d can load data from an <code>Array</code>, a <code>DataSet</code> or a <code>DataView</code>. | |||
JSON 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>. | |||
<p> | |||
Graph2d can be provided with two types of data: | |||
</p> | |||
<ul> | |||
<li><a href="#items">Items</a> containing a set of points to be displayed.</li> | |||
<li><a href="#groups">Groups</a> containing a set of groups used to group items | |||
together. All items belonging to a group will be drawn as a single graph.</li> | |||
</ul> | |||
<h3 id="items">Items</h3> | |||
<pre class="prettyprint lang-js"> | |||
var items = [ | |||
{x: '2014-06-13', y: 30, group: 0}, | |||
{x: '2014-06-14', y: 10, group: 0}, | |||
{x: '2014-06-15', y: 15, group: 1}, | |||
{x: '2014-06-16', y: 30, group: 1}, | |||
{x: '2014-06-17', y: 10, group: 1}, | |||
{x: '2014-06-18', y: 15, group: 1} | |||
]; | |||
</pre> | |||
<table> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Required</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>x</td> | |||
<td>number</td> | |||
<td>yes</td> | |||
<td>Location on the x-axis.</td> | |||
</tr> | |||
<tr> | |||
<td>y</td> | |||
<td>number</td> | |||
<td>yes</td> | |||
<td>Location on the y-axis.</td> | |||
</tr> | |||
</tr> | |||
<tr> | |||
<td>group</td> | |||
<td>number | string</td> | |||
<td>no</td> | |||
<td>The ID of the group this point belongs to.</td> | |||
</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 individual graphs. Groups can contain the properties <code>id</code>, | |||
<code>content</code>, <code>className</code> (optional) and <code>options</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 = new vis.DataSet(); | |||
groups.add({ | |||
id: 1, | |||
content: 'Group 1' | |||
// Optional: a field 'className' | |||
// Optional: options | |||
}) | |||
groups.add({ | |||
// 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. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>options</td> | |||
<td>JSON object</td> | |||
<td>no</td> | |||
<td>This field is optional. The options can be used to give a group a specific draw style. | |||
Any options that are colored green in the Configuration Options can be used as options here. | |||
</tr> | |||
</table> | |||
<h2 id="Configuration_Options">Configuration Options</h2> | |||
<h3 id="graph2dOptions">Graph2d Options</h3> | |||
Options can be used to customize the Graph2d to your purposes. These options can be passed to the Graph2d object either in | |||
the constructor, or by the <code>setOptions</code> function. | |||
<pre class="prettyprint lang-js"> | |||
var options = { | |||
width: '100%', | |||
height: '400px', | |||
style: 'surface' | |||
}; | |||
</pre> | |||
The options colored in green can also be used as options for the groups. All options are optional. | |||
<table> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td class="greenField">yAxisOrientation</td> | |||
<td>String</td> | |||
<td>'left'</td> | |||
<td>This defines with which axis, left or right, the graph is coupled. <a href="../examples/graph2d/05_bothAxis.html">Example 5</a> shows groups with different Y axis. If no groups are coupled | |||
with an axis, it will not be shown.</td> | |||
</tr> | |||
<tr> | |||
<td>defaultGroup</td> | |||
<td>String</td> | |||
<td>'default'</td> | |||
<td>This is the label for the default, ungrouped items when shown in a legend.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">sort</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>This determines if the items are sorted automatically. | |||
They are sorted by the x value. If sort is enabled, more optimizations are possible, increasing the performance.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">sampling</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>If sampling is enabled, graph2D will automatically determine the amount of points per pixel. | |||
If there are more than 1 point per pixel, not all points will be drawn. Disabling sampling will cause a decrease in performance.</td> | |||
</tr> | |||
<tr> | |||
<td>graphHeight</td> | |||
<td>Number | String</td> | |||
<td>'400px'</td> | |||
<td>This is the height of the graph SVG canvas. | |||
If it is larger than the height of the outer frame, you can drag up and down | |||
the vertical direction as well as the usual horizontal direction.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">shaded</td> | |||
<td>Boolean | Object</td> | |||
<td>false</td> | |||
<td>Toggle a shaded area with the default settings.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">shaded.enabled</td> | |||
<td>Boolean</td> | |||
<td>false</td> | |||
<td>This toggles the shading.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">shaded.orientation</td> | |||
<td>String</td> | |||
<td>'bottom'</td> | |||
<td>This determines if the shaded area is at the bottom or at the top of the curve. The options are 'bottom' or 'top'.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">style</td> | |||
<td>String</td> | |||
<td>'line'</td> | |||
<td>This allows the user to define if this should be a linegraph or a barchart. The options are: 'line' or 'bar'.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">barChart.width</td> | |||
<td>Number</td> | |||
<td>50</td> | |||
<td>The width of the bars.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">barChart.align</td> | |||
<td>String</td> | |||
<td>'center'</td> | |||
<td>The alignment of the bars with regards to the coordinate. The options are 'left', 'right' or 'center'.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">catmullRom</td> | |||
<td>Boolean | Object</td> | |||
<td>true</td> | |||
<td>Toggle the interpolation with the default settings. For more customization use the JSON format.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">catmullRom.enabled</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Toggle the interpolation.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">catmullRom.parametrization</td> | |||
<td>String</td> | |||
<td>'centripetal'</td> | |||
<td>Define the type of parametrizaion. <a href="../examples/graph2d/07_scrollingAndSorting.html">Example 7</a> shows the different methods. The options are 'centripetal' (best results), 'chordal' and 'uniform'. Uniform is the computationally cheapest variant. | |||
If catmullRom is disabled, linear interpolation is used.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">drawPoints</td> | |||
<td>Boolean | Object</td> | |||
<td>true</td> | |||
<td>Toggle the drawing of the datapoints with the default settings.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">drawPoints.enabled</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Toggle the drawing of the datapoints.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">drawPoints.size</td> | |||
<td>Number</td> | |||
<td>6</td> | |||
<td>Determine the size at which the data points are drawn.</td> | |||
</tr> | |||
<tr> | |||
<td class="greenField">drawPoints.style</td> | |||
<td>String</td> | |||
<td>'square'</td> | |||
<td>Determine the shape of the data points. The options are 'square' or 'circle'.</td> | |||
</tr> | |||
<tr> | |||
<td>dataAxis.showMinorLabels</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Toggle the drawing of the minor labels on the Y axis.</td> | |||
</tr> | |||
<tr> | |||
<td>dataAxis.showMajorLabels</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Toggle the drawing of the major labels on the Y axis.</td> | |||
</tr> | |||
<tr> | |||
<td>dataAxis.icons</td> | |||
<td>Boolean</td> | |||
<td>false</td> | |||
<td>Toggle the drawing of automatically generated icons the Y axis.</td> | |||
</tr> | |||
<tr> | |||
<td>dataAxis.width</td> | |||
<td>Number | String</td> | |||
<td>'40px'</td> | |||
<td>Set the (minimal) width of the yAxis. The axis will resize to accomodate the labels of the Y values.</td> | |||
</tr> | |||
<tr> | |||
<td>dataAxis.visible</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Show or hide the data axis.</td> | |||
</tr> | |||
<tr> | |||
<td>legend</td> | |||
<td>Boolean</td> | |||
<td>false</td> | |||
<td>Toggle the legend with the default settings.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.enabled</td> | |||
<td>Boolean</td> | |||
<td>false</td> | |||
<td>Toggle the legend.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.icons</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Show automatically generated icons on the legend.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.left.visible</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>Both axis, left and right, have a corresponding legend. This toggles the visibility of the legend that is coupled with the left axis.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.left.position</td> | |||
<td>String</td> | |||
<td>'top-left'</td> | |||
<td>Determine the position of the legend coupled to the left axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.right.visible</td> | |||
<td>Boolean</td> | |||
<td>true</td> | |||
<td>This toggles the visibility of the legend that is coupled with the right axis.</td> | |||
</tr> | |||
<tr> | |||
<td>legend.right.position</td> | |||
<td>String</td> | |||
<td>'top-right'</td> | |||
<td>Determine the position of the legend coupled to the right axis. Options are 'top-left', 'top-right', 'bottom-left' or 'bottom-right'.</td> | |||
</tr> | |||
</table> | |||
<h3 id="timelineOptions">Timeline Options</h3> | |||
<p> | |||
Graph2d is built upon the framework of the timeline. These options from the timeline can be used with graph2D. | |||
All options are optional. | |||
</p> | |||
<table> | |||
<tr> | |||
<th>Name</th> | |||
<th>Type</th> | |||
<th>Default</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>autoResize</td> | |||
<td>boolean</td> | |||
<td>true</td> | |||
<td>If true, the Timeline will automatically detect when its container is resized, and redraw itself accordingly. If false, the Timeline can be forced to repaint after its container has been resized using the function <code>redraw()</code>.</td> | |||
</tr> | |||
<tr> | |||
<td>end</td> | |||
<td>Date | Number | String</td> | |||
<td>none</td> | |||
<td>The initial end date for the axis of the timeline. | |||
If not provided, the latest date present in the items set is taken as | |||
end date.</td> | |||
</tr> | |||
<tr> | |||
<td>height</td> | |||
<td>Number | String</td> | |||
<td>none</td> | |||
<td>The height of the timeline in pixels or as a percentage. | |||
When height is undefined or null, the height of the timeline is automatically | |||
adjusted to fit the contents. | |||
It is possible to set a maximum height using option <code>maxHeight</code> | |||
to prevent the timeline from getting too high in case of automatically | |||
calculated height. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>margin.axis</td> | |||
<td>Number</td> | |||
<td>20</td> | |||
<td>The minimal margin in pixels between items and the time axis.</td> | |||
</tr> | |||
<tr> | |||
<td>margin.item</td> | |||
<td>Number</td> | |||
<td>10</td> | |||
<td>The minimal margin in pixels between items.</td> | |||
</tr> | |||
<tr> | |||
<td>max</td> | |||
<td>Date | Number | String</td> | |||
<td>none</td> | |||
<td>Set a maximum Date for the visible range. | |||
It will not be possible to move beyond this maximum. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>maxHeight</td> | |||
<td>Number | String</td> | |||
<td>none</td> | |||
<td>Specifies the maximum height for the Timeline. Can be a number in pixels or a string like "300px".</td> | |||
</tr> | |||
<tr> | |||
<td>min</td> | |||
<td>Date | Number | String</td> | |||
<td>none</td> | |||
<td>Set a minimum Date for the visible range. | |||
It will not be possible to move beyond this minimum. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>minHeight</td> | |||
<td>Number | String</td> | |||
<td>none</td> | |||
<td>Specifies the minimum height for the Timeline. Can be a number in pixels or a string like "300px".</td> | |||
</tr> | |||
<tr> | |||
<td>orientation</td> | |||
<td>String</td> | |||
<td>'bottom'</td> | |||
<td>Orientation of the timeline: 'top' or 'bottom' (default). If orientation is 'bottom', the time axis is drawn at the bottom, and if 'top', the axis is drawn on top.</td> | |||
</tr> | |||
<tr> | |||
<td>showCurrentTime</td> | |||
<td>boolean</td> | |||
<td>true</td> | |||
<td>Show a vertical bar at the current time.</td> | |||
</tr> | |||
<tr> | |||
<td>showCustomTime</td> | |||
<td>boolean</td> | |||
<td>false</td> | |||
<td>Show a vertical bar displaying a custom time. This line can be dragged by the user. The custom time can be utilized to show a state in the past or in the future. When the custom time bar is dragged by the user, the event <code>timechange</code> is fired repeatedly. After the bar is dragged, the event <code>timechanged</code> is fired once.</td> | |||
</tr> | |||
<tr> | |||
<td>showMajorLabels</td> | |||
<td>boolean</td> | |||
<td>true</td> | |||
<td>By default, the timeline shows both minor and major date labels on the | |||
time axis. | |||
For example the minor labels show minutes and the major labels show hours. | |||
When <code>showMajorLabels</code> is <code>false</code>, no major labels | |||
are shown.</td> | |||
</tr> | |||
<tr> | |||
<td>showMinorLabels</td> | |||
<td>boolean</td> | |||
<td>true</td> | |||
<td>By default, the timeline shows both minor and major date labels on the | |||
time axis. | |||
For example the minor labels show minutes and the major labels show hours. | |||
When <code>showMinorLabels</code> is <code>false</code>, no minor labels | |||
are shown. When both <code>showMajorLabels</code> and | |||
<code>showMinorLabels</code> are false, no horizontal axis will be | |||
visible.</td> | |||
</tr> | |||
<tr> | |||
<td>start</td> | |||
<td>Date | Number | String</td> | |||
<td>none</td> | |||
<td>The initial start date for the axis of the timeline. | |||
If not provided, the earliest date present in the events is taken as start date.</td> | |||
</tr> | |||
<tr> | |||
<td>width</td> | |||
<td>String</td> | |||
<td>'100%'</td> | |||
<td>The width of the timeline in pixels or as a percentage.</td> | |||
</tr> | |||
<tr> | |||
<td>zoomMax</td> | |||
<td>Number</td> | |||
<td>315360000000000</td> | |||
<td>Set a maximum zoom interval for the visible range in milliseconds. | |||
It will not be possible to zoom out further than this maximum. | |||
Default value equals about 10000 years. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>zoomMin</td> | |||
<td>Number</td> | |||
<td>10</td> | |||
<td>Set a minimum zoom interval for the visible range in milliseconds. | |||
It will not be possible to zoom in further than this minimum. | |||
</td> | |||
</tr> | |||
</table> | |||
<h2 id="Methods">Methods</h2> | |||
<p> | |||
The Graph2d supports the following methods. | |||
</p> | |||
<table> | |||
<tr> | |||
<th>Method</th> | |||
<th>Return Type</th> | |||
<th>Description</th> | |||
</tr> | |||
<tr> | |||
<td>clear([what])</td> | |||
<td>none</td> | |||
<td> | |||
Clear the Graph2d. An object can be passed specifying which sections to clear: items, groups, | |||
and/or options. By Default, items, groups and options are cleared, i.e. <code>what = {items: true, groups: true, options: true}</code>. Example usage: | |||
<pre class="prettyprint lang-js">Graph2d.clear(); // clear items, groups, and options | |||
Graph2d.clear({options: true}); // clear options only | |||
</pre> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>destroy()</td> | |||
<td>none</td> | |||
<td>Destroy the Graph2d. The Graph2d is removed from memory. all DOM elements and event listeners are cleaned up. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>getCustomTime()</td> | |||
<td>Date</td> | |||
<td>Retrieve the custom time. Only applicable when the option <code>showCustomTime</code> is true. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>setCustomTime(time)</td> | |||
<td>none</td> | |||
<td>Adjust the custom time bar. Only applicable when the option <code>showCustomTime</code> is true. <code>time</code> is a Date object. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>getWindow()</td> | |||
<td>Object</td> | |||
<td>Get the current visible window. Returns an object with properties <code>start: Date</code> and <code>end: Date</code>.</td> | |||
</tr> | |||
<tr> | |||
<td>on(event, callback)</td> | |||
<td>none</td> | |||
<td>Create an event listener. The callback function is invoked every time the event is triggered. Avialable events: <code>rangechange</code>, <code>rangechanged</code>, <code>select</code>. The callback function is invoked as <code>callback(properties)</code>, where <code>properties</code> is an object containing event specific properties. See section <a href="#Events">Events for more information</a>.</td> | |||
</tr> | |||
<tr> | |||
<td>off(event, callback)</td> | |||
<td>none</td> | |||
<td>Remove an event listener created before via function <code>on(event, callback)</code>. See section <a href="#Events">Events for more information</a>.</td> | |||
</tr> | |||
<tr> | |||
<td>redraw()</td> | |||
<td>none</td> | |||
<td>Force a redraw of the Graph2d. Can be useful to manually redraw when option autoResize=false. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>setGroups(groups)</td> | |||
<td>none</td> | |||
<td>Set a data set with groups for the Graph2d. | |||
<code>groups</code> can be an Array with Objects, | |||
a DataSet, or a DataView. For each of the groups, the items of the | |||
Graph2d 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> | |||
<td>Set a data set with items for the Graph2d. | |||
<code>items</code> can be an Array with Objects, | |||
a DataSet, or a DataView. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>setOptions(options)</td> | |||
<td>none</td> | |||
<td>Set or update options. It is possible to change any option of the Graph2d at any time. You can for example switch orientation on the fly. | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>setWindow(start, end)</td> | |||
<td>none</td> | |||
<td>Set the current visible window. The parameters <code>start</code> and <code>end</code> can be a <code>Date</code>, <code>Number</code>, or <code>String</code>. If the parameter value of <code>start</code> or <code>end</code> is null, the parameter will be left unchanged.</td> | |||
</tr> | |||
</table> | |||
<h2 id="Events">Events</h2> | |||
<p> | |||
Graph2d fires events when changing the visible window by dragging, when | |||
selecting items, and when dragging the custom time bar. | |||
</p> | |||
<p> | |||
Here an example on how to listen for a <code>rangeChanged</code> event. | |||
</p> | |||
<pre class="prettyprint lang-js"> | |||
Graph2d.on('select', function (properties) { | |||
alert('selected items: ' + properties.nodes); | |||
}); | |||
</pre> | |||
<p> | |||
A listener can be removed via the function <code>off</code>: | |||
</p> | |||
<pre class="prettyprint lang-js"> | |||
function onChange (properties) { | |||
alert('changed!'); | |||
} | |||
// add event listener | |||
Graph2d.on('rangechanged', onChange); | |||
// do stuff... | |||
// remove event listener | |||
Graph2d.off('rangechanged', onChange); | |||
</pre> | |||
<p> | |||
The following events are available. | |||
</p> | |||
<table> | |||
<colgroup> | |||
<col style="width: 20%;"> | |||
<col style="width: 40%;"> | |||
<col style="width: 40%;"> | |||
</colgroup> | |||
<tr> | |||
<th>name</th> | |||
<th>Description</th> | |||
<th>Properties</th> | |||
</tr> | |||
<tr> | |||
<td>rangechange</td> | |||
<td>Fired repeatedly when the user is dragging the Graph2d window. | |||
</td> | |||
<td> | |||
<ul> | |||
<li><code>start</code> (Number): timestamp of the current start of the window.</li> | |||
<li><code>end</code> (Number): timestamp of the current end of the window.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>rangechanged</td> | |||
<td>Fired once after the user has dragged the Graph2d window. | |||
</td> | |||
<td> | |||
<ul> | |||
<li><code>start</code> (Number): timestamp of the current start of the window.</li> | |||
<li><code>end</code> (Number): timestamp of the current end of the window.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>timechange</td> | |||
<td>Fired repeatedly when the user is dragging the custom time bar. | |||
Only available when the custom time bar is enabled. | |||
</td> | |||
<td> | |||
<ul> | |||
<li><code>time</code> (Date): the current time.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
<tr> | |||
<td>timechanged</td> | |||
<td>Fired once after the user has dragged the custom time bar. | |||
Only available when the custom time bar is enabled. | |||
</td> | |||
<td> | |||
<ul> | |||
<li><code>time</code> (Date): the current time.</li> | |||
</ul> | |||
</td> | |||
</tr> | |||
</table> | |||
<h2 id="Styles">Styles</h2> | |||
<p> | |||
All parts of the Graph2d have a class name and a default css style just like the Timeline. | |||
The styles can be overwritten, which enables full customization of the layout | |||
of the Graph2d. | |||
</p> | |||
<p> | |||
Additionally, Graph2d has 10 preset styles for graphs, which are cycled through when loading groups. These styles can be overwritten | |||
as well, along with defining your own classes to style the graphs! <a href="../examples/graph2d/04_rightAxis.html">Example 4</a> and | |||
<a href="../examples/graph2d/05_bothAxis.html">example 5</a> show the usage of custom styles. | |||
</p> | |||
<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> |
@ -1,18 +0,0 @@ | |||
<html> | |||
<head> | |||
<title>Graph | DOT Language</title> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
</head> | |||
<body> | |||
<div id="mygraph"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('mygraph'); | |||
var data = { | |||
dot: 'digraph {node[shape=circle]; 1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }' | |||
}; | |||
var graph = new vis.Graph(container, data); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,53 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |||
<meta content="utf-8" http-equiv="encoding"> | |||
<title>Graph2d | Basic Example</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Basic Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the most basic functionality of the vis.js Graph2d module. An array or a vis.Dataset can be used as input. | |||
In the following examples we'll explore the options Graph2d offest for customization. This example uses all default settings. | |||
There are 10 predefined styles that will be cycled through automatically when you add different groups. Alternatively you can | |||
create your own styling. | |||
<br /><br /> | |||
Graph2d is built upon the framework of the newly refactored timeline. A lot of the timeline options will also apply to Graph2d. | |||
In these examples however, we will focus on what's new in Graph2d! | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,57 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Bar Graph Example</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Bar Graph Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the most the same data as the first example, except we plot the data as bars! The | |||
dataAxis (y-axis) icons have been enabled as well. These icons are generated automatically from the CSS | |||
styling of the graphs. Finally, we've used the option from Timeline where we draw the x-axis (time-axis) on top. | |||
<br /><br /> | |||
The <code>align</code> option can be used to align the bar at the center of the datapoint or on the left or right side of it. | |||
This example uses the default center alignment. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
style:'bar', | |||
barChart: {width:50, align:'center'}, // align: left, center, right | |||
drawPoints: false, | |||
dataAxis: { | |||
icons:true | |||
}, | |||
orientation:'top', | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, items, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,112 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Groups Example</title> | |||
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"> | |||
<meta content="utf-8" http-equiv="encoding"> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Groups Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the groups functionality within Graph2d. This works in the same way as it does in Timeline, | |||
We have however simplified the constructor to accept groups as well to shorten the code. These groups are the | |||
method used in Graph2d to define individual graphs. These groups can be given an individual class as well as all the | |||
styling options you can supply to Graph2d! This example, as well as the ones that follow will showcase a few different usages | |||
of these options. <br /> <br /> | |||
This example also introduces the automatically generated legend. The icons are automatically generated and the label is the | |||
content as you define it in the groups. If you have datapoints that are not part of a group, a default group is created with the label: 'default'. | |||
In this example, the setting <code>defaultGroup</code> is used to rename the default group to 'ungrouped'. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
// create a dataSet with groups | |||
var names = ['SquareShaded', 'Bar', 'Blank', 'CircleShaded']; | |||
var groups = new vis.DataSet(); | |||
groups.add({ | |||
id: 0, | |||
content: names[0], | |||
options: { | |||
drawPoints: { | |||
style: 'square' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'bottom' // top, bottom | |||
} | |||
}}); | |||
groups.add({ | |||
id: 1, | |||
content: names[1], | |||
options: { | |||
style:'bar' | |||
}}); | |||
groups.add({ | |||
id: 2, | |||
content: names[2], | |||
options: {drawPoints: false} | |||
}); | |||
groups.add({ | |||
id: 3, | |||
content: names[3], | |||
options: { | |||
drawPoints: { | |||
style: 'circle' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'top' // top, bottom | |||
} | |||
}}); | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-13', y: 60}, | |||
{x: '2014-06-14', y: 40}, | |||
{x: '2014-06-15', y: 55}, | |||
{x: '2014-06-16', y: 40}, | |||
{x: '2014-06-17', y: 50}, | |||
{x: '2014-06-13', y: 30, group: 0}, | |||
{x: '2014-06-14', y: 10, group: 0}, | |||
{x: '2014-06-15', y: 15, group: 1}, | |||
{x: '2014-06-16', y: 30, group: 1}, | |||
{x: '2014-06-17', y: 10, group: 1}, | |||
{x: '2014-06-18', y: 15, group: 1}, | |||
{x: '2014-06-19', y: 52, group: 1}, | |||
{x: '2014-06-20', y: 10, group: 1}, | |||
{x: '2014-06-21', y: 20, group: 2}, | |||
{x: '2014-06-22', y: 60, group: 2}, | |||
{x: '2014-06-23', y: 10, group: 2}, | |||
{x: '2014-06-24', y: 25, group: 2}, | |||
{x: '2014-06-25', y: 30, group: 2}, | |||
{x: '2014-06-26', y: 20, group: 3}, | |||
{x: '2014-06-27', y: 60, group: 3}, | |||
{x: '2014-06-28', y: 10, group: 3}, | |||
{x: '2014-06-29', y: 25, group: 3}, | |||
{x: '2014-06-30', y: 30, group: 3} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
defaultGroup: 'ungrouped', | |||
legend: true, | |||
start: '2014-06-10', | |||
end: '2014-07-04' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options, groups); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,126 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Right Axis Example</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
.customStyle1 { | |||
fill: #0df200; | |||
fill-opacity:0; | |||
stroke-width:2px; | |||
stroke: #0df200; | |||
} | |||
.customStyle2 { | |||
fill: #f23303; | |||
fill-opacity:0; | |||
stroke-width:2px; | |||
stroke: #ff0004; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Right Axis Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the all of the graphs outlined on the right side using the <code>yAxisOrientation</code> option. | |||
We also show a few custom styles for the graph and show icons on the axis, which are adhering to the custom styling. | |||
Finally, the legend is manually positioned. Both the left and right axis | |||
have their own legend. If one of the axis is unused, the legend is not shown. The options for the legend have been split | |||
in a <code>left</code> and a <code>right</code> segment. Since this example shows the right axis, the right legend is configured. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
// create a dataSet with groups | |||
var names = ['Custom1', 'Custom2', 'Blank', 'CircleShaded']; | |||
var groups = new vis.DataSet(); | |||
groups.add({ | |||
id: 0, | |||
content: names[0], | |||
className: 'customStyle1', | |||
options: { | |||
drawPoints: { | |||
style: 'square' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'bottom' // top, bottom | |||
} | |||
}}); | |||
groups.add({ | |||
id: 1, | |||
content: names[1], | |||
className: 'customStyle2', | |||
options: { | |||
style:'bar', | |||
drawPoints: {style: 'circle', | |||
size: 10 | |||
} | |||
}}); | |||
groups.add({ | |||
id: 2, | |||
content: names[2], | |||
options: { | |||
drawPoints: false | |||
} | |||
}); | |||
groups.add({ | |||
id: 3, | |||
content: names[3], | |||
options: { | |||
drawPoints: { | |||
style: 'circle' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'top' // top, bottom | |||
} | |||
}}); | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-13', y: 30, group: 0}, | |||
{x: '2014-06-14', y: 10, group: 0}, | |||
{x: '2014-06-15', y: 15, group: 1}, | |||
{x: '2014-06-16', y: 30, group: 1}, | |||
{x: '2014-06-17', y: 10, group: 1}, | |||
{x: '2014-06-18', y: 15, group: 1}, | |||
{x: '2014-06-19', y: 52, group: 1}, | |||
{x: '2014-06-20', y: 10, group: 1}, | |||
{x: '2014-06-21', y: 20, group: 2}, | |||
{x: '2014-06-22', y: 60, group: 2}, | |||
{x: '2014-06-23', y: 10, group: 2}, | |||
{x: '2014-06-24', y: 50, group: 2}, | |||
{x: '2014-06-25', y: 30, group: 2}, | |||
{x: '2014-06-26', y: 20, group: 3}, | |||
{x: '2014-06-27', y: 60, group: 3}, | |||
{x: '2014-06-28', y: 10, group: 3}, | |||
{x: '2014-06-29', y: 85, group: 3}, | |||
{x: '2014-06-30', y: 30, group: 3} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
legend: {right: {position: 'top-left'}}, | |||
yAxisOrientation: 'right', // right, left | |||
dataAxis: {icons: true}, | |||
start: '2014-06-10', | |||
end: '2014-07-04', | |||
movable: false | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options, groups); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,138 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Both Axis Example</title> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
.customStyle1 { | |||
fill: #f2ea00; | |||
fill-opacity:0; | |||
stroke-width:2px; | |||
stroke: #b3ab00; | |||
} | |||
.customStyle2 { | |||
fill: #00a0f2; | |||
fill-opacity:0; | |||
stroke-width:2px; | |||
stroke: #050092; | |||
} | |||
.customStyle3 { | |||
fill: #00f201; | |||
fill-opacity:0; | |||
stroke-width:2px; | |||
stroke: #029200; | |||
} | |||
path.customStyle3.fill { | |||
fill-opacity:0.5 !important; | |||
stroke: none; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Both Axis Example</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example shows the some of the graphs outlined on the right side using the <code>yAxisOrientation</code> option within the groups. | |||
We also show a few more custom styles for the graphs. Finally, the legend is manually positioned. Both the left and right axis | |||
have their own legend. If one of the axis is unused, the legend is not shown. The options for the legend have been split | |||
in a <code>left</code> and a <code>right</code> segment. The default position of the left axis has been changed. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
// create a dataSet with groups | |||
var names = ['SquareShaded', 'Bar', 'Blank', 'CircleShaded']; | |||
var groups = new vis.DataSet(); | |||
groups.add({ | |||
id: 0, | |||
content: names[0], | |||
className: 'customStyle1', | |||
options: { | |||
drawPoints: { | |||
style: 'square' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'bottom' // top, bottom | |||
} | |||
}}); | |||
groups.add({ | |||
id: 1, | |||
content: names[1], | |||
className: 'customStyle2', | |||
options: { | |||
style:'bar', | |||
drawPoints: {style: 'circle', | |||
size: 10 | |||
} | |||
}}); | |||
groups.add({ | |||
id: 2, | |||
content: names[2], | |||
options: { | |||
yAxisOrientation: 'right', // right, left | |||
drawPoints: false | |||
} | |||
}); | |||
groups.add({ | |||
id: 3, | |||
content: names[3], | |||
className: 'customStyle3', | |||
options: { | |||
yAxisOrientation: 'right', // right, left | |||
drawPoints: { | |||
style: 'circle' // square, circle | |||
}, | |||
shaded: { | |||
orientation: 'top' // top, bottom | |||
} | |||
}}); | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-12', y: 0 , group: 0}, | |||
{x: '2014-06-13', y: 30, group: 0}, | |||
{x: '2014-06-14', y: 10, group: 0}, | |||
{x: '2014-06-15', y: 15, group: 1}, | |||
{x: '2014-06-16', y: 30, group: 1}, | |||
{x: '2014-06-17', y: 10, group: 1}, | |||
{x: '2014-06-18', y: 15, group: 1}, | |||
{x: '2014-06-19', y: 52, group: 1}, | |||
{x: '2014-06-20', y: 10, group: 1}, | |||
{x: '2014-06-21', y: 20, group: 2}, | |||
{x: '2014-06-22', y: 600, group: 2}, | |||
{x: '2014-06-23', y: 100, group: 2}, | |||
{x: '2014-06-24', y: 250, group: 2}, | |||
{x: '2014-06-25', y: 300, group: 2}, | |||
{x: '2014-06-26', y: 200, group: 3}, | |||
{x: '2014-06-27', y: 600, group: 3}, | |||
{x: '2014-06-28', y: 1000, group: 3}, | |||
{x: '2014-06-29', y: 250, group: 3}, | |||
{x: '2014-06-30', y: 300, group: 3} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
dataAxis: {showMinorLabels: false}, | |||
legend: {left:{position:"bottom-left"}}, | |||
start: '2014-06-09', | |||
end: '2014-07-03' | |||
}; | |||
var graph2d = new vis.Graph2d(container, items, options, groups); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,101 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Interpolation</title> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Interpolation</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
The Graph2d makes use of <a href="http://en.wikipedia.org/wiki/Centripetal_Catmull%E2%80%93Rom_spline" target="_blank">Catmull-Rom spline interpolation</a>. | |||
The user can configure these per group, or globally. In this example we show all 4 possiblities. The differences are in the parametrization of | |||
the curves. The options are <code>uniform</code>, <code>chordal</code> and <code>centripetal</code>. Alternatively you can disable the Catmull-Rom interpolation and | |||
a linear interpolation will be used. The <code>centripetal</code> parametrization produces the best result (no self intersection, yet follows the line closely) and is therefore the default setting. | |||
<br /><br /> | |||
For both the <code>centripetal</code> and <code>chordal</code> parametrization, the distances between the points have to be calculated and this makes these methods computationally intensive | |||
if there are very many points. The <code>uniform</code> parametrization still has to do transformations, though it does not have to calculate the distance between point. Finally, the | |||
linear interpolation is the fastest method. For more on the Catmull-Rom method, <a href="http://www.cemyuksel.com/research/catmullrom_param/catmullrom.pdf" target="_blank">C. Yuksel et al. have an interesting paper titled ″On the parametrization of Catmull-Rom Curves″</a>. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
// create a dataSet with groups | |||
var names = ['centripetal', 'chordal', 'uniform', 'disabled']; | |||
var groups = new vis.DataSet(); | |||
groups.add({ | |||
id: 0, | |||
content: names[0], | |||
options: { | |||
drawPoints: false, | |||
catmullRom: { | |||
parametrization: 'centripetal' | |||
} | |||
}}); | |||
groups.add({ | |||
id: 1, | |||
content: names[1], | |||
options: { | |||
drawPoints: false, | |||
catmullRom: { | |||
parametrization: 'chordal' | |||
} | |||
}}); | |||
groups.add({ | |||
id: 2, | |||
content: names[2], | |||
options: { | |||
drawPoints: false, | |||
catmullRom: { | |||
parametrization: 'uniform' | |||
} | |||
} | |||
}); | |||
groups.add({ | |||
id: 3, | |||
content: names[3], | |||
options: { | |||
drawPoints: { style: 'circle' }, | |||
catmullRom: false | |||
}}); | |||
var container = document.getElementById('visualization'); | |||
var dataset = new vis.DataSet(); | |||
for (var i = 0; i < names.length; i++) { | |||
dataset.add( [ | |||
{x: '2014-06-12', y: 0 , group: i}, | |||
{x: '2014-06-13', y: 40, group: i}, | |||
{x: '2014-06-14', y: 10, group: i}, | |||
{x: '2014-06-15', y: 15, group: i}, | |||
{x: '2014-06-15', y: 30, group: i}, | |||
{x: '2014-06-17', y: 10, group: i}, | |||
{x: '2014-06-18', y: 15, group: i}, | |||
{x: '2014-06-19', y: 52, group: i}, | |||
{x: '2014-06-20', y: 10, group: i}, | |||
{x: '2014-06-21', y: 20, group: i} | |||
]); | |||
} | |||
var options = { | |||
dataPoints: false, | |||
dataAxis: {visible: false}, | |||
legend: true, | |||
start: '2014-06-11', | |||
end: '2014-06-22' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options, groups); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,74 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Scrolling and Sorting</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
} | |||
</style> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Scrolling and Sorting</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
You can determine the height of the Graph2d seperately from the height of the frame. If the <code>graphHeight</code> | |||
is defined, and the <code>height</code> is not, the frame will auto-scale to accommodate the graphHeight. If the <code>height</code> | |||
is defined as well, the user can scroll up and down vertically as well as horizontally to view the graph. | |||
<br /><br /> | |||
Vertical scrolling is planned, though not yet available. The graphHeight also does not conform if only the <code>height</code> is defined. | |||
<br /><br /> | |||
You can manually disable the automatic sorting of the datapoints by using the <code>sort</code> option. However, doing so does reduce the optimization | |||
of the drawing so if you have a lot of points, keep <code>sort</code> turned on for the best results. | |||
</div> | |||
<br /> | |||
<div id="visualization"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('visualization'); | |||
var items = [ | |||
{x: '2014-06-11', y: 10}, | |||
{x: '2014-06-12', y: 25}, | |||
{x: '2014-06-13', y: 30}, | |||
{x: '2014-06-14', y: 10}, | |||
{x: '2014-06-15', y: 15}, | |||
{x: '2014-06-16', y: 30}, | |||
{x: '2014-06-11', y: 100}, | |||
{x: '2014-06-12', y: 250}, | |||
{x: '2014-06-13', y: 300}, | |||
{x: '2014-06-14', y: 100}, | |||
{x: '2014-06-15', y: 150}, | |||
{x: '2014-06-16', y: 300}, | |||
{x: '2014-06-11', y: 400}, | |||
{x: '2014-06-12', y: 450}, | |||
{x: '2014-06-13', y: 400}, | |||
{x: '2014-06-14', y: 500}, | |||
{x: '2014-06-15', y: 420}, | |||
{x: '2014-06-16', y: 600}, | |||
{x: '2014-06-11', y: 810}, | |||
{x: '2014-06-12', y: 825}, | |||
{x: '2014-06-13', y: 830}, | |||
{x: '2014-06-14', y: 810}, | |||
{x: '2014-06-15', y: 815}, | |||
{x: '2014-06-16', y: 900} | |||
]; | |||
var dataset = new vis.DataSet(items); | |||
var options = { | |||
legend: true, | |||
sort: false, | |||
defaultGroup: 'doodle', | |||
graphHeight: '1500px', | |||
height: '500px', | |||
start: '2014-06-10', | |||
end: '2014-06-18' | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,150 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Graph2d | Performance</title> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
span.label { | |||
width:150px; | |||
display:inline-block; | |||
} | |||
</style> | |||
<!-- note: moment.js must be loaded before vis.js, else vis.js uses its embedded version of moment.js --> | |||
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.3.1/moment.min.js"></script> | |||
<script src="../../dist/vis.js"></script> | |||
<link href="../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<h2>Graph2d | Performance</h2> | |||
<div style="width:700px; font-size:14px; text-align: justify;"> | |||
This example is a test of the performance of the Graph2d. Select the amount of datapoints you want to plot and press draw. | |||
You can choose between the style of the points as well as the interpolation method. This can only be toggled with the buttons. | |||
The interpolation options may not look different for this dataset but you can see their effects clearly in example 7. | |||
<br /><br /> | |||
Linear interpolation and no points are the settings that will render quickest. By default, Graph2d will downsample when there are more | |||
than 1 point per pixel. This can be manually disabled at the cost of performance by using the <code>sampling</code> option. | |||
</div> | |||
<br /> | |||
<p> | |||
<span class="label">Number of items:</span><input id="count" value="50000"> | |||
<input id="draw" type="button" value="draw" style="width:200px;"> <span id="description"><b>Click the draw button to load the data!</b></span> | |||
<br /> | |||
<span class="label">Interpolation method:</span><input id="interpolation" value="linear"> | |||
<input id="toggleInterpolation" type="button" value="toggle Interpolation" style="width:200px;"> | |||
<br /> | |||
<span class="label">Points style:</span><input id="points" value="none"> | |||
<input id="togglePoints" type="button" value="toggle Points" style="width:200px;"> | |||
</p> | |||
<div id="visualization"></div> | |||
<script> | |||
var points = 'none'; | |||
var interpolation = 'linear'; | |||
function togglePoints() { | |||
var pointsOptions = {}; | |||
var pointsField = document.getElementById("points"); | |||
if (points == "none") { | |||
points = 'circle'; | |||
pointsOptions = {drawPoints: {style: points}}; | |||
} | |||
else if (points == "circle") { | |||
points = 'square'; | |||
pointsOptions = {drawPoints: {style: points}}; | |||
} | |||
else if (points == "square") { | |||
points = 'none'; | |||
pointsOptions = {drawPoints: false}; | |||
} | |||
pointsField.value = points; | |||
graph2d.setOptions(pointsOptions); | |||
} | |||
function toggleInterpolation() { | |||
var interpolationOptions = {}; | |||
var interpolationField = document.getElementById("interpolation"); | |||
if (interpolation == "linear") { | |||
interpolation = 'centripetal'; | |||
interpolationOptions = {catmullRom: {parametrization: interpolation}}; | |||
} | |||
else if (interpolation == "centripetal") { | |||
interpolation = 'chordal'; | |||
interpolationOptions = {catmullRom: {parametrization: interpolation}}; | |||
} | |||
else if (interpolation == "chordal") { | |||
interpolation = 'uniform'; | |||
interpolationOptions = {catmullRom: {parametrization: interpolation}}; | |||
} | |||
else if (interpolation == "uniform") { | |||
interpolation = 'linear'; | |||
interpolationOptions = {catmullRom: false}; | |||
} | |||
interpolationField.value = interpolation; | |||
graph2d.setOptions(interpolationOptions); | |||
} | |||
// create a dataset with items | |||
var now = moment().minutes(0).seconds(0).milliseconds(0); | |||
var dataset = new vis.DataSet({ | |||
type: {start: 'ISODate', end: 'ISODate' } | |||
}); | |||
var startPoint = now; | |||
var endPoint = now + 3600000 * 5000; | |||
// create data -- this is seperated into 3 functions so we can update the span. | |||
function createData() { | |||
var span = document.getElementById("description"); | |||
span.innerHTML = 'Generating data... (just javascript, not vis.graph2D)...'; | |||
setTimeout(generateData,10); | |||
} | |||
function generateData() { | |||
var count = parseInt(document.getElementById('count').value) || 100; | |||
var newData = []; | |||
var span = document.getElementById("description"); | |||
var start = now; | |||
for (var i = 0; i < count; i++) { | |||
var yval = Math.sin(i/100) * Math.cos(i/50) * 50 + Math.sin(i/1000) * 50; | |||
newData.push({id: i, x: start + 3600000 * i, y: yval}); | |||
} | |||
span.innerHTML = 'Loading data into Graph2d...'; | |||
setTimeout(function() {loadDataIntoVis(newData);},10); | |||
} | |||
function loadDataIntoVis(newData) { | |||
var span = document.getElementById("description"); | |||
dataset.clear(); | |||
dataset.add(newData); | |||
span.innerHTML = 'Done!'; | |||
} | |||
document.getElementById('draw').onclick = createData; | |||
document.getElementById('toggleInterpolation').onclick = toggleInterpolation; | |||
document.getElementById('togglePoints').onclick = togglePoints; | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
sampling: true, | |||
drawPoints: {enabled:false, size:3}, | |||
catmullRom: false, | |||
start: startPoint, | |||
end: endPoint | |||
}; | |||
var graph2d = new vis.Graph2d(container, dataset, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,87 @@ | |||
html, body { | |||
width: 100%; | |||
height: 100%; | |||
padding: 0; | |||
margin: 0; | |||
} | |||
body, td, th { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
color: #4D4D4D; | |||
line-height: 1.7em; | |||
} | |||
#container { | |||
margin: 0 auto; | |||
padding-bottom: 50px; | |||
width: 900px; | |||
} | |||
h1 { | |||
font-size: 180%; | |||
font-weight: bold; | |||
padding: 0; | |||
margin: 1em 0 1em 0; | |||
} | |||
h2 { | |||
padding-top: 20px; | |||
padding-bottom: 10px; | |||
border-bottom: 1px solid #a0c0f0; | |||
color: #2B7CE9; | |||
} | |||
h3 { | |||
font-size: 140%; | |||
} | |||
a { | |||
color: #2B7CE9; | |||
text-decoration: none; | |||
} | |||
a:visited { | |||
color: #2E60A4; | |||
} | |||
a:hover { | |||
color: red; | |||
text-decoration: underline; | |||
} | |||
hr { | |||
border: none 0; | |||
border-top: 1px solid #abc; | |||
height: 1px; | |||
} | |||
pre { | |||
display: block; | |||
font-size: 10pt; | |||
line-height: 1.5em; | |||
font-family: monospace; | |||
} | |||
pre, code { | |||
background-color: #f5f5f5; | |||
} | |||
table | |||
{ | |||
border-collapse: collapse; | |||
} | |||
th { | |||
font-weight: bold; | |||
border: 1px solid lightgray; | |||
background-color: #E5E5E5; | |||
text-align: left; | |||
vertical-align: top; | |||
padding: 5px; | |||
} | |||
td { | |||
border: 1px solid lightgray; | |||
padding: 5px; | |||
vertical-align: top; | |||
} |
@ -0,0 +1,21 @@ | |||
<html> | |||
<head> | |||
<link rel='stylesheet' href='default.css' type='text/css'> | |||
</head> | |||
<body> | |||
<div id="container"> | |||
<h1>Graph2d Examples</h1> | |||
<p><a href="01_basic.html">01_basic.html</a></p> | |||
<p><a href="02_bars.html">02_bars.html</a></p> | |||
<p><a href="03_groups.html">03_groups.html</a></p> | |||
<p><a href="04_rightAxis.html">04_rightAxis.html</a></p> | |||
<p><a href="05_bothAxis.html">05_bothAxis.html</a></p> | |||
<p><a href="06_interpolation.html">06_interpolation.html</a></p> | |||
<p><a href="07_scrollingAndSorting.html">07_scrollingAndSorting.html</a></p> | |||
<p><a href="08_performance.html">08_performance.html</a></p> | |||
</div> | |||
</body> | |||
</html> |
@ -0,0 +1,18 @@ | |||
<html> | |||
<head> | |||
<title>Network | DOT Language</title> | |||
<script type="text/javascript" src="../../dist/vis.js"></script> | |||
</head> | |||
<body> | |||
<div id="mynetwork"></div> | |||
<script type="text/javascript"> | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
dot: 'dinetwork {node[shape=circle]; 1 -> 1 -> 2; 2 -> 3; 2 -- 4; 2 -> 1 }' | |||
}; | |||
var network = new vis.Network(container, data); | |||
</script> | |||
</body> | |||
</html> |