Created
September 1, 2014 14:16
-
-
Save patilv/c2d199103dfd346380c4 to your computer and use it in GitHub Desktop.
nwl
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 = 'chart1d1c73ee15dc' class = 'rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart1d1c73ee15dc() | |
}); | |
function drawchart1d1c73ee15dc(){ | |
var opts = { | |
"dom": "chart1d1c73ee15dc", | |
"width": 800, | |
"height": 400, | |
"x": "Team", | |
"y": "Count", | |
"group": "Win.Loss", | |
"type": "multiBarChart", | |
"id": "chart1d1c73ee15dc" | |
}, | |
data = [ | |
{ | |
"Team": "Baltimore Ravens", | |
"Win.Loss": "Loss", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Chicago Bears", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Dallas Cowboys", | |
"Win.Loss": "Loss", | |
"Count": 3 | |
}, | |
{ | |
"Team": "Denver Broncos", | |
"Win.Loss": "Loss", | |
"Count": 5 | |
}, | |
{ | |
"Team": "Green Bay Packers", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Indianapolis Colts", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Kansas City Chiefs", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Miami Dolphins", | |
"Win.Loss": "Loss", | |
"Count": 3 | |
}, | |
{ | |
"Team": "New England Patriots", | |
"Win.Loss": "Loss", | |
"Count": 4 | |
}, | |
{ | |
"Team": "New Orleans Saints", | |
"Win.Loss": "Loss", | |
"Count": 0 | |
}, | |
{ | |
"Team": "New York Giants", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "New York Jets", | |
"Win.Loss": "Loss", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Oakland Raiders", | |
"Win.Loss": "Loss", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Pittsburgh Steelers", | |
"Win.Loss": "Loss", | |
"Count": 2 | |
}, | |
{ | |
"Team": "San Francisco 49ers", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Seattle Seahawks", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "St. Louis Rams", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Tampa Bay Buccaneers", | |
"Win.Loss": "Loss", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Washington Redskins", | |
"Win.Loss": "Loss", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Los Angeles Raiders", | |
"Win.Loss": "Loss", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Baltimore Colts", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Arizona Cardinals", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Atlanta Falcons", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Buffalo Bills", | |
"Win.Loss": "Loss", | |
"Count": 4 | |
}, | |
{ | |
"Team": "Carolina Panthers", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Cincinnati Bengals", | |
"Win.Loss": "Loss", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Minnesota Vikings", | |
"Win.Loss": "Loss", | |
"Count": 4 | |
}, | |
{ | |
"Team": "Philadelphia Eagles", | |
"Win.Loss": "Loss", | |
"Count": 2 | |
}, | |
{ | |
"Team": "San Diego Chargers", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Tennessee Titans", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Los Angeles Rams", | |
"Win.Loss": "Loss", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Baltimore Ravens", | |
"Win.Loss": "Win", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Chicago Bears", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Dallas Cowboys", | |
"Win.Loss": "Win", | |
"Count": 5 | |
}, | |
{ | |
"Team": "Denver Broncos", | |
"Win.Loss": "Win", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Green Bay Packers", | |
"Win.Loss": "Win", | |
"Count": 4 | |
}, | |
{ | |
"Team": "Indianapolis Colts", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Kansas City Chiefs", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Miami Dolphins", | |
"Win.Loss": "Win", | |
"Count": 2 | |
}, | |
{ | |
"Team": "New England Patriots", | |
"Win.Loss": "Win", | |
"Count": 3 | |
}, | |
{ | |
"Team": "New Orleans Saints", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "New York Giants", | |
"Win.Loss": "Win", | |
"Count": 4 | |
}, | |
{ | |
"Team": "New York Jets", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Oakland Raiders", | |
"Win.Loss": "Win", | |
"Count": 2 | |
}, | |
{ | |
"Team": "Pittsburgh Steelers", | |
"Win.Loss": "Win", | |
"Count": 6 | |
}, | |
{ | |
"Team": "San Francisco 49ers", | |
"Win.Loss": "Win", | |
"Count": 5 | |
}, | |
{ | |
"Team": "Seattle Seahawks", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "St. Louis Rams", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Tampa Bay Buccaneers", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Washington Redskins", | |
"Win.Loss": "Win", | |
"Count": 3 | |
}, | |
{ | |
"Team": "Los Angeles Raiders", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Baltimore Colts", | |
"Win.Loss": "Win", | |
"Count": 1 | |
}, | |
{ | |
"Team": "Arizona Cardinals", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Atlanta Falcons", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Buffalo Bills", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Carolina Panthers", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Cincinnati Bengals", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Minnesota Vikings", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Philadelphia Eagles", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "San Diego Chargers", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Tennessee Titans", | |
"Win.Loss": "Win", | |
"Count": 0 | |
}, | |
{ | |
"Team": "Los Angeles Rams", | |
"Win.Loss": "Win", | |
"Count": 0 | |
} | |
] | |
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([ "red", "green" ]) | |
.reduceXTicks(false) | |
.stacked(true) | |
.margin({ | |
"bottom": 150 | |
}) | |
chart.xAxis | |
.rotateLabels( -45) | |
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