Created
August 25, 2014 21:42
-
-
Save patilv/9f5e1a053900115cde95 to your computer and use it in GitHub Desktop.
np1
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 = 'chartecc2f4a6f3a' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchartecc2f4a6f3a() | |
}); | |
function drawchartecc2f4a6f3a(){ | |
var opts = { | |
"dom": "chartecc2f4a6f3a", | |
"width": 800, | |
"height": 400, | |
"x": "result", | |
"y": "percentage", | |
"group": "tour", | |
"type": "multiBarChart", | |
"stacked": false, | |
"id": "chartecc2f4a6f3a" | |
}, | |
data = [ | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "1st Serves in Play ", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 60 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "1st Serve Points Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 74 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "2nd Serve Points Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 50 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "Service Games Won", | |
"tour": "WTA Tour Stats", | |
"year": 2014, | |
"percentage": 81 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "1st Serves in Play ", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 67 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "1st Serve Points Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 65 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "2nd Serve Points Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 34 | |
}, | |
{ | |
"player": "Serena Williams", | |
"type": "Serves", | |
"result": "Service Games Won", | |
"tour": "Grand Slam Losses", | |
"year": 2014, | |
"percentage": 60 | |
} | |
] | |
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