Created
March 10, 2014 00:25
-
-
Save heathermkrause/9457303 to your computer and use it in GitHub Desktop.
All Countries Sowing
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/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='chart9c520f049ae' class='rChart nvd3'></div> | |
| <script type='text/javascript'> | |
| $(document).ready(function(){ | |
| drawchart9c520f049ae() | |
| }); | |
| function drawchart9c520f049ae(){ | |
| var opts = { | |
| "dom": "chart9c520f049ae", | |
| "width": 800, | |
| "height": 400, | |
| "x": "Variable", | |
| "y": "Percentage", | |
| "group": "Grade", | |
| "type": "multiBarChart", | |
| "id": "chart9c520f049ae" | |
| }, | |
| data = [ | |
| { | |
| "Variable": "Use of Inputs", | |
| "Grade": "A", | |
| "Percentage": 0.57 | |
| }, | |
| { | |
| "Variable": "Use of Inputs", | |
| "Grade": "B", | |
| "Percentage": 0.22 | |
| }, | |
| { | |
| "Variable": "Use of Inputs", | |
| "Grade": "C", | |
| "Percentage": 0.17 | |
| }, | |
| { | |
| "Variable": "Use of Inputs", | |
| "Grade": "D", | |
| "Percentage": 0.04 | |
| }, | |
| { | |
| "Variable": "Planting", | |
| "Grade": "A", | |
| "Percentage": 0.08 | |
| }, | |
| { | |
| "Variable": "Planting", | |
| "Grade": "B", | |
| "Percentage": 0.04 | |
| }, | |
| { | |
| "Variable": "Planting", | |
| "Grade": "C", | |
| "Percentage": 0.69 | |
| }, | |
| { | |
| "Variable": "Planting", | |
| "Grade": "D", | |
| "Percentage": 0.18 | |
| }, | |
| { | |
| "Variable": "Pest Management (Sowing)", | |
| "Grade": "A", | |
| "Percentage": 0.13 | |
| }, | |
| { | |
| "Variable": "Pest Management (Sowing)", | |
| "Grade": "B", | |
| "Percentage": 0.53 | |
| }, | |
| { | |
| "Variable": "Pest Management (Sowing)", | |
| "Grade": "C", | |
| "Percentage": 0.29 | |
| }, | |
| { | |
| "Variable": "Pest Management (Sowing)", | |
| "Grade": "D", | |
| "Percentage": 0.04 | |
| }, | |
| { | |
| "Variable": "Pest Management (Vegetative)", | |
| "Grade": "A", | |
| "Percentage": 0.05 | |
| }, | |
| { | |
| "Variable": "Pest Management (Vegetative)", | |
| "Grade": "B", | |
| "Percentage": 0.02 | |
| }, | |
| { | |
| "Variable": "Pest Management (Vegetative)", | |
| "Grade": "C", | |
| "Percentage": 0.06 | |
| }, | |
| { | |
| "Variable": "Pest Management (Vegetative)", | |
| "Grade": "D", | |
| "Percentage": 0.87 | |
| } | |
| ] | |
| 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 Sowing Domains") | |
| 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