UNPKG

1.65 kBHTMLView Raw
1<!doctype html>
2<html>
3<head>
4 <title>Graph 3D cloud with sized dots</title>
5
6 <style>
7 body {font: 10pt arial;}
8 </style>
9 <script type="text/javascript" src="../../dist/vis-graph3d.min.js"></script>
10
11 <script type="text/javascript">
12 var data = null;
13 var graph = null;
14
15 // Called when the Visualization API is loaded.
16 function drawVisualization() {
17 // create the data table.
18 data = new vis.DataSet();
19
20 // create some shortcuts to math functions
21 var sqrt = Math.sqrt;
22 var pow = Math.pow;
23 var random = Math.random;
24
25 // create the animation data
26 var imax = 100;
27 for (var i = 0; i < imax; i++) {
28 var x = pow(random(), 2);
29 var y = pow(random(), 2);
30 var z = pow(random(), 2);
31
32 var dist = sqrt(pow(x, 2) + pow(y, 2) + pow(z, 2));
33 var range = sqrt(2) - dist;
34
35 data.add({x:x,y:y,z:z,style:range});
36 }
37
38 // specify options
39 var options = {
40 width: '600px',
41 height: '600px',
42 style: 'dot-size',
43 showPerspective: false,
44 showGrid: true,
45 keepAspectRatio: true,
46 legendLabel:'value',
47 verticalRatio: 1.0,
48 cameraPosition: {
49 horizontal: -0.54,
50 vertical: 0.5,
51 distance: 1.6
52 },
53 dotSizeMinFraction: 0.5,
54 dotSizeMaxFraction: 2.5
55 };
56
57 // create our graph
58 var container = document.getElementById('mygraph');
59 graph = new vis.Graph3d(container, data, options);
60 }
61 </script>
62</head>
63
64<body onload="drawVisualization()">
65<div id="mygraph"></div>
66
67<div id="info"></div>
68</body>
69</html>