$(document).ready(function(){
// ajax home to get data for this prototype
// in real implementation, we'll just ship
// over at the same time as the page.
$.ajax({
url: 'http://dev5.purplewire.com/~jason/data/sway.json',
dataType: 'json',
success: function(d){
// how many data elements?
var l = d.length;
// split data into xy, xz, and yz
var xydata = [];
var xzdata = [];
var yzdata = [];
var minx;
var maxx;
var miny;
var maxy;
var minz;
var maxz;
var first = true;
for( var i=0; i<l; i++) {
var r = d[i];
var x = parseFloat(d[i][0]);
var y = parseFloat(d[i][1]);
var z = parseFloat(d[i][2]);
xydata.push([ x, y ]);
xzdata.push([ x, z ]);
yzdata.push([ y, z ]);
if(first) {
minx=maxx=x;
miny=maxy=y;
minz=maxz=z;
first = false;
}
if( x <= minx )
minx = x;
if( x >= maxx )
maxx = x;
if( y <= miny )
miny = y;
if( y >= maxy )
maxy = y;
if( z <= minz )
minz = z;
if( z >= maxz )
maxz = z;
}
//console.log('mm',minx, maxx, miny, maxy, minz, maxz)
var xspread = Math.abs(maxx) > Math.abs(minx) ? Math.abs(maxx) : Math.abs(minx);
var yspread = Math.abs(maxy) > Math.abs(miny) ? Math.abs(maxy) : Math.abs(miny);
var zspread = Math.abs(maxz) > Math.abs(minz) ? Math.abs(maxz) : Math.abs(minz);
//console.log('spread',xspread,yspread,zspread)
makeChart({
containerName: 'xyContainer',
data: xydata,
title: 'Sway X vs Y',
color: 'rgba(254,187,73,0.5)',
xspread: xspread,
yspread: yspread
});
makeChart({
containerName: 'xzContainer',
data: xzdata,
title: 'Sway X vs Z',
color: 'rgba(254,77,44,0.5)',
xspread: xspread,
yspread: zspread
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.