Created
March 10, 2014 00:18
-
-
Save heathermkrause/9457228 to your computer and use it in GitHub Desktop.
All Countries PreSowing
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> | |
<meta charset = 'utf-8'> | |
<html> | |
<head> | |
<link rel='stylesheet' href='http://nvd3.org/src/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/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='chart9c55df18bd4' class='rChart nvd3'></div> | |
<script type='text/javascript'> | |
$(document).ready(function(){ | |
drawchart9c55df18bd4() | |
}); | |
function drawchart9c55df18bd4(){ | |
var opts = { | |
"dom": "chart9c55df18bd4", | |
"width": 800, | |
"height": 400, | |
"x": "Variable", | |
"y": "Percentage", | |
"group": "Grade", | |
"type": "multiBarChart", | |
"id": "chart9c55df18bd4" | |
}, | |
data = [ | |
{ | |
"Variable": "Input & Land Management", | |
"Grade": "A", | |
"Percentage": 0.14 | |
}, | |
{ | |
"Variable": "Input & Land Management", | |
"Grade": "B", | |
"Percentage": 0.39 | |
}, | |
{ | |
"Variable": "Input & Land Management", | |
"Grade": "C", | |
"Percentage": 0.29 | |
}, | |
{ | |
"Variable": "Input & Land Management", | |
"Grade": "D", | |
"Percentage": 0.17 | |
}, | |
{ | |
"Variable": "Soil & Water", | |
"Grade": "A", | |
"Percentage": 0.32 | |
}, | |
{ | |
"Variable": "Soil & Water", | |
"Grade": "B", | |
"Percentage": 0.26 | |
}, | |
{ | |
"Variable": "Soil & Water", | |
"Grade": "C", | |
"Percentage": 0.31 | |
}, | |
{ | |
"Variable": "Soil & Water", | |
"Grade": "D", | |
"Percentage": 0.11 | |
} | |
] | |
if(!(opts.type==="pieChart" || opts.type==="sparklinePlus")) { | |
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]() | |
.x(function(d) { return d[opts.x] }) | |
.y(function(d) { return d[opts.y] }) | |
.width(opts.width) | |
.height(opts.height) | |
chart | |
.color([ "#1a9641", "#a6d96a", "#fdae61", "#d7191c" ]) | |
chart.xAxis | |
.axisLabel("Grade Categories of All Groups in the Project in the PreSowing Domain") | |
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