Skip to content

Instantly share code, notes, and snippets.



Created Aug 17, 2014
What would you like to do?
Example of Nyaplotjs (Vectors)
<html lang='en'>
<title>Nyaplotjs example -- Vector field</title>
<script src=''></script>
<script src=''></script>
<div id='vis'></div>
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');};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment