@ -0,0 +1,72 @@ | |||||
<!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 /> | |||||
Graph2D does not sort the data. It is plotted as it is inputted. If you want your data to be sorted, sort your data. | |||||
</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, | |||||
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,116 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Graph2D | Performance</title> | |||||
<style> | |||||
body, html { | |||||
font-family: arial, sans-serif; | |||||
font-size: 11pt; | |||||
} | |||||
</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 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 /> | |||||
<p> | |||||
<label for="count">Number of items</label> | |||||
<input id="count" value="100"> | |||||
<input id="draw" type="button" value="draw"> | |||||
<input id="toggleInterpolation" type="button" value="toggle Interpolation"> | |||||
<input id="togglePoints" type="button" value="toggle Points"> | |||||
</p> | |||||
<div id="visualization"></div> | |||||
<script> | |||||
var points = ''; | |||||
var interpolation = ''; | |||||
function togglePoints() { | |||||
var pointsOptions = {}; | |||||
if (points == "") { | |||||
points = 'circle'; | |||||
pointsOptions = {drawPoints: {style: 'circle'}}; | |||||
} | |||||
else if (points == "circle") { | |||||
points = 'square'; | |||||
pointsOptions = {drawPoints: {style: 'square'}}; | |||||
} | |||||
else if (points == "square") { | |||||
points = ''; | |||||
pointsOptions = {drawPoints: false}; | |||||
} | |||||
graph2D.setOptions(pointsOptions); | |||||
} | |||||
function toggleInterpolation() { | |||||
var interpolationOptions = {}; | |||||
if (interpolation == "") { | |||||
interpolation = 'centripetal'; | |||||
interpolationOptions = {drawPoints: {style: 'circle'}}; | |||||
} | |||||
else if (interpolation == "circle") { | |||||
interpolation = 'chordal'; | |||||
interpolationOptions = {drawPoints: {style: 'square'}}; | |||||
} | |||||
else if (interpolation == "square") { | |||||
interpolation = 'uniform'; | |||||
interpolationOptions = {drawPoints: false}; | |||||
} | |||||
else if (interpolation == "square") { | |||||
interpolation = ''; | |||||
interpolationOptions = {drawPoints: false}; | |||||
} | |||||
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.clone().add('days', 100); | |||||
// create data | |||||
function createData() { | |||||
var count = parseInt(document.getElementById('count').value) || 100; | |||||
var newData = []; | |||||
for (var i = 0; i < count; i++) { | |||||
newData.push({id: i, x: now.clone().add('days', i), y: Math.sin(0.1 * 3.14159654 * i)}); | |||||
} | |||||
dataset.clear(); | |||||
dataset.add(newData); | |||||
} | |||||
createData(); | |||||
document.getElementById('draw').onclick = createData; | |||||
document.getElementById('toggleInterpolation').onclick = createData; | |||||
document.getElementById('togglePoints').onclick = createData; | |||||
var container = document.getElementById('visualization'); | |||||
var options = { | |||||
start: startPoint, | |||||
end: endPoint | |||||
}; | |||||
var graph2D = new vis.Graph2d(container, dataset, options); | |||||
</script> | |||||
</body> | |||||
</html> |
@ -1,102 +0,0 @@ | |||||
<!DOCTYPE HTML> | |||||
<html> | |||||
<head> | |||||
<title>Graph2d | Basic demo</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 options = { | |||||
yAxisOrientation: 'left', | |||||
shaded: { | |||||
enabled: true, | |||||
orientation: 'bottom' // top, bottom | |||||
}, | |||||
drawPoints: { | |||||
enabled: false, | |||||
size: 6, | |||||
style: 'circle' // square, circle | |||||
} | |||||
}; | |||||
// create a data set with groups | |||||
var names = ['John', 'Alston', 'Lee', 'Grant']; | |||||
var groups = new vis.DataSet(); | |||||
groups.add({ | |||||
id: 0, | |||||
content: names[0], | |||||
// className: "graphGroup9", | |||||
options: { | |||||
drawPoints: { | |||||
style: 'square' // square, circle | |||||
}, | |||||
shaded: { | |||||
orientation: 'bottom' // top, bottom | |||||
} | |||||
}}); | |||||
groups.add({ | |||||
id: 1, | |||||
content: names[1], | |||||
options: { | |||||
style:'bar', | |||||
// yAxisOrientation: 'right', | |||||
drawPoints: false, // square, circle | |||||
shaded: { | |||||
orientation: 'top' // top, bottom | |||||
} | |||||
}}); | |||||
groups.add({ | |||||
id: 2, | |||||
content: names[2], | |||||
options: { | |||||
yAxisOrientation: 'right', | |||||
shaded: { | |||||
enabled: false, | |||||
orientation: 'top' // top, bottom | |||||
} | |||||
}}); | |||||
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, 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: 100, group: 1}, | |||||
{x: '2014-06-18', y: 150, group: 1}, | |||||
{x: '2014-06-19', y: 520, group: 1}, | |||||
{x: '2014-06-20', y: 100, 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-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 graph2d = new vis.Graph2d(container, items, options, groups); | |||||
</script> | |||||
</body> | |||||
</html> |