| <!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, groups, options); | |
| 
 | |
| </script> | |
| </body> | |
| </html> |