Skip to content

Instantly share code, notes, and snippets.

@domitry

domitry/index.html

Created Aug 17, 2014
Embed
What would you like to do?
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