Skip to content

Instantly share code, notes, and snippets.

@domitry
Created November 17, 2015 11:23
Show Gist options
  • Save domitry/2433a5d1b4bfb72ac816 to your computer and use it in GitHub Desktop.
Save domitry/2433a5d1b4bfb72ac816 to your computer and use it in GitHub Desktop.

Line: Nyaplotjs v2

<html>
<head>
<title>Line with Nyaplotjs</title>
<script src='http://d3js.org/d3.v3.min.js'></script>
<script src='https://cdn.rawgit.com/domitry/Nyaplotjs/a1b10b68f08cfbd5afc4e145103ac46297951d45/release/nyaplot.min.js'></script>
<script>
window.onload = function(){
var xarr=[], yarr1=[], yarr2=[], N=1000, curry1=0.0, curry2=0.0;
for(var i=0;i < N;i++){
xarr.push(i);
yarr1.push(curry1+=(Math.random()-0.5));
yarr2.push(curry2+=(Math.random()-0.5));
}
var plot = new Nyaplot.Plot({xlabel: "Number of steps"});
var line1 = new Nyaplot.Line(xarr, yarr1, {color: "#fbb4ae"});
var line2 = new Nyaplot.Line(xarr, yarr2, {color: "#b3cde3"});
plot.add([line1, line2]);
plot.show("vis");
};
</script>
</head>
<body>
<h1>Random walk</h1>
<div id="vis"></div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment