Created
September 7, 2016 23:30
-
-
Save polinabee/97c9992e291a471b06c801e0bbf0a217 to your computer and use it in GitHub Desktop.
Google Graphs: GDP
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
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<section id="chart"></section> |
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
google.charts.load('current', { | |
packages: ['corechart', 'controls'] | |
}); | |
google.charts.setOnLoadCallback(drawDashboard); | |
function drawDashboard() { | |
$.ajax({ | |
url: "https:raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/GDP-data.json", | |
dataType: "JSON" | |
}).done(function(json) { | |
var data_array = [ | |
["Date", "GDP"] | |
]; | |
$.each(json.data, function() { | |
var data_item = [this[0], this[1]]; | |
data_array.push(data_item); | |
}); | |
var options = { | |
title: "U.S. Gross Domestic Product, billions of dollars (USD)", | |
subtitle:"in billions of dollars (USD)", | |
interpolateNulls: true, | |
legend: 'none', | |
hAxis: { | |
title: 'Date' | |
}, | |
vAxis: { | |
title: 'GDP', | |
format: 'short' | |
} | |
}; | |
var tableData = google.visualization.arrayToDataTable(data_array); | |
var areachart = new google.visualization.AreaChart( | |
document.getElementById('chart')); | |
areachart.draw(tableData,options); | |
}); | |
} |
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
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.5/angular.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js"></script> |
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
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment