Skip to content

Instantly share code, notes, and snippets.

@domitry
Created August 17, 2014 01:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save domitry/1e1222cbc48ab3880849 to your computer and use it in GitHub Desktop.
Save domitry/1e1222cbc48ab3880849 to your computer and use it in GitHub Desktop.
Example of Nyaplotjs (Vectors)
<html lang='en'>
<head>
<title>Nyaplotjs example -- Vector field</title>
<script src='http://d3js.org/d3.v3.min.js'></script>
<script src='https://rawgit.com/domitry/Nyaplotjs/master/release/nyaplot.js'></script>
</head>
<body>
<div id='vis'></div>
<script>
var data1 = [], MAX=50, MIN=0;
for(var x=0;x<50;x+=5){
for(var y=0;y<50;y+=5){
var rad = (Math.PI*x/50)+(Math.random()*10);
data1.push({x: x, y: y, dx: 3*Math.cos(rad), dy:3*Math.sin(rad) , fill_by: x+y});
}
}
models = {data:{data1: data1},panes: [{diagrams:[{type: 'vectors', data: 'data1', options: {x:'x', y:'y', dx:'dx', dy:'dy', fill_by:'fill_by', stroke_width:2}}],options:{width:500, height:500, xrange: [-5, 50], yrange: [-5, 50], zoom:true}}]};
window.onload = function(){Nyaplot.core.parse(models, '#vis');};
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment