Kasperwing-ng flight
Kasperwing-ng flight visualisation. Source: becomeapro.pl
by mikasjp
HTML
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<div id="graph"></div>
JavaScript
Array.prototype.max = function() {
return Math.max.apply(null, this);
};
Array.prototype.min = function() {
return Math.min.apply(null, this);
};
Plotly.d3.csv('https://gist.githubusercontent.com/mikasjp/3e085cc899b6dcaf9d8a87a05b05acc6/raw/c999df05ed5ba67f9eb8fabd8fa624a3f2c85041/gps.csv', function(err, rows){
function unpack(rows, key) {
return rows.map(function(row)
{ return row[key]; }); }
var x = unpack(rows , 'x');
var y = unpack(rows , 'y');
var z = unpack(rows , 'z');
var c = [];
var z_min = z.min();
var z_max = z.max();
for(i=0; i<x.length; i++)
{
var red = Math.floor(0xFF * (z[i]-z_min)/(z_max - z_min));
var green = 0xFF - red;
c.push("rgb("+red+", "+green+", 0)");
}
Plotly.plot('graph', [{
type: 'scatter3d',
mode: 'lines',
x: x,
y: y,
z: z,
opacity: 1,
line: {
width: 6,
color: c,
reversescale: false
}
}], {
height: 600
});
});