Created
August 25, 2014 21:45
-
-
Save patilv/ebe9b5884594b099dec8 to your computer and use it in GitHub Desktop.
np2
This file contains hidden or 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> | |
<meta charset = 'utf-8'> | |
<html> | |
<head> | |
<link rel='stylesheet' href='http://nvd3.org/assets/css/nv.d3.css'> | |
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script> | |
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script> | |
<script src='http://timelyportfolio.github.io/rCharts_nvd3_tests/libraries/widgets/nvd3/js/nv.d3.min-new.js' type='text/javascript'></script> | |
<script src='http://nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script> | |
<style> | |
.rChart { | |
display: block; | |
margin-left: auto; | |
margin-right: auto; | |
width: 800px; | |
height: 400px; | |
} | |
</style> | |
</head> | |
<body > | |
<div id = 'chartecc25325d4c' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchartecc25325d4c() | |
}); | |
function drawchartecc25325d4c(){ | |
var opts = { | |
"dom": "chartecc25325d4c", | |
"width": 800, | |
"height": 400, | |
"x": "result", | |
"y": "percentage", | |
"group": "tour", | |
"type": "multiBarChart", | |
"stacked": false, | |
"id": "chartecc25325d4c" | |
}, | |
data = [ | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "1st Serve Return Points Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 43 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "2nd Serve Return Points Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 57 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "Return Games Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 47 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "1st Serve Return Points Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 28 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "2nd Serve Return Points Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 48 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Returning Serve", | |
"result": "Return Games Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 23 | |
} | |
] | |
if(!(opts.type==="pieChart" || opts.type==="sparklinePlus" || opts.type==="bulletChart")) { | |
var data = d3.nest() | |
.key(function(d){ | |
//return opts.group === undefined ? 'main' : d[opts.group] | |
//instead of main would think a better default is opts.x | |
return opts.group === undefined ? opts.y : d[opts.group]; | |
}) | |
.entries(data); | |
} | |
if (opts.disabled != undefined){ | |
data.map(function(d, i){ | |
d.disabled = opts.disabled[i] | |
}) | |
} | |
nv.addGraph(function() { | |
var chart = nv.models[opts.type]() | |
.width(opts.width) | |
.height(opts.height) | |
if (opts.type != "bulletChart"){ | |
chart | |
.x(function(d) { return d[opts.x] }) | |
.y(function(d) { return d[opts.y] }) | |
} | |
chart | |
.color([ "#AA66cc", "#FF4444" ]) | |
.tooltipContent( function(key, x, y, e, graph){ | |
return e.point.tour + '<br>'+ x + ': <br>' + y +'%' | |
} ) | |
d3.select("#" + opts.id) | |
.append('svg') | |
.datum(data) | |
.transition().duration(500) | |
.call(chart); | |
nv.utils.windowResize(chart.update); | |
return chart; | |
}); | |
}; | |
</script> | |
<script></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment