Created
April 24, 2013 19:34
-
-
Save timelyportfolio/5454895 to your computer and use it in GitHub Desktop.
example of scatter weirdness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype HTML> | |
<html> | |
<head> | |
<link rel='stylesheet' href='http://nvd3.org/src/nv.d3.css'> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' type='text/javascript'></script> | |
<script src='http://d3js.org/d3.v2.min.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/nv.d3.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/lib/fisheye.js' type='text/javascript'></script> | |
<style> | |
.rChart { | |
display: block | |
margin: auto auto; | |
width: 900px; | |
height: 500px; | |
} | |
</style> | |
</head> | |
<body> | |
<div id='chart32a8232751f2' class='rChart nvd3Plot nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart32a8232751f2() | |
}); | |
function drawchart32a8232751f2(){ | |
var opts = {"dom":"chart32a8232751f2","width":800,"height":400,"x":"x","y":"y","group":"series","type":"scatterChart","id":"chart32a8232751f2"}, | |
data = [{"series":"HAM1","y":0.1375,"x":0.0888,"NA":1.5491},{"series":"HAM2","y":0.1747,"x":0.1272,"NA":1.3732},{"series":"HAM3","y":0.1512,"x":0.1265,"NA":1.1955},{"series":"HAM4","y":0.1215,"x":0.1843,"NA":0.6592},{"series":"HAM5","y":0.0373,"x":0.1584,"NA":0.2356},{"series":"HAM6","y":0.1373,"x":0.0825,"NA":1.6642},{"series":"EDHEC LS EQ","y":0.118,"x":0.0708,"NA":1.6657},{"series":"SP500 TR","y":0.0967,"x":0.15,"NA":0.6449},{"series":"US 10Y TR","y":0.0513,"x":0.0706,"NA":0.7265},{"series":"US 3m TR","y":0.0394,"x":0.0052,"NA":7.6201}] | |
var data = d3.nest() | |
.key(function(d){ | |
return opts.group === undefined ? 'main' : d[opts.group] | |
}) | |
.entries(data) | |
nv.addGraph(function() { | |
var chart = nv.models[opts.type]() | |
.x(function(d) { return d[opts.x] }) | |
.y(function(d) { return d[opts.y] }) | |
.width(opts.width) | |
.height(opts.height) | |
chart | |
.showDistX(true) | |
.showDistY(true) | |
.showControls(false) | |
d3.select("#" + opts.id) | |
.append('svg') | |
.datum(data) | |
.transition().duration(500) | |
.call(chart); | |
nv.utils.windowResize(chart.update); | |
return chart; | |
}); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment