@ -0,0 +1,63 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Label margins</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 600px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
p { | |||
max-width:600px; | |||
} | |||
</style> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<p>The labels of box, circle, database, icon and text nodes may have different margin values. | |||
Top, right, bottom and left margins may be different for each node.</p> | |||
<p>Setting the margin value in the network's nodes property sets it as the default.</p> | |||
<p>Setting a the value to a number uses that number for the margins. If the value is an object, a different value for each margin will be set.</p> | |||
<p>Note that negative values appropriately push labels outside the node. | |||
<div id="mynetwork"></div> | |||
<script type="text/javascript"> | |||
// create an array with nodes | |||
var nodes = [ | |||
{ id: 1, label: 'Default Value\n(5)', x: -150, y: -150 }, | |||
{ id: 2, label: 'Single Value\n(25)', margin: 20, x: 0, y: 0 }, | |||
{ id: 3, label: 'Different Values\n(10, 20, 40, 30)', margin: { top: 10, right: 20, bottom: 40, left: 30 }, x: 120, y: 120}, | |||
{ id: 4, label: 'A Negative Value\n(10, 20, 40, -50)', margin: { top: 10, right: 20, bottom: 30, left: -20 }, x: 300, y: -300} | |||
]; | |||
// create an array with edges | |||
var edges = [ | |||
{from: 1, to: 2}, | |||
{from: 2, to: 3}, | |||
{from: 3, to: 4} | |||
]; | |||
// create a network | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
nodes: { | |||
shape: 'box' | |||
} | |||
}; | |||
var network = new vis.Network(container, data, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,115 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Multifont Labels</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 600px; | |||
height: 400px; | |||
border: 1px solid lightgray; | |||
} | |||
code { | |||
font-size: 15px; | |||
} | |||
p { | |||
max-width: 600px; | |||
} | |||
.indented { | |||
margin-left: 30px; | |||
} | |||
table { | |||
border-collapse: collapse; | |||
font-family: sans-serif; | |||
} | |||
table code { | |||
background: #dddddd; | |||
} | |||
th, td { | |||
border: 1px solid #aaaaaa; | |||
text-align: center; | |||
padding: 5px; | |||
font-weight: normal; | |||
} | |||
</style> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<p>Node and edge labels may be marked up to be drawn with multiple fonts.</p> | |||
<div id="mynetwork"></div> | |||
<p>The value of the <code>font.multi</code> property may be set to <code>'html'</code>, <code>'markdown'</code> or a boolean.</p> | |||
<table class="indented"> | |||
<tr><th colspan='4'>Embedded Font Markup</th></tr> | |||
<tr><th rowspan=2>font mod</th><th colspan=3><code>font.multi</code> setting</th></tr> | |||
<tr><th><code>'html'</code> or <code>true</code></th><th><code>'markdown'</code> or <code>'md'</code></th><th><code>false<code></th></tr> | |||
<tr><th>bold</th><td><code><b></code> ... <code></b></code></td><td><code> *</code> ... <code>* </code></td><td>n/a</td></tr> | |||
<tr><th>italic</th><td><code><i></code> ... <code></i></code></td><td><code> _</code> ... <code>_ </code></td><td>n/a</td></tr> | |||
<tr><th>mono-spaced</th><td><code><code></code> ... <code></code></code></td><td><code> `</code> ... <code>` </code></td><td>n/a</td></tr> | |||
</table> | |||
<p> | |||
The <code>html</code> and <code>markdown</code> rendering is limited: bolds may be embedded in italics, italics may be embedded in bolds, and mono-spaced may be embedded in bold or italic, but will not be altered by those font mods, nor will embedded bolds or italics be handled. | |||
The only entities that will be observed in html are <code>&lt;</code> and <code>&amp;</code> and in <code>markdown</code> a backslash will escape the following character (including a backslash) from special processing. | |||
Any font mod that is started in a label line will be implicitly terminated at the end of that line. | |||
While this interpretation may not exactly match <i>official</i> rendering standards, it is a consistent compromise for drawing multifont strings in the non-multifont html canvas element underlying vis. | |||
</p> | |||
<p>This implies that four additional sets of font properties will be recognized in label processing.</p> | |||
<p class="indented"><code>font.bold</code> designates the font used for rendering bold font mods. | |||
<br/><code>font.ital</code> designates the font used for rendering italic font mods. | |||
<br/><code>font.boldital</code> designates the font used for rendering bold-<b><i>and</i></b>-italic font mods. | |||
<br/><code>font.mono</code> designates the font used for rendering monospaced font mods.</p> | |||
<p>Any font mod without a matching font will be rendered using the normal <code>font</code> (or default) value.</p> | |||
<p>The <code>font.multi</code> and extended font settings may be set in the network's <code>nodes</code> or <code>edges</code> properties, or on individual nodes and edges. | |||
Node and edge label fonts are separate.</p> | |||
<script type="text/javascript"> | |||
var nodes = [ | |||
{ id: 1, label: 'This is a\nsingle-font label', x: -120, y: -120 }, | |||
{ id: 2, font: { multi: true }, label: '<b>This</b> is a\n<i>default</i> <b><i>multi-</i>font</b> <code>label</code>', x: -40, y: -40 }, | |||
{ id: 3, font: { multi: 'html', size: 20 }, label: '<b>This</b> is an\n<i>html</i> <b><i>multi-</i>font</b> <code>label</code>', x: 40, y: 40 }, | |||
{ id: 4, font: { multi: 'md', face: 'georgia' }, label: '*This* is a\n_markdown_ *_multi-_ font* `label`', x: 120, y: 120}, | |||
]; | |||
var edges = [ | |||
{from: 1, to: 2, label: "single to default"}, | |||
{from: 2, to: 3, font: { multi: true }, label: "default to <b>html</b>" }, | |||
{from: 3, to: 4, font: { multi: "md" }, label: "*html* to _md_" } | |||
]; | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
edges: { | |||
font: { | |||
size: 12 | |||
} | |||
}, | |||
nodes: { | |||
shape: 'box', | |||
font: { | |||
bold: { | |||
color: '#0077aa' | |||
} | |||
} | |||
}, | |||
physics: { | |||
enabled: false | |||
} | |||
}; | |||
var network = new vis.Network(container, data, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,118 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Label Width and Height Settings</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 600px; | |||
height: 400px; | |||
border: 1px solid lightgray; | |||
} | |||
code { | |||
font-size: 14px; | |||
background: #dddddd; | |||
} | |||
p { | |||
max-width: 600px; | |||
} | |||
.indented { | |||
margin-left: 30px; | |||
} | |||
.sep { | |||
height: 1px; | |||
width: 35%; | |||
margin-left: 40px; | |||
background-color: #dddddd; | |||
} | |||
</style> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<p>Nodes may be set to have fixed, minimum and maximum widths and minimum heights. | |||
Nodes with minimum heights may also have a vertical alignment set.</p> | |||
<p>Edges may be set to have maximum widths.</p> | |||
<div id="mynetwork"></div> | |||
<p>The <code>widthConstraint: value</code> option means a fixed width, the minimum and maximum width of the element are set to the value (respecting left and right margins). Lines exceeding the maximum width will be broken at space boundaries to fit.</p> | |||
<p>The <code>widthConstraint: { minimum: value }</code> option sets the minimum width of the element to the value.</p> | |||
<p>The <code>widthConstraint: { maximum: value }</code> option sets the maximum width of the element to the value (respecting left and right margins). Lines exceeding the maximum width will be broken at space boundaries to fit.</p> | |||
<p>Minimum width line sizing is applied after maximum width line breaking, so counterintuitively, the minimum being greater than the maximum has a meaningful interpretation.</p> | |||
<div class="sep"></div> | |||
<p>The <code>heightConstraint: value</code> option sets the minimum height of the element to the value (respecting top and bottom margins).</p> | |||
<p>The <code>heightConstraint: { minimum: value }</code> option also sets the minimum height of the element to the value (respecting top and bottom margins).</p> | |||
<p>The <code>heightConstraint: { valign: value }</code> option (with value <code>'top'</code>, <code>'middle'</code>, or <code>'bottom'</code>, sets the alignment of the text in the element's label to the elements top, middle or bottom (respecting top and bottom margins) when it's height is less than the minimum. The middle value is the default.</p> | |||
<div class="sep"></div> | |||
<p>Node width and height constraints may both be applied together, of course.</p> | |||
<p>The constraint options may be applied to elements individually, or at the whole-set level. | |||
Whole-set node and edge constraints are exclusive.</p> | |||
<script type="text/javascript"> | |||
var nodes = [ | |||
{ id: 100, label: 'This node has no fixed, minimum or maximum width or height', x: -50, y: -300 }, | |||
{ id: 210, widthConstraint: { minimum: 120 }, label: 'This node has a mimimum width', x: -400, y: -200 }, | |||
{ id: 211, widthConstraint: { minimum: 120 }, label: '...so does this', x: -500, y: -50 }, | |||
{ id: 220, widthConstraint: { maximum: 170 }, label: 'This node has a maximum width and breaks have been automatically inserted into the label', x: -150, y: -150 }, | |||
{ id: 221, widthConstraint: { maximum: 170 }, label: '...this too', x: -100, y: 0 }, | |||
{ id: 200, font: { multi: true }, widthConstraint: 150, label: '<b>This</b> node has a fixed width and breaks have been automatically inserted into the label', x: -300, y: 50 }, | |||
{ id: 201, widthConstraint: 150, label: '...this as well', x: -300, y: 200 }, | |||
{ id: 300, heightConstraint: { minimum: 70 }, label: 'This node\nhas a\nminimum\nheight', x: 100, y: -150 }, | |||
{ id: 301, heightConstraint: { minimum: 70 }, label: '...this one here too', x: 100, y: 0 }, | |||
{ id: 400, heightConstraint: { minimum: 100, valign: 'top' }, label: 'Minimum height\nvertical alignment\nmay be top', x: 300, y: -200 }, | |||
{ id: 401, heightConstraint: { minimum: 100, valign: 'middle' }, label: 'Minimum height\nvertical alignment\nmay be middle\n(default)', x: 300, y: 0 }, | |||
{ id: 402, heightConstraint: { minimum: 100, valign: 'bottom' }, label: 'Minimum height\nvertical alignment\nmay be bottom', x: 300, y: 200 } | |||
]; | |||
var edges = [ | |||
{ from: 100, to: 210, label: "unconstrained to minimum width"}, | |||
{ from: 210, to: 211, label: "more minimum width"}, | |||
{ from: 100, to: 220, label: "unconstrained to maximum width"}, | |||
{ from: 220, to: 221, label: "more maximum width"}, | |||
{ from: 210, to: 200, label: "minimum width to fixed width"}, | |||
{ from: 220, to: 200, label: "maximum width to fixed width"}, | |||
{ from: 200, to: 201, label: "more fixed width"}, | |||
{ from: 100, to: 300, label: "unconstrained to minimum height"}, | |||
{ from: 300, to: 301, label: "more minimum height"}, | |||
{ from: 100, to: 400, label: "unconstrained to top valign"}, | |||
{ from: 400, to: 401, label: "top valign to middle valign"}, | |||
{ from: 401, to: 402, label: "middle valign to bottom valign"}, | |||
]; | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
edges: { | |||
font: { | |||
size: 12 | |||
}, | |||
widthConstraint: { | |||
maximum: 90 | |||
} | |||
}, | |||
nodes: { | |||
shape: 'box', | |||
margin: 10 | |||
}, | |||
physics: { | |||
enabled: false | |||
} | |||
}; | |||
var network = new vis.Network(container, data, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,466 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Chosen Elements</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 900px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
code { | |||
font-size: 14px; | |||
background: #dddddd; | |||
} | |||
p { | |||
max-width: 600px; | |||
} | |||
.indented { | |||
margin-left: 30px; | |||
} | |||
.sep { | |||
height: 1px; | |||
width: 35%; | |||
margin-left: 40px; | |||
background-color: #dddddd; | |||
} | |||
</style> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<p>When a node or edge is selected or hovered its visible characteristics can be changed.</p> | |||
<div id="mynetwork"></div> | |||
<p>In this network, an element (node, edge or label) will change a characteristic when hovered, and it will be locked in when selected. | |||
This is managed by setting up a 'chosen' function that will be called when the element containing the function is chosen. | |||
These functions may be set on nodes, edges and labels, at the individual or group level.</p> | |||
<p>All states (unselected, hover-over-unselected, selected, and hover-over selected) may be handled as needed by the application using vis, as the select and hover states are passed to the chosen function when called. | |||
Additionally, the id of the element is passed to allow context-specific characteristic adjustment on select or hover as needed.</p> | |||
<p><i>It should be noted that the characteristics which might affect the position of elements have been left out on purpose. | |||
While it might be interesting to make them changeable, this is problematic on hovering. | |||
Consider that the user hovers over an object. | |||
If it changed characteristics that moved it outside of the hover-distance, it would then no longer be hovering. | |||
So it would be moved back to its original prosition, within the hover-distance and then again be hovering over the object. | |||
This hysteresis loop is kept from occurring by leaving out the characteristics that could cause it. | |||
Some seemingly innocuous changes (such as resizing a node's label on hover that would in turn cause the node to resize and move out of hover-distance) may still cause hysteresis, but with care they should be avoidable.</i></p> | |||
<script type="text/javascript"> | |||
var changeChosenLabelColor = | |||
function(ctx, values, id) { | |||
values.color = "#ff0000"; | |||
} | |||
var changeChosenLabelSize = | |||
function(ctx, values, id) { | |||
values.size += 1; | |||
} | |||
var changeChosenLabelFace = | |||
function(ctx, values, id) { | |||
values.face = "serif"; | |||
} | |||
var changeChosenLabelMod = | |||
function(ctx, values, id) { | |||
values.mod = "bold italic"; | |||
} | |||
var changeChosenLabelStrokeWidth = | |||
function(ctx, values, id) { | |||
values.strokeWidth = 5; | |||
} | |||
var changeChosenLabelStrokeColor = | |||
function(ctx, values, id) { | |||
values.strokeColor = "#00ff00"; | |||
} | |||
var changeChosenNodeColor = | |||
function(values, id, selected, hovering) { | |||
values.color = "#ffdd88"; | |||
} | |||
var changeChosenNodeBorderWidth = | |||
function(values, id, selected, hovering) { | |||
values.borderWidth = 3; | |||
} | |||
var changeChosenNodeBorderColor = | |||
function(values, id, selected, hovering) { | |||
values.borderColor = "#ff0000"; | |||
} | |||
var changeChosenNodeSize = | |||
function(values, id, selected, hovering) { | |||
values.size = 30; | |||
} | |||
var changeChosenNodeBorderDashes = | |||
function(values, id, selected, hovering) { | |||
values.borderDashes = [ 10, 10 ]; | |||
} | |||
var changeChosenNodeBorderRadius = | |||
function(values, id, selected, hovering) { | |||
values.borderRadius = 15; | |||
} | |||
var changeChosenNodeShadow = | |||
function(values, id, selected, hovering) { | |||
values.shadow = true; | |||
} | |||
var changeChosenNodeShadowColor = | |||
function(values, id, selected, hovering) { | |||
values.shadowColor = "#ff0000"; | |||
} | |||
var changeChosenNodeShadowSize = | |||
function(values, id, selected, hovering) { | |||
values.shadowSize = 30; | |||
} | |||
var changeChosenNodeShadowX = | |||
function(values, id, selected, hovering) { | |||
values.shadowX = -5; | |||
} | |||
var changeChosenNodeShadowY = | |||
function(values, id, selected, hovering) { | |||
values.shadowY = -5; | |||
} | |||
var changeChosenEdgeToArrow = | |||
function(values, id, selected, hovering) { | |||
values.toArrow = true; | |||
} | |||
var changeChosenEdgeToArrowScale = | |||
function(values, id, selected, hovering) { | |||
values.toArrowScale = 2; | |||
} | |||
var changeChosenEdgeToArrowType = | |||
function(values, id, selected, hovering) { | |||
values.toArrowType = "circle"; | |||
} | |||
var changeChosenEdgeMiddleArrow = | |||
function(values, id, selected, hovering) { | |||
values.middleArrow = true; | |||
} | |||
var changeChosenEdgeMiddleArrowScale = | |||
function(values, id, selected, hovering) { | |||
values.middleArrowScale = 2; | |||
} | |||
var changeChosenEdgeMiddleArrowType = | |||
function(values, id, selected, hovering) { | |||
values.middleArrowType = "circle"; | |||
} | |||
var changeChosenEdgeFromArrow = | |||
function(values, id, selected, hovering) { | |||
values.fromArrow = true; | |||
} | |||
var changeChosenEdgeFromArrowScale = | |||
function(values, id, selected, hovering) { | |||
values.fromArrowScale = 2; | |||
} | |||
var changeChosenEdgeFromArrowType = | |||
function(values, id, selected, hovering) { | |||
values.fromArrowType = "circle"; | |||
} | |||
var changeChosenEdgeArrowStrikethrough = | |||
function(values, id, selected, hovering) { | |||
values.arrowStrikethrough = false; | |||
} | |||
var changeChosenEdgeColor = | |||
function(values, id, selected, hovering) { | |||
values.color = "#00ff00"; | |||
} | |||
var changeChosenEdgeInheritsColor = | |||
function(values, id, selected, hovering) { | |||
values.inheritsColor = "both"; | |||
} | |||
var changeChosenEdgeOpacity = | |||
function(values, id, selected, hovering) { | |||
values.opacity = 0.25; | |||
} | |||
var changeChosenEdgeHidden = | |||
function(values, id, selected, hovering) { | |||
values.hidden = true; | |||
} | |||
var changeChosenEdgeShadow = | |||
function(values, id, selected, hovering) { | |||
values.shadow = true; | |||
} | |||
var changeChosenEdgeShadowColor = | |||
function(values, id, selected, hovering) { | |||
values.shadowColor = "#00ffff"; | |||
} | |||
var changeChosenEdgeShadowSize = | |||
function(values, id, selected, hovering) { | |||
values.shadowSize = 20; | |||
} | |||
var changeChosenEdgeShadowX = | |||
function(values, id, selected, hovering) { | |||
values.shadowX = -5; | |||
} | |||
var changeChosenEdgeShadowY = | |||
function(values, id, selected, hovering) { | |||
values.shadowY = -5; | |||
} | |||
var changeChosenEdgeWidth = | |||
function(values, id, selected, hovering) { | |||
values.width = 5; | |||
} | |||
var changeChosenEdgeDashes = | |||
function(values, id, selected, hovering) { | |||
values.dashes = [10, 10]; | |||
} | |||
var nodes = [ | |||
{ id: 1000, label: "label does not change", | |||
x: -400, y: -300, | |||
chosen: { label: false, node: false } }, | |||
{ id: 1010, label: "label default settings", | |||
x: -400, y: -225, | |||
chosen: { label: true, node: false } }, | |||
{ id: 1020, label: "label changes color", | |||
x: -400, y: -150, | |||
chosen: { label: changeChosenLabelColor, node: false } }, | |||
{ id: 1030, label: "label changes size", | |||
x: -400, y: -75, | |||
chosen: { label: changeChosenLabelSize, node: false } }, | |||
{ id: 1040, label: "label changes face", | |||
x: -400, y: 0, | |||
chosen: { label: changeChosenLabelFace, node: false } }, | |||
{ id: 1050, label: "label changes modifier", | |||
x: -400, y: 75, | |||
chosen: { label: changeChosenLabelMod, node: false } }, | |||
{ id: 1060, label: "label changes stokeWidth", | |||
x: -400, y: 150, | |||
chosen: { label: changeChosenLabelStrokeWidth, node: false } }, | |||
{ id: 1070, label: "label changes stokeColor", | |||
x: -400, y: 225, font: { strokeWidth: 2 }, | |||
chosen: { label: changeChosenLabelStrokeColor, node: false } }, | |||
{ id: 2000, label: "node does not change", | |||
x: 0, y: -300, | |||
chosen: { label: false, node: false } }, | |||
{ id: 2010, label: "node default settings", | |||
x: 0, y: -225, | |||
chosen: { label: false, node: true } }, | |||
{ id: 2020, label: "node changes color", | |||
x: 0, y: -150, | |||
chosen: { label: false, node: changeChosenNodeColor } }, | |||
{ id: 2030, label: "node changes borderWidth", | |||
x: 0, y: -75, | |||
chosen: { label: false, node: changeChosenNodeBorderWidth } }, | |||
{ id: 2040, label: "node changes borderColor", | |||
x: 0, y: 0, | |||
chosen: { label: false, node: changeChosenNodeBorderColor } }, | |||
{ id: 2050, label: "shaped nodes change size", | |||
x: 0, y: 70, shape: 'star', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2051, x: -60, y: 70, shape: 'dot', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2052, x: -120, y: 70, shape: 'diamond', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2053, x: 60, y: 70, shape: 'square', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2054, x: 120, y: 70, shape: 'triangle', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2055, x: 165, y: 70, shape: 'triangleDown', | |||
chosen: { label: false, node: changeChosenNodeSize } }, | |||
{ id: 2060, label: "node changes borderDashes", | |||
x: 0, y: 150, | |||
chosen: { label: false, node: changeChosenNodeBorderDashes } }, | |||
{ id: 2070, label: "node changes borderRadius", | |||
x: 0, y: 225, | |||
chosen: { label: false, node: changeChosenNodeBorderRadius } }, | |||
{ id: 2080, label: "node changes shadow", | |||
x: 0, y: 300, | |||
chosen: { label: false, node: changeChosenNodeShadow } }, | |||
{ id: 2090, label: "node changes shadowColor", | |||
x: 0, y: 375, shadow: true, | |||
chosen: { label: false, node: changeChosenNodeShadowColor } }, | |||
{ id: 2100, label: "node changes shadowSize", | |||
x: 0, y: 450, shadow: true, | |||
chosen: { label: false, node: changeChosenNodeShadowSize } }, | |||
{ id: 2110, label: "node changes shadowX", | |||
x: 0, y: 525, shadow: true, | |||
chosen: { label: false, node: changeChosenNodeShadowX } }, | |||
{ id: 2120, label: "node changes shadowY", | |||
x: 0, y: 600, shadow: true, | |||
chosen: { label: false, node: changeChosenNodeShadowY } }, | |||
{ id: 3000, x: 275, y: -310, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3001, x: 525, y: -210, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3010, x: 275, y: -235, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3011, x: 525, y: -135, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3020, x: 275, y: -160, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3021, x: 525, y: -60, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3030, x: 275, y: -85, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3031, x: 525, y: 15, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3040, x: 275, y: -10, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3041, x: 525, y: 90, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3050, x: 275, y: 65, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3051, x: 525, y: 165, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3060, x: 275, y: 140, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3061, x: 525, y: 240, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3070, x: 275, y: 215, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3071, x: 525, y: 315, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3080, x: 275, y: 290, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0}, | |||
{ id: 3081, x: 525, y: 390, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3090, x: 275, y: 365, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3091, x: 525, y: 465, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3100, x: 275, y: 440, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3101, x: 525, y: 540, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3110, x: 275, y: 515, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3111, x: 525, y: 615, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3120, x: 575, y: -310, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3121, x: 825, y: -210, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3130, x: 575, y: -235, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3131, x: 825, y: -135, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3140, x: 575, y: -160, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3141, x: 825, y: -60, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3150, x: 575, y: -85, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3151, x: 825, y: 15, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3160, x: 575, y: -10, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3161, x: 825, y: 90, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3170, x: 575, y: 65, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3171, x: 825, y: 165, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3180, x: 575, y: 140, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3181, x: 825, y: 240, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3190, x: 575, y: 215, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3191, x: 825, y: 315, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3200, x: 575, y: 290, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3201, x: 825, y: 390, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3210, x: 575, y: 365, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3211, x: 825, y: 465, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
{ id: 3220, x: 575, y: 440, chosen: false, shape: "dot", size: 10, color: "#dd6644", borderWidth: 0 }, | |||
{ id: 3221, x: 825, y: 540, chosen: false, shape: "dot", size: 10, color: "#6699dd", borderWidth: 0 }, | |||
]; | |||
var edges = [ | |||
{ id: 4000, from: 3000, to: 3001, label: "edge does not change", | |||
chosen: false }, | |||
{ id: 4010, from: 3010, to: 3011, label: "edge has default settings", | |||
chosen: { label: false, edge: true } }, | |||
{ id: 4020, from: 3020, to: 3021, label: "edge changes toArrow", | |||
chosen: { label: false, edge: changeChosenEdgeToArrow } }, | |||
{ id: 4030, from: 3030, to: 3031, label: "edge changes toArrowScale", | |||
arrows: { to: true }, | |||
chosen: { label: false, edge: changeChosenEdgeToArrowScale } }, | |||
{ id: 4040, from: 3040, to: 3041, label: "edge changes toArrowType", | |||
arrows: { to: true }, | |||
chosen: { label: false, edge: changeChosenEdgeToArrowType } }, | |||
{ id: 4050, from: 3050, to: 3051, label: "edge changes middleArrow", | |||
chosen: { label: false, edge: changeChosenEdgeMiddleArrow } }, | |||
{ id: 4060, from: 3060, to: 3061, label: "edge changes middleArrowScale", | |||
arrows: { middle: true }, | |||
chosen: { label: false, edge: changeChosenEdgeMiddleArrowScale } }, | |||
{ id: 4070, from: 3070, to: 3071, label: "edge changes middleArrowType", | |||
arrows: { middle: true }, | |||
chosen: { label: false, edge: changeChosenEdgeMiddleArrowType } }, | |||
{ id: 4080, from: 3080, to: 3081, label: "edge changes fromArrow", | |||
chosen: { label: false, edge: changeChosenEdgeFromArrow } }, | |||
{ id: 4090, from: 3090, to: 3091, label: "edge changes fromArrowScale", | |||
arrows: { from: true }, | |||
chosen: { label: false, edge: changeChosenEdgeFromArrowScale } }, | |||
{ id: 4100, from: 3100, to: 3101, label: "edge changes fromArrowType", | |||
arrows: { from: true }, | |||
chosen: { label: false, edge: changeChosenEdgeFromArrowType } }, | |||
{ id: 4110, from: 3110, to: 3111, label: "edge changes arrowStrikethrough", | |||
arrows: { to: true, from: true }, width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeArrowStrikethrough } }, | |||
{ id: 4120, from: 3120, to: 3121, label: "edge changes color", | |||
chosen: { label: false, edge: changeChosenEdgeColor } }, | |||
{ id: 4130, from: 3130, to: 3131, label: "edge inherits color", | |||
chosen: { label: false, edge: changeChosenEdgeInheritsColor } }, | |||
{ id: 4140, from: 3140, to: 3141, label: "edge changes opacity", | |||
chosen: { label: false, edge: changeChosenEdgeOpacity } }, | |||
{ id: 4150, from: 3150, to: 3151, label: "edge changes hidden", | |||
chosen: { label: false, edge: changeChosenEdgeHidden } }, | |||
{ id: 4160, from: 3160, to: 3161, label: "edge changes shadow", | |||
width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeShadow } }, | |||
{ id: 4170, from: 3170, to: 3171, label: "edge changes shadowColor", | |||
shadow: true, width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeShadowColor } }, | |||
{ id: 4180, from: 3180, to: 3181, label: "edge changes shadowSize", | |||
shadow: true, width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeShadowSize } }, | |||
{ id: 4190, from: 3190, to: 3191, label: "edge changes shadowX", | |||
shadow: true, width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeShadowX } }, | |||
{ id: 4200, from: 3200, to: 3201, label: "edge changes shadowY", | |||
shadow: true, width: 7, | |||
chosen: { label: false, edge: changeChosenEdgeShadowY } }, | |||
{ id: 4210, from: 3210, to: 3211, label: "edge changes width", | |||
chosen: { label: false, edge: changeChosenEdgeWidth } }, | |||
{ id: 4220, from: 3220, to: 3221, label: "edge changes dashes", | |||
chosen: { label: false, edge: changeChosenEdgeDashes } }, | |||
]; | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = { | |||
edges: { | |||
font: { | |||
size: 16 | |||
}, | |||
selfReferenceSize: 30 | |||
}, | |||
nodes: { | |||
shape: 'box', | |||
widthConstraint: 250, | |||
color: "#cccccc", | |||
margin: 10, | |||
font: { | |||
size: 16 | |||
} | |||
}, | |||
physics: { | |||
enabled: false | |||
}, | |||
interaction: { | |||
hover: true | |||
} | |||
}; | |||
var network = new vis.Network(container, data, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,140 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<title>Network | Cursor Change</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 600px; | |||
height: 400px; | |||
border: 1px solid lightgray; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<p>Here is a simple network with nodes and edges that demonstrates how to change the cursor on hover for nodes and edges.</p> | |||
<p>Use the dropdowns and button below to change the cursor type bound to an event.</p> | |||
<div> | |||
Event Type - | |||
<select id="eventType"> | |||
<option value="hoverNode">hoverNode</option> | |||
<option value="blurNode">blurNode</option> | |||
<option value="hoverEdge">hoverEdge</option> | |||
<option value="blurEdge">blurEdge</option> | |||
<option value="dragStart">dragStart</option> | |||
<option value="dragging">dragging</option> | |||
<option value="dragEnd">dragEnd</option> | |||
</select> | |||
| |||
Cursor Type - | |||
<select id="cursorType"> | |||
<option value="auto">auto</option> | |||
<option value="default">default</option> | |||
<option value="context-menu">context-menu</option> | |||
<option value="help">help</option> | |||
<option value="pointer">pointer</option> | |||
<option value="progress">progress</option> | |||
<option value="wait">wait</option> | |||
<option value="cell">cell</option> | |||
<option value="crosshair">crosshair</option> | |||
<option value="text">text</option> | |||
<option value="vertical-text">vertical-text</option> | |||
<option value="alias">alias</option> | |||
<option value="copy">copy</option> | |||
<option value="move">move</option> | |||
<option value="no-drop">no-drop</option> | |||
<option value="not-allowed">not-allowed</option> | |||
<option value="all-scroll">all-scroll</option> | |||
<option value="col-resize">col-resize</option> | |||
<option value="row-resize">row-resize</option> | |||
<option value="n-resize">n-resize</option> | |||
<option value="e-resize">e-resize</option> | |||
<option value="w-resize">w-resize</option> | |||
<option value="s-resize">s-resize</option> | |||
<option value="ne-resize">ne-resize</option> | |||
<option value="nw-resize">nw-resize</option> | |||
<option value="se-resize">se-resize</option> | |||
<option value="sw-resize">sw-resize</option> | |||
<option value="ew-resize">ew-resize</option> | |||
<option value="ns-resize">ns-resize</option> | |||
<option value="nesw-resize">nesw-resize</option> | |||
<option value="nwse-resize">nwse-resize</option> | |||
<option value="zoom-in">zoom-in</option> | |||
<option value="zoom-out">zoom-out</option> | |||
<option value="grab">grab</option> | |||
<option value="grabbing">grabbing</option> | |||
</select> | |||
| |||
<button onClick="changeEventCursor(document.getElementById('eventType').value,document.getElementById('cursorType').value);">Change Cursor for Event</button> | |||
</div> | |||
<div id="mynetwork"></div> | |||
<script type="text/javascript"> | |||
// create an array with nodes | |||
var nodes = new vis.DataSet([ | |||
{id: 1, label: 'Node 1'}, | |||
{id: 2, label: 'Node 2'}, | |||
{id: 3, label: 'Node 3'}, | |||
{id: 4, label: 'Node 4'}, | |||
{id: 5, label: 'Node 5'} | |||
]); | |||
// create an array with edges | |||
var edges = new vis.DataSet([ | |||
{from: 1, to: 3}, | |||
{from: 1, to: 2}, | |||
{from: 2, to: 4}, | |||
{from: 2, to: 5} | |||
]); | |||
// create a network | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = {interaction:{hover:true}}; | |||
var network = new vis.Network(container, data, options); | |||
//Get the canvas HTML element | |||
var networkCanvas = document.getElementById("mynetwork").getElementsByTagName("canvas")[0] | |||
function changeCursor(newCursorStyle){ | |||
networkCanvas.style.cursor = newCursorStyle; | |||
} | |||
function changeEventCursor(eventName,cursorType){ | |||
network.on(eventName, function() { | |||
changeCursor(cursorType); | |||
}); | |||
} | |||
network.on('hoverNode', function () { | |||
changeCursor('grab'); | |||
}); | |||
network.on('blurNode', function () { | |||
changeCursor('default'); | |||
}); | |||
network.on('hoverEdge', function () { | |||
changeCursor('grab'); | |||
}); | |||
network.on('blurEdge', function () { | |||
changeCursor('default'); | |||
}); | |||
network.on('dragStart', function () { | |||
changeCursor('grabbing'); | |||
}); | |||
network.on('dragging', function () { | |||
changeCursor('grabbing'); | |||
}); | |||
network.on('dragEnd', function () { | |||
changeCursor('grab'); | |||
}); | |||
</script> | |||
</body> | |||
</html> | |||
@ -0,0 +1,254 @@ | |||
<!doctype html> | |||
<html> | |||
<head> | |||
<meta charset="utf-8"/> | |||
<title>Network | Manipulation | Edit Edge Without Drag</title> | |||
<style type="text/css"> | |||
body, select { | |||
font: 10pt sans; | |||
} | |||
#mynetwork { | |||
position:relative; | |||
width: 800px; | |||
height: 600px; | |||
border: 1px solid lightgray; | |||
} | |||
table.legend_table { | |||
font-size: 11px; | |||
border-width:1px; | |||
border-color:#d3d3d3; | |||
border-style:solid; | |||
} | |||
table.legend_table,td { | |||
border-width:1px; | |||
border-color:#d3d3d3; | |||
border-style:solid; | |||
padding: 2px; | |||
} | |||
div.table_content { | |||
width:80px; | |||
text-align:center; | |||
} | |||
div.table_description { | |||
width:100px; | |||
} | |||
#operation { | |||
font-size:28px; | |||
} | |||
#node-popUp { | |||
display:none; | |||
position:absolute; | |||
top:350px; | |||
left:170px; | |||
z-index:299; | |||
width:250px; | |||
height:120px; | |||
background-color: #f9f9f9; | |||
border-style:solid; | |||
border-width:3px; | |||
border-color: #5394ed; | |||
padding:10px; | |||
text-align: center; | |||
} | |||
#edge-popUp { | |||
display:none; | |||
position:absolute; | |||
top:350px; | |||
left:170px; | |||
z-index:299; | |||
width:250px; | |||
height:90px; | |||
background-color: #f9f9f9; | |||
border-style:solid; | |||
border-width:3px; | |||
border-color: #5394ed; | |||
padding:10px; | |||
text-align: center; | |||
} | |||
</style> | |||
<script type="text/javascript" src="../exampleUtil.js"></script> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<script type="text/javascript"> | |||
var nodes = null; | |||
var edges = null; | |||
var network = null; | |||
// randomly create some nodes and edges | |||
var data = getScaleFreeNetwork(25); | |||
var seed = 2; | |||
function setDefaultLocale() { | |||
var defaultLocal = navigator.language; | |||
var select = document.getElementById('locale'); | |||
select.selectedIndex = 0; // set fallback value | |||
for (var i = 0, j = select.options.length; i < j; ++i) { | |||
if (select.options[i].getAttribute('value') === defaultLocal) { | |||
select.selectedIndex = i; | |||
break; | |||
} | |||
} | |||
} | |||
function destroy() { | |||
if (network !== null) { | |||
network.destroy(); | |||
network = null; | |||
} | |||
} | |||
function draw() { | |||
destroy(); | |||
nodes = []; | |||
edges = []; | |||
// create a network | |||
var container = document.getElementById('mynetwork'); | |||
var options = { | |||
layout: {randomSeed:seed}, // just to make sure the layout is the same when the locale is changed | |||
locale: document.getElementById('locale').value, | |||
manipulation: { | |||
addNode: function (data, callback) { | |||
// filling in the popup DOM elements | |||
document.getElementById('node-operation').innerHTML = "Add Node"; | |||
editNode(data, callback); | |||
}, | |||
editNode: function (data, callback) { | |||
// filling in the popup DOM elements | |||
document.getElementById('node-operation').innerHTML = "Edit Node"; | |||
editNode(data, callback); | |||
}, | |||
addEdge: function (data, callback) { | |||
if (data.from == data.to) { | |||
var r = confirm("Do you want to connect the node to itself?"); | |||
if (r != true) { | |||
callback(null); | |||
return; | |||
} | |||
} | |||
document.getElementById('edge-operation').innerHTML = "Add Edge"; | |||
editEdgeWithoutDrag(data, callback); | |||
}, | |||
editEdge: { | |||
editWithoutDrag: function(data, callback) { | |||
document.getElementById('edge-operation').innerHTML = "Edit Edge"; | |||
editEdgeWithoutDrag(data,callback); | |||
} | |||
} | |||
} | |||
}; | |||
network = new vis.Network(container, data, options); | |||
} | |||
function editNode(data, callback) { | |||
document.getElementById('node-label').value = data.label; | |||
document.getElementById('node-saveButton').onclick = saveNodeData.bind(this, data, callback); | |||
document.getElementById('node-cancelButton').onclick = clearNodePopUp.bind(); | |||
document.getElementById('node-popUp').style.display = 'block'; | |||
} | |||
function clearNodePopUp() { | |||
document.getElementById('node-saveButton').onclick = null; | |||
document.getElementById('node-cancelButton').onclick = null; | |||
document.getElementById('node-popUp').style.display = 'none'; | |||
} | |||
function cancelNodeEdit(callback) { | |||
clearNodePopUp(); | |||
callback(null); | |||
} | |||
function saveNodeData(data, callback) { | |||
data.label = document.getElementById('node-label').value; | |||
clearNodePopUp(); | |||
callback(data); | |||
} | |||
function editEdgeWithoutDrag(data, callback) { | |||
// filling in the popup DOM elements | |||
document.getElementById('edge-label').value = data.label; | |||
document.getElementById('edge-saveButton').onclick = saveEdgeData.bind(this, data, callback); | |||
document.getElementById('edge-cancelButton').onclick = cancelEdgeEdit.bind(this,callback); | |||
document.getElementById('edge-popUp').style.display = 'block'; | |||
} | |||
function clearEdgePopUp() { | |||
document.getElementById('edge-saveButton').onclick = null; | |||
document.getElementById('edge-cancelButton').onclick = null; | |||
document.getElementById('edge-popUp').style.display = 'none'; | |||
} | |||
function cancelEdgeEdit(callback) { | |||
clearEdgePopUp(); | |||
callback(null); | |||
} | |||
function saveEdgeData(data, callback) { | |||
if (typeof data.to === 'object') | |||
data.to = data.to.id | |||
if (typeof data.from === 'object') | |||
data.from = data.from.id | |||
data.label = document.getElementById('edge-label').value; | |||
clearEdgePopUp(); | |||
callback(data); | |||
} | |||
function init() { | |||
setDefaultLocale(); | |||
draw(); | |||
} | |||
</script> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body onload="init();"> | |||
<h2>Editing the nodes and edges-without-drag (localized)</h2> | |||
<p style="width: 700px; font-size:14px; text-align: justify;"> | |||
The localization is only relevant to the manipulation buttons. | |||
</p> | |||
<p> | |||
<label for="locale">Select a locale:</label> | |||
<select id="locale" onchange="draw();"> | |||
<option value="en">en</option> | |||
<option value="de">de</option> | |||
<option value="es">es</option> | |||
<option value="it">it</option> | |||
<option value="nl">nl</option> | |||
<option value="pt-br">pt</option> | |||
<option value="ru">ru</option> | |||
</select> | |||
</p> | |||
<div id="node-popUp"> | |||
<span id="node-operation">node</span> <br> | |||
<table style="margin:auto;"> | |||
<tr> | |||
<td>id</td><td><input id="node-id" value="new value" /></td> | |||
</tr> | |||
<tr> | |||
<td>label</td><td><input id="node-label" value="new value" /></td> | |||
</tr> | |||
</table> | |||
<input type="button" value="save" id="node-saveButton" /> | |||
<input type="button" value="cancel" id="node-cancelButton" /> | |||
</div> | |||
<div id="edge-popUp"> | |||
<span id="edge-operation">edge</span> <br> | |||
<table style="margin:auto;"> | |||
<tr> | |||
<td>label</td><td><input id="edge-label" value="new value" /></td> | |||
</tr></table> | |||
<input type="button" value="save" id="edge-saveButton" /> | |||
<input type="button" value="cancel" id="edge-cancelButton" /> | |||
</div> | |||
<br /> | |||
<div id="mynetwork"></div> | |||
</body> | |||
</html> |
@ -0,0 +1,85 @@ | |||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | |||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |||
<html xmlns="http://www.w3.org/1999/xhtml"> | |||
<head> | |||
<title>Network | On Load Animation</title> | |||
<script type="text/javascript" src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-network.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
#mynetwork { | |||
width: 600px; | |||
height: 400px; | |||
border: 1px solid lightgray; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<h2>Vis.js network onLoad animation</h2> | |||
<p>easeIn functions accelerate from zero velocity.</p> | |||
<p>easeOut functions decelerate to zero velocity.</p> | |||
<p>easeInOut functions accelerate from zero till halfway then after the halfway point they decrease until zero.</p> | |||
<div> | |||
Onload Animation Easing Function - | |||
<select id="easingFunction"> | |||
<option value="linear">linear</option> | |||
<option value="easeInQuad">easeInQuad</option> | |||
<option value="easeOutQuad">easeOutQuad</option> | |||
<option value="easeInOutQuad">easeInOutQuad</option> | |||
<option value="easeInCubic">easeInCubic</option> | |||
<option value="easeOutCubic">easeOutCubic</option> | |||
<option value="easeInOutCubic">easeInOutCubic</option> | |||
<option value="easeInQuart">easeInQuart</option> | |||
<option value="easeOutQuart">easeOutQuart</option> | |||
<option value="easeInOutQuart">easeInOutQuart</option> | |||
<option value="easeInQuint">easeInQuint</option> | |||
<option value="easeOutQuint">easeOutQuint</option> | |||
<option value="easeInOutQuint">easeInOutQuint</option> | |||
</select> | |||
<button onClick="createNetwork(document.getElementById('easingFunction').value);">Demo Easing Function</button> | |||
</div> | |||
<p>For more information on easing functions check out <a href="http://easings.net/">easings.net</a></p> | |||
<div id="mynetwork"></div> | |||
<script type="text/javascript"> | |||
document.getElementById("easingFunction").selectedIndex = 0; | |||
function createNetwork(easingType) { | |||
var nodes = new vis.DataSet([ | |||
{id: 1, label: 'Node 1'}, | |||
{id: 2, label: 'Node 2'}, | |||
{id: 3, label: 'Node 3'}, | |||
{id: 4, label: 'Node 4'}, | |||
{id: 5, label: 'Node 5'} | |||
]); | |||
var edges = new vis.DataSet([ | |||
{from: 1, to: 3}, | |||
{from: 1, to: 2}, | |||
{from: 2, to: 4}, | |||
{from: 2, to: 5} | |||
]); | |||
var container = document.getElementById('mynetwork'); | |||
var data = { | |||
nodes: nodes, | |||
edges: edges | |||
}; | |||
var options = {}; | |||
var network = new vis.Network(container, data, options); | |||
network.once("beforeDrawing", function() { | |||
network.focus(2, { | |||
scale: 12 | |||
}); | |||
}); | |||
network.once("afterDrawing", function() { | |||
network.fit({ | |||
animation: { | |||
duration: 3000, | |||
easingFunction: easingType | |||
} | |||
}); | |||
}); | |||
} | |||
createNetwork("linear"); | |||
</script> | |||
</body> | |||
</html> | |||
@ -0,0 +1,99 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Individual editable items</title> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
div.vis-editable, | |||
div.vis-editable.vis-selected { | |||
/* custom styling for editable items... */ | |||
} | |||
div.vis-readonly, | |||
div.vis-readonly.vis-selected { | |||
/* custom styling for readonly items... */ | |||
background-color: #ff4500; | |||
border-color: red; | |||
color: white; | |||
} | |||
</style> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" /> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<p>Specify individual items to be editable or readonly. Toggle edit options and override behavior from timeline.editable</p> | |||
<div id="visualization"></div> | |||
<p> | |||
<form> | |||
Timeline.editable = {</br> | |||
<input name="add" type="checkbox" checked>add</input></br> | |||
<input name="remove" type="checkbox" checked>remove</input></br> | |||
<input name="updateGroup" type="checkbox">updateGroup</input></br> | |||
<input name="updateTime" type="checkbox" checked>updateTime</input><br> | |||
<input name="overrideItems" type="checkbox">overrideItems</input><br> | |||
} | |||
</form> | |||
</p> | |||
<script> | |||
// create a DataSet with items | |||
var items = new vis.DataSet([ | |||
{id: 1, content: 'Editable', editable: true, start: '2010-08-23', group: 1}, | |||
{id: 2, content: 'Editable', editable: true, start: '2010-08-23T23:00:00', group: 2}, | |||
{id: 3, content: 'Read-only', editable: false, start: '2010-08-24T16:00:00', group: 1}, | |||
{id: 4, content: 'Read-only', editable: false, start: '2010-08-26', end: '2010-09-02', group: 2}, | |||
{id: 5, content: 'Editable', editable: true, start: '2010-08-28', group: 1}, | |||
{id: 6, content: 'Read-only', editable: false, start: '2010-08-29', group: 2}, | |||
{id: 7, content: 'Editable', editable: true, start: '2010-08-31', end: '2010-09-03', group: 1}, | |||
{id: 8, content: 'Read-only', editable: false, start: '2010-09-04T12:00:00', group: 2}, | |||
{id: 9, content: 'Default', start: '2010-09-04', group: 1}, | |||
{id: 10, content: 'Default', start: '2010-08-24', group: 2} | |||
]); | |||
var groups = [ | |||
{ | |||
id: 1, | |||
content: 'group 1' | |||
}, | |||
{ | |||
id: 2, | |||
content: 'group 2' | |||
} | |||
] | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
editable: { | |||
add: true, | |||
remove: true, | |||
updateGroup: false, | |||
updateTime: true, | |||
overrideItems: false | |||
} // default for all items | |||
}; | |||
var timeline = new vis.Timeline(container, items, groups, options); | |||
var updateEditOptions = function(e){ | |||
var changedOption = e.target.name; | |||
var options = { editable: { } }; | |||
options.editable[changedOption] = e.target.checked; | |||
timeline.setOptions(options); | |||
}; | |||
var cbs = document.getElementsByTagName("input"); | |||
[].forEach.call(cbs, function(cb){ | |||
cb.onchange = updateEditOptions; | |||
}); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,113 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Nested Groups example</title> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
#visualization { | |||
box-sizing: border-box; | |||
width: 100%; | |||
height: 300px; | |||
} | |||
</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.8.4/moment.min.js"></script> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis.min.css" rel="stylesheet" type="text/css" /> | |||
</head> | |||
<body> | |||
<p> | |||
This example demonstrate using groups. Note that a DataSet is used for both | |||
items and groups, allowing to dynamically add, update or remove both items | |||
and groups via the DataSet. | |||
</p> | |||
<div id="visualization"></div> | |||
<script> | |||
var now = moment().minutes(0).seconds(0).milliseconds(0); | |||
var itemCount = 60; | |||
// create a data set with groups | |||
var groups = new vis.DataSet(); | |||
groups.add([ | |||
{ | |||
id: 1, | |||
content: "Lee", | |||
nestedGroups: [11,12,13] | |||
}, | |||
{ | |||
id: 2, | |||
content: "invisible group", | |||
visible: false | |||
}, | |||
{ | |||
id: 3, | |||
content: "John", | |||
nestedGroups: [14], | |||
showNested: false | |||
}, | |||
{ | |||
id: 4, | |||
content: "Alson" | |||
}, | |||
]); | |||
groups.add([ | |||
{ | |||
id: 11, | |||
content: "cook", | |||
}, | |||
{ | |||
id: 12, | |||
content: "shop", | |||
}, | |||
{ | |||
id: 13, | |||
content: "clean house", | |||
}, | |||
{ | |||
id: 14, | |||
content: "wash dishes", | |||
} | |||
]); | |||
// create a dataset with items | |||
var items = new vis.DataSet(); | |||
var groupIds = groups.getIds(); | |||
var types = [ 'box', 'point', 'range', 'background'] | |||
for (var i = 0; i < itemCount; i++) { | |||
var start = now.clone().add(Math.random() * 200, 'hours'); | |||
var end = start.clone().add(2, 'hours'); | |||
var randomGroupId = groupIds[Math.floor(Math.random() * groupIds.length)]; | |||
var type = types[Math.floor(4 * Math.random())] | |||
items.add({ | |||
id: i, | |||
group: randomGroupId, | |||
content: 'item ' + i, | |||
start: start, | |||
end: end, | |||
type: type | |||
}); | |||
} | |||
// create visualization | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
groupOrder: 'content' // groupOrder can be a property name or a sorting function | |||
}; | |||
var timeline = new vis.Timeline(container, items, groups, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,45 @@ | |||
<html> | |||
<head> | |||
<title>Timeline | rolling mode Option</title> | |||
<meta charset="utf-8"> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<h1><i id="icon">⛶</i>Timeline rolling mode option</h1> | |||
<div id="mytimeline"></div> | |||
<script> | |||
var container = document.getElementById('mytimeline'); | |||
var items = new vis.DataSet(); | |||
for (var i = 10; i >= 0; i--) { | |||
items.add({ | |||
id: i, | |||
content: "item " + i, | |||
start: new Date(new Date().getTime() + i*100000) | |||
}); | |||
} | |||
// Configuration for the Timeline | |||
// specify options | |||
var options = { | |||
start: new Date(), | |||
end: new Date(new Date().getTime() + 1000000), | |||
rollingMode: true | |||
}; | |||
// create a Timeline | |||
timeline = new vis.Timeline(container, items, null, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,111 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | expected vs actual times items</title> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis.css" rel="stylesheet" type="text/css" /> | |||
<style> | |||
body, html { | |||
font-family: arial, sans-serif; | |||
font-size: 11pt; | |||
} | |||
.vis-item.expected { | |||
background-color: transparent; | |||
border-style: dashed!important; | |||
z-index: 0; | |||
} | |||
.vis-item.vis-selected { | |||
opacity: 0.6; | |||
} | |||
.vis-item.vis-background.marker { | |||
border-left: 2px solid green; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<div id="visualization"></div> | |||
<script> | |||
// create a dataset with items | |||
// we specify the type of the fields `start` and `end` here to be strings | |||
// containing an ISO date. The fields will be outputted as ISO dates | |||
// automatically getting data from the DataSet via items.get(). | |||
var items = new vis.DataSet({ | |||
type: { start: 'ISODate', end: 'ISODate' } | |||
}); | |||
var groups = new vis.DataSet([ | |||
{ | |||
id: 'group1', | |||
content:'group1' | |||
} | |||
]); | |||
// add items to the DataSet | |||
items.add([ | |||
// group 1 | |||
{ | |||
id: 'background1', | |||
start: '2014-01-21', | |||
end: '2014-01-22', | |||
type: 'background', | |||
group:'group1' | |||
}, | |||
// subgroup 1 | |||
{ | |||
id: 1, | |||
content: 'item 1 (expected time)', | |||
className: 'expected', | |||
start: '2014-01-23 12:00:00', | |||
end: '2014-01-26 12:00:00', | |||
group:'group1', | |||
subgroup:'sg_1' | |||
}, | |||
{ | |||
id: 2, | |||
content: 'item 1 (actual time)', | |||
start: '2014-01-24 12:00:00', | |||
end: '2014-01-27 12:00:00', | |||
group:'group1', | |||
subgroup:'sg_1' | |||
}, | |||
// subgroup 2 | |||
{ | |||
id: 3, | |||
content: 'item 2 (expected time)', | |||
className: 'expected', | |||
start: '2014-01-13 12:00:00', | |||
end: '2014-01-16 12:00:00', | |||
group:'group1', | |||
subgroup:'sg_2' | |||
}, | |||
{ | |||
id: 4, | |||
content: 'item 2 (actual time)', | |||
start: '2014-01-14 12:00:00', | |||
end: '2014-01-17 12:00:00', | |||
group:'group1', | |||
subgroup:'sg_2' | |||
} | |||
]); | |||
var container = document.getElementById('visualization'); | |||
var options = { | |||
start: '2014-01-10', | |||
end: '2014-02-10', | |||
editable: true, | |||
stack: false, | |||
stackSubgroups: false | |||
}; | |||
var timeline = new vis.Timeline(container, items, groups, options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,84 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Tooltips</title> | |||
<style type="text/css"> | |||
body, html { | |||
font-family: sans-serif; | |||
max-width: 800px; | |||
} | |||
</style> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" /> | |||
<script src="../../googleAnalytics.js"></script> | |||
</head> | |||
<body> | |||
<h1>Tooltips</h1> | |||
<p> | |||
Setting the tooltip in various ways. | |||
</p> | |||
<div id="tooltips"></div> | |||
<p> | |||
The example below has the tooltip follow the mouse. | |||
</p> | |||
<div id="tooltips-follow"></div> | |||
<p> | |||
The example below has the tooltip overflow set to 'cap'. Compare this to the one above, | |||
to see how they differ. For the best results, move the cursor to the top right, | |||
where the tool-tip is going to overflow out of the timeline. | |||
</p> | |||
<div id="tooltips-cap"></div> | |||
<script type="text/javascript"> | |||
// Create a DataSet (allows two way data-binding) | |||
var items = new vis.DataSet([ | |||
{id: 1, content: 'Item 1', start: '2016-01-01', end: '2016-01-02', | |||
title: 'Normal text'}, | |||
{id: 2, content: 'Item 2', start: '2016-01-02', title: '<b>Bold</b>'}, | |||
{id: 3, content: 'Item 3', start: '2016-01-03', type: 'point', | |||
title: '<span style="color: red">Red</span> text'}, | |||
{id: 4, content: '<h1>HTML</h1> Item', start: '2016-01-03', end: '2016-01-04', | |||
title: '<table border="1"><tr><td>Cell 1</td><td>Cell 2</td></tr></table>'} | |||
]); | |||
// Options | |||
var options = {}; | |||
// Timeline object | |||
var timelineTooltips = new vis.Timeline(document.getElementById('tooltips'), | |||
items, options | |||
); | |||
// Follow options | |||
var follow_options = { | |||
tooltip: { | |||
followMouse: true | |||
} | |||
}; | |||
var timelineFollow = new vis.Timeline(document.getElementById('tooltips-follow'), | |||
items, follow_options); | |||
// Cap options | |||
var cap_options = { | |||
tooltip: { | |||
followMouse: true, | |||
overflowMethod: 'cap' | |||
} | |||
} | |||
var timelineCap = new vis.Timeline(document.getElementById('tooltips-cap'), | |||
items, cap_options); | |||
</script> | |||
</body> | |||
</html> |
@ -0,0 +1,67 @@ | |||
<!DOCTYPE HTML> | |||
<html> | |||
<head> | |||
<title>Timeline | Dynamic Content</title> | |||
<script src="../../../dist/vis.js"></script> | |||
<link href="../../../dist/vis.min.css" rel="stylesheet" type="text/css" /> | |||
<style type="text/css"> | |||
.progress-wrapper { | |||
background: white; | |||
width: 100%; | |||
height: 18px; | |||
text-align: center; | |||
position: relative; | |||
overflow: hidden; | |||
} | |||
.progress { | |||
height: 100%; | |||
width: 60%; | |||
position: absolute; | |||
left: 0px; | |||
top: 0px; | |||
background: #63ed63; | |||
} | |||
.progress-label { | |||
position: absolute; | |||
z-index: 1; | |||
} | |||
</style> | |||
</head> | |||
<body> | |||
<div id="myTimeline"></div> | |||
<script type="text/javascript"> | |||
// DOM element where the Timeline will be attached | |||
var container = document.getElementById('myTimeline'); | |||
// Create a DataSet (allows two way data-binding) | |||
var items = new vis.DataSet([ | |||
{id: 1, value: 0.2, content: 'item 1', start: '2014-04-20', end: '2014-04-26'}, | |||
{id: 2, value: 0.6, content: 'item 2', start: '2014-05-14', end: '2014-05-18'}, | |||
{id: 3, type: 'point', content: 'item 3', start: '2014-04-15', end: '2014-05-18'}, | |||
{id: 4, content: 'item 4 with visibleFramTemplate in item', start: '2014-04-16', end: '2014-04-26', visibleFramTemplate: '<div class="progress-wrapper"><div class="progress"></div><label class="progress-label">80%<label></div>' | |||
} | |||
]); | |||
// Configuration for the Timeline | |||
var options = { | |||
visibleFrameTemplate: function(item) { | |||
if (item.visibleFramTemplate) { | |||
return item.visibleFramTemplate; | |||
} | |||
var percentage = item.value * 100 + '%'; | |||
return '<div class="progress-wrapper"><div class="progress"></div><label class="progress-label">' + percentage + '<label></div>'; | |||
} | |||
}; | |||
// Create a Timeline | |||
var timeline = new vis.Timeline(container, items, options); | |||
</script> | |||
</body> | |||
</html> |