Skip to content

Instantly share code, notes, and snippets.

@domitry
Created July 11, 2014 15:01
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/6ee128d9f5cd348a1c58 to your computer and use it in GitHub Desktop.
Save domitry/6ee128d9f5cd348a1c58 to your computer and use it in GitHub Desktop.
NyaplotjsBoxplotExample
<html lang='en'>
<head>
<title>Nyaplotjs example -- Boxplot</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=[];
for(var i=0;i<100;i++){
data1.push({
norm1:d3.random.normal(0, 1)(),
norm2:d3.random.normal(3, 2)(),
norm3:d3.random.normal(1, 0.5)()
});
}
var y_min = d3.min(data1, function(d){return (d.norm2 < d.norm1 ? d.norm2 : d.norm1)})-1;
var y_max = d3.max(data1, function(d){return (d.norm2 > d.norm1 ? d.norm2 : d.norm1)})+1;
models = {data:{data1: data1},panes: [{type:'rectangular', diagrams:[{type: 'box', data: 'data1', options: {value:["norm1","norm2","norm3"]}}],options:{width:500, height:500, xrange: ["norm1","norm2","norm3"], yrange: [y_min, y_max]}}]};
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